in reply to "touching" a file

You cannot usually create a regular file without opening it (this does not apply to a directory). There is only one way around this I know, and that only works for the super-user: the mknod syscall.

Update: added readmore. You don't want to know why.

You don't have to create a perl filehandle object however, you can create a unix filehandle with syscall, but that is ugly:

$h = syscall 5, ($n="filename"), 65, 0777; $h<0 and die $!; syscall 6, + $h;
(You'd have to change this to work in windows of course.)

Replies are listed 'Best First'.
Re^2: "touching" a file
by DrHyde (Prior) on Jun 17, 2004 at 21:07 UTC
    Why the ($n="filename") and not just "filename"?

      Perl 5.6.1 gives me "Modification of a read-only value attempted" without the assignment.

      From perldoc perlfunc syscall:

      You can't use a string literal (or other read-only string) as an argument to "syscall" because Perl has to assume that any string pointer might be written through.

      (Update:) you can probably get around this with unpack"i",pack"p","filename" but I haven't tried.