G'day peli,

Welcome to the Monastery.

As ++karlgoethebier pointed out, and which you apparently didn't understand, you have a disembodied "use version" at the start of your code. You probably intended something else (see version) but didn't complete that line. Perl keeps reading until it finds a statement terminator (the semicolon, two lines later); it sees something like this:

$ perl -MO=Deparse -e 'use version $X="x";' use version ($X = 'x'); -e syntax OK

Your choice of using dynamic, instead of lexical, variables is questionable. As you've only provided part of your code, it's not possible to tell what effect that might have. I'd recommend using lexical variables; and using them in the smallest scope possible.

You should always use the strict and warnings pragmata. See "perlintro - Perl introduction for beginners" for further discussion.

You are using two different methods for handling whitespace in pathnames (i.e. "X X" and "X\ X"). Investigate whether that's causing any problems.

It's hard to tell with only part of the code presented; however, it looks like you're performing various file operations without checking whether they worked as expected. Perl's builtin autodie pragma can probably do most, if not all, of this work for you; alternatively, write the code for these checks yourself.

— Ken


In reply to Re: Backup User's files by kcott
in thread Backup User's files by peli

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.