[Chicago-talk] "File-scraping"
Steven Lembark
lembark at wrkhors.com
Fri Jan 16 00:07:51 CST 2004
-- petemar1 <petemar1 at perlmonk.org>
> I already have my regex, it's a filehandling issue. I can open(FILE
> ">>filename"); and close(FILE) and write to it with print FILE "blah," but
> what's the function to read from said FILE?
er, sort of like:
sub slurpify
{
if( open my $file, '<', shift )
{
local $/;
# caller gets the source back as a scalar.
my $rx = shift;
( my $input = <$file> ) =~ /$rx/;
}
else
{
die "trying...";
}
}
# slurp the file wholesale then apply the regex
# to it for the coupe de rx.
my @stuff = slurpify $path, qr/$your_regex_here/i;
This can hack a socket also if you feel like playing
with networks.
--
Steven Lembark 2930 W. Palmer
Workhorse Computing Chicago, IL 60647
+1 888 359 3508
More information about the Chicago-talk
mailing list