In addition to other problems commented upon, I see a couple more: you're using prototypes (improperly); you're not using warnings and strictures (see strict).

Abandoning the use of prototypes until you understand what they do (and that you should almost never use them) will save you great and needless suffering. Using warnings and strictures will initially cause additional pain, but it will be a healing pain! Addressing the problems that warnings and strictures bring to light will ultimately make your code more robust.

c:\@Work\Perl\monks>perl -le "use warnings; use strict; ;; my $filename; ;; Grab($filename); ;; $filename = 'too late'; ;; sub Grab($filename){ print qq{filename is '$filename'}; my @ra = (9, 8, 7); print 'it matches!' if @ra =~ m{ 3 }xms; } " Illegal character in prototype for main::Grab : $filename at -e line 1 +. Applying pattern match (m//) to @array will act on scalar(@array) at - +e line 1. main::Grab() called too early to check prototype at -e line 1. Use of uninitialized value $filename in concatenation (.) or string at + -e line 1. filename is '' it matches!

In reply to Re: Catching expressions from a file by AnomalousMonk
in thread Catching expressions from a file by kepler

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.