Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: STDIN to the Max?!?

by jeffenstein (Hermit)
on Mar 21, 2002 at 08:47 UTC ( [id://153276]=note: print w/replies, xml ) Need Help??


in reply to STDIN to the Max?!?

Do you want to do this instead?

chomp(@var = <STDIN>);

$var = <STDIN> will only read one line at a time.

Replies are listed 'Best First'.
Re: Re: STDIN to the Max?!?
by defyance (Curate) on Mar 21, 2002 at 18:12 UTC
    The scalar was a typo, this particular field required an @array just like you said, but it still only takes in 18 lines of data. That's not really an issue, I was just curious as to if there was a max amount of data STDIN can handle, in general. Its not an important script that I was writing, just something I was playing with that sparked my curiosity. Thanks for the ideas however, and ++ to you all!

    -- Yes, I am a criminal. My crime is that of defyance.
Re: Re: STDIN to the Max?!?
by tmiklas (Hermit) on Mar 21, 2002 at 18:20 UTC
    But if it's to be a 'small' script, then using @var will occupy a lot more memory than the loop sholud...
    Everything depends on what do you mean by 'quite a bit of data' :-)

    Greetz, Tom.
      See, I'm not even worried about the script, I'll make it work, that's not a prob. I was just wondering if anyone knew of any limitations on the amount of data that STDIN can handle, I probably should have made that more clear..

      And tmiklas your right about it occupying more mem, but as you know, a @var handles multiple scalars which is what I want, in order to split the imputed data..

      -- Yes, I am a criminal. My crime is that of defyance.

        STDIN shouldn't have a per-line limit.

        However, there may be a per-process limit to the amount of memory that you can use. Check out ulimit(1).

        The little snippet below will print a string of about 80MB, then read it back into a single scalar in perl. I just tried this out on my workstation, and it seems to work just fine.

        perl -e 'print "a"x85000000' | \ perl -e 'my $line = <STDIN>; print length($line), "\n";'

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://153276]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (4)
As of 2024-03-29 12:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found