--- zentara <[EMAIL PROTECTED]> wrote:
> Hi,
> I'm trying to find all .so.xxx files on my system.
> Eventually I want to do things with them, but for
> now I just want to identify them.
> 
> I pretty much have it, except I'm lacking enough
> regex knowledge to separate out the  so  from the .so.
> files.
> 
> I'm matching 
> 
> cursor
> moc_sound
> libqt.so.2
> libqt-mt.so
> etc.
> 
> It's pretty close but not clean enough.
> Anyone? Thanks.
> 
> ##########################################
> #!/usr/bin/perl -w
> use strict;
> use File::Basename;
> use File::Find;
> my $name;
> my $dirname= '/usr/lib';
> 
> find (\&found, $dirname);
> 
> sub found {
> ($name) = basename("$File::Find::name"); 
> if ($name =~ m/.so/){
> print $name,"\n";
> }}
> ##########################################

If I read your question correctly, you wanted to match files with a literal ".so." 
embedded in the
same (i.e., a dot both before and after the 'so'):

    #!/usr/bin/perl -w
    use strict;
    use File::Basename;
    use File::Find;
    my $dirname= '/usr/lib';
 
    find (\&found, $dirname);
 
    sub found {
        my $name = basename( $File::Find::name ); 
        if ($name =~ m/\.so\./){
            print "$name\n";
        }
    }

Note that I also declared $name in found() instead of outside of it.  Once the 
subroutine is
finished, you would only have the last value in $name anyway, so declaring it outside 
of the
function is useless.  On the other hand:

    my @names;

    sub found {
        my $name = basename( $File::Find::name ); 
        if ($name =~ m/\.so\./){
            push @names, $name;
        }
    }

I list that in the event you were trying to preserve the filenames for some reason.

Cheers,
Curtis "Ovid" Poe

=====
"Ovid" on http://www.perlmonks.org/
Someone asked me how to count to 10 in Perl:
push@A,$_ for reverse q.e...q.n.;for(@A){$_=unpack(q|c|,$_);@a=split//;
shift@a;shift@a if $a[$[]eq$[;$_=join q||,@a};print $_,$/for reverse @A

__________________________________________________
Do You Yahoo!?
Send FREE video emails in Yahoo! Mail!
http://promo.yahoo.com/videomail/

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to