Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Hi, I am trying to run the program below:
#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 :

VOR#000 EQU * MVC A,B move B to A CLC VAR1,VAR2 compare VAR2 != VAR1 BNE COMP EJECT
my expected output should be :
VOR#000 MVC A,B CLC VAR1,VAR2 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?

In reply to please help me to resolve the Line comments and appending issue by suno

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (8)
As of 2024-04-16 07:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found