Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!elroy.jpl.nasa.gov!jpl-devvax!lwall From: lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) Newsgroups: comp.lang.perl Subject: Re: Reading a file into a string Message-ID: <11242@jpl-devvax.JPL.NASA.GOV> Date: 31 Jan 91 00:42:15 GMT References: <97130172@bfmny0.BFM.COM> <11235@jpl-devvax.JPL.NASA.GOV> <97130173@bfmny0.BFM.COM> <120644@uunet.UU.NET> Reply-To: lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) Organization: Jet Propulsion Laboratory, Pasadena, CA Lines: 49 In article <120644@uunet.UU.NET> rbj@uunet.UU.NET (Root Boy Jim) writes: : OK, so Larry was being too literal. I'm like that sometimes. It started at an early age, when my mom told me to hop in the bathtub. : Suppose we replace -s FILE with $MAXINT? : Sysread will get whatever it can. However, this begs the question, : how does $foo get allocated? By sending the third arg to malloc? Noises of affirmation. : In that case, perhaps one should set a limit on how much they slurp : and die/complain on therwise. Perhaps one should, as long as they aren't Perl. Any limit Perl might set would be too small for some people and too large for others. : This would also be a good time to ask about args to ioctls. I have : been precreating them out of paranoia: : $sgtty = 'ioekfl'; ioctl(FH,$TIOCGETP,$sgtty); : Is this necessary? In either case, why? Never necessary on a BSD-derived system, and seldom necessary on other systems. $TIOCGETP encodes the required length of $sgtty on BSD systems, so it preallocates that much for you. On non-BSD systems it preallocates 256 bytes, so you only have to preallocate it if you're expecting more info back than that. It also adds a sentinel byte at the end so it can die gracefully when you blow it. fcntl works the same way. syscall does nothing for you by way of pre-extension. : (6) $"=''; @str = ; $str = "@str"; : (7) @str = ; $str = join(//,"@str"); : : Horshoe mode .signature: perl -e 'print "Just another $0 hacker,"' That may not do what you expect. You might be interested to know that 4.0 will allow you to assign to $0 to modify what ps sees. (Suggested by Tom Christiansen.) die "shucks" if $] < 4.000; $0 = 'Just another Perl hacker,'; print grep(s/.*Just/Not just/, `ps`); Larry