#!/usr/bin/perl #configuration thingies $lsdir = '/var/www/foto'; #this is the dir to look in $dir = '2004'; #hard to explain this one, but it doesnt matter much $year = '04'; #what is the value of yy in yy-mm-dd in on of the values grabbed ############################################## foreach (`ls $lsdir`) { #do a ls if (/album(\d{2,})/) { $album_nr = $1; $file = "$lsdir" . '/album' . "$album_nr" . '/album.dat'; open FILE, "$file" or warn "coud not open $file: $! \n" and next; #so this looks in each /var/www/foto/album{2,}/album.dat $/ = ';'; #each string in album.dat is seperated by a ; ;; $_ = ; s/\n//g; $name = (/.*\"(.*)\"/)[0]; #get the name from album.dat ; $_ = ; s/\n//g; ($desc = (/.*\"(.+)\"/)[0]) || ($desc = "");# get the description from album.dat while () { if (/parentAlbumName/) { $_ = ; $file_dir = (/.*\"(.+)\"/)[0]; last; } } #get the virtual directory from album.dat #all the values needed are stored. now some conditions the values should meet, or else get lost. if ($file_dir eq $dir) { if ($name =~ /\d\d\-\d\d\-\d\d/) { $date = "$&"; $date =~ s/\-//g; unless ($date =~ /^$year/) { warn "the date of album $album_nr ($name) doesn't seem to be in yy-mm-dd format. skipping..\n"; next; } } else { warn "the title of album $album_nr ($name) doesn't seem to contain a date, or a date in yy-mm-dd format. skipping..\n"; next; } #so if the values met those conditions, store them in @names. unshift @names, "$album_nr:$name:$desc\n"; } } } print "@names"; #print