exp0 (copy)

Download exp0 (copy)

If you can't read please download the document

Upload: chethan-jayasimha

Post on 12-Jan-2016

213 views

Category:

Documents


0 download

DESCRIPTION

perl example

TRANSCRIPT

#! /usr/bin/perl####################################################################################################### START OF PROGRAM#################################################################################################################### DECLARATION OF VARIABLES ############my $n= 0;my $input_file = $ARGV[1];my $output_file = $ARGV[3];my $data;my $data_out;my $line;if(($ARGV[0] eq '') || ($ARGV[2] eq '') || ($ARGV[1] eq '') || ($ARGV[3] eq '') ) {print ("Usage: perl pc_ar.pl -input -output \n"); } else {print"argv1 =$ARGV[1]\n"; # Prints the arguments given by user print"argv3 =$ARGV[3]\n";print"argv2 =$ARGV[2]\n";print"argv0 =$ARGV[0]\n";&main1;}sub main1 {open($data,"$ARGV[3]") or die ("can't open file\n"); # open output filewhile() {$line = $_;chomp;if(m/\bThe scan channel unload value\b/) {#print "time found\n";@array = split(/is/,$line);print "array = $array[0], $array[1],$array[2],$array[3],$array[8], $array[9],$array[10],$array[11],$array[12]\n";@bin_spt = split(/\s+/,$array[1]);print "bin_spt = $bin_spt[0], $bin_spt[1], $bin_spt[2]\n"; $bin_data = reverse $bin_spt[1];print "bin_spt = $bin_spt[1] \nbin_data = $bin_data\n";print $data_out "$array[1] is $bin_data $bin_spt[2]\n";} elsif(m/\bThe scan chainin value\b/) {@array = split(/is/,$line);print "array = $array[0], $array[1],$array[2],$array[3],$array[8], $array[9],$array[10],$array[11],$array[12]\n";@bin_spt = split(/\s+/,$array[1]);print "bin_spt = $bin_spt[0], $bin_spt[1], $bin_spt[2]\n"; $bin_data = reverse $bin_spt[1];print "bin_spt = $bin_spt[1] \nbin_data = $bin_data\n";print $data_out "$array[1] is $bin_data $bin_spt[2]\n";} else {print $data_out "$_\n";}}close($data);close(Sdata_out);}