I am trying a script where I am in directory C:/perl64/bin/extract. My perl script is in this directory and .caz(form of zip) files are also there in this directory. My script creates another directory in the above directory using the names of .caz files. and copied them into respective folders. I am trying to extract this .caz files in the newly created directory i.e C:/perl64/bin/extract/$newdir(name as .caz file). When I am excuting the scirpt the files are extracting at C:/perl64/bin/extract , but I want to change to new directory and extract eh fiel inside that. Please help me. code I am using is below. I tried servral options to "cd" in windows but not able to execute the file inside the new directory.

open(DAT, $data_file); my @raw_data = <DAT>; foreach my $fileLine1 (@raw_data) { chomp($fileLine1); my @dir = split('\.caz',$fileLine1); foreach my $newdir (@dir){ chomp($newdir); mkdir $newdir; my $newdir1 = "$dir\\$newdir"; opendir(DIR, $dir) or die "can't opendir $dir: $! \n"; @files=readdir(DIR); closedir DIR; my $oldfile="$dir\\$newdir.caz"; copy($oldfile, $newdir1) or die "File cannot be copied"; #my $final_dest= "C:\\Perl64\\bin\\extract\\$newdir"; #my $cmd1 = system("cmd /K cd /d $newdir1"); #my $cmd1= "cd C:\\Perl64\\bin\\extract\\$newdir"; my $cmd1= 'cd C:\Perl64\bin\extract\$newdir'; open (CMD, "|$cmd1") or die "fail1"; #chdir("C:\\Perl64\\bin\\extract\\$newdir\\"); #print $cmd1; my $cmd = "cazipxp -u $newdir\.caz"; my %newfiles = open (CMD, "|$cmd") or die "fail"; }}

In reply to change directory in windows and extract the files from a .zip file inside the folder by sreevno

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.