Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re^2: if -s clause on a FILEHANDLE

by drock (Beadle)
on Jun 08, 2004 at 14:24 UTC ( [id://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);
      thanks!

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (4)
As of 2024-04-19 04:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found