Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Simple copy script called mycopy.pl

Reply
Thread Tools

Simple copy script called mycopy.pl

 
 
Leander Jedamus
Guest
Posts: n/a
 
      10-04-2012
Hi!

I just wrote a simple script to fit my needs to copy from a SD-Card only
those photos which are newer then a timestamp-file.
Use at your on risk!

It can be found at
http://paste.ubuntu.com/1259875/

A short instruction-list can be found at
http://paste.ubuntu.com/1260073/

Enjoy!
Leander Jedamus
 
Reply With Quote
 
 
 
 
Leander Jedamus
Guest
Posts: n/a
 
      10-05-2012
Am 04.10.2012 19:57, schrieb Ben Morrow:
>
> Quoth Leander Jedamus <(E-Mail Removed)>:
>>
>> I just wrote a simple script to fit my needs to copy from a SD-Card only
>> those photos which are newer then a timestamp-file.
>> Use at your on risk!
>>
>> It can be found at
>> http://paste.ubuntu.com/1259875/

>
> - Use Term::ANSIColor rather than rolling your own.
>
> - Don't call subs with '&' unless you need to.
>
> - 'warn' is a builtin. Defining a sub with that name is a bad idea.
>
> - `date -r` is not portable (on my system it does something quite
> different). Use stat() and POSIX::strftime.
>
> - This
>
> sub mycopy
> {
> my $sdir = $_[0];# source dir
> my $ddir = $_[1];# destination dir
> my $sfiles = $_[2];# the files to copy
> my $rekursive = $_[3];# if going recursive? (y/n)
> my $use_stamp = $_[4];# use stamp? (y/n)
> my $stamp = $_[5];# the stamp
> my $warn = $_[6];# warn level
> my $debug = $_[7];#
>
> is a horrid mess. Learn how to use list assignment.
>
> - mkdirhier is not portable (it's part of X, from the bad old days when
> mkdir didn't always understand -p). Use 'mkdir -p' (which ought to be)
> or File:ath (which definitely is).
>
> - I can't follow the logic in 'mycopy' at all. It must be possible to
> write it without quite so many layers of ifs.
>
> - I don't think there is a single comment in that program which makes
> anything clearer. Something like a general description of the logic
> implemented by the twisty maze of ifs in mycopy would have been much
> more useful than closing every sub with '};# sub foo'.
>
> - Use multi-arg system
>
> system "cp", "-p", $sfile, $dfile;
>
> rather than trying to get shell quoting right. What if there's a file
> with " in its name?
>
> After that I got bored, but is this really doing anything you can't do
> with find -newer | xargs cp ? Or just forget the stamps and use rsync.
>
> Ben
>


Thanks! I will look into it.

Grüße
Leander Jedamus
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Simple sproc executes 240 times slower when called from asp.net thanwhen called from QA Radu ASP .Net 7 08-28-2009 09:09 PM
What is called carry chain structure in FPGA is called in IC? Weng Tianxiang VHDL 6 09-12-2007 07:19 AM
what is Deep Copy, shallow copy and bitwises copy.? saxenavaibhav17@gmail.com C++ 26 09-01-2006 09:37 PM
is dict.copy() a deep copy or a shallow copy Alex Python 2 09-05-2005 07:01 AM
three times copy ctor called, one ctor called, why? Apricot C++ 4 04-16-2004 07:55 AM



Advertisments