Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: Extracting files from .7z using Perl

by Lotus1 (Priest)
on Jun 12, 2017 at 13:53 UTC ( #1192628=note: print w/replies, xml ) Need Help??


in reply to Extracting files from .7z using Perl

It appears you are attempting concatenation with the '.' operator but inside of qq(). In that context the period is just text and not an operator. Try getting your glob to work first and keep adding small tested chunks to your program until you have built up what you need. Also, the '\' backslash inside a glob is seen as quoting the next character. You need to use the front slash '/' inside a glob.

Just glancing at the rest of the program, I don't think millions of calls to 7z.exe is going to work like this. Inside your nested loop when you call 7zip each time it will need to extract the archive to find the file you need. It might make more sense to unzip everything at once to a temporary folder and then operate on the files, then remove the temporary folder.

# !perl use strict; # because we should use warnings; # because we should my $base = 'C:\usr\pm\temp\test1\\'; my $search = qq($base.Gridfee0?.7z\\); print "1: $search \n"; my $search2 = qq(${base}Gridfee0?.7z\\); print "2: $search2 \n"; my $search3 = qq(C:/usr/pm/temp/test1/Gridfee0?.7z\\); print "3: $search3 \n"; my $archive = glob qq($base.Gridfee0?.7z\\); #Tried glob qq($base.Gridfee0?.7z\\Gridfee*\\) and glob qq($base.G +ridfee0?.7z) too, same result print "archive = $archive\n"; my @archs = glob $search3; #Tried glob qq($base.Gridfee0?.7z\\Gridfee*\\) and glob qq($base.G +ridfee0?.7z) too, same result print "archs = @archs\n"; __END__ Use of uninitialized value $archive in concatenation (.) or string at +C:\usr\pm\temp\1192612.pl line 18. 1: C:\usr\pm\temp\test1\.Gridfee0?.7z\ 2: C:\usr\pm\temp\test1\Gridfee0?.7z\ 3: C:/usr/pm/temp/test1/Gridfee0?.7z\ archive = archs = C:/usr/pm/temp/test1/Gridfee02.7z\ C:/usr/pm/temp/test1/Gridfe +e05.7z\

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (3)
As of 2018-11-18 03:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My code is most likely broken because:
















    Results (205 votes). Check out past polls.

    Notices?