mmazlan67 has asked for the wisdom of the Perl Monks concerning the following question:
Hi, i am really new to Perl because before this i worked on Excel VBA. For now i have 3 different perl scripts in VNC that i plan to combine them into one.
The first script will ask user for file name (e.g summary.txt), find the matching string in the summary.txt and saved the output in inout.txt using command on console "perl step1.pl summary.txt > inout.txt". But error will occur Then, i run the second script just to take all the necessary data based on the requirement and saved the output in result.txt using command on console "perl step2.pl inout.txt > result.txt. The third script will send result.txt to an email which can be viewed in Windows. I know that it is possible but i have no idea on how to do it as i got stuck on thinking how to open summary.txt file to read and open inout.txt to write at the same time.
I add this code below in step1.pl but then i cannot run the script on console using "perl step1.pl summary.txt > inout.txt"
print "Enter the name of the file: "; my $base_dir = <>; chomp($base_dir);open( my $DATA, "<" , $base_dir) or die "Can't open f +ile '$base_dir': $!"; while ( <$DATA> )
step1.pl
#! /tools/perl/5.8.8/linux/bin/perl use strict; use warnings; while (<>) { if ($_ =~ /^\s\s(\S+)*delay\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+ +(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+) +/) { print "$_"; } }
step2.pl
#! /tools/perl/5.8.8/linux/bin/perl use strict; use warnings; while ( <> ) { #if my ( $set ) = m/^\s+(\S+)/; #get the first word my ( $name,$value ) = m/-name (\S+) (\S+)/; #get the name and value my ( $mode ) = m/mode == (\S+)\"/; #get the mode print "$mode $name $set $value\n"; }
step3.pl
#! /tools/perl/5.8.8/linux/bin/perl use strict; use warnings; my $name='inoutdata'; system("uuencode /home/user/set/result.txt | mailx -s '$name' email");
|
|---|