in reply to Out of a hole?
Warning: This really is a very evil hack. And it won't work on non-POSIXish systems...
This obviously requires the syscall.ph header (and strict and Carp, but you can get rid of them easily). If you really don't want to use that either, you can find out the value returned by SYS_getcwd. This goes beyond evil, by the way, but under Linux (and probably nothing else), this will work:require 'syscall.ph'; use strict; use Carp; sub cwd () { my $buf = ' ' x 256; $! = 0; my $res = syscall(&SYS_getcwd, $buf, length($buf)) croak "getcwd: $!" if ($res == -1 && $! != 0); $buf =~ /\0.*$//; return $buf; }
But it will almost certainly have radically different results on other operating systems!my $res = syscall(183, $s, length($s));
Of course, if you are using Win32, it may not have getcwd, but it may have an equivalent.
Andrew.
|
|---|