I have a file which I am reading and then I need to extract a particualr word and if it matches the line.
Means if the line contain Virtual server I need to extract the id .
Code I wrote
But it is not working
Code:
2015-01-22 07:30:17,814000 +0900 [29133:main]/INFO:[configuration.manager/Cont'd_0031] - <ns2:virtualServerid="PH11PK" />
Code I wrote
Code:
#!/usr/bin/perl
#@filename = 'file.txt';
$VS=@_;
$1;
open (FILE, "file.txt") or die;
while (my $line= <FILE>) {
#foreach $line (@filename)
{
if ($line =~ /Info : \[([a-zA-Z]+)\] - [([a-zA-Z]+)\]\/) {
print ("Login successful for ID $2\n");
$VS++;
}
else{
print ("ID $2 not connected,please check!!");
}
Moderator's Comments: | ||
|