Consult perlfunc, which contains the following for my:

       my EXPR
       my TYPE EXPR
       my EXPR : ATTRS
       my TYPE EXPR : ATTRS
               A "my" declares the listed variables to be local (lexically) to the enclosing block,
               file, or "eval".  If more than one value is listed, the list must be placed in paren-
               theses.

               The exact semantics and interface of TYPE and ATTRS are still evolving.  TYPE is cur-
               rently bound to the use of "fields" pragma, and attributes are handled using the
               "attributes" pragma, or starting from Perl 5.8.0 also via the "Attribute::Handlers"
               module.  See "Private Variables via my()" in perlsub for details, and fields,
               attributes, and Attribute::Handlers.

While I still don't understand why you return $last if $first is found, I think you may be looking for a hash:

#!/usr/bin/perl -w use strict; my %hints; open FILE, 'hints'; while (<FILE>) { chomp; my @hint = split(/\s*==\s*/); $hints{$hint[0]} = $hint[1]; } close FILE; my $filename = 'file'; open FILE, $filename; binmode FILE; { local $/; my $file = <FILE>; print map { $file =~ /$_/ ? $hints{$_} : () } keys %hints; } close FILE;

Granted the above code is likely slower than using `strings | grep`, but it illustrates that this can be done in pure perl.


In reply to Re^3: Search Script by eibwen
in thread Search Script by arebc

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.