Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re (tilly) 1: bag of questions...

by tilly (Archbishop)
on Aug 27, 2000 at 18:22 UTC ( #29896=note: print w/replies, xml ) Need Help??


in reply to bag of questions...

Perl will close the old file or handle upon opening a new one. To localize FOO you can either local(*FOO) or else store your handle in a variable. With 5.6 you can use a regular variable as a handle. With 5.005 and earlier you can either
use Symbol; # Time passes my $foo = gensym(); open ($foo, "<$file") or die "Cannot read $file: $!";
If you don't want to use a module you can always do it yourself:
my $foo = do {local *FOO};

Now for more useful comments. Do as it says in perlstyle and on every open of a file, directory, etc check for errors and die with an informative message. The basic rule is avoid making errors if you can, arrange that any errors you make will be caught ASAP, and arrange that they are caught with enough information to fix the error. With your code should the code be run by a user who does not have sufficient permissions to create the directory you won't get told what the real problem is and it may take a while to even notice the problem.

And finally for this task I strongly suggest getting and installing rsync. (Search at Google if you do not have it already.) Efficiently recursively backing up directories from one spot to another, one machine to another if need be, using a variety of protocols is a solved problem. :-)

Replies are listed 'Best First'.
RE: Re (tilly) 1: bag of questions...
by kapper (Chaplain) on Aug 27, 2000 at 18:31 UTC
    Thanks for the comments =)
    I do fully realize that I am reinventing the wheel with this script... but after about 4 years of mostly Java and c++ coding, I thought I needed to excercise my perl skills with a couple of small problems... this being one of them =)
    I have had only minor experience with rsync, and as far as i know it's unix only... the script i am writing, is meant to run on a w2k file server...
      Win2K? I feel for you, believe me I do...

      Anyways, rsync has been ported. So play around with this wheel for practice (I certainly have done that plenty! :-) but I still recommend that you try rsync for the real job.

        Win2K? I feel for you, believe me I do...
        he he... no need to! I work in an ad agency, the script is for backing up the work of the "new media designers" =), so that they won't bother the sysadmin or me, when they need that file from yesterday which they just destroyed...
        My plans are to make the script only take an image when there has been changes, and start creating zips for images older than a week...
        For my own work, i have a notebook running w2k, an SGI indy running irix, a Powermac running linux and finally a Compaq iPaq pocketpc running linux (mostly for fun)
        Basicly i get to use what ever tools i wish on what ever platform i wish to do my job...

        Anyways.. I will take a look at rsync, looks like it might be a neat tool for file server maintenance....

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://29896]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (1)
As of 2021-12-06 06:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    R or B?



    Results (31 votes). Check out past polls.

    Notices?