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

Re: Perl: how to insert words at the end of each line and open the file?

by toolic (Bishop)
on Oct 31, 2013 at 17:53 UTC ( #1060615=note: print w/ replies, xml ) Need Help??


in reply to Perl: how to insert words at the end of each line and open the file?

This gives you the output you want:

use warnings; use strict; while (my $line = <DATA>) { if ($line =~ /(\S+)/) { my $libn = "$1.lib"; print "$libn\n"; } } __DATA__ b05_ln_rmmm_0.85v_0.00c_core /p/ldb/ln/b05_ln_rmmm_0.85v_0.00c_core. +ldb:b05_ln_rmmm_0.85v_0.00c_core.ldb b05_nn__rmmm_g9v_098c_core /p/ldb/nn/b05_nn__rmmm_g9v_098c_core.ldb: +b05_nn__rmmm_g9v_098c_core b05_un_rsss_0.66v_0.44c_core /p/ldb/un/b05_un_rsss_0.66v_0.44c_core. +ldb:b05_un_rsss_0.66v_0.44c_core


Comment on Re: Perl: how to insert words at the end of each line and open the file?
Download Code
Re^2: Perl: how to insert words at the end of each line and open the file?
by WWq (Novice) on Nov 01, 2013 at 02:39 UTC

    Thank you for guidance. I keep the library names in an array and try to open each of them to do further editing. It seems I cannot open the file directly using file handle. I will be very much appreciate if you shed light on this.Thanks.

    while ($line = <CF>) { @arr2 = @empty_arr; if ($line =~ /(\S+)/) { $libn = "$1.lib"; #print "$libn\n"; push (@arr2,$libn); #print "@arr2\n"; } } foreach $libn (@arr2) { open (VI,"$libn") || die "ERROR: can't read $libn\n"; #print"$libn\n"; if ($line =~ m/(Car code:)((.*))/) { $a = $line; .... .. }
        Thank you.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (9)
As of 2015-07-02 23:07 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 (46 votes), past polls