Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sun-barr!newstop!texsun!convex!convex.COM From: tchrist@convex.COM (Tom Christiansen) Newsgroups: comp.lang.perl Subject: Re: Possible problem with syscall() Message-ID: <109273@convex.convex.com> Date: 27 Nov 90 14:58:40 GMT References: <1454@tharr.UUCP> Sender: usenet@convex.com Reply-To: tchrist@convex.COM (Tom Christiansen) Organization: CONVEX Software Development, Richardson, TX Lines: 31 In article <1454@tharr.UUCP> gustav@tharr.UUCP (Paul Moore) writes: >system routines. These include a "print a string" call, and I noticed the >problem when I tried to print "1" - as mentioned above. > >However, from what I can gather of unix syscall(), it allows you to call >any system call available - so what about syscall(creat,"1",0666) [or >however you would say it] to create a file "1"? This is one of those times that perl cares about strings versus numerics. Sometimes you might have to add 0 or concat a null to coerce to the right type, but in practice I find this seldom to be the case. There's a big difference between syscall(&SYS_write,1,1,1) and syscall(&SYS_write,1,"1",1) The first sets $! to indicate a bad address (0x01) for that expected (char*) buffer to write (on my system, where the high bit indicates user space, not system space as on a Vax). The second actually writes a "1" to STDOUT. I course, you would really have uses syswrite() in the above case. For the record, syscall(&SYS_creat,"1",0666) does indeed creat a file named "1", as you would hope. --tom