Perl

Simple Perl Howto

Search and replace text in multiple files perl -pi -e 's/OLD_TEXT/NEW_TEXT/' FILE_PATTERN e.g. perl -pi -e 's/Hello World/Goodbye World/' hello.c

spacer

Perl Subroutine for Logging

I have a perl subroutine that I use often to create a log file for my scripts. #!/bin/perl ############################################################# # ############################################################# use Time::localtime; $LOG_LOCATION="/var/log"; $LOG_FILE_PREFIX="myscript"; logMessage("This is a test"); ############################################################# # Returns logfile = /var/log/myscriptYYYYMMDD.log ############################################################# sub getLogFilename() { my $currentYear; my $currentMonth; my $currentDay; my $targetFilename; my $currentDateStat; $currentDateStat = localtime; $currentYear = $currentDateStat->year

spacer