Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: File extraction 2nd try

by Athanasius (Archbishop)
on Jan 19, 2016 at 04:16 UTC ( [id://1153055]=note: print w/replies, xml ) Need Help??


in reply to File extraction 2nd try

Hello knight.of.ni,

tangent has identified the logic error in your code, and AnomalousMonk has outlined a better approach. I just want to point out that if you exit from the while loop you will never reach the close statements after the loop ends. Use last instead.

A few other points:

  • The first my $zeichen is masked by the declaration of my $zeichen within the while loop condition.
  • The /g modifier on the regex does nothing in this case.
  • In fact, a regex isn’t really needed here at all: if ($buffer eq 'IEND') is clearer and more efficient.
  • You should either test the open and close statements for failure, or use autodie.

Hope that helps,

Athanasius <°(((><contra mundum Iustus alius egestas vitae, eros Piratica,

Replies are listed 'Best First'.
Re^2: File extraction 2nd try
by knight.of.ni (Initiate) on Jan 19, 2016 at 18:41 UTC
    Thanks to all of you for your answers. Especially to tangent and Athanasius. You two helped me a lot!

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (9)
As of 2024-04-23 14:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found