Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re^3: How can I print part of a line between two different lines

by madtoperl (Hermit)
on Jan 27, 2017 at 14:09 UTC ( [id://1180476]=note: print w/replies, xml ) Need Help??


in reply to Re^2: How can I print part of a line between two different lines
in thread How can I print part of a line between two different lines

#!/usr/bin/perl use strict; use warnings; my @finalArray = (); while(<DATA>){ if ($_=~/^sample_char/){ my @line = split(/\=/,$_); #push (@finalArray, $line[1]); push @finalArray, $line[1]; } } print "Final data :: @finalArray"; __DATA__ sample = 123 sample_sub = info sample_char = abc sample_char = abc1 sample_char = abc2 sample_end sample = 124 sample_sub = info sample_char = bbc sample_char = bbc1 sample_char = bbc2 sample_end sample = 125 sample_sub = info sample_char = cbc sample_char = cbc1 sample_char = cbc2 sample_end
OUTPUT
Final data :: abc abc1 abc2 bbc bbc1 bbc2 cbc cbc1 cbc2

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (4)
As of 2024-03-28 23:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found