Am coding to display directory contents on a HTML page and liked the look of File::Listing to parse the directory. My problem is that calling the parse_dir command doesn't work as I thought it would. The manual (un)helpfully provides only this to describe it's application:
parse_dir(`ls -l`)
But hey that's ok, I need to move up/down directory trees so I thought it'd be a doddle to change the function call thus:
my $dir = "/foo";
parse_dir("ls -l $dir")
Except it doesn't work!!!
even calling the function with single quotes i.e.parse_dir('ls -l') won't return.
I can get around it by calling a chdir() command prior to issuing the parse_dir call but i'm running under mod_perl so that just opens another can of worms...
What's with the back apostophe?! And how can I get around this with my teeth intact?...it's tarnishing my saintly demeanour!!
Paul
I don't know this module, but based on your desciption, you want:
my $dir = "/foo"; parse_dir(`ls -l $dir`);
The backquote operator is described in [perldoc://perlop], but briefly, it executes an external command, capturing its (standard) output.
HTH,
print "Just another Perl ${\(trickster and hacker)},"
The Sidhekin proves Sidhe did it!
In the computing world, ` (`, backtick or backquote), ' (', single-quote), and " (", double-quote) are all different things, and are used for different purposes. If you can't tell the difference between the three, change your font. The documentation used ` (backtick), because the point is that it runs ls -l, then passes the output of that command to the function parse_dir.
You can find all three documented in great detail in perlop.
(Note, BTW, that while ' is both single-quote and apostrophe, the single-quote meaning is normaly the one that is being referred to when ' is used, except in strange circumstances, or inside of a human-readable string.)
If you are using Apache on *nix you can make a dir/subdirs readable in a browser simply by making that dir world readable (readable by apache) with chmod. Provided you don't have an index.htm (or whatever your config details as the defualt) Apache will produce a nice browsable dir listing for you.
cheers
tachyon
------
We are the carpenters and bricklayers of the Information Age.
Then there are Damian modules.... *sigh* ... that's not about being less-lazy -- that's about being on some really good drugs -- you know, there is no spoon. - flyingmoose
I shouldn't have to say this, but any code, unless otherwise stated, is untested
I would never put a default Apache build on a production box. But, that's just me.
Neither do I. mod_perl and mod_rewrite and getting the latest patches are amongst the reasons, not excluding mod_dir ;-)
cheers
tachyon
perlmonks.org content © perlmonks.org and dragonchild, paulpi, Sidhekin, tachyon, theorbtwo
prlmnks.org © 2006 edmund von der burg (eccles & toad)
v 0.03