in reply to Re: Tar GZip Question
in thread Tar GZip Question

to:
system("/usr/bin/mv ./katt0$number.tar.gz ../html/img/katt0$number.tar.gz");
Err no. You're right he doesn't need to escape the dots of course, but his system LIST form avoids the shell, yours doesn't.
rename("$tarball", "../html/img/$tarball");

That is usually better, but don't forget to mention the caveat that mv(1) will work across filesystem boundaries and rename won't. File::Copy is what you usually want when you're using rename. (Oh, and why the quotes around $tarball?)

Playing with $ENV{PWD} does not do anything other than confuse yourself - it doesn't actually change the working directory. You either want to actually chdir or (as I posted above) use the -C option to tar.

Makeshifts last the longest.

Replies are listed 'Best First'.
Re: Re^2: Tar GZip Question
by l2kashe (Deacon) on Oct 30, 2002 at 20:11 UTC
    I didn;t know about that functionality in regards to the LIST context of the system command..

    I quoted $tarball cause I'm paranoid.. I always quote, or use braces liberally... I'd rather be overly paranoid and make sure the guy coming after me knows exactly what I meant when I wrote it as opposed to leaving some ambiguity...

    And thanks for the chdir ... couldn't remember the function name, but I knew it was buried in there somewhere..

    /* And the Creator, against his better judgement, wrote man.c */
      You won exactly nothing by quoting $tarball though - it doesn't have any noteworthy effect other than making Perl do some extra work to concatenate it into a new string consisting only of the variable's content. You also break references if you try to pass them around like this, and if you don't enable strictures, you're going to accidentally be turning the references into symbolic ones to boot. Perl ain't shell, so don't quote variables when you're not concatenating them into a larger string.

      Makeshifts last the longest.