Note: This web page was automatically created from a PalmOS "pedit32" memo.

perl notes


Very basic test to see if a perl module is importable: esmf04m-root> perl use foo::bar Can't locate foo/bar.pm in @INC (@INC contains: /usr/local/lib/perl5/5.8.3/aix-64all /usr/local/lib/perl5/5.8.3 /usr/local/lib/perl5/site_perl/5.8.3/aix-64all /usr/local/lib/perl5/site_perl/5.8.3 /usr/local/lib/perl5/site_perl .) at - line 1. BEGIN failed--compilation aborted at - line 1. esmf04m-root> perl use Time::HiRes esmf04m-root>
A little bit more sophisticated test, from Harry Mangalam: #test nonfatally for useful modules my $hiresfound; BEGIN {eval "use Time::HiRes qw(usleep ualarm gettimeofday tv_interval)"; $hiresfound = $@ ? 0 : 1} #$hiresfound = 0; # uncomment to simulate not found if ($hiresfound == 0) { print "\nOoops! Time::HiRes (needed for accurate timing) not found\nContinuing without timing."; } else { print "Time::HiRes ... found!\n"; }
Install a perl module named Net::SNMP : perl -MCPAN -e"install Net::SNMP"
> In python, I typically use something like: > > #!/usr/bin/python > > def isvowel(c): > return c in 'aeiouy' > > print isvowel('i') > print isvowel('b') #!/usr/local/bin/perl -l sub isvowel { return "True" if @_[0] =~ /[aeiouy]/ ; return "False" ; } print isvowel('i'); print isvowel('b');
Apparently "." is a string concatenation operator in perl.


Back to Dan's palm memos