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?

--Edward H. 

> -----Original Message-----
> From: Craig DeForest [mailto:[email protected]] 
> Sent: Sunday, March 08, 2009 9:54 PM
> To: Hyer, Dr. Edward
> Cc: Craig DeForest; [email protected]
> Subject: Re: [Perldl] Simple stuff: PDL::IO::FlexRaw and data types
> 
> Hi, Edward,
> 
> You're right, PDL doesn't have a ulong type -- only a ushort. 
>  Since your values aren't likely to be larger than 2**31, you 
> are probably OK  
> just using "long" rather than "ulong".   That might be the source of  
> your readflex error, too; why not try it with "long" instead 
> of "ulong"?
> 
> Cheers,
> Craig
> 
> 
> On Mar 8, 2009, at 10:22 PM, Hyer, Dr. Edward wrote:
> 
> > Hello PDL Wizards,
> >
> > Always embarrassed to ask easy questions, but I'm stumped.
> >
> > Trying to set up and read from a raw binary file (from 
> someone else).
> > File has a 64-item,unsigned-long header, which must be 
> queried to find 
> > the start and dimensions of the data block. Cribbing 
> directly from the 
> > FlexRaw docs, I did this:
> >
> > open(AREA,"<$file2");
> > binmode(AREA)
> > $head = readflex(AREA, [{NDims=>1, Dims=>[64], Type='ulong'}])
> > $pixels=$head->(9)
> > $lines=$head->(8)
> > $datastart=$head->(33)
> > seek(AREA,($pixels * $lines)+$datastart,0) $areadata = 
> readflex(AREA, 
> > [{NDims=>2, Dims=>[$pixels,$lines],
> > Type='byte'}])
> > close(AREA);
> >
> > Two questions:
> >
> > 1) I can't get past the first readflex(), because of this error:
> >
> > Can't modify constant item in scalar assignment at (eval 
> 119) line 4, 
> > at EOF
> >
> > 2) Does PDL actually have a 'ulong' type? (32-bit unsigned)
> >
> > Thanks,
> >
> >
> > --Edward H.
> >
> > _______________________________________________
> > Perldl mailing list
> > [email protected]
> > http://mailman.jach.hawaii.edu/mailman/listinfo/perldl
> >
> 
> 

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

Reply via email to