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 ', ' ' ];
In reply to Having an issue with -F by Pug
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |