Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
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":



  • 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 making s'mores by the fire in the courtyard of the Monastery: (7)
As of 2024-04-16 11:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found