Categories

Category Specific RSS

Append a string to a file in PERL

open OUT, “>>”, “filename” or die “Couldn’t open file: $!\n”; print OUT “aString”; close OUT;

FacebookTwitterGoogle+PinterestTumblrStumbleUponRedditLinkedInBaiduApp.netBufferDeliciousDiggDiigoWordPressBlogger PostEmailPrintFriendlyShare

Random password generator in PERL

Usage: perl script.pl length

 

#!/usr/bin/perl # Script: Random password generator # Fri 03 Dec 2010 01:30:24 PM CET #use strict;

# List of chars. Modify this if you need to add more, like simbols, etc… my @chars = qw( a b c d e f g h i j k l m n o […]

FacebookTwitterGoogle+PinterestTumblrStumbleUponRedditLinkedInBaiduApp.netBufferDeliciousDiggDiigoWordPressBlogger PostEmailPrintFriendlyShare

list all files in directory with PERL

opendir(IMD, $dirtoget) || die(“Cannot open directory”); @thefiles= readdir(IMD); closedir(IMD);

print “Content-type: text/html\n\n”; print “<html><body>”;

foreach $f (@thefiles) { unless ( ($f eq “.”) || ($f eq “..”) ) { print “$f<br />”; } }

FacebookTwitterGoogle+PinterestTumblrStumbleUponRedditLinkedInBaiduApp.netBufferDeliciousDiggDiigoWordPressBlogger PostEmailPrintFriendlyShare

Validate email in PERL

use Regexp::Common qw[Email::Address]; use Email::Address;

while (<>) { my @found = /($RE{Email}{Address})/g; my @addrs = map $_->address, Email::Address->parse(“@found”);

print “X-Addresses: “, join(“, “, @addrs), “\n”; }

FacebookTwitterGoogle+PinterestTumblrStumbleUponRedditLinkedInBaiduApp.netBufferDeliciousDiggDiigoWordPressBlogger PostEmailPrintFriendlyShare