Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change

Re: don't want to print certain lines

by krusty (Hermit)
on Oct 27, 2004 at 01:37 UTC ( #402873=note: print w/replies, xml ) Need Help??

in reply to don't want to print certain lines

Try the following:
$ver="abc.txt"; open (IN,$ver); $new="new.txt"; open(OUT,"> $new"); while (<IN>){ <IN> and next if /^FIELD/; print OUT; }

This should print to new.txt all lines except any beginning with FIELD and the line immediately following.

Replies are listed 'Best First'.
Re^2: don't want to print certain lines
by dee00zee (Novice) on Oct 27, 2004 at 01:56 UTC
    I try it and it works..thank you.
    But I don't understand this part

    <IN> and next if /^FIELD/;
    print OUT;
    What does <IN> do here and why it didn't print ); that
    appear after FIELD lines:?

      The problem is your first next in your if block, any thing in that block after that next will never be executed.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://402873]
[marinersk]: I appear to be unusually dependent on spacial stability. I have had trouble from someone moving an object a mere four inches to the left.
[Eily]: I think the solution is to write posts so brilliant that you gain XP on each refresh, no matter how often :P
[marinersk]: Eily++ and LOL
[marinersk]: I get a lighter version of this disconcertion (new word?) when the n points remaining until rank disappears.
[choroba]: :-D
[marinersk]: I've often marvelled over the past few decades at just how little it takes to mess me up with this spacial dependence thing. I wonder if I'm mildly autistic or something.

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (9)
As of 2017-05-29 13:57 GMT
Find Nodes?
    Voting Booth?