On Wed, Jun 1, 2011 at 18:23, rodeored <in...@reenie.org> wrote:

> If I try adding the @: $output.="<p>".commify_series(@$topTypes[0])."</
> p>";
> There's no output.
>
> How do I just get the first line?

What you have there is an array of array references. (Aside: this
would be a great place to use Data::Dumper, to cue off a recent thread
on this list...)

Your final effort isn't working because the dereferencing operation
(the leading '@') is binding tighter than the subscripting operation
(the trailing '[0]'). Be a bit more explicit with the dereference:

use strict;
use warnings;

my @topTypes = (
  [ 'Type7' , 'Type8' ] ,
  [ 'Type4' , 'Type5' , 'Type6' ] ,
  [ 'Type2' ] ,
);

# like so:
print commify_series( @{ $topTypes[0] } );

# too lazy to write the real routine
sub commify_series { join ',' , @_ }


Incidentally, if you were running with 'use strict' and 'use
warnings', your previous attempt would have told you something like:

$ ./try.pl
Global symbol "$topTypes" requires explicit package name at ./try.pl line 14.

which is an indication that you're not really accomplishing what
you're trying to do.

chrs,
john.

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to