in reply to Re: Making tmp copies of files
in thread Making tmp copies of files

copy ("$html_dir/$figfile", "$html_dir/$figfile.tmp") or die "Can not make temporary copy of file: $1";
You have no idea how much I appreciate your help. I
made the suggested changes as you can see above, and
get this error:

Use of uninitialized value in concatenation (.) or
string at ./engine_figurelinks.pl line 53 (#1)
(W uninitialized) An undefined value was used as if it
was a mistake. To suppress this warning assign a
defined value to your variables.

To help you figure out what was undefined, perl tells
you what operation you used the dedefined value in.
Note, however, that perl optimizes your progrm and the
operation displayed in the warning may not necessarily
appear literally in your program. For example, "that
$foo" is usually optimized into "that" . $foo, and the
warning will refer to the concatenation (.) operator,
even though there is no . in your program.

Uncaught exception from user code:
HTML files do not exist: at ./engine_figurelinks.pl line 53

Replies are listed 'Best First'.
Re^3: Making tmp copies of files
by shotgunefx (Parson) on Feb 21, 2006 at 19:07 UTC
    This isn't going to work. $1 isn't defined as no capture has taken place.

    Try this.
    # For foo.htm => foo.htm.tmp opendir( HTMLSTORIES, "$html_dir") || die "HTML files do not exist: $! +"; @FigureArray = grep{/\.htm$/} readdir ( HTMLSTORIES ); foreach $figfile (@FigureArray) { copy ($figfile, "$figfile.tmp") or die "Can not make temporary cop +y of file [$figfile]: $!"; }
    BTW, make copies of the original before overwriting them. The last thing you want to do is blow them all away and realize you don't have backups.


    -Lee
    "To be civilized is to deny one's nature."
Re^3: Making tmp copies of files
by xdbd063 (Friar) on Feb 21, 2006 at 19:07 UTC
    This last problem turned out to be a system created
    problem. The files in /tmp are deleted on a time
    basis and all my files were gone. I just didn't
    realize it at first. IT WORKS!!!! Thank you very,
    very much!
Re^3: Making tmp copies of files
by alienhuman (Pilgrim) on Feb 21, 2006 at 19:24 UTC

    copy ("$html_dir/$figfile", "$html_dir/$figfile.tmp") or die "Can not make temporary copy of file: $1"; Isn't going to give you a meaningful error message, since as we pointed out earlier $1 is undef.

    IOW, your die message is going to look like: Can not make temporary copy of file: And you won't know which file the script died on.

    Try: copy ("$html_dir/$figfile", "$html_dir/$figfile.tmp") or die "Can not make temporary copy of file: $html_dir/$figfile\n";

    ----------
    Using perl 5.8.1-RC3 unless otherwise noted. Apache/1.3.33 (Darwin) unless otherwise noted. Mac OS X 10.3.9 unless otherwise noted.