Hi there,
I am also just starting out in perl, but I would use the split funtion. It
takes the variable a part at desired points just like awk.
example:
#!/usr/bin/perl
#########################################################################
open (FH,"</path/to/logfile");#Opens main log file with entries to parse.
while (<FH>) { #Reads log file to $_ (Standard variable)
chomp; #Gets rid of trailing \n!
split ("/",$_); #Splits variable at "/" character
print "Filename :$_[2]\n"; #File name is third ($_[2]) element in @_
}
close (FH); #Closes logfile. Grab lunch, your
done.
#########################################################################
Some people's solution may be quicker, or less steps, but I like to write it
out.
It helps keep the logic straight.
If there are entries in the log file that contain undesired information,
use an expresion before chomp that says "if $_!~/usersA2F/){next;}"
This will skip undesired lines in the log file. (Replace "usersA2F" with
common denominator)
Take it easy, and good luck.
James Hughes
DREGIS Dresdner Global IT-Services Gesellschaft mbH
Bankbetrieb
Server u. Geschaftsstellenservices (SH GM) Telephone
+49 (0) 69 / 2 63 - 82653
Fax +49
(0) 69 / 2 63 - 10 347
Wilhelm-Leuschner-Stra?e 4-6, 4. OG
60627 Frankfurt / Main, Germany E-Mail [EMAIL PROTECTED]
-----Ursprungliche Nachricht-----
Von: LADDO [mailto:[EMAIL PROTECTED]]
Gesendet: Dienstag, 13. August 2002 06:31
An: [EMAIL PROTECTED]
Betreff: regular expression
Hi all
Iam new to perl so please bear with me
i have a log file that i open to extract some information from
file is
like this
var/backup/usersA2F.0.1_1027468994_24
var/backup/usersA2F.0.2_1027468994_24
var/backup/usersA2F.0.3_1027468994_24
var/backup/usersA2F.0.4_1027468994_24
var/backup/usersA2F.0.5_1027468994_24
var/backup/usersA2F.0.6_1027468994_24
i want a regular expression that can find only the third part
i.e only
usersA2F.0.1_1027468994_24
with awk i can do it easily like cat {thisfile} | awk -F'/'
[{print $3 }'
what is the equilent in perl ?
Bobby
--
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]