Chris Marshall wrote:
> Doug Hunt wrote:
>> Hi Edward:  Two ideas:
>>
>> One, try using the newer style file open:
>>
>> open my $fh, '<', $file or die "Cannot open $file";
>> binmode($fh); # not sure if this is necessary (probably not on unix)
>> my $header = readflex($fh, $hdr);
>>
>> (not tested!)
>>
>> I don't think its usual practice to pass raw file handles to routines:
>>
>> readflex(AREA, $hdr)
>>
>> The newer form of open gets around this problem.
>>
>> Secondly, it is sad that PDL does not have an unsigned long type, but you 
>> can often get away with using a signed long and then 'undoing' the sign 
>> bit manually and casting to a double:
>>
>> perldl> p $toobig =  (2**31 + 1)
>> 2147483649
>> perldl> p long($toobig)
>> -2147483648
>> perldl> p double(long($toobig) + (2**32 + 1))
>> 2147483649
>>
>> Regards,
>>
>>    Doug Hunt
>>
>>
>> [email protected]
>> Software Engineer IV
>> UCAR - COSMIC, Tel. (303) 497-2611
>>
>> On Mon, 9 Mar 2009, Hyer, Dr. Edward wrote:
>>
>>> Craig,
>>>
>>> You're right: 'long' works fine for this application. Thanks!
>>>
>>> I did get readflex() to work, but only by giving it the filename rather
>>> than the filehandle. As in, this works:
>>>
>>> $file='/path/to/file.dat';
>>> $hdr=[{NDims=>1,Dims=>[64],Type=>'long'}]
>>> $header=readflex($file,$hdr);
>>>
>>> This does not:
>>>
>>> open(AREA,"<$file");
>>> binmode(AREA)
>>> $header=readflex(AREA,$hdr);
>>>
>>> Error is 'PDL: Couldn't open 'AREA' for reading.'
>>>
>>> What am I doing wrong?
> 
> You might try passing a reference to a typeglob
> instead of the bare handle. (e.g. \*AREA)

I took a look at the perl documentation for PDL::IO::FlexRaw
and it explicitly says that you need a reference to a file
handle.  However, later in the short function descriptions,
the requirement for a reference to a file handle is not
shown.  Looks like a POD bug to me.

--Chris


_______________________________________________
Perldl mailing list
[email protected]
http://mailman.jach.hawaii.edu/mailman/listinfo/perldl

Reply via email to