I've been debugging a simple script to rename and copy a directory of files. It's shown below (minus the comments). The first command line argument is a name stem (all target files match the $stem), the second is a range/iterator, the third is a target directory and filename. The first three prints are for debugging.
my $stem = $ARGV[0]; my $start = $ARGV[1]; my $dir = $ARGV[2]; print "STEM: $stem\n"; print "START: $start\n"; print "DIR: $dir\n"; my $outstring; while(<*.pdb*>){ if(m,\.viols,){next} if(m,$stem,){ chomp; $outstring = $dir.$start.'.pdb'; print `cp $_ $outstring\n`; $start++}}
When I run with "use Strict" (as is my default these days, along with warnings) I get "unitialized variable messages" typically indicating I did something less-than-ideal. The print flags above show that $stem, set to $ARGV[0] is not getting defined (but the other arguments are). There is some cryptic and suspect output from Strict regarding "Subroutine bits redefined":
Subroutine bits redefined at /System/Library/Perl/5.8.6/strict.pm line + 11. Subroutine import redefined at /System/Library/Perl/5.8.6/strict.pm li +ne 27. Subroutine unimport redefined at /System/Library/Perl/5.8.6/strict.pm +line 32. Use of uninitialized value in concatenation (.) or string at rename4li +b.pl line 16.
When I stop using Strict, the error messages go away and the debug prints now give the expected output. Everything's hunky dory. The ouput's as expected. Is this something regarding Strict that I don't understand (for example, does it sanity check/filter command line arguments)?

I don't want my subroutine bits defined, do I? I'm alone and frightened.

Thanks much,
ry

"I'm not afraid of Al Quaeda. I'm afraid of Al Cracker." -Chris Rock

In reply to use Strict: a rigorous way to break my command line variables? by NamfFohyr

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.