in reply to finding and replacing
#!/usr/bin/perl -w use strict; my @array = ('dave', 'brian','alex's','eddie's'); print "@array\n";
If we try to execute that, we get:
String found where operator expected at array.pl line 4, at end of lin +e (Missing semicolon on previous line?) syntax error at array.pl line 4, near "'alex's','eddie's" Can't find string terminator "'" anywhere before EOF at array.pl line +4.
A better way to define your array is like so:
my @array = qw(dave brian alex's eddie's);
Which gives us the correct output:
barney:/home/darren/perlmonks# perl array.pl dave brian alex's eddie's
An explaination of the use of qw can be found under the "Regexp Quote-Like Operators" section in perlop
Hope this helps,
Darren :)
|
|---|