'ls' question, splitting and files with spaces in their name...

Rick Delaney rick-h4KjNK7Mzas at public.gmane.org
Sun May 23 18:29:21 UTC 2004


On Sun, May 23, 2004 at 11:43:16AM -0400, Madison Kelly wrote:
> Hi Tim,
> 
>   I am trying to test this command with a mini script I wrte based on 
> your suggestion but for the life of me I can't get the darn thing to 
> tun. Can you see if I made an error somewhere?

I considered mentioning readdir/stat but it seemed to me you were
writing shell scripts in Perl so I decided there was no need to get
"fancy".  It looks like I was right. ;-)

> =- Code
> #!/usr/bin/perl
> use CGI::Carp "fatalsToBrowser";
> print "Content-type: text/html\n\n";
> 
> print "<pre>\n";
> opendir(DIR, /home) or die "Can't open root: $!";
Hint:          ^^^^^

> for (readdir(DIR))
> {
> 	($dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $size, $atime, 
> 	$mtime, $ctime, $blksize, $blocks) = stat($_);
> 	print "$dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $size, $atime, 
> $mtime, $ctime, $blksize, $blocks\n";
> }
> closedir(DIR)
Future hint:   ^

> print "</pre>\n";
> =- End Code

When you get this to compile, please consult the readdir entry in
perlfunc.  It will explain why it only works for the current directory.

Hope this helps,

-- 
Rick Delaney
rick-h4KjNK7Mzas at public.gmane.org
--
The Toronto Linux Users Group.      Meetings: http://tlug.ss.org
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://tlug.ss.org/subscribe.shtml





More information about the Legacy mailing list