Hi Siegfried

Am Dienstag, 19. April 2005 23.21 schrieb Siegfried Heintze:
> Hey Perlers!
>
> This code used to work and then I changed something 

_What_ did you change? 
If you don't k know: Use some version control system, so you can reconstruct 
all changes.

> and it no longer works! 
> The problem is the output no longer includes "string 2a" and "string 2b".
> What am I doing wrong?

put 

  use strict; 
  use warnigs; 

ot top of every script. I get the following with your code below:

   Useless use of push with no values at - line 15.

> How do explicitly assign an array (not an array reference, but an array) to
> an array cell?

You can't... an array element can only contain a scalar.

> Thanks,
> Sieg
>
>
> sub concat {
>   # All arguments are assumed to be strings or nested arrays of strings.
>   # Concatenate all elements of all arguments.
>   return join "", map ref eq "ARRAY" ? concat( @$_ ) : $_, @_ }
>
> my @sResult = ();
> push @sResult,  "string 1";
> push @sResult,  "string 2";
>
> my $nMark = @sResult;
>
> push @sResult, ();  # make an array of an array cell: does not work

perl -le '
use strict; use warnings;
my @a =(1,2,3);
push @a, ();
print join "-", @a;
'
# prints:
1-2-3

> push @sResult = "string 3";

push @sResult, "string 3";

> [EMAIL PROTECTED] = "string 2a";
> [EMAIL PROTECTED] = "string 2b";
>
> print concat [EMAIL PROTECTED];

hth, joe


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to