I never use File::Copy, as it's not flexible, and just does the wrong thing in certain cases. There are no File::Copy equivalents to cp file1 file2 dir1, or cp -a file1 file2, but what's worse is that File::Copy::copy("file1", "file2") loses the execute bit:
#!/usr/bin/perl use strict; use warnings; use File::Copy; my ($src, $dest1, $dest2) = ("/tmp/f1", "/tmp/f2", "/tmp/f3"); # Create source file, give it execute permission. open my $fh, "> $src" or die; close $fh or die; chmod 0755, $src or die; die "No execute permission on source\n" unless -x $src; # Make sure destination files are removed. if (-f $dest1) {unlink $dest1 or die;} if (-f $dest2) {unlink $dest2 or die;} # Set umask. umask 022 or die; system "cp $src $dest1" and die; die "Lost execute permission using 'system cp'\n" unless -x $dest1; copy $src, $dest2; die "Lost execute permission using 'File::Copy'\n" unless -x $dest2; __END__ Lost execute permission using 'File::Copy'

OTOH, I've been using Sys::Syslog for many, many years.

I tend to use modules if they are good, they are not doing something different than what they are supposed to replace, and if they don't require more typing. I still use my $text = `cat file`; - it does what I need it to do, and it's short.


In reply to Re: System vs modules by Anonymous Monk
in thread System vs modules by uksza

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.