Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

need help with simple code "ls -al" with time in format 14:38 Mar 14

Status
Not open for further replies.

stuellry

Programmer
Apr 14, 2004
4
US
Absolute beginner in PERL but I want to replace LS with a PERL script that emulates "ls -al" and add some other features, please help.
 
Try looking at:

perldoc -f opendir
perldoc -f readdir
perldoc File::Stat
 
$result = `ls -al`;

print "$result\n";


Kind Regards
Duncan
 
stu,

Tom's pointers will get you off to a good start, actually form there, there's not a wild pile more you can do without developing a GUI.

What have you in mind of some other features

Dunc's method could give you some display flexibility, but not os portability
Code:
@results=`ls -la`;
foreach (@results) {
  (@atoms)=split (/\s+/,$_);
   #do something funky with the atoms
}

Let us know what you have in mind

--Paul
 
you can do something like this:

#!/usr/local/bin/perl

@ls = `ls -al`;

foreach $line (@ls) {
chomp $line;
$ls = join("\t", (split(' ', $line))[0,1,2,3,4,7,5,6,8]);
print "$ls\n";
}

it might not do what you want exactly but for quick and dirty it will get you started in what you want.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top