The program I'll post below is really only a test of a subroutine I
want to use in a larger program. Trying to get the subroutine ironed
out in this test script below so there is a little extra bumping
around to get it executed as sub routine, but It fails with these
errors:
Variable "$rgx" will not stay shared at ./test line 30.
Global symbol "$finddir" requires explicit package name at ./test line
19.
Execution of ./test aborted due to compilation errors.
I don't understand why that happens.
------- 8< snip --------
#!/usr/local/bin/perl
use strict;
use warnings;
my $flag = shift;
checkfile($flag);
sub checkfile {
use File::Find;
use File::MMagic;
use FileHandle;
my ($rgx,$use,@finddir);
$use = shift @_;
$rgx = qr/(^|:)$use /;
@finddir = "/usr/portage/profiles";
find(\&wanted, @finddir) or die " Failed to open
finddir <$finddir>: $!";
sub wanted {
my ($mm,$res,$testfile);
$testfile = $_;
$mm = new File::MMagic; # use internal magic file
$res = $mm->checktype_filename($testfile);
if ($res =~ /^plain\/text/) {
open(FILE,"<$File::Find::dir") or die "Can't open <$File::Find::dir>:
$!";
}
while(<FILE>) {
if (/$rgx/) {
print " $File::Find::dir\n";
print " $_\n";
}
}
}
}
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/