@stuff=($0.5,$0.5,$0.5)
You're concatenating the value of the special variable $0
with 5. For the example you gave, this would fill @stuff
with ('-e5', '-e5', '-e5').
Watch out for variable interpolation.
perl -e "@stuff=('$0.5', '$0.5', '$0.5');my $x=0;foreach (@stuff){s/\$//; $x+=$_}; print $x"
or
perl -e "@stuff=qw($0.5 $0.5 $0.5);my $x=0;foreach (@stuff){s/\$//; $x+=$_}; print $x"
| [reply] [d/l] [select] |
I don't think so - have you missed the s/\$//; in the second one-liner? perlcgi
| [reply] |
No, you're right takshaka. Thanks man.
| [reply] |
(removed in deference to proper timeflow)
| [reply] |
Not that it matters much, but your last ; was enclosing your foreach statement and not the $x+=$_ as I would suppose you wanted. I think one liners are cool, but you really gotta double check, cause its easy to misplace a comma, period or a bracket.
#!/home/bbq/bin/perl
# Trust no1!
| [reply] |
You can leave the semicolon off of the last statement in a block. The semicolon after the block is necessary to terminate the foreach statement.
| [reply] |