in reply to creating word from array of array

@characters = ( [ "h" ], [ "e" ], [ "l", "p", "i" ], [ "l" ], [ "o" ], ); sub spell{ my $prefix = shift; my @c = @{+shift}; unless( @c ){ return print "$prefix\n"; } foreach( @c ){ spell("$prefix$_",@_); } } spell("",@characters);

Replies are listed 'Best First'.
Re: Re: creating word from array of array
by dvergin (Monsignor) on Feb 16, 2002 at 23:15 UTC
    This code fails at "my @c = @{+shift};" with the message, "Can't use an undefined value as an ARRAY reference..."

    Fixing that leads to an endless loop with a warning about an uninitialized value.

    Update: /me puzzles over screamingeagle's results with the same OS and Perl version and wonders why copy-and-paste ain't what it used to be...

      fyi...the code ran just fine for me (Windows 98 ,ActiveState Perl 5.6.0)
      (++ for your post too) :-)