in reply to Re: Re: Re: Re: Adding and Deleting Upload File name and File
in thread Adding and Deleting Upload File name and File
You say you also tried my %test = (@song_titles, @song_files); which just strings the two lists together but because a hash takes pairs of elements you found that the pairings were incorrect. This can be resolved with my initial example (see above post) of @songs{@song_titles} = @song_files;.# i renamed %test to %songs for sanity's sake for my $song_title (keys %songs) { my $song_file = $songs{$song_title}; if (grep $_ eq $song_file, @{$q->param('files')) { delete $song{$song_title}; unlink $song_file; } }
The thing with hashes is that the keys are all unique so to me it would make more sense if you used the filename (including path) as the key and the title (which there may be more than one instance of) as the value - this also removes your need to iterate through the songs to find the one to delete. Just an idea to make it work for you instead of the other way around.
Hope this helps,
larryk perl -le "s,,reverse killer,e,y,rifle,lycra,,print" Will code for food - looking for work - London - CV
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: Re: Re: Re: Adding and Deleting Upload File name and File
by lex2001 (Sexton) on Dec 06, 2001 at 14:33 UTC | |
by larryk (Friar) on Dec 07, 2001 at 15:43 UTC |