Gunnar Hjalmarsson wrote:
> Digger wrote:
> > Sherm Pendley wrote:
> >> Digger wrote:
> >>> How can I get that single url out of a file and store it to be
> >>> used for something else?
> >>
> >> You left out a critical bit of information: What format is the file
> >> in? If it's HTML, use HTML:
arser.
> >
> > Sorry, yes......
> >
> > It's a flat text log file.....
> >
> > date : error message: url: other garbage
>
> What part of the task do you have difficulties with? Show us what you
> have tried so far, and somebody may be able to point you in the right
> direction.
>
> A hint: check out the split() function.
#!/usr/bin/perl
use strict;
use warnings;
open my $file, 'log.txt' or die "error: could not open file: $!";
for (<$file>)
{
print if s/.*url:\s+(\S+)\s+.*/$1/;
}
For the flat text log file described, I was thinking of something like
this, but it won't work if the url has spaces in it (like local paths
in Windows) or if there is not at least one space on each side of the
url.
mjl