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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |