in reply to Extract field after keyword

while (<DPSLOTFILE>) { my ($slot) = /$dpdrivloc:\s*(\d+)/; # Do something with $slot }

------
We are the carpenters and bricklayers of the Information Age.

Please remember that I'm crufty and crochety. All opinions are purely mine and all code is untested, unless otherwise specified.

Replies are listed 'Best First'.
Re: Re: Extract field after keyword
by Anonymous Monk on Mar 19, 2004 at 20:02 UTC
    Tried:
    
    
    while (<DPSLOTFILE>) { my ($slot) = /$dpdrivloc:\s*(\d+)/; print "$slot"; }
    and there was no output.... Part of me was thingking it might be an issue with an ASCII file. I tried opening the file using:
    binmode (STDOUT);
    and no difference...
      I just tried it, substituting my while-loop for yours and it works for me. Maybe posting your entire script and test file would help .....

      ------
      We are the carpenters and bricklayers of the Information Age.

      Please remember that I'm crufty and crochety. All opinions are purely mine and all code is untested, unless otherwise specified.

      You want print "$slot\n";, since otherwise your prompt might cover things up if you don't print anything else (depending on your shell).

        Yep, I should have had that.... My bad. I entered it and it inserted about 5 or 6 newline characters, but $slot is still null...