-
-
Recent Posts
Recent Comments
Categories
- Bash
- BerkeleyDB
- Browsers
- Cable
- Chrome
- Cool Problems
- CPAN
- CSS
- Data Structures
- Databases
- DNS
- Editors
- Errors
- Everything Else
- Fedora
- Firefox
- Firewall
- Flash
- Forking
- Hardware
- HTML
- ImageMagick
- Images
- Internet Explorer
- IpTables
- Lingo
- Linux
- Log4perl
- Mediawiki
- Monitoring
- Munin
- MySQL
- Netgear
- Perl
- PHP
- PhpMyAdmin
- Postfix
- Regular Expressions
- Routers
- RPM
- Samba
- Screen
- SSH
- SSHFS
- Subversion
- Synergy
- Troubleshooting
- Ubuntu
- VIM
- Windows
- Windows Vista
- Wordpress
- YUM
Blogroll
Archives
Tags
September 2010 M T W T F S S « Aug 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 Meta
CNN.com- Bonnie Blue actress from 'GWTW' dies
- President to aides: Find economic spark
- Hurricane Earl downgraded as it approaches East Coast
- Workers rescued after oil platform fire
- BP uncaps oil well in Gulf
- Mideast peace talks start
- Convicted killer spared death penalty
- Opinion: Social Security can help states
- U.S., Iran battle on basketball court
- She drops 100 pounds, gains new life
BBC- Europe agrees finance watchdogs
- ICC chief executive on cricket charges
- Explosion on Gulf of Mexico rig
- Tanker runs aground off N Canada
- DCAL cuts 'will mean job losses'
- Pakistan trio hit by ICC charges
- Strike 'kills Afghan civilians'
- Bid for Middle East peace begins
- The mint with a whole lot of food miles
- Man 'strangled wife and hid body'
AL JAZEERA ENGLISH (AJE)
Category Archives: Perl
How To Show Different Colors Per Level Using Log4perl
Use the following appender to show different colors. You can also customize the color per level. log4perl.appender.SCREEN = Log::Log4perl::Appender::ScreenColoredLevels log4perl.appender.SCREEN.color.INFO = white log4perl.appender.SCREEN.color.FATAL= bold underline blink red on_white attributes BOLD, DARK, UNDERLINE, UNDERSCORE, BLINK colors BLACK, RED, GREEN, YELLOW, BLUE, … Continue reading
Posted in Log4perl, Perl
Leave a comment
How To Print in Color Using Perl
http://perldoc.perl.org/Term/ANSIColor.html use Term::ANSIColor; print color ‘bold blue’; print “This text is bold blue.\n”; print color ‘reset’; print “This text is normal.\n”; print colored (“Yellow on magenta.”, ‘yellow on_magenta’), “\n”; print “This text is normal.\n”; print colored ['yellow on_magenta'], ‘Yellow on … Continue reading
Posted in Perl
Leave a comment
How To Log to Multiple Files Using Log4perl
How to log to multiple files using a single Log4perl logger. Example: you have an INFO level logger, but you want to log warnings and errors to separate files. You also want to log to the screen. ### Throw everything … Continue reading
Posted in Log4perl, Perl
Leave a comment
How To Access Values in Perl Hash as an Array, Given a List of Keys
my @fields = ( “country_name”, “region_name”, “city_name”, ); while (my $row = $sth->fetchrow_hashref) { my %row = %$row; printf $format, @row{ @fields }; }
Posted in Perl
Leave a comment
Perl Version of PHP's "ucwords" Function
my $string = ‘this is a string of text’; $string =~ s/\b(\w+)\b/ucfirst($1)/ge; print “$string\n”;
Posted in PHP, Perl
Leave a comment
How To Change Your CPAN urllist
# cpan cpan> o conf init … Connecting to ftp.perl.org|64.27.65.115|:21… connected. Logging in as anonymous … Logged in! ==> SYST … done. ==> PWD … done. ==> TYPE I … done. ==> CWD /pub/CPAN … done. ==> SIZE MIRRORED.BY … … Continue reading
Posted in CPAN, Perl
Leave a comment
How To Fix a Perl Memory Leak
If you’re using HTML::TreeBuilder, you might find a memory leak when creating lots of trees. You must explicitly delete the trees because HTML::Tree does not use weak refs. Here’s how to delete the ref: use HMTL::TreeBuilder; my $formatter = HTML::FormatText->new(); … Continue reading
Posted in Perl
Leave a comment
How To Redirect STDERR to STDOUT in Perl
Redirecting STDERR to STDOUT in Perl: open STDERR, ‘>&STDOUT’; Reassign raw file handles: *STDERR = *STDOUT; Redirect all output to a logfile: open(LOG,”>/tmp/foo.log”); *STDERR = *LOG; *STDOUT = *LOG; Example: #!/usr/bin/perl use strict; use warnings; warn “regular error”; open STDERR, … Continue reading
Extract parts of string into array using Perl regular expression
How to go directly from string to an array using Perl Regex extraction: my ($first, $second, $third) = ( $string =~ /not(.*?)this(.*?)stuff(.*?)/ );
Posted in Perl
Leave a comment
How To Profile a Perl Script
Perl Profiling can be done by using the DProf debugging switch: # perl -d:DProf test.pl hello # ls test.plĀ tmon.out # dprofpp tmon.out Total Elapsed Time = 0.009982 Seconds User+System Time = 0.009982 Seconds Exclusive Times %Time ExclSec CumulS #Calls … Continue reading
Posted in Perl
Leave a comment
libMagick.so.10: cannot open shared object file
Can’t load ‘…/auto/Image/Magick/Magick.so’ for module Image::Magick: libMagick.so.10: cannot open shared object file: No such file or directory at /usr/lib/perl5/5.8.8/i386-linux-thread-multi/DynaLoader.pm line 230. Add /usr/local/lib to /etc/ld.so.conf Run ldconfig as root.
Posted in ImageMagick, Linux, Perl
Leave a comment
Change URLLIST in CPAN due to lagging
To remove the first entry in the urllist, do this: o conf urllist shift This will make CPAN use the next FTP site in the queue.
Posted in Perl
Leave a comment
How to Fork in Perl
Kick off multiple processes simultaneously in Perl. my $num = 10; my @children; for (my $i = 0; $i < $num; $i++) { my $pid = fork(); if ($pid) { # parent push @children, $pid; } elsif ($pid == 0) … Continue reading