Can't make sense out of this Perl code -
this snippet reads file line line, looks like:
album=in between dreams interpret=jack johnson titel=better titel=never know titel=banana pancakes album=pictures interpret=katie melua titel=mary pickford titel=it's in head titel=if lights go out album=all lost souls interpret=james blunt titel=1973 titel=one of brightest stars
so somehow connects "interpreter" album , album list of titles. don't quite how:
while ($line = <in>) { chomp $line; if ($line =~ /=/) { ($name, $wert) = split(/=/, $line); } else { next; } if ($name eq "album") { $album = $wert; } if ($name eq "interpret") { $interpret = $wert; $cd{$interpret}{album} = $album; // assigns album interpreter? $titelnummer = 0; } if ($name eq "titel") { $cd{$interpret}{titel}[$titelnummer++] = $wert; // assigns titles interpreter - wtf? how can work? } }
the while
loop keeps running , putting current line $line
long there new lines in file handle <in>
. chomp
removes newline @ end of every row.
split
splits line 2 parts on equal sign (/=/
regular expression) , puts first part in $name
, second part in $wert
.
%cd
hash contains references other hashes. first "level" name of interpreter.
(please ask more specific questions if still not understand.)
Comments
Post a Comment