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

Re: Need a little help appending lines

by dwm042 (Priest)
on Sep 11, 2007 at 20:25 UTC ( [id://638422]=note: print w/replies, xml ) Need Help??


in reply to Need a little help appending lines

I'm going to simplify your input parsing as I think it's a bit confusing. But one way of appending output is:

#!/usr/bin/perl use warnings; use strict; my $file = "outtest.txt"; open OUT, ">>", $file || die("Cannot open file for output.\n"); my @array; while(<DATA>) { s/tcp//g; @array = split(/\s+/, $_); print OUT "Address1=",$array[1],"\n"; print OUT "Address2=",$array[2],"\n"; print OUT "Address3=",$array[3],"\n"; } __DATA__ tcp 20 tcp 40 tcp 80
And the output is:

<code> C:\Code>perl outtest.pl C:\Code>perl outtest.pl C:\Code>type outtest.txt Address1=20 Address2=40 Address3=80 Address1=20 Address2=40 Address3=80

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (2)
As of 2024-06-17 00:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.