Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re^2: how to append 2 lines

by suno (Acolyte)
on Sep 05, 2012 at 12:18 UTC ( #991821=note: print w/ replies, xml ) Need Help??


in reply to Re: how to append 2 lines
in thread how to append 2 lines

Hi,....

Thanks for the advice....

but another doubt....This is fine if i give the input then and there... but i want to give my input in a file... i want to perform this action for the above lines in a file.. please help me in this also...

Thanks in advance...


Comment on Re^2: how to append 2 lines
Re^3: how to append 2 lines
by philiprbrenan (Monk) on Sep 05, 2012 at 21:43 UTC

    May I suggest something like this to read your lines of text:

    use feature ":5.14"; use warnings FATAL => qw(all); use strict; use Data::Dump qw(dump pp); sub readFile($) {my ($f) = @_; $f or die "readFile: No file specified"; open my $F, "<$f" or die "Cannot open $f for input"; local $/ = undef; <$F> } print readFile("readFile.pm");

    Produces:

    use feature ":5.14"; use warnings FATAL => qw(all); use strict; use Data::Dump qw(dump pp); sub readFile($) {my ($f) = @_; $f or die "readFile: No file specified"; open my $F, "<$f" or die "Cannot open $f for input"; local $/ = undef; <$F> } print readFile("readFile.pm");
      Hi,

      Thanks for the help...i was successfully able to finish it...

      i have one more doubt..

      say my code is          F$SFH FIRST,SC==H'160',        COMMENTS                    *   i need to replace ',*' instead of ", K.160 LESEN *" so that my code looks like F$SFH FIRST,SC==H'160',*

      I tried using substitution function.. but i dont know where i am going wrong,. please help me in this... my code looks somewhat like

      $a = F$SFH FIRST,SC==H'160', K.160 LESEN +* $a =~ s/\,[\s]*\*/\,\*/;

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://991821]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (4)
As of 2015-07-04 07:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (58 votes), past polls