Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Parsing text file question

by Aragorn (Curate)
on Jun 28, 2004 at 09:03 UTC ( #370150=note: print w/ replies, xml ) Need Help??


in reply to Parsing text file question

Another way of doing this:

#!/usr/local/bin/perl use strict; use warnings; my @lines_ok = (); while (<DATA>) { chomp; pop @lines_ok, next if /fail/; push @lines_ok, $_; } print join(", ", @lines_ok); __DATA__ line 1 line 2 line 3 fail line 4 line 5
Arjen


Comment on Re: Parsing text file question
Download Code
Re^2: Parsing text file question
by husker (Chaplain) on Jun 28, 2004 at 13:41 UTC
    This also excludes lines that have "fail" in them, which is not specified in the OP. Remove the "next" phrase from the "pop" line and I think you've got it.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (8)
As of 2015-07-06 15:36 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 (77 votes), past polls