Hi Jorge
This does what you want, and I think is fairly straightforward. The line 'local
$/' temporarily undefines the record separator for the scope of the enclosing
block, so that the read on the next line pulls in all of the file. (I assume
your files aren't any bigger than you showed us?)
open FILE, "< file.txt" or die $!;
my $data;
{
local $/;
$data = <FILE>;
}
close FILE;
$data =~ m/DHCPDISCOVER from\s*(.+?)\s*via eth0/;
$data = $1;
print "$data\n";
Come back to me if there's anything you don't understand.
Cheers,
Rob
> -----Original Message-----
> From: Jorge Goncalvez [mailto:[EMAIL PROTECTED]]
> Sent: 05 September 2001 10:49
> To: [EMAIL PROTECTED]
> Subject: Re:Parse file
>
>
> Hi, I have a file which looks like :
>
> dhcpd : LOG_INFO : Internet Software Consortium DHCP Server 2.0
> dhcpd : LOG_INFO : Copyright 1995, 1996, 1997, 1998, 1999 The
> Internet Software
> Consortium.
> dhcpd : LOG_INFO : All rights reserved.
> dhcpd : LOG_INFO :
> dhcpd : LOG_INFO : Please contribute if you find this software useful.
> dhcpd : LOG_INFO : For info, please visit http://www.isc.org/dhcp-contrib.html
> dhcpd : LOG_INFO :
> dhcpd : LOG_INFO : Listening on Socket/eth0/155.132.0.0
> dhcpd : LOG_INFO : Sending on Socket/eth0/155.132.0.0
> dhcpd : LOG_INFO : DHCPDISCOVER from
> 52:41:53:20:c0:f6:c8:35:6c:80:c0:01:01:00:00:00 via eth0
> dhcpd : LOG_ERR : Booting denied, no alcatel XID and the vendor class is empty
> dhcpd : LOG_INFO : DHCPDISCOVER from
> 52:41:53:20:b0:c0:d0:69:49:34:c1:01:01:00:00:00 via eth0
> dhcpd : LOG_ERR : Booting denied, no alcatel XID and the vendor class is empty
> LOG_INFO : cabs41.col.bsf.alcatel.fr: read request for /bootp/cygwin.bat:
> success.
>
>
> How can I extract what is betwwen DHCPDISCOVER from and via eth0?
>
> Thanks
>
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]