Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Except of course that File::Copy::copy will take three arguments, and that's documented as well.

But since File::Copy::copy is usually promoted as "Perl's replacement for cp", people will expect it to behave as cp. And not study the documentation carefully.

You for instance either didn't study the documentation carefully, or if you did, forgot it. Because you wrongly assumed File::Copy::copy only takes two arguments. Now your mistake isn't as costly as forgetting the meaning of the third parameter. But if you can forget File::Copy::copy having a third parameter, you might as well forget that File::Copy::copy acts the same as cp when given two arguments, but very, very different when given three.

use File::Copy; my @files1 = qw [foo]; my @files2 = qw [bar baz]; my $dir = "/tmp"; copy @files1, $dir; # No problem. copy @files2, $dir; # File::Copy will warn, but erase 'baz' anyw +ay.
Now had you used your systems 'cp', it would have copied all three files into /tmp.

And had you used an all numeric $dir in the above code fragment, File::Copy::copy would have overwritten baz without so much as a warning.


In reply to Re^3: cp in perl by Anonymous Monk
in thread cp in perl by sanku

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (5)
As of 2024-04-24 12:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found