[EMAIL PROTECTED] wrote:
> Hi, all.
> 
> Sorry to've ignited such a firestorm with my questions regarding
> stat() vs ls for file dating... ;-))  I hope this question will be
> less provocative.  
> 
> 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+(.*)$/;
> 
> 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?  

If you are using the GNU ls, then you could use the -Q switch to quote
the file name(s), which should make them easier to locate with a regex,
or possibly Text::Balanced.

However, I don't know why you would want to use ls and a regex. The
following seems easier and more reliable to me:

foreach (<*>) {
    print $_;
    print " -> ", readlink if -l;
    print "\n";
}

HTH

-- 
Brian Raven
 


-----------------------------------------------------------------------
The information contained in this e-mail is confidential and solely 
for the intended addressee(s). Unauthorised reproduction, disclosure, 
modification, and/or distribution of this email may be unlawful. If you 
have received this email in error, please notify the sender immediately 
and delete it from your system. The views expressed in this message 
do not necessarily reflect those of LIFFE Holdings Plc or any of its subsidiary 
companies.
-----------------------------------------------------------------------


_______________________________________________
ActivePerl mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to