Thursday, March 31, 2016

Single command to replace string in Perl

Ref:
https://techome.wordpress.com/2007/12/22/perl-commandline-search-and-replace/
http://www.atrixnet.com/in-line-search-and-replace-in-files-with-real-perl-regular-expressions/


C:\strawberry\perl\bin\perl.exe -pe "s/\\audio_hole_log\\/\\audio_hole_log/g" 

-e option allows you to define Perl code to be executed by the compiler. For example, it’s not necessary to write a “Hello World” program in Perl when you can just type this at the command line.
# perl -e ‘print “Hello World\n”‘
-p option, adds loops around your -e code.It creates code like this:
LINE:
while (<>) {
# your code goes here
} continue {
print or die “-p destination: $!\n”;
}
-i option. Actually, Perl renames the input file and reads from this renamed version while writing to a new file with the original name. If -i is given a string argument, then that string is appended to the name of the original version of the file. For example, to change all occurrences of “PHP” to “Perl” in a data file you could write something like this:
# perl -i -pe ‘s/PHP/Perl/g’ file.txt

Monday, March 28, 2016

Linux web page error message location


Error File location for page error:
sudo cat /var/log/httpd/error_log


Wednesday, March 23, 2016

Listing Perl Modules - default or local installed

http://www.perlhowto.com/list_the_installed_modules

This additional
~$ cpan -l

There are several ways to obtain the list of perl modules installed in a system:
-- Using perldoc
There are 2 commands, depending of the kind of perl module:
perldoc perlmodlib
'perldoc perlmodlib' list the modules that come preinstalled with the standard perl package.
perldoc perllocal
'perldoc perllocal' lists the optional modules that are installed in your system that don't come with perl by default.
This command returns lots of useful information for every optional module installed, like the installation date, the directory where the module was installed, the module version number, etc.
-- Using a script
If you want to obtain the list of all modules installed using a script, you may use the following one-liner (have a look at 'perldoc perlmodlib' for details about this one-liner):
perl -MFile::Find=find -MFile::Spec::Functions -Tlw
     -e 'find { wanted => sub { print canonpath $_ if /\.pm\z/ },
         no_chdir => 1 }, @INC'
-- If using ActivePerl
If you use ActivePerl (very likely if you're using Perl in Windows), you may use the following command to obtain the list of modules:
ppm query