Pug has asked for the wisdom of the Perl Monks concerning the following question:
According to my copy of perlrun -F has this description
-Fpattern
specifies the pattern to split on if -a is also in
effect. The pattern may be surrounded by "//", """",
or "''", otherwise it will be put in single quotes.
If I put the code below in a file and run it like this perl test.plI get in perl version 5.6.1 on linux this error message#!/usr/bin/perl -apnF"monkey" use Data::Dumper; print Data::Dumper->Dump([\@F]);
"use" not allowed in expression at test.pl line 2, at end of line
syntax error at test.pl line 2, near "use Data::Dumper"
Execution of test.pl aborted due to compilation errors.
When I got this error I changed the first line into this
#!/usr/bin/perl -apnF "monkey"
The code runs and if you type 'my monkey' @F does not have 2 elements in it as expected. Instead Data::Dumper prints out this
Then I changed the first line into this #!/usr/bin/perl -apn$VAR1 = [ 'my monkey ' ];
and run the program like this
perl -F"monkey" test.pl
This gave me this output from Data::Dumper.
What am I doing wrong?$VAR1 = [ 'my ', ' ' ];
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Having an issue with -F
by hv (Prior) on Feb 19, 2003 at 23:46 UTC | |
by Pug (Monk) on Feb 19, 2003 at 23:59 UTC | |
|
Re: Having an issue with -F
by dragonchild (Archbishop) on Feb 19, 2003 at 23:31 UTC | |
by Pug (Monk) on Feb 19, 2003 at 23:41 UTC | |
|
Re: Having an issue with -F
by Limbic~Region (Chancellor) on Feb 19, 2003 at 23:58 UTC |