View Single Post
Old 03-11-2004, 04:57 PM   #4 (permalink)
ratbastid
Darth Papa
 
ratbastid's Avatar
 
Location: Yonder
Quote:
chomp " $cvar , $rvar , $tvar ";
That won't work. You're only passing one argument to chomp, and it's a string composed of each of your variables separated by a comma and a space. It's syntactically valid, but it does nothing. You're going to leave the return characters on the end of each of those $vars.

You should instead be getting your input like this:

chomp(my $cvar = <STDIN>);

That'll chomp DURING the assignment. You also save a line, which is important when you're playing Perl Golf.

And now that you know the ** operator, that formula should be a one-liner too.
ratbastid is offline  
 

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76