|
| WICHTIG !!!!!!!! Hi ihr Perlers
Ich möchte Euch mitteilen, das Ihr den """Wallbanger"""" bitte aus Eurer
Liste streichen sollt.!!!!!!!!!!
Ich habe keine Lust, jeden Montag über 100 Mails von Euch zu Löschen.
OLAF KLENNER ist jetzt ein 1/2 Jahr schon TOD !!!!!!
mit lieben Gruß
Sonja seine Frau!!!!!
----- Original Message -----
From: "Gunnar Hjalmarsson" <noreply@gunnar.cc>
To: <beginners@perl.org>
Sent: Friday, October 29, 2004 1:19 AM
Subject: Re: Extracting Directories and Sub Directories and Counting
> [ replying to the list since that's where the discussion belongs ]
>
> Ron Smith wrote (to me privately):
>
> Well, it's not a special variable type. $HoA{$dir} is a reference to an
> anonymous array, which you dereference with the @{ $HoA{$dir} } construct.
>
>
> I now realize that the small piece of code above combines three
> components of Perl that make it a really powerful programming language:
> Hashes, references and regular expressions.
>
>
> Sounds plausible. :)
>
>
> Hmm.. It's usually practical to not add "\n" like that, but take care of
> linebreaks in connection with printing the variable. Without adding
> "\n", instead of saying
>
> print @basenames;
>
> you can say e.g.
>
> print join("\n", @basenames), "\n";
>
>
> No, it's rather just because you didn't declare the %count hash properly
> (you also had 'frames' instead of '$frames' a couple of times). Instead of
>
> for my $frames (@{ $HoA{$dir}}) {
> my $count{frames} += 1;
> print "$count{frames}\n";
> }
>
> you want
>
> my %count;
> for my $frames ( @{ $HoA{$dir} } ) {
> $count{$frames} += 1;
> print "$count{$frames}\n";
> }
>
>
> Now when I've helped you with the syntax error, I believe you can figure
> out how to print the counts similar to what you did with the previous
> code version. If not, please feel free to post (to the list) again.
>
>
> References and data structures are indeed tricky in the beginning - I
> sure thought they were - but they are well documented at the same time.
> These are some applicable parts of the Perl docs:
>
> perldoc perlreftut
> perldoc perlref
>
> perldoc perldsc
> perldoc perllol
>
> As regards books, others are better suited than me to give
> recommendations (the only Perl book I have is the "Camel").
>
>
> Only you can tell.
>
> --
> Gunnar Hjalmarsson
> Email: http://www.gunnar.cc/cgi-bin/contact.pl
>
> --
> To unsubscribe, e-mail: beginners-unsubscribe@perl.org
> For additional commands, e-mail: beginners-help@perl.org
> <http://learn.perl.org/> <http://learn.perl.org/first-response>
>
>
|
|