Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid

Re: Newbie to PERL removing text from array

by Erez (Priest)
on Feb 14, 2012 at 12:19 UTC ( #953693=note: print w/replies, xml ) Need Help??

in reply to Newbie to PERL removing text from array

This mainly depends on the file format. If you can be 100% sure that this, and only this is the way lines will be presented, then you can do the following:

my @output; foreach my $line (@lines) { my @split = split ' ', $line; #split by whitespace pop @split if $split[0] eq '*'; #getting rid of leading * $split[0] =~ s/\.//g #remove the dots from the element push @output, $split[0] . ' ' . $split[3]; }

Otherwise, you'll need to do a foreach on each of @split's elements, match them to a pattern and use those that you need.

Principle of Least Astonishment: Any language that doesn’t occasionally surprise the novice will pay for it by continually surprising the expert

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://953693]
[Corion]: Eily: Yeah - my French isn't even good to understand jokes, much less to make them :-D
[Corion]: marto: That post is a repost/duplicate of Excel sheet data write issue :-D
[Corion]: Whoops - Merging worksheets in .xls in one Excel sheet
[marto]: Corion, whoops, can the moderation me amended?
[Corion]: marto: We could vote, unconsider and reconsider ;)
[Corion]: "vote keep", I meant ;)
[Corion]: marto: But that aside, I hope you are well!
Corion is slowly acclimatizing to working only four days a week
[marto]: the back pain is still there, it's been a rough week, trying to do building work with a bad back
[Corion]: marto: Ow! That doesn't sound good :-/ The work won't help your back...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (10)
As of 2017-09-21 14:40 GMT
Find Nodes?
    Voting Booth?
    During the recent solar eclipse, I:

    Results (248 votes). Check out past polls.