Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

Re: passing arguments to subroutine

by grinder (Bishop)
on Jul 23, 2001 at 22:16 UTC ( #99107=note: print w/replies, xml ) Need Help??

in reply to passing arguments to subroutine

You don't need to chomp. If you printed the variable out you would see it is so. You will also need to interpolate $i/controlpanel in a string context.

I would rewrite the copying code as follows:

mkdir $i/controlpanel/ unless -d "$i/controlpanel"; system 'cp', '-fRp', $dir, $i" and die "cp went boom ($?).\n";

When oh when will people check for system errors?

shift is as good a way as any for reading the arguments passed to a routine.

update: hmm, the fact that the mkdir call is not checked is left as an exercise to the reader (it also needs a protection mask la 0500).

g r i n d e r

Replies are listed 'Best First'.
Re: Re: passing arguments to subroutine
by c (Hermit) on Jul 23, 2001 at 22:38 UTC
    More than one mistake in that code. I'd like to say that I left that mkdir check out because the code is still in the beginning stages, but I like to think of myself as an honest guy.

    mkdir("$i/controlpanel", 0755) or die "Problems making dir : $!\n" unl +ess ( -d "$i/controlpanel" ); system("cp -fRp $dir/controlpanel") or die "Problems copying dir : $!\ +n";


    humbly -c

      All the more reason for you to check your mkdir if the code is in it's beginning stages. You want to throw all the sanity checking devices that you can think of in your code (especially beta code).

      Silicon Cowboy
      system("cp -fRp $dir/controlpanel") or die "Problems copying dir : $!\ +n";
      system("cp -fRp $dir/controlpanel") == 0 or die "Problems copying dir +: $!\n";
      system returns the exit status of the program being run, and the programs conventionally return 0 (zero) on success.

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (3)
As of 2019-07-18 23:25 GMT
Find Nodes?
    Voting Booth?

    No recent polls found