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

Rick Delaney rick-h4KjNK7Mzas at public.gmane.org
Sat May 22 14:19:58 UTC 2004


On Sat, May 22, 2004 at 09:48:20AM -0400, Madison Kelly wrote:
> Hi all,
> 
>   I need to read in the results of an 'ls' call to a bunch of variables 
> (in Perl) and I am doing so like this:
> 
>  =- Snip
> 	open (LS, "ls -lA '$mnt_dir' 2>&1 |");
> 	while (<LS>)
> 	{
> 		s/\n//;

    chomp;

> 		# The first $perm will be "total"
> 		($perm, $num, $owner, $group, $size, $month, $day, 
> 		$time_year, $file)=split/\s+/;

Limit the number of fields to split into:

    split " ", $_, 9;

perldoc -f split

-- 
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