pass a filehandle then use it in grep{}?

2004-10-06 Thread West, William M
this does not work: sub extract{ #retrieve subset of data from a single file #return that data in a list context my $fh = shift; #filehandle reference my @creds; local $/ = ''; @creds = grep {/./} $fh; @creds } this does work:: sub extrac

Re: pass a filehandle then use it in grep{}?

2004-10-06 Thread Gunnar Hjalmarsson
William M West wrote: this does not work: sub extract{ #retrieve subset of data from a single file #return that data in a list context my $fh = shift; #filehandle reference my @creds; local $/ = ''; @creds = grep {/./} $fh; Try: @creds = grep {/./

RE: pass a filehandle then use it in grep{}?

2004-10-06 Thread West, William M
>> @creds = grep {/./} $fh; > >Try: > > @creds = grep {/./} <$fh>; > >-- >Gunnar Hjalmarsson >Email: http://www.gunnar.cc/cgi-bin/contact.pl ah!! i was so used to that /not/ being the case with a normal filehandle that i didn't think to use it with a reference *laugh* thank

Re: pass a filehandle then use it in grep{}?

2004-10-06 Thread Gunnar Hjalmarsson
William M West wrote: Gunnar Hjalmarsson wrote: William M West wrote: @creds = grep {/./} $fh; Try: @creds = grep {/./} <$fh>; ah!! i was so used to that /not/ being the case with a normal filehandle Don't understand. Which syntax(es) are you referring to when saying that? thank you :)

RE: pass a filehandle then use it in grep{}?

2004-10-08 Thread West, William M
> Gunnar Hjalmarsson wrote: >>> William M West wrote: @creds = grep {/./} $fh; >>> >>> Try: >>> >>> @creds = grep {/./} <$fh>; >> >> ah!! i was so used to that /not/ being the case with a normal >> filehandle > >Don't understand. Which syntax(es) are you referring to when s

Re: pass a filehandle then use it in grep{}?

2004-10-08 Thread Gunnar Hjalmarsson
William M West wrote: Gunnar Hjalmarsson wrote: William M West wrote: ah!! i was so used to that /not/ being the case with a normal filehandle Don't understand. Which syntax(es) are you referring to when saying that? my @array =grep {-d "$directory\/$_"} readdir ; gives me this error:: Type of ar

RE: pass a filehandle then use it in grep{}?

2004-10-08 Thread West, William M
>Right. readdir() expects a DIRHANDLE as the argument, while grep() >expects a LIST as the second argument. > >> which is fine- my careless reading of my other code got the misuse >> of <> stuck in my head- that kept me from seeing the proper >> solution. > >Make it a habit to study the docs for

Re: pass a filehandle then use it in grep{}?

2004-10-08 Thread Gunnar Hjalmarsson
William M West wrote: Gunnar Hjalmarsson wrote: Make it a habit to study the docs for the functions you are using: perldoc -f grep perldoc -f readdir oddly- the grep documentation in perldoc doesn't even mention filehandles. readdir does show proper use though- when i looked up grep in th

Re: pass a filehandle then use it in grep{}?

2004-10-09 Thread John W. Krahn
West, William M wrote: my @array =grep {-d "$directory\/$_"} readdir ; gives me this error:: Type of arg 1 to readdir must be HANDLE (not ) at ./subdirs.pl line 30, near ";" Execution of ./subdirs.pl aborted due to compilation errors. The expression "readdir ;" is the same as "readdir readline LS2;

Re: pass a filehandle then use it in grep{}?

2004-10-09 Thread John W. Krahn
West, William M wrote: oddly- the grep documentation in perldoc doesn't even mention filehandles. readdir does show proper use though- readdir does not use a filehandle and therefore does not show the proper use of them. The opendir/readdir/rewinddir/seekdir/telldir/closedir functions all use d