Here is one using rindex to get what you want:
#!perl -w
$_ = '15P4aa-0000U5-00.log:>>> Virus \'W32/Apology-B\' found in file \
/var/spool/exim/qtine/15P4aa-0000U5-00.exp/qi_test.exe';
my $MyPtr = rindex($_,'/');
my $MyFileName ;
if ( $MyPtr < 0 ) {
print "No slash found in $_";
}else {
$MyFileName = substr($_,++$MyPtr);
}
print "1: $MyFileName\n";
Wags ;)
-----Original Message-----
From: Gary Stainburn [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, July 24, 2001 11:29
To: perl
Subject: basename ?
Hi all, I'm trying to parse a log file generated by a virus scanner so I can
extract the basename from a line, but I can't find the basename function in
perl. The line I'm getting in is:
15P4aa-0000U5-00.log:>>> Virus 'W32/Apology-B' found in file \
/var/spool/exim/qtine/15P4aa-0000U5-00.exp/qi_test.exe
The bit I want to get is:
qi_test.exe
What I'm getting is:
var/spool/exim/qtine/15P4aa-0000U5-00.exp/qi_test.exe
and I'm trying (loads of variations of):
grep '^>>>' *.log|perl -nle "print \$1 if (/\/(\S*)$/);"
--
Gary Stainburn
This email does not contain private or confidential material as it
may be snooped on by interested government parties for unknown
and undisclosed purposes - Regulation of Investigatory Powers Act, 2000
--
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]