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
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 {/./
>> @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
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 :)
> 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
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
>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
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
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;
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
10 matches
Mail list logo