I have a hash which looks something like this:
%hash = ( foo => 'a', bar => 'b', filespec => "$filespec");
I also have a function which includes the following code:
# Figure out if we were passed a filename or an array ref
if ( exists $info -> {filespec} ) {
$filespec = $info -> {filespec};
if ( ref($filespec) eq "ARRAY" ) {
#process filenames from array;
print "filespec = $filespec, filespec type = ", ref($filespec),
"\n";
print "Processing an array\n";
} else {
print "Processing single filename: $filespec\n";
print "filespec = $filespec, filespec type = ", ref($filespec),
"\n";
}
} else {
die "No Files passed in for processing!\n";
}
__END__
I'm passing a reference to the hash into the function. The function is
actually
contained in a module I'm developing, but I don't think that should matter?
When processing gets to this part of the code the "if" condition always
fails
Instead it always processes the "else" block.
When $filespec is a string I get (correct) output that looks like this:
filespec = somefile.txt, filespec type =
When $filespec is an arrayref I get (incorrect) output that looks like this
out of the else block:
filespec = ARRAY(0x3c01b424), filespec type =
where I expect to see something like:
filespec = ARRAY(0x3c01b424), filespec type = ARRAY
Anybody see where I've gone wrong?
Thanks for the help!
richf
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>