CUFP
blazar
snippet
<div class="Description">Minimal example exhibiting a <strong>double reference autovivification trick</strong> (learnt from <em>Brian McCauley</em> in a [href://news:comp.lang.perl.misc|clpmisc] [href://news:1155102735.358626.78050@i3g2000cwc.googlegroups.com|thread]) to convert a list of structured strings as that below the <c>__END__</c> token to a complex data structure as that illustrated by the output of the program. [id://567024|More details] follow.</div>
<c>
#!/usr/bin/perl
use strict;
use warnings;
use Data::Dumper;
my %dirhash;
while (<DATA>) {
chomp;
my $last=\\%dirhash;
$last=\$$last->{$_} for split qr|/|;
}
print Dumper \%dirhash;
__END__
/file.txt
/a/file.txt
/a/b/c
/a/b/c/file.txt
/z/m/w/file.txt
</c>