Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

STDIN usage in interactive debug

by abdan (Novice)
on Oct 24, 2021 at 03:26 UTC ( #11137932=perlquestion: print w/replies, xml ) Need Help??

abdan has asked for the wisdom of the Perl Monks concerning the following question:

Why in interactive debug cannot do input:
DB<1> @ln=<STDIN>; <"FILE" DB<2> print "$ln[0] $ln[1]"
How to have it working directly

Replies are listed 'Best First'.
Re: STDIN usage in interactive debug
by haj (Priest) on Oct 24, 2021 at 08:16 UTC

    In the debugger you can either use debugger commands or valid Perl, but <"FILE" is neither.

    To get the contents of a file into an array, valid Perl isn't that difficult:

    DB<1> open ($in,'<','FILE') DB<2> @ln = <$in> DB<3> close $in

      Or you could even do it all in one line (without needing the close). . .

      DB<1> @lines = do { open( my $fh, '<', 'FILE' ); <$fh> }

      The cake is a lie.
      The cake is a lie.
      The cake is a lie.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://11137932]
Front-paged by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (3)
As of 2021-12-01 18:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    R or B?



    Results (13 votes). Check out past polls.

    Notices?