Showing posts with label perl. Show all posts
Showing posts with label perl. Show all posts

Thursday, 9 May 2013

Perl regular expression tip


An easy one to forget when using perlre

See red brackets

The difference between this..
my $genArgs = ($foo =~ /genericJvmArguments \[(.+)]]/);

and this...
my ($genArgs) = ($foo =~ /genericJvmArguments \[(.+)]]/);

Is that the first one yields $genArgs set to 1 (which is what you don't want)

whereas the second version yields something like $genArgs set to -XX:ParallelGCThreads=2 -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintHeapAtGC -d64 -XX:MaxPermSize=512m (which is exactly what you do want)

In the first version I forgot the brackets around the $genArgs variable



Thursday, 28 February 2013

How to list all installed Perl modules

/usr/bin/perl -MFile::Find=find -MFile::Spec::Functions -Tlwe 'find { wanted => sub { print canonpath $_ if /\.pm\z/ }, no_chdir => 1 }, @INC'

Works on all NIX's