perlfaq
view release on metacpan or search on metacpan
lib/perlfaq3.pod view on Meta::CPAN
# identify text files
perl -le 'for(@ARGV) {print if -f && -T _}' *
# remove (most) comments from C program
perl -0777 -pe 's{/\*.*?\*/}{}gs' foo.c
# make file a month younger than today, defeating reaper daemons
perl -e '$X=24*60*60; utime(time(),time() + 30 * $X,@ARGV)' *
# find first unused uid
perl -le '$i++ while getpwuid($i); print $i'
# display reasonable manpath
echo $PATH | perl -nl -072 -e '
s![^/+]*$!man!&&-d&&!$s{$_}++&&push@m,$_;END{print"@m"}'
OK, the last one was actually an Obfuscated Perl Contest entry. :-)
=head2 Why don't Perl one-liners work on my DOS/Mac/VMS system?
The problem is usually that the command interpreters on those systems
lib/perlfaq9.pod view on Meta::CPAN
The L<Email::MIME> module can decode base 64-encoded email message parts
transparently so the developer doesn't need to worry about it.
=head2 How do I find the user's mail address?
Ask them for it. There are so many email providers available that it's
unlikely the local system has any idea how to determine a user's email address.
The exception is for organization-specific email (e.g. foo@yourcompany.com)
where policy can be codified in your program. In that case, you could look at
$ENV{USER}, $ENV{LOGNAME}, and getpwuid($<) in scalar context, like so:
my $user_name = getpwuid($<)
But you still cannot make assumptions about whether this is correct, unless
your policy says it is. You really are best off asking the user.
=head2 How do I send email?
Use the L<Email::Stuffer> module, like so:
# first, create your message
my $message = Email::Stuffer->from('you@example.com')
( run in 0.256 second using v1.01-cache-2.11-cpan-454fe037f31 )