suno has asked for the wisdom of the Perl Monks concerning the following question:
#Perl program # Variable to get the command line arguments # Command line arguments are Source and Destination filename $src_filename = $ARGV[0]; $var_filename = $ARGV[1]; $tgt_filename = $ARGV[2]; $mac_filename = $ARGV[2]; # Statement to read data in Source file using file handler # Declaring the file handlers to read the input file open(IFILE,"<$src_filename") || die "error in opening source file\n"; open(OFILE2,"+>$tgt_filename") || die "error in opening dest file\n"; open(OFILE1,"+>$var_filename") || die "error in opening dest file\n"; open(OFILE,"<$mac_filename") || die "error in opening macro file\n"; # Read input file into a input array to process the data @Read_Array = (); # Array initialization @Read_Array = <IFILE>; # Read all contents of file into a +n array @Var_File_Array = (); # Output array for modified assmeb +ler code @Tgt_File_Array = (); # Temporary variables $Line = ''; $Indx = 0; # Variable for array indexes # Read Array print @Read_Array; # Preprocessing for each line in an array foreach $Line (@Read_Array) { #Read only 1 - 72 columns data $Line =~ /.{72}/; $Line = $&; $Line = $Line."\n"; #$Line =~ /(.+)*\s+(.+)$/; $Temp = $Line; #Remove evrything after column 40 fromt he code $Line =~ /.{40}/; $description = $'; $Line = $&; chomp($description); $description =~s/\s+$//g; $Line =~s/\(/\'/g; $Line =~s/\)/\'/g; if($Line =~/([^\s]+)\s+(DC|DS|EQU)\s+(A|X|C|H|F|D|0X|0D|0C)+(L)* +([^\'\(\s]+)*(\'(.+)\')*\s*/i) { $Print_Line = " "; $Print_Line = $1.",".$3.",".$5.",".$7.",".$description."\n"; push(@Var_File_Array,$Print_Line); } else { if($Temp!~/^\s*\*/ and $Temp!~/^\s+$/) #lines other than comment +s and line spaces { push(@Tgt_File_Array,$Temp); if($Temp=~/\s+(EQU)\s+(\*)/i) #remove EQU * from the state +ments { $Temp = $`; $Temp = $Temp."\n"; pop @Tgt_File_Array; push(@Tgt_File_Array,$Temp); if(length($Temp)>1) { @split_words = split(' ',$Temp); #to remove line co +mments #pop @Tgt_File_Array; push(@Tgt_File_Array,@split_words[0],' ',@split_words[1]); } } } } }
here when i give my input as :
my expected output should be :VOR#000 EQU * MVC A,B move B to A CLC VAR1,VAR2 compare VAR2 != VAR1 BNE COMP EJECT
but..here i am facing some issues with removing the line comments and i need to append "BNE COMP" along with the previous line...i am very new to perl...can you please help me out to resolve this issue?VOR#000 MVC A,B CLC VAR1,VAR2 BNE COMP EJECT
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: please help me to resolve the Line comments and appending issue
by aitap (Curate) on Aug 08, 2012 at 14:32 UTC | |
by suno (Acolyte) on Aug 09, 2012 at 07:48 UTC | |
by aitap (Curate) on Aug 09, 2012 at 10:43 UTC | |
by suno (Acolyte) on Aug 10, 2012 at 12:51 UTC | |
by aitap (Curate) on Aug 10, 2012 at 14:04 UTC | |
| |
by suno (Acolyte) on Aug 09, 2012 at 08:43 UTC |