RE: Testing for filehandles

2002-03-28 Thread Bob Showalter
-Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Wednesday, March 27, 2002 6:16 PM To: Beginners Perl Mailing List Subject: RE: Testing for filehandles On Wed, 27 Mar 2002, Bob Showalter wrote: You can pass a filehandle glob to IO::Handle::opened

RE: Testing for filehandles

2002-03-28 Thread eric-perl
On Thu, 28 Mar 2002, Bob Showalter wrote: From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Thanks, Bob! After reading the IO::Handle man page, I decided to distill this approach a bit further: print F if fileno(F); Of course, that's even simpler! Just to be nitpicky, the test

RE: Testing for filehandles

2002-03-27 Thread Timothy Johnson
You'd probably have better luck testing for the open() command's success use Getopts::Std; getopts(n); if($opt_n){ open(OPT_LOG,/tmp/foo.txt) || die Could not open foo.txt!\n; } -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Wednesday, March 27, 2002

Re: Testing for filehandles

2002-03-27 Thread Chas Owens
On Wed, 2002-03-27 at 15:18, [EMAIL PROTECTED] wrote: Hello, All: I've looked around for an answer to this (The Camel Book, The Ram Book, perldoc, google.com, etc.) but can't find a thing: Is it possible to test for the existence of a filehandle? I've got a small script that optionally

RE: Testing for filehandles

2002-03-27 Thread eric-perl
Tim: I know, I know: I excluded the or die portion for readability/simplicity. On Wed, 27 Mar 2002, Timothy Johnson wrote: You'd probably have better luck testing for the open() command's success I wrote: use Getopts::Std; getopts(n); open(OPT_LOG,/tmp/foo.txt) if ($opt_n); while () {

Re: Testing for filehandles

2002-03-27 Thread Agustin Rivera
Mailing List [EMAIL PROTECTED] Sent: Wednesday, March 27, 2002 1:32 PM Subject: RE: Testing for filehandles You'd probably have better luck testing for the open() command's success use Getopts::Std; getopts(n); if($opt_n){ open(OPT_LOG,/tmp/foo.txt) || die Could not open foo.txt!\n

RE: Testing for filehandles

2002-03-27 Thread Timothy Johnson
, 2002 1:46 PM To: Timothy Johnson; Beginners Perl Mailing List Subject: Re: Testing for filehandles How would that work with use strict;? I tried it once and when I declared my $opt_n before using getopts, it wouldn't work. Agustin Rivera Webmaster, Pollstar.com http://www.pollstar.com

Re: Testing for filehandles

2002-03-27 Thread eric-perl
On Wed, 27 Mar 2002, Agustin Rivera wrote: How would that work with use strict;? I tried it once and when I declared my $opt_n before using getopts, it wouldn't work. Agustin: From the Getopt::Std man page: Note that, if your code is running under the recommended `use strict

Re: Testing for filehandles

2002-03-27 Thread Chas Owens
] Sent: Wednesday, March 27, 2002 1:32 PM Subject: RE: Testing for filehandles You'd probably have better luck testing for the open() command's success use Getopts::Std; getopts(n); if($opt_n){ open(OPT_LOG,/tmp/foo.txt) || die Could not open foo.txt!\n; } -Original

Re: Testing for filehandles

2002-03-27 Thread eric-perl
On 27 Mar 2002, Chas Owens wrote: Getopt::Std creates the $opt_n variables. To use it with use strict; in place you must use the use vars ($opt_n); pragma as well. or just use the getopts('n', \%opts); call. Then you can say $opts{n}. Agustin: Also from the Getopt::Std man page:

RE: Testing for filehandles

2002-03-27 Thread Bob Showalter
-Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Wednesday, March 27, 2002 3:18 PM To: Beginners Perl Mailing List Subject: Testing for filehandles Hello, All: I've looked around for an answer to this (The Camel Book, The Ram Book, perldoc,

Re: Testing for filehandles

2002-03-27 Thread Agustin Rivera
Owens [EMAIL PROTECTED] To: Agustin Rivera [EMAIL PROTECTED] Cc: Beginners Perl Mailing List [EMAIL PROTECTED] Sent: Wednesday, March 27, 2002 1:51 PM Subject: Re: Testing for filehandles Getopt::Std creates the $opt_n variables. To use it with use strict; in place you must use the use vars ($opt_n

Re: Testing for filehandles

2002-03-27 Thread eric-perl
On Wed, 27 Mar 2002, Agustin Rivera wrote: Ok, I've tried it both ways and it returns 1 (true) as the value. What am I doing wrong? Agustin: 1. What *exactly* do you mean both ways? 2. References... From the Getopt::Std man page: getopt('oDI'); # -o, -D -I take arg. Sets

RE: Testing for filehandles

2002-03-27 Thread eric-perl
On Wed, 27 Mar 2002, Bob Showalter wrote: You can pass a filehandle glob to IO::Handle::opened(): Thanks, Bob! After reading the IO::Handle man page, I decided to distill this approach a bit further: print F if fileno(F); -- Eric P. Los Gatos, CA -- To unsubscribe, e-mail: [EMAIL