Operating System - HP-UX
1757033 Members
2590 Online
108858 Solutions
New Discussion юеВ

Error PERL Script: No filehandle passed

 
Stefan Wusowski
Frequent Advisor

Error PERL Script: No filehandle passed

Hello,
i want to run slipwire.pl on a HP-UX 11.11 System and i get a error: No filehandle passed at ./slipwire.pl line 157, line 1.

Slipwire.pl is a script to get information about files/directories, create a hash and write this information to a database.

The error is generated by creating the hashes.
..
find($file_list_line);

sub wanted {

$i++;
open (FILEH, $name);

my $key = $name;

$ctx = Digest::SHA1->new;
$ctx->addfile(FILEH);
$sha = $ctx->b64digest;

my @fileinfo;
..

The complete script is attached.


Any ideas???? - Thanks
5 REPLIES 5
Mark Grant
Honored Contributor

Re: Error PERL Script: No filehandle passed

I might be missing something but I can't see where $name gets set. Possibly therefore, as there is no error checking on the "open()", maybe the "open" fails and FILEH isn't a file handle.
Never preceed any demonstration with anything more predictive than "watch this"
Stefan Wusowski
Frequent Advisor

Re: Error PERL Script: No filehandle passed

Hello,
$name is set by find ... sub wanted ...

If I commet OUT the create hash lines, the script is running well.

Mark Grant
Honored Contributor

Re: Error PERL Script: No filehandle passed

Well, I imagine it does because it's the " $ctx->addfile(FILEH);" that is probably causing the error. I imagine that FILEH is not a valid file handle.

Perhaps you could change the line " open (FILEH, $name);" to

open (FILEH, $name) or die "ERROR: $!\n";

This way you will see if there is an error being generated with the open.
Never preceed any demonstration with anything more predictive than "watch this"
H.Merijn Brand (procura
Honored Contributor

Re: Error PERL Script: No filehandle passed

adding

use strict;
use warnings;


at the top of your script might also lead to the problem. I /always/ use those two. It also catches typo's and everyone makes typo's

Enjoy, Have FUN! H.Merijn
Enjoy, Have FUN! H.Merijn
Stefan Wusowski
Frequent Advisor

Re: Error PERL Script: No filehandle passed

Hallo,
thanks.
The error is generate while the open() is try to open a FileHandle for a link and that don't work.

;-)