0

So running into an issue with my code here not sure what exactly i'm doing wrong i pass it the two arguments it searches for the file but its always going to does not exist.

i pass this to the file

perl restore.cgi users_old_52715.tar.gz Ace_Walker

its not finding the file it exist i assure you.

#!/usr/bin/perl
use Archive::Tar;

my $tarPath    = $ARGV[0];
my $playerfile = $ARGV[1].".ini";



my $tar = Archive::Tar->new($tarPath);
if ($tar->contains_file($playerfile)) {
    $tar->read($tarPath);
    $tar->extract_file($playerfile, './' );
    print "Successfully restored $playerfile to production enviroment\n";
    exit 0;
}else{
    print $playefile." does not exist in this archive!\n";
    exit 0;
}
4

2 回答 2

0

只需写Scott Hunter评论作为答案:

尝试使用绝对路径而不是相对路径。

于 2015-07-16T17:09:39.323 回答
0
if( $tar->extract_file($playerfile, './'.$playerfile )){ 
  print "Successfully restored $playerfile to production enviroment\n";
}
exit 0;

man Archive::Tar

$tar->extract_file( $file, [$extract_path] )
写入一个条目,其名称等同于提供给磁盘的文件名。可选地采用第二个参数,它是条目将被写入的完整本机路径(包括文件名)。

于 2015-07-16T17:10:06.783 回答