Hi Dennis-

It is a bit difficult to debug something without sample
input data.  I created the following 'opacity.txt' file:

 less opacity.txt
> bogus 2 7
> funny 0 99
> Rosseland 1 3
>

and then ran your rcols() line by hand in the pdl2 shell
(highly recommended as a debugging tool and for
creating/verifying small test cases.  This is what I
got:

pdl> @aux = rcols 'opacity.txt', { perlcols=>[0] }
> Reading data into piddles of type: [ Double Double ]
> Read in 3 elements.
>
> pdl> p @aux
> ARRAY(0x386f170) [2 0 1] [7 99 3]
>
> pdl> p @{ $aux[0] }
> bogus funny Rosseland
>

so you can see the problem is that you are
matching against the last column (a piddle)
instead of the first column, a ref to a perl array
with the strings.  I looked at the docs for
rcols() and it appears that the behavior
seen is not quite as documented (although
it is the original behavior).

The latest rcols() now can treat the
PERLCOLS column data and the numeric
piddle columns on an equal footing so
there is no real reason to tack them on
the end out-of-order with the other
column data.  If you use $aux[0] which
is now col0, things should work out.

--Chris

On Tue, Jan 17, 2012 at 3:59 PM, Denis Gonzalez <[email protected]>wrote:

> Hi everyone,
>
> I just to update my fedora  (from 13 to 16) and I am trying to run a old
> pdl code but it doesn't work.  The code extracts the first column of the
> file "opacity.txt" an save it in a perl array ,,,and then it looks for the
> position of the string "Rosseland".
>
> The shell shows me the following message:
>
> "multielement piddle in conditional expression at test.pl line 9"
>
> Does anybody know how to write the lines 8 and 9?
>
> The code:
>
> #!/usr/bin/perl
> use PDL;
> use List::MoreUtils qw{firstidx};
>
> $fname  = sprintf('opacity.txt');
> @aux    = rcols $fname,{PERLCOLS => [0]};
> @col0   = @{$aux[-1]};
> #line 8
> $position   = firstidx { $_ eq 'Rosseland' } @col0;     #line 9
> print $position, "\n";
>
> Regards,
> Denis.
>
>
> _______________________________________________
> 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