i am trying to copy only files from specfic source to specfic destination (into sub folder of source ) with the date appended here is what i have tried:
use File::Copy;
$dir="/tmp/test2/magic/";
opendir(DIR, $dir) or die "can't opendir $dir: $! \n";
@files=readdir(DIR);
closedir DIR;
# Get currect date/time
my @date = (localtime)[5,4,3,2,1,0];
$date[0] +=1900;
++$date[1];
$date_string = sprintf('%04d%02d%02d',@date[0,1,2]);
foreach $file (@files) {
if (-f "$dir$file") {
$moveloc="/tmp/test2/magic/backup/$file.$date_string";
$old = "$dir$file
$new = "$moveloc";
copy($old, $new) or die "Copy Faild: $!";
My machine is AIX5.1 when i try to execute i get the following errors:
./testrenp11122010b
./testrenp11122010b: use: not found.
./testrenp11122010b[3]: =/tmp/test2/magic/: not found.
./testrenp11122010b[4]: 0403-057 Syntax error at line 4 : `(' is not e
+xpected.
when i change directory the path is actually present, but error shows not found , i am actually getting started with perl i have no idea of other error please correct me
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.