--- In perl-beginner@y..., Jorge Goncalvez <goncal11@c...> wrote:
> HI, I have a file like this:
> 1015322638: in.tftpd : Win32 Process Id = 0xBF : Cygwin Process Id
= 0xBF : RRQ
> from 188.8.131.52 filename /bootp/linux/4.0/alize/initrd.img
> And I wanted to match what is between from and filename ie
184.108.40.206 and what
> comes after filemane ie /bootp/linux/4.0/alize/initrd.img
> without (in.tftpd)
> How can I do thanks to a regexp.
As you don't say if all the lines will have exactly the same data or
whether you only wish to match one line in the whole file...
Maybe split on the colons:
$Line = '1015322638: in.tftpd : ..etc.. (in.tftpd)';
my @SplitLine = split( /\s*:/s*/, $Line;
# $SplitLine = 'RRQ ..etc.. (in.tftpd)'
# You can either split on spaces
my $filename = ( split( /\s+/, $SplitLine ) );
# or use a reg exp.
$SplitLine =~ /^RRQ from [\d|\.]+? filename (.*?) \(in/;
$filename = $1;
I didn't check this code so there may be incorrect indices on the
And I'm sure others will have other/better solutions.