Copyright © tutorialspoint.com

PERL select Function


Syntax

select FILEHANDLE

select

select RBITS, WBITS, EBITS, TIMEOUT


Definition and Usage

Sets the default filehandle for output to FILEHANDLE, setting the filehandle used by functions such as print and write if no filehandle is specified. If FILEHANDLE is not specified, then it returns the name of the current default filehandle.

select (RBITS, WBITS, EBITS, TIMEOUT )Calls the system function select( ) using the bits specified. The select function sets the controls for handling non-blocking I/O requests. Returns the number of filehandles awaiting I/O in scalar context, or the number of waiting filehandles and the time remaining in a list context

Return Value

  • Previous default filehandle if FILEHANDLE specified

  • Current default filehandle if FILEHANDLE is not specified

Example

#!/usr/bin/perl -w

open(FILE,">/tmp/t.out");
$oldHandle = select(FILE);
print("This is sent to /tmp/t.out.\n");
select($oldHandle);
print("This is sent to STDOUT.\n");

Copyright © tutorialspoint.com