Hi, I want to go threw a file until a line matches a pattern. It then prints that line and exits. The pattern I want to match is: <item>anything</item>
Her is my script so far.
As you can see I don't know how to do the pattern matching. Remember I want it to match: <item>anything</item>
anything could be numbers, letters, spaces or any combination.
Thanks for all help!
_______________________________________
You don't know me.
Her is my script so far.
Code:
#!/usr/bin/perl -w
use strict;
use CGI qw(:standard);
use Fcntl qw(:flock :seek);
open(FILE, ">>feed.rss") or die "Can not open feed.rss: $!";
seek(FILE,0,0);
my @file = <FILE>;
foreach (@file)
{
if ($_ =~ /some pattern/) # Help!
{
print "$_";
print "<br>Matched!";
exit;
}
}
close FILE;
exit;
As you can see I don't know how to do the pattern matching. Remember I want it to match: <item>anything</item>
anything could be numbers, letters, spaces or any combination.
Thanks for all help!
_______________________________________
You don't know me.