tachyon has asked for the wisdom of the Perl Monks concerning the following question:

Does anyone know if there is a perl module that produces an expanding/condensing directory tree structure like you see in Windows Explorer, Midnight Commander, etc? There are plenty of javascript examples. I could not find this functionality in perl so I wrote a little module to do it. I just want to know if there is any point in packaging it up for CPAN as say HTML::FolderTree

cheers

tachyon

s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print

  • Comment on Folder Tree functionality in perl. Does it exist?

Replies are listed 'Best First'.
•Re: Folder Tree functionality in perl. Does it exist?
by merlyn (Sage) on Nov 30, 2002 at 15:21 UTC
Re: Folder Tree functionality in perl. Does it exist?
by hawtin (Prior) on Nov 30, 2002 at 15:16 UTC

    Try Tk::DirTree

Re: Folder Tree functionality in perl. Does it exist?
by rob_au (Abbot) on Dec 01, 2002 at 08:43 UTC
    <merlyn> I actually wrote something like this recently </merlyn>

    I implemented this through the use of a CGI script and a patched Template Toolkit installation. This patch to the Template Toolkit was to add support for bitwise AND and XOR operations into templates - This patch can be found here and has been submitted to Andy Wardley for consideration for incorporation into the Template Toolkit distribution. This code made the development of this Folder Tree functionality quite easy and can be demonstrated temporarily here.

    The CGI script employed is quite simple:

    #!/usr/bin/perl -Tw use CGI; use CGI::Carp qw/ fatalsToBrowser /; use Template; use strict; my $cgi = CGI->new; my $index = 0; if ( defined $cgi->path_info ) { my $path = substr( $cgi->path_info, 1 ); $index = $1 if $path =~ /^(\d+)$/; } my $template = Template->new({ 'INCLUDE_PATH' => '/http/development.co +wsnet.com.au/templates' }); my $html = ''; $template->process( 'navigation.tt2', { 'index' => $index }, \$html ) || croak( 'main:: - Cannot process output template - ', $template->e +rror ); print STDOUT $cgi->header, $html; exit 0;

    The corresponding template file can be found here - The integer value passed to this CGI script as additional path information is employed through the use of bitwise operations in the template in the following fashion:

    <tr> <td bgcolor="#eeeeee" style="padding:2px 4px 2px 4px;" onMouse +Out="this.style.backgroundColor='#eeeeee';" onMous eOver="this.style.backgroundColor='#cbcbe8';"> <font face="Arial" style="font-size:8pt;"><b><a href="/cgi-b +in/navigation.cgi/[% index ^ 1 %]" style="text-dec oration:none;">Access Control</a></b></font><br> </td> </tr> [% IF index & 1 %] <tr> <td bgcolor="#aaaaaa"><img src="/images/spacer.gif" border="0" + height="1" width="1" alt="" /></td> </tr> . . [% END %]

    The bitwise AND and XOR operations are used to test the expansion/collapse state of the folder tree and the switching of integer bits respectively.

     

    perl -e 'print+unpack("N",pack("B32","00000000000000000000000111101110")),"\n"'