View Single Post

  #3 (permalink)  
Old 12-02-2006
Koncept
 
Posts: n/a
Default Re: perl to php translation

In article <ekpvs1$nre$1@online.de>, Ric <antispam@randometry.com>
wrote:

> > could someone traslate this small piece of perl code to php ?
> > many thanks
> > Jor
> >
> > select ( undef, undef, undef, 0.3 );


There is no *select* function in PHP. If you wanted to duplicate this
could, you would have to write a function to handle it. Something that
would handle the vars detailed in perldoc -f select

($nfound, $timeleft ) = select($rout=$rin,
$wout=$win,$eout=$ein,$timeout);

> > open ( LOCKFILE, ">counter.lock" );


To handle a locked file, you can use *flock*
$fp = fopen('counter.lock','w');
if(flock($fp,LOCK_EX)){ // lock the file
// do stuff here
flock($fp, LOCK_UN); // release lock
}

> > $counter = <CD>;

If you want to read an entire file handle into a scalar, you can use
file_get_contents or the way Ric laid things out.

// Not sure what your $count var references but you do...
$counter = file_get_contents( "$count" );

--
Koncept <<
"The snake that cannot shed its skin perishes. So do the spirits who are
prevented from changing their opinions; they cease to be a spirit." -Nietzsche
Reply With Quote