Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: remove backups

by smitz (Chaplain)
on Nov 05, 2002 at 11:32 UTC ( #210430=note: print w/replies, xml ) Need Help??


in reply to remove backups

Hmmm...

  • You chomp $dirname - why?
  • You define the scalar $dirname - why?
  • You use a system call to rm, making it platform dependant. Why not use unlink?
  • You empty the entire directory from which this is run - why not use rm * | del *.* | whatever?

Just some friendly critique

SMiTZ

Update: I Sir, am a plonker.

Replies are listed 'Best First'.
Re: Re: remove backups
by Sidhekin (Priest) on Nov 05, 2002 at 12:07 UTC

    ... chomp $dirname - why?

    To get rid of that pesky newline. (Yes, there is one.)

    ... define the scalar $dirname - why?

    That he may print it (in the last line)?

    ... use a system call to rm, making it platform dependant. Why not use unlink?

    Opening "ls *~|" already makes it platform dependent. Of course, that could be glob("*~"), so your question still stands ...

    ... empty the entire directory from which this is run - why not use rm * | del *.* | whatever?

    I think you miss the point: the alternative would be rm *~, which is quite easy to get wrong. Or at least easy enough to make guys like me paranoid.

    Me, I have a bash function for this sort of thing:

    function cleanup { rm "$@" *~ .*~ #* }

    If it ever gets complicated enough that I make a Perl script out of it, I'll probably make it platform independant. For now, it does the job.

    The Sidhekin
    print "Just another Perl ${\(trickster and hacker)},"

      Undeserved Abbots are quick to reply, slow to think. Of course pwd is a command, not a directory name. The backticks should have given it away, but its one of those days|weeks|lives.
      Apologies to pfm, you know where the -- button is...

      SMiTZ

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (3)
As of 2022-08-07 19:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?