which shows me the output of#!/usr/bin/perl -w use strict; use Data::Dumper; sub data_for_path { my $path = shift; if (-f $path or -l $path) { #files or symbolic links return undef; } if (-d $path) { my %directory; opendir PATH, $path or die "cannot opendir $path: $!"; my @names = readdir PATH; closedir PATH; for my $name (@names) { next if $name eq '.' or $name eq '..'; $directory{$name} = data_for_path("$path/$name"); } return \%directory; } warn "$path is neither a file nor a directory\n"; return undef; } print Dumper(data_for_path('.'));
But I was trying to do it without datadumper to see if I can print out the structure..(possibly with references) tried couple things but does not work.. any suggestion? Problem I see is that I am not so sure what is being return from the sub routines.. and even if I know what it looks like, if sub directory has multiple subdirectories.. woudln't it make it almost impossible to build a right structure of reference?$VAR1 = { 'perl.1' => undef, 'bin' => { 'perl.1' => undef, 'chaos.1' => undef }, 'perl.sub_sub' => undef, 'perl.sub_multi' => undef, 'chaos.1' => undef, 'perl.filehandle' => undef, 'man' => {}, 'lib' => { 'yahoo3' => { 'yahoo3' => { 'yahoo1111' => undef }, 'yahoo5' => undef }, 'yahoo2' => undef, 'yahoo' => undef }, 'perl.log' => undef, 'perl.recursive_data' => undef, 'perl.callbacks' => undef };
In reply to subroutine reference questions by convenientstore
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |