Cool/useful short examples of Perl?

Uri Guttman uri at StemSystems.com
Mon May 30 20:58:46 BST 2011


>>>>> "PN" == Philip Newton <philip.newton at gmail.com> writes:

  PN> On Mon, May 30, 2011 at 17:59, Uri Guttman <uri at stemsystems.com> wrote:
  >> 
  >> # Here is a simple and fast way to load and save a simple config file
  >> # made of key=value lines.
  >> 
  >>  my %conf = read_file( $file_name ) =~ /^(\w+)=(\.*)$/mg ;
  >>  write_file( $file_name, {atomic => 1}, map "$_=$conf{$_}\n", keys %conf ;

  PN> I wonder what kind of configuration you use, where values can consist
  PN> only of one or more dots....

good catch. but i encode the values in the number of dots. unary math
rules!

uri

-- 
Uri Guttman  ------  uri at stemsystems.com  --------  http://www.sysarch.com --
-----  Perl Code Review , Architecture, Development, Training, Support ------
---------  Gourmet Hot Cocoa Mix  ----  http://bestfriendscocoa.com ---------



More information about the london.pm mailing list