Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
While your points are good and valid, I'd like to point out there is is a good reason to invoke cp via system instead of using File::Copy: The latter doesn't preserve file permissions on Unix and Linux.

I personally believe this is very well known, with Abigail often advocating its use. Another issue I've "always" been wondering about has to do with sparse files: if I create one and then copy it with cp, IIRC the target file will also be sparse and a quick experiment now confirms my memory:

1;0 blazar@feather:~/tmp$ perl -e 'open F, ">foo.txt"; seek F, 2**30, +0; print F 1' 1;0 blazar@feather:~/tmp$ ls -lh . ; du -sh . total 12K -rw-r--r-- 1 blazar blazar 1.1G Nov 16 10:22 foo.txt 16K . 1;0 blazar@feather:~/tmp$ time cp foo.txt bar.txt && echo -e "\a" real 0m2.357s user 0m0.204s sys 0m2.064s 1;0 blazar@feather:~/tmp$ ls -lh . ; du -sh . total 24K -rw-r--r-- 1 blazar blazar 1.1G Nov 16 10:22 bar.txt -rw-r--r-- 1 blazar blazar 1.1G Nov 16 10:22 foo.txt 28K .

It takes some time (which further increases with the size of the file) and I don't have the slightest idea of how it manages to do so... (perhaps some fiddling with strace(1) may help, but I should be more confident with it.) But it succeeds. How does File::Copy behave in this respect? I believe it will create a file with an actual disk usage comparable to its own size, filled with nulls, ain't it?

Granted, I would regard this as a minor but not completely irrelevant issue.

--
If you can't understand the incipit, then please check the IPB Campaign.

In reply to Re^4: copy excel sheets to a different workbook by blazar
in thread copy excel sheets to a different workbook by sagnal

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 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? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (6)
As of 2021-12-06 09:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    R or B?



    Results (32 votes). Check out past polls.

    Notices?