Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

STDIN usage in interactive debug

by abdan (Acolyte)
on Oct 24, 2021 at 03:26 UTC ( [id://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 (Vicar) 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?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (3)
As of 2024-04-25 07:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found