[EMAIL PROTECTED] wrote:
At one point in my script, I still use ls to get a line of data for files,
what I'm trying for is a regexp that'll pull the filename out--including
soft links. What I have right now--while it works--is rather, um, long:
$line =~
/^[-l][-rswx]{9}\s+\d+\s+\w+\s+\w+\s+\d+\s+\w+\s+\d+\s+(?:\d{4}|\d\d:\d\d)\s+(.*)$/;
I had a shorter regexp, actually *much* shorter:
$line =~ /^.+(?:\d{4}|\d\d:\d\d)\s+(.*)$/;
The long ls on my machine looks like it's a fixed format. It's 53
characters from the line start to the first character of the time, so
start the regexp with the exact number of "any" characters :
$line =~ /^.{52}(\d\d:\d\d)\s+(.*)$/;
Either that or use unpack:
my ($time, $name) = unpack("x52a5xa*", $line);
but it ran into a problem with the following file line:
lrwxrwxrwx ... Sep 10 15:15 1614 -> /opt/K/SCO/...1614
It tripped on the 1614 and returned only "-> /opt/K/SCO/...1614" as the
filename. Anyone have any suggestions for shortening that monster regexp
listed above?
_______________________________________________
ActivePerl mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs