in reply to Creating table from file lists
( Just kidding!! :)
#!/usr/bin/perl use strict; use warnings; my $h; while (<DATA>) { chomp; s|^/|\$h->{'|; s|/|'}{'|g; s|([^']*)$|\0$1'} = 1;|; eval; } use Data::Dumper; $Data::Dumper::Indent = 1; $Data::Dumper::Sortkeys = 1; open my $savedout, ">&STDOUT" or die $!; close STDOUT; open STDOUT, ">", \my $dump or die $!; print Dumper $h; open STDOUT, ">&", $savedout or die $!; open my $fh, "<", \$dump or die $!; while (<$fh>) { s/^(\s*)'/$1/; s/' =>.*//; next if /^\$|\s*}/; print; } __DATA__ /a/f1.mp3 /a/f2.mp3 /a/b/f1.mp3 /a/b/f2.mp3 /a/b/f3.mp3 /a/c/f1.mp3 /a/c/f2.mp3 /a/c/e/f5.mp3 /a/c/e/f6.mp3 /b/d/f4.mp3
Output:
a f1.mp3 f2.mp3 b f1.mp3 f2.mp3 f3.mp3 c f1.mp3 f2.mp3 e f5.mp3 f6.mp3 b d f4.mp3
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Creating table from file lists
by jakobi (Pilgrim) on Oct 05, 2009 at 16:38 UTC | |
by almut (Canon) on Oct 05, 2009 at 22:17 UTC | |
by jakobi (Pilgrim) on Oct 05, 2009 at 23:02 UTC |