in reply to How do I backtrack while reading a file line-by-line?

Nothing to do with your question, but...

while ($newline = <FILEHANDLE>){
use strict; use warnings;

and then

while (my $newline = <FILEHANDLE>){
if ($newline = /^>/) {

This is most probably not what you want, since you're assigning to $newline. You want

if ($newline =~ /^>/) {

instead.

$stuff = $newline; &play_with($stuff);

Unless play_with() modifies its argument, you may want to pass $newline directly to it, without passing through an intermediate variable. But more importantly, the &-form of sub call is now obsolete and likely not to do what one may think, so unless you do know, don't!

Replies are listed 'Best First'.
Re^2: How do I backtrack while reading a file line-by-line?
by mdunnbass (Monk) on Oct 18, 2006 at 20:21 UTC
    Thanks.

    I didn't know about the & form being deprecated, so i will get rid of that.

    And &play_with($stuff) does indeed modify $stuff, so I guess I am doing the right thing there, although I can't take credit for doing it on purpose. ;)

    Thanks for the info though.
    Matt

      Oh, heck.

      When I wrote the code block in the original post, the

      if($newline = /^>/) {
      was NOT deliberate. just a typo. In my actual code, it reads:
      if($newline =~ /^>/) {