I took your code and down loaded it, then I realized a few things:

A) you left out the first brace on the line
next unless $file =~ /\.t(?:ar\.)?gz\z/); # it should be next unless ($file =~ /\.t(?:ar\.)?gz\z/);
That was not meant to flame you, just to point it out for others who read this.

<ident>B) Your script runs into the same flaw as mine: It expands the archives in the CWD. I read the manual on tar, but it was older than tar, so the option I thought should work didn't. Really all I think I need to do is to change the current working directory to whatever $ARGV[0] is at the time. That should solve it. Thanx again for the regex compression. i re-wrote mine as this:
#!/usr/bin/perl -w $|++; use strict; my (@list, $d, $i); die "Need Directory Param!\n" unless $ARGV[0]; my $cmd = qq/tar -zxvf /; opendir LOCAL,$ARGV[0] || die "Cannot Open dir $ARGV[0]"; @list = readdir LOCAL; foreach $d (0..$#list) { if($list[$d] =~ /.+\.t?(ar\.)?gz/) { qx/$cmd $ARGV[0]\/$list[$d]/; $i++; } } print "$i files expanded!\n"; closedir LOCAL;
Of Course this is still a few lines larger than yours, but you see, this is my code and I kept it how i originally wrote it. No offense to you, but that is your code. Besides the fact that I did not explain my whole purpose in writing this program. I am going to expand this and need to have the directory read into an array for later use. Thanx again.

<straywalrus>

In reply to Re: Re: Yet Another Tar-Gzip File Expander by straywalrus
in thread Yet Another Tar-Gzip File Expander by straywalrus

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.