⭐ in reply to How do I get directory structure into a hash?
If you build your own, to avoid the problem merlyn you would probably do something like
A starting point:$result{home}{"."}[0] $result{home}{user1} $result{home}{user1}{"."}[0]
#!/usr/bin/perl -w use strict; use File::Find; use File::Spec::Functions qw(splitdir); use Data::Dumper; my %hash; find( sub { return if $_ eq '.' or $_ eq '..'; my $cursor = \%hash; $cursor = $cursor->{$_} ||= {} for splitdir $File::Find::dir; -d $_ ? $cursor->{$_} = { "." => [] } : push @{$cursor->{"."}}, $_; }, @ARGV); print Dumper \%hash;
|
|---|