Home > Archive > PERL CGI Beginners > February 2005 > Addendum: Content_Length.
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Addendum: Content_Length.
|
|
|
| Why the length is not coming out? Any ideas?
########################################
#########
my @aho = ("fgfgfgf", "fgfgfgfgf", "fgfgfgfg");
my $length += length($_) for @aho;
print "Content-type: text/plain\n\n";
print "$length";
########################################
#########
Thanks,
Sara.
| |
| Bob Showalter 2005-02-03, 3:55 pm |
| Sara wrote:
> Why the length is not coming out? Any ideas?
>
> ########################################
#########
>
> my @aho = ("fgfgfgf", "fgfgfgfgf", "fgfgfgfg");
>
> my $length += length($_) for @aho;
A perl "gotcha". The 'for' modifier creates a loop, and the 'my' is scoped
to the body of that loop (I think; I may not be exactly correct here). You
need to write it like this:
my $length;
$length += length($_) for @aho;
|
|
|
|
|