Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!convex!usenet From: tchrist@convex.COM (Tom Christiansen) Newsgroups: comp.lang.perl Subject: Re: Reading a file into a string Message-ID: <1991Jan31.012957.25993@convex.com> Date: 31 Jan 91 01:29:57 GMT References: <11235@jpl-devvax.JPL.NASA.GOV> <97130173@bfmny0.BFM.COM> <120644@uunet.UU.NET> Sender: usenet@convex.com (news access account) Reply-To: tchrist@convex.COM (Tom Christiansen) Organization: CONVEX Software Development, Richardson, TX Lines: 46 Nntp-Posting-Host: pixel.convex.com From the keyboard of rbj@uunet.UU.NET (Root Boy Jim): :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? I believe ioctl() works like syscall(), in that you need to pre-extend the string so the kernel has a place to write what it needs. This is different from sysread, who knows how much it'll need. BTW, I like to do stuff like this: $sgttyb_t = 'c4 s'; sub sgttyb { wantarray ? unpack($sgttyb_t, @_) : pack($sgttyb_t, @_); } You could then say to init: $sgttyb = &sgttyb(); But don't forget the parens. This time they matter. You don't want the previous guy's old @_. :(6) $"=''; @str = ; $str = "@str"; It seems a tad wasteful to my efficiency-maniacal self to allocate all those array members just to cat them together. At least undef it or let it go out of local scope. :(7) @str = ; $str = join(//,"@str"); If you didn't set $" to null, you'll get the "wrong" answer there, i.e. extra spaces by default. Skip the quotes if you want. :Horshoe mode .signature: perl -e 'print "Just another $0 hacker,"' "Just another /tmp/perl-e029116 hacker,"? Well, it IS different. --tom -- "Hey, did you hear Stallman has replaced /vmunix with /vmunix.el? Now he can finally have the whole O/S built-in to his editor like he always wanted!" --me (Tom Christiansen )