Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic

Re^2: if -s clause on a FILEHANDLE

by drock (Beadle)
on Jun 08, 2004 at 14:24 UTC ( #362346=note: print w/replies, xml ) Need Help??

in reply to Re: if -s clause on a FILEHANDLE
in thread if -s clause on a FILEHANDLE

what exactly is
select( (select(OUT),$|=1)[0] )
saying? I still want to state
if ( -s "@ftapes" ) { ..... }
right? not just if ( "@ftapes" )

Replies are listed 'Best First'.
Re^3: if -s clause on a FILEHANDLE
by Fletch (Bishop) on Jun 08, 2004 at 14:42 UTC

    The select stuff is a hackish shortcut from the dawn of time (or at lest the perl4 days) to set autoflush on a handle without changing the current default output handle afterwards. The chunk inside the inner parens is a list consisting of the previous default output handle (what you were getting with my $svsel = select OUT;) and then setting $| on the default output handle (which is then OUT since the select executes first). The list value is subscripted to get just the first element (the old saved handle) and that's passed to select to reset the default output handle.

    And no, you don't want  -s "@ftapes". -s gets the size of a file (either by name or for an already opened filehandle). Yours would attempt to find the size of a file named after the contents of @ftapes joined by $,. Using an array in a scalar context evaluates to the number of items in the array; if you found any items then @ftapes will have a non-zero number of elements and evaluate to a true boolean value.

      Is there a ideal way to "touch" a file instead of opening a file then >$foo it? for example,
      my $foo="/tmp/ftapes_runfile"; open (RUNFILE, ">$foo") || die "could not open runfile: $!;" close (RUNFILE);

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://362346]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (7)
As of 2023-09-21 08:27 GMT
Find Nodes?
    Voting Booth?

    No recent polls found