#!/usr/bin/perl use warnings; use strict; #It needs ARGS and readable file my $logfile=$ARGV[0]; my $contract=$ARGV[1]; unless (@ARGV == 2) { print "USAGE: $0 \"logfile\" \"numero\"\n"; exit(1); } my $output="/tmp/session_".$contract.".txt"; unless (-e $logfile) { print "O ficheiro $logfile usado para input n\343o existe. Verifique o nome do mesmo sff.\n"; exit(1); } if (-e $output) { unlink($output); } open(OUTPUT,">>",$output) or die("Could not open conf file."); open(LOG, $logfile) or die("Could not open conf file."); while () { if (/:NOTICE:user=$contract,session=\d+:/ .. /\)\[/) { print OUTPUT $_ } } close(LOG); close(OUTPUT); #### open(OUTPUT,">>",$output) or die("Could not open conf file."); open(LOG, $logfile) or die("Could not open conf file."); while (defined($line = ) ) { if ($line =~/:NOTICE:user=$contract,session=(\d+):/) { print OUTPUT $line; $echo=1; } elsif ($echo == 1) { print OUTPUT $line; if ($line =~/\)\[/) { $echo=0; } } }