Dec
21
2007
The original post can be found at http://www.perlmonks.org/?node_id=464358
I have made slight changes
(1) Put the following in a file "cfg.cfg"
%CFG = (
'servers' => {
'SRV1' => {
'IP' => '99.32.4.0',
'user' => 'aname',
'pswd' => 'p4ssw0rd',
'status' => 'unavailable'
},
'SRV2' => {
'IP' => '129.99.10.5',
'user' => 'guest',
'pswd' => 'guest',
'status' => 'unavailable',
},
},
);
(2) The following will load the config file and print out SVR1's IP
#!/usr/bin/perl
use strict;
our (%CFG);
# Read a configuration file
sub ReadCfg
{
my $file = $_[0];
our $err;
{ # Put config data into a separate namespace
package CFG_PKG;
# Process the contents of the config file
my $rc = do($file);
# Check for errors
if ($@) {
$::err = "ERROR: Failure compiling '$file' - $@";
} elsif (! defined($rc)) {
$::err = "ERROR: Failure reading '$file' - $!";
} elsif (! $rc) {
$::err = "ERROR: Failure processing '$file'";
}
}
return ($err);
}
# Get our configuration information
if (my $err = ReadCfg('cfg.cfg')) {
print(STDERR $err, "\\n");
exit(1);
}
print "SRV1's IP: ", $CFG_PKG::CFG{'servers'}{'SRV1'}{'IP'}, "\\n";
Dec
12
2007
To count occurrence of a character, say "\", in a string:
#!/usr/bin/perl -w
use strict;
my $url='http://www.aaa.com/bbb/ccc/ddd/eee/fff/aaa';
my $k = ($url =~ tr/\\//\\//);
print "cnt = $k\\n";
Dec
12
2007
Bookmark the following links: Select and Search For Google, Select and Search For Yahoo. Now, on any webpage, highlight some text, and click on the bookmark item. It will bring you to Google / Yahoo search with query as the text you just selected.
If you are already on Yahoo search, click the Google link, it will bring you the google search result with the same term, vice verse.
Dec
02
2007
Official Map can be download at http://www.ebparks.org/files/EBRPD_files/brochure/mission_peak_map.pdf

I have been to mission peak for many times and found it very enjoyable.

It’s roughly a three mile climb up to Mission Peak at about 2500 feet. Starting from the trailhead at the end of of Stanford Ave, passing the first gate (ot1 on the map), I followed the Hidden Valley Trail. The hike is moderately hard with constant ascending. There are a lot of shortcuts in between the trails. If you would like to challenge yourself a little more, they will save you some time but make your heart beat faster. Before you get to second gate (marked at ot2 on the map), there is a pile of stones. Don't follow the Peak Meadow trail if you are determined to get to the top :-)
Make a right turn when you hit the Peak trail. The last several hundred yards could be tough. On top of Mission Peak there’s an old, hollow pipe that sticks out of the ground. From there you have a very good view of the neighborhood areas.
