Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

STDIN usage in interactive debug

by abdan (Acolyte)
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?

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

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (4)
As of 2022-01-23 20:54 GMT
Find Nodes?
    Voting Booth?
    In 2022, my preferred method to securely store passwords is:

    Results (64 votes). Check out past polls.