Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
=head1 NAME File autobackup utility =head1 SYNOPSIS autobackup -d: The d flag backs up files to/from the locations hardcoded in +to the script. Only use this if you have edited in your own loc +ations. autobackup -h: The h flag displays usage information. Use it for instructio +ns. autobackup -p FILEPATH: The p flag should be used if you have not set up the script +to work with the d flag. When calling the script with the p flag, you should specifiy + the filepath of the files you want to be copied as an argument: "autobackup -p C:\myfiles". You + will then be asked for a target location for the files in the directory that you specified w +hen you called the program. I'M ASSUMING WE ALL KNOW HOW TO ENTER PROPPER FILEPATHS... =head1 DESCRIPTION In a nutshell, this script copies files from one location to another. I wrote this script to transfer files from my computer to an external +drive easily more easily. =head1 DEPENDENCIES This script requires the File::Copy::Recursive module. =head1 AUTHOR Matthew Young ( [] =cut #!usr/bin/perl use strict; use warnings; use File::Copy::Recursive qw(dircopy); use Getopt::Std; use Pod::Usage; #--------file copy vars (uncomment if you want) #local $File::Copy::Recursive::SkipFlop = 1; #keeps the script going i +f somethign fails #$File::Copy::Recursive::MaxDepth #you can set this to change the maxi +mum depth of the copy. #I get to play with hashes a bit... #grabs our argv values and stores them in a hash (key is the flag, val +ue is the actual argument) my %options=(); getopts('dp:h', \%options); pod2usage(2) if (keys %options != 1); if ($options{d}){ #if 'default' flag: #paths can be changed by editing what's in qw() - on the left is l +ocation of files, #on the right is where you want to put them. my ($original, $targetlocation) = qw/C:\test C:\test1/; my ($numberoffiles, $numberofdirs, $depth) = dircopy($original, $t +argetlocation) or die $!; print "$numberoffiles files copied, across $numberofdirs directori +es, at a level of depth of $depth."; } if ($options{p}){ #if 'path' flag: my $original = $options{p}; print "Target directory: "; my $targetlocation = <STDIN>; chomp $targetlocation; my ($numberoffiles, $numberofdirs, $depth) = dircopy($original, $t +argetlocation) or die $!; print "$numberoffiles files copied, across $numberofdirs directori +es, at a level of depth of $depth."; } if ($options{h}){ pod2usage(2); #YES! }
Once again I apologize for the formatting - it looks a lot better inside of eclipse :). This is my first actual script - so if you guys see any glaring errors or bad practices - point them out! EDIT: Now with Pod::Usage!!

In reply to File Backup Utility by misterMatt

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, 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, 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.
  • Log In?

    What's my password?
    Create A New User
    and all is quiet...

    How do I use this? | Other CB clients
    Other Users?
    Others drinking their drinks and smoking their pipes about the Monastery: (9)
    As of 2018-06-18 16:15 GMT
    Find Nodes?
      Voting Booth?
      Should cpanminus be part of the standard Perl release?

      Results (110 votes). Check out past polls.