My problem is that I am trying to use -F command line switch on the #! line but it does not look like it follows the docs in perlrun.

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.pl
#!/usr/bin/perl -apnF"monkey" use Data::Dumper; print Data::Dumper->Dump([\@F]);
I get in perl version 5.6.1 on linux this error message

"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

$VAR1 = [ 'my monkey ' ];
Then I changed the first line into this #!/usr/bin/perl -apn

and run the program like this
 perl -F"monkey" test.pl
This gave me this output from Data::Dumper.

$VAR1 = [ 'my ', ' ' ];
What am I doing wrong?
--
Pug

In reply to Having an issue with -F by Pug

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.