Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: help with unraring

by nikosv (Hermit)
on Apr 24, 2012 at 07:41 UTC ( #966756=note: print w/ replies, xml ) Need Help??


in reply to help with unraring

list_files_in_archive does not return references to the contained files but just dumps them to stdout. If you need to get the filenames then you must capture the stdout and process it. Instead of forking, use the IO::CaptureOutput module

use Archive::Unrar qw(list_files_in_archive process_file); use IO::CaptureOutput qw(capture); my @files; { local ($stdout, $stderr); capture sub {list_files_in_archive( file=>"C:/perl2exe/For perl 5.10. +1/test.rar" ,undef)}, \$stdout, \$stderr; @files=map {/Archive contents : (.*\.txt$)/ } split ("\n",$stdout); } foreach (@files) { print "file ",++$i," : ",$_,"\n"; }

Also check the $result value to get and indication of the error returned


Comment on Re: help with unraring
Download Code
Re^2: help with unraring
by gautamparimoo (Beadle) on Apr 24, 2012 at 11:23 UTC

    thanks for the reply. $result gives error -->found in chain.already processed. What does that mean ? How can i remove it?

      is that a multipart file you are trying to extract? you can safely ignore this message;it merely says that the file has been already processed.It is used for caching purposes

        yes it is a multipart file. But the archive is not extracted to the given directory because of this error.

        Also can you tell me how to process each extracted file one at a time such that one file is extracted and its contents are processed for a regex than the next one is processed in similar fashion and so on instead of just extracting in a single go?

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://966756]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (14)
As of 2014-10-02 14:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    What is your favourite meta-syntactic variable name?














    Results (61 votes), past polls