Archive for August, 2010

 

How to clear linux memory cache ..

Aug 26, 2010 in Linux

From http://www.scottklarr.com/topic/134/linux-how-to-clear-the-cache-from-memory/

$ sync; echo 3 > /proc/sys/vm/drop_caches

Wait for caches to be flushed..

$ sync; echo 0 > /proc/sys/vm/drop_caches

Counting characters in perl..

Aug 13, 2010 in Perl

From http://www.perlmonks.org/?node_id=63955

How many ‘a’ characters are in the string?

#!/usr/bin/perl

my $str = 'abcatpdmeuziapmb';
my $cnt = @{[$str =~ /(a)/g]};
print "$cnt\n";