Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re^3: how to append 2 lines

by philiprbrenan (Monk)
on Sep 05, 2012 at 21:43 UTC ( #991953=note: print w/replies, xml ) Need Help??


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

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");

Replies are listed 'Best First'.
Re^4: how to append 2 lines
by suno (Acolyte) on Sep 10, 2012 at 10:26 UTC
    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://991953]
help
Chatterbox?
[shmem]: msh210: you can save the perlbug text in a file and send that via your mail agent of choice
[msh210]: hm, okay, I'll try, thanks
[shmem]: ...not as an attachment, it's probably better to c&p that into the mail body

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (12)
As of 2017-04-24 12:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I'm a fool:











    Results (439 votes). Check out past polls.