mrbbq has asked for the wisdom of the Perl Monks concerning the following question:
At this point I cant even get a match. Can one of you Monks point me in the right direction. Thanks in advance$my_default="\\\\my\.domain\.net\\"; $my_file="info.txt"; my $path = shift @ARGV; sub usage{ print STDERR "\nUsage:\n"; print STDERR "\t$0 \"the\path\"\n"; print "\n"; } sub grep_pattern{ # print "$patten\n"; foreach (@my_data) {print "$_\n" if /$pattern/; } print "\n\n"; } sub print_array{ for ($i=0; $i<=$#my_data;$i++) {print $my_data[$i], "\n"; } print "\n\n"; } unless ($path){ &usage; exit (-1); } open(HANDLE, $my_file) || die("Open the file failed!"); @my_data=<HANDLE>; print_array; # Try and find the ARGV $pattern = $path; print "Searching for: $pattern\n"; grep_pattern;
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Pattern matching and setting the match to a variable
by kyle (Abbot) on Feb 15, 2008 at 22:10 UTC | |
by mrbbq (Sexton) on Feb 15, 2008 at 22:20 UTC | |
Re: Pattern matching and setting the match to a variable
by starX (Chaplain) on Feb 15, 2008 at 22:09 UTC | |
Re: Pattern matching and setting the match to a variable
by ikegami (Patriarch) on Feb 16, 2008 at 19:53 UTC |