develooper Front page | perl.beginners | Postings from September 2011

File test failed!

Thread Next
From:
yyq@eisoo.com
Date:
September 16, 2011 02:53
Subject:
File test failed!
Message ID:
4E731C95.7000600@eisoo.com
Hi, All:

     I want to test if a file exists or it is a link or not, the code is:
#!/usr/bin/perl -w

use strict;
use File::Basename;
use File::stat;
use Fcntl ':mode';

my $elfobj = $ARGV[0];

sub strtrim ()
{
     #.....
}

sub copyfile ()
{
     #.....
}

my @deps = `ldd $elfobj`;
foreach my $lib (@deps) {
     chomp ($lib);
     my ($dep,$path) = split ("=>", $lib);
     ##handle path, and it value is /lib64/ld-linux-x86-64.so.2, which 
is a link file.
             if (-e $path) {
                 print $path."\n";
             }
}

But the highlighted code always return undef. When put the code outside 
of the foreach, it ok. Any one encountered this situation?


Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About