Create a gist now

Instantly share code, notes, and snippets.

Continuity based browser "deep ls"
#!/usr/bin/env perl
use strict;
use warnings;
use Continuity;
use File::chdir;
my $server = Continuity->new(port => 8080);
sub main {
my $req = shift;
$req->print( <<END );
<form method=POST>
Enter a directory name:
<input name=dir>
<input type=submit>
my $dir = $req->param('dir');
sub do_something {
return shift . "</br>";
sub walk_dir {
my $dir = shift;
local $CWD = $dir;
opendir(my $dh, $CWD);
my $return = "In: $CWD</br>";
while (my $entry = readdir $dh) {
next if ($entry =~ /^\.+$/);
if (-d $entry) {
$return .= walk_dir($entry);
} elsif (-f $entry) {
$return .= do_something($entry);
return $return;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment