<html>
<!-- P26.2005.3.28 geoffmclane.com -->
<head>
<meta http-equiv="Content-Language" content="en-au">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>Perl</title>
<LINK REL=StyleSheet HREF="../page2.css" TYPE="text/css">
<script language="JavaScript" type="text/javascript">
<!-- begin
var newwindow;
var feats='height=500,width=800,location=yes,resizable=yes,scrollbars=yes,menubar=yes,toolbar=yes,status=yes';
function pop(url) { // newwindow=window.open([url],[name],[features],[replace]);
 newwindow=window.open(url,'name',feats,'replace=no');
 if (window.focus) {newwindow.focus()}
}
// end -->
</script>

</head>

<body CLASS=pblue>

<h1 align="center"><b>Perl</b></h1>
<p><a href="index.htm">Perl Index</a> *|* <a href="../cvineng2.htm">Back to cv</a> 
*|* <a href="../home2.htm">to Home Page</a> *|* <a href="perl.htm">Perl Next</a></p>
<p align="left">perl - <b>Practical Extraction and Report Language</b> - a great script/shell ... with lots of power ;=)) [<a href="http://www.perl.com/">http://www.perl.com/</a>]
for the source, or [<a href="http://www.activestate.com/Products/ActivePerl/?_x=1">http://www.activestate.com/Products/ActivePerl/?_x=1</a>]
for windows binaries ... using the Microsoft Installer (MSI), gets you set up with perl
in a very short time after you have downloaded and run the 'current' MSI file
... in my case was a big, descriptive name -<br>
12/03/2005  12:11 PM        13,195,084 ActivePerl-5.8.6.811-MSWin32-x86-122208.msi<br>
which, when run, and accepting the MS 'unsigned' warning, it will install in a $root, say
C:\Perl and establish a CONSOLE path to $root\bin ...</p>
<p align="left">Once installed, in a CONSOLE, write a file, say test1.pl,
containing just the line -<br>
print("Hello World!\n");<br>
then, [current-path&gt;] perl test1.pl, will print out &quot;Hello World!&quot;, plus a
new line, on the CONSOLE window (screen) ... of course, perl can do a little
more than that ;=))</p>
<p align="left">Naturally, most *nix perl samples will start with a line like -<br>
#!/usr/bin/perl -w<br>
but, in WIN32, XP this is not 'used', unless you have installed an 'environment'
that emulates, or simulates a unix/linux (*nix) work place, or you could have
chosen this as your 'root' install choice ...</p>
<p align="left">An agreed power of perl, is its string handling ... particularly
using 'regular expressions' to parse up a line ... understanding that 'regular
expressions' is a 'language' in itself ... see <a href="http://www.regular-expressions.info/">http://www.regular-expressions.info/</a>
... and as stated there &quot;... whether that code is written in Perl, PHP,
Java, a .NET language or a multitude of other languages....&quot; ... or, as
implemented in perl - [<a href="http://search.cpan.org/dist/perl/pod/perlre.pod">http://search.cpan.org/dist/perl/pod/perlre.pod</a>]
...</p>
<p align="left">The examples, $root\eg contains some great, simple code, doing
some 'powerful' actions ... how it joins with the Windows Scripting Host&nbsp;
to, for example, get the current ENVIRONMENT variables ... see showenv.wsf ...
open notepad, and send it a sentence ... see notepad.wsf ... etc ...</p>
<p align="left">Where can you find an 'Integrated Development Environment'
(IDE), that assists with perl and regular expression syntax, and where you can
fully, interactively, debug a script, stopping anywhere, and examining variable
... try <a href="http://search.cpan.org/dist/perl/pod/perlre.pod">http://search.cpan.org/dist/perl/pod/perlre.pod</a>
... but, be warned, this is quite a 'rudimentary' colour coded editor, with no
'context-sensitive' help, on perl itself ... and the debugging is 'difficult'
... but these *nix tools are only VERY SLOWLY becoming available in the FREE,
OPEN SOURCE community ... they represent lots of 'dedicated' hours of code work
... a big thank you, to the maintainers ...</p>
<p align="left">Of course, Perl can be used in the 'Common Gateway Interface' (<a href="http://www.w3.org/CGI/">CGI</a>)
context ... that is, since a CGI program can be written in any language that
allows it to be executed on the HTTP (HTTPd) server system, such as C/C++,
Fortran, TCL, Any Unix shell, Visual Basic, AppleScript, ... Perl is the choice
of some ...</p>
<p align="left">Perl handles command line arguments very easily, in a way ...
for example, it can be put in a 'function', or sub-routine, or whatever you call
it ... ;=))<br>
parse_arguments(@ARGV);<br>
would pass the commands to such a service ... here is a little program to do
that -</p>
<p><a href="../cvineng2.htm">Back to cv</a> or <a href="../home2.htm">to Home Page</a></p>
<p>#!perl -w</p>
<p>my $program = 'test5';<br>
my $verbose = 0;<br>
my $static_lib = 0;<br>
my $package = 'temptest5';<br>
my @input_files = ();<br>
my $file_lines = 0;</p>
<p>parse_arguments(@ARGV);</p>
<p>die &quot;program: no input files found or specified\n&quot; if ! @input_files;</p>
<p>init_out_file($package);</p>
<p>my $in_file;</p>
<p>foreach $in_file (@input_files) {<br>
do_this_file($package, $in_file);<br>
}</p>
<p>$in_file = $package . '.txt';<br>
print &quot;Done $in_file.\n&quot;;</p>
<p>sub parse_arguments {<br>
my @av = @_; # take it off the passed stack<br>
while (@av) {<br>
if ($av[0] eq '--version') {<br>
print 'Version 0.1\n';<br>
} elsif ($av[0] eq '--help' || $av[0] eq '--h' || $av[0] eq '-h' || $av[0] eq
'-?') {<br>
die &quot;No help available!\n&quot;;<br>
} elsif ($av[0] eq '--verbose' || $av[0] eq '-v') {<br>
print &quot;Setting verbose.\n&quot;;<br>
$verbose = 1;<br>
} elsif ($av[0] eq '--package' || $av[0] eq '-p') {<br>
require_argument(@av);<br>
shift @av;<br>
$package = $av[0];<br>
} elsif ($av[0] eq '--lib') {<br>
print 'Setting static.\n';<br>
$static_lib = 1;<br>
} elsif ($av[0] =~ /^-/) {<br>
die &quot;$program: unrecognised option -- `$av[0]'\nTry $program --help for
more information.\n&quot;;<br>
} else {<br>
print &quot;Storing argument [$av[0]].\n&quot;;<br>
push(@input_files, $av[0]);<br>
}<br>
shift @av; # move to next argument<br>
} # while arguments<br>
}</p>
<p># Ensure argument exists, or die.<br>
sub require_argument<br>
{<br>
my ($arg, @arglist) = @_;<br>
die &quot;$program: no argument given for option \`$arg'\n&quot; if ! @arglist;<br>
}<br>
</p>
<p>sub init_out_file<br>
{<br>
my $name = shift;<br>
my $out_name = $name . '.txt';<br>
print &quot;Creating $out_name\n&quot; if $verbose;</p>
<p>open(DSP, &quot;&gt;$out_name&quot;)<br>
|| die &quot;Can not create $out_name: $!\n&quot;;</p>
<p>print &quot;Writing to $out_name ...\n&quot; if $verbose;</p>
<p>$file_lines++;</p>
<p>print DSP &lt;&lt;&quot;EOF&quot;;<br>
# line $file_lines out to File - &quot;$out_name&quot; \r<br>
EOF</p>
<p>print &quot;Closing $out_name.\n&quot; if $verbose;</p>
<p>close(DSP);<br>
}</p>
<p>sub do_this_file {<br>
my ($name,$mfile) = @_;<br>
my $out_name = $name . '.txt';</p>
<p>print &quot;Opening, for append $out_name\n&quot; if $verbose;</p>
<p>open(DSP, &quot;&gt;&gt;$name&quot; . '.txt')<br>
|| die &quot;Can't append to $out_name: $!\n&quot;;</p>
<p>print &quot;Writing to $out_name ...\n&quot; if $verbose;</p>
<p>$file_lines++;</p>
<p>print DSP &lt;&lt;&quot;EOF&quot;;<br>
line $file_lines: Next file line with $mfile ...\r<br>
EOF</p>
<p>close(DSP);</p>
<p>print &quot;Closing $out_name.\n&quot; if $verbose;</p>
<p>}</p>
<p><a href="../cvineng2.htm">Back to cv</a> or <a href="../home2.htm">to Home Page</a></p>
<p align="left">A good perl reference is 
<a href="javascript:pop('http://www.rexswain.com/perl5.html');">http://www.rexswain.com/perl5.html</a>
- it quickly, and succinctly, IMHO, describes just about everything you need to
know ... and a link to (book) 
<a href="javascript:pop('http://www.squirrel.nl/people/jvromans/perlref.html');">
http://www.squirrel.nl/people/jvromans/perlref.html</a>
... and<br>
&nbsp; <a href="javascript:pop('http://www.perldoc.com/perl5.8.0/pod/perlfunc.html');">
http://www.perldoc.com/perl5.8.0/pod/perlfunc.html</a>
... <a href="javascript:pop('http://www.perl.com/pub/q/documentation');">
http://www.perl.com/pub/q/documentation</a>
... etc, etc, etc ... Of course, the best teacher is writing some ... ;=))</p>
<p align="left">A few 'samples' can be found at - 
<a href="javascript:pop('http://www.sentex.net/~jmackay/code-samples.html#Perl');">
http://www.sentex.net/~jmackay/code-samples.html#Perl</a>
-...- 
<a href="javascript:pop('http://www.dwarfworks.com/demo/index2.html');">
http://www.dwarfworks.com/demo/index2.html</a>
 -...- 
<a href="javascript:pop('http://sedition.com/perl/code-index.html');">
http://sedition.com/perl/code-index.html</a>
 -...- 
<a href="javascript:pop('http://search.cpan.org/modlist/File_Handle_Input_Output');">
http://search.cpan.org/modlist/File_Handle_Input_Output</a>
 -..-. 
<a href="javascript:pop('http://search.cpan.org/');">
http://search.cpan.org/</a>  -...-</p>

<p align="left">'Regular Expressions' plays an important part of Perl ... this
uses a relatively small set of 'special' characters ... characters that have
special meaning, like '^' matches the beginning of the target. If you want to
find a '^', then is must be 'escaped', with the special 'escape' character, '\',
like '\^' = '^', '\\' = '\', etc ... the set of 'specials' is -</p>

<p align="center"><tt><b><font size="4">+ ? . * ^ $ ( ) [ ] { } | \</font></b></tt></p>

<p align="left">The '\' escapes any special meaning of the above, but it also
turns most alphanumeric characters into something special ... like '\r' is
carriage return (CR), '\n' is line feed (LF), '\t' TAB, ... and other specials,
like '\w' matches alphanumeric, including _, \W matches non-alphanumeric ... and
there are some special '$' variables, like '$_', being the default input space
... '$/' input record separator ...</p>
<p align="left">The search and replace functions -&nbsp;<br>
[ <font size="-1">EXPR</font> <tt><b>=~</b></tt> ] [ <b>m</b> ] <tt><b>/</b></tt><font size="-1">PATTERN</font><tt><b>/</b></tt>
[ <b>g</b> ] [ <b>i</b> ] [ <b>m</b> ] [ <b>o</b> ] [ <b>s</b> ] [ <b>x</b> ]<br>
[ <tt><b>$</b></tt><font size="-1">VAR</font> <tt><b>=~</b></tt> ] <b>s</b><tt><b>/</b></tt><font size="-1">PATTERN</font><tt><b>/</b></tt><font size="-1">REPLACEMENT</font><tt><b>/</b></tt>
[ <b>e</b> ] [ <b>g</b> ] [ <b>i</b> ] [ <b>m</b> ] [ <b>o</b> ] [ <b>s</b> ] [ <b>x</b>
]<br>
and translate -<br>
[ <tt><b>$</b></tt><font size="-1">VAR</font> <tt><b>=~</b></tt> ] <b>tr</b><tt><b>/</b></tt><font size="-1">SEARCHLIST</font><tt><b>/</b></tt><font size="-1">REPLACEMENTLIST</font><tt><b>/</b></tt>
[ <b>c</b> ] [ <b>d</b> ] [ <b>s</b> ]</p>
<p align="left">To be able to 'read', and 'understand' perl code, you also need
to be able to 'read' regular expressions ... so what does this say -<br>
my $IGNORE_PATTERN = &quot;<b>^##([^#].*)?\$</b>&quot;;<br>
and here is it use -<br>
while (&lt;M_FILE&gt; { # process line by line file input<br>
&nbsp;if (/$IGNORE_PATTERN/o) { # note the [ m ] left out - <b>o</b>
interpolates variables only once<br>
# Merely ignore, delete comments beginning with two hashes.<br>
&nbsp;} elsif (/$WHITE_PATTERN/o) ...</p>
<p align="left">The '^' matches the beginning of the target ($_), then 2 hashes,
then start a group, '(', until ')' to match a single element, then start a
class, '[', until ']', of character(s) to match to, remembering that '[^...]'
negates the class, so in this case it say match 2 hashes, and any third
character, except a hash ...&nbsp; followed by any character, '.', quantified by
the zero or more, '*', then end this group, ']' ... then match zero or one time,
'?' ... to end '\$' ...</p>
<p align="left">Or this -<br>
my $WHITE_PATTERN = &quot;<b>^[ \t]*\$</b>&quot;;</p>
<p align="left">Maybe, something like, match from beginning of line, '^', for
the class, '[', space, ' ', and tab, '\t', end class, ']', quantified to zero or
more times, '*', until end of line, '\$' ... used in the form - if ( /$WHITE_PATTERN/o
) - will be true if the line is ALL spacey ... ;=))</p>
<p align="left">my $PATH_PATTERN='<b>(\\w|/|\\.)+</b>';<br>
the style is ( ... | ... | ... ), matches one of the alternatives, '\\w', '/',
and '\\.' ... like ... search for group, '(', escape '\' the '\', alphanumeric,
plus '_', '\w', or '|', forward slash, '/', or '|', back slash, '\\', ... and
arbitrary characters, '.', then, close group, ')' ... and this is quantified by
match the preceding pattern one or more times, &quot;+'&nbsp; ... simple huh,
;=))</p>
<p align="left">An example using this type of 'path' pattern would be - # Return
directory name of file.<br>
sub dirname { # passed a path, './dir1/dir2/file.name' returns './dir1/dir2/<br>
&nbsp;&nbsp; my ($file) = @_;<br>
&nbsp;&nbsp; my ($sub);<br>
&nbsp;&nbsp; ($sub = $file) =~ s,/+[^/]+$,,g;<br>
&nbsp;&nbsp; $sub = '.' if $sub eq $file;<br>
&nbsp;&nbsp;&nbsp; return $sub;<br>
}</p>
<p align="left">Using the <tt><b>$</b></tt><font size="-1">VAR</font> <tt><b>=~</b></tt>
<b>s</b><tt><b>/</b></tt><font size="-1">PATTERN</font><tt><b>/</b></tt><font size="-1">REPLACEMENT</font><b><tt>/</tt></b>g
form, where a ',' character is used to separate the s,PATTERN,&lt;nul
replacement&gt;,g, so it says, search for '/' character, match one or more
times, '+', then a group, '[', not, '^' the '/' character, end group, one or
more times, '+', until the end of line, '$' ... and put this match into $sub, if
no '/' characters in string, default to $file, the whole thing ... return the
relative, '.', if only given a file name ...</p>
<p align="left">To use this service in windows, you will need to make sure ALL
DOS path separator, '\', are converted to the unix path separator, '/' ... like
the following .<br>
my $src_dir = $base_dir . $relative_dir . '/'; # use *nix forward slash ...<br>
$src_dir =~ s/\\/\//g; # set *nix path separators ...<br>
which says - search for '\', written as escape, '\\', substitute '/', written
as, '\/', for all instances, 'g' ...&nbsp;</p>
<p align="left">or ...<br>
$src_dir =~ s/\//\\/g; # set DOS path separators, for when unsure ...<br>
search for '/', written as escape forward slash, '\/', and replace with '\',
written as escape backslash, '\\' ... or use s,\/,\\,g, where g = for all
instances ...</p>
<p align="left">Putting perl variables into a PATTERN string also make 'read' a
little more difficult ... consider -<br>
&nbsp;if ($path =~ s/^\$\(top_srcdir\)\///)<br>
note the $top_srcdir has to be suitably 'escaped' ... start of line, '^', find
$(top_srcdir)</p>

<p align="left">This site - <a href="http://www.regular-expressions.info/quickstart.html">http://www.regular-expressions.info/quickstart.html</a>
- has some help ... it lays it out in a colourful way ... like -</p>

<p align="left"><a href="../cvineng2.htm">Back to cv</a> or <a href="../home2.htm">to Home Page</a></p>
<p align="left">&lt;quote&gt;
</p>
<h2>Greedy and Lazy Repetition</h2>
<p>The repetition operators or quantifiers are greedy. They will expand the
match as far as they can, and only give back if they must to satisfy the
remainder of the regex. The regex <tt class="regex">&lt;.+&gt;</tt> will 
match <tt class="peach">&lt;EM&gt;first&lt;/EM&gt;</tt>
in <tt class="string">This is a &lt;EM&gt;first&lt;/EM&gt; test</tt>.</p>
<p>Place a question mark after the quantifier to make it lazy. <tt class="regex">&lt;.+?&gt;</tt>
will match <tt class="peach">&lt;EM&gt;</tt> in the above string.</p>
<p>A better solution is to follow my advice to use the dot sparingly. Use <tt class="regex">&lt;[^&lt;&gt;]+&gt;</tt>
to quickly match an HTML tag without regard to attributes. The negated character
class is more specific than the dot, which helps the regex engine find matches
quickly.</p>
<p align="left">&lt;/quote&gt;</p>

<p align="left">The <a href="perl2.htm">page</a> contains one of my most useful
perl applications ... of course, I wrap in in a batch file ... it uses the
following 'regular expressions' ...</p>
<p align="left">
my $WHITE_PATTERN = &quot;<TT CLASS="regex">^[ \t]*\$</TT>&quot;; # only spacey
stuff, like if ( /$WHITE_PATTERN/o ) { ...}<br>
$ff =~ <TT CLASS="regex">s/\\/\//g</TT>; # sub *nix path separators<br>
$sb =~ <TT CLASS="regex">s/\//\\/g</TT>; # set DOS path separators<br>
if ($a =~ <TT CLASS="regex">/^-/</TT>) { ... } # if the line begins with a dash<br>
[$_ =~] <TT CLASS="regex">s/\t/$tab_stg /g</TT>; # substitute TAB characters<br>
[$_ =~] <TT CLASS="regex">s/&quot;/&amp;quot;/g</TT>; # sub double quotes with &amp;quot;<br>
[$_ =~] <TT CLASS="regex">s/\&lt;/&amp;lt;/g</TT>; # substitute less than tag beginning<br>
[$_ =~] <TT CLASS="regex">s/\&gt;/&amp;gt;/g</TT>; # and substitute html/xml tag ending<br>
[$_ =~] <TT CLASS="regex">s/ {$sps}/$nbs/</TT>; # replace (N) spaces with '&amp;nbsp; x N<br>
($sub = $file) =~ <TT CLASS="regex">s,/+[^/]+$,,g</TT>; # passed a path, './d1/d2/fn' returns './d1/d2/<br>
and this application does VERY LITTLE ... ;=))
</p>
<p align="left">
Some others seen ...<br>
$reserved = <TT CLASS="regex">q(;/?:@&amp;=+$,[])</TT>;<br>
$mark = <TT CLASS="regex">q(-_.!~*'())</TT>; #'; emacs<br>
$unreserved = &quot;<TT CLASS="regex">A-Za-z0-9\Q$mark\E</TT>&quot;;<br>
$uric = <TT CLASS="regex">quotemeta($reserved) . $unreserved . &quot;%&quot;</TT>;<br>
$scheme_re = '<TT CLASS="regex">[a-zA-Z][a-zA-Z0-9.+\-]*</TT>';
</p>

<p align="left">
foreach (@hash{qw[key1 key2]}) {<br>
<TT CLASS="regex">s/^\s+//</TT>; # trim leading whitespace<br>
<TT CLASS="regex">s/\s+$//</TT>; # trim trailing whitespace<br>
<TT CLASS="regex">s/(\w+)/\u\L$1/g</TT>; # &quot;titlecase&quot; words<br>
}<br>
my $actdir = &quot;C:/GTools&quot;;<br>
sub subactdir {<br>
my ($d) = @_;
my ($nd);<br>
($nd = $d) =~ <TT CLASS="regex">s,^$actdir,,</TT>; # remove, at beginning, $actdir<br>
if (length($nd) == 0) {<br>
$nd = $actdir;<br>
} else {<br>
$nd =~ <TT CLASS="regex">s,^/,,</TT>; # remove leading '/'<br>
}
return $nd;}<br>
my (@mcols) = split( <TT CLASS="regex">/\|/</TT>, $msg); 
<TT CLASS="comment"># split message &quot;one|two|...&quot;</TT><br>
foreach my $col (@mcols) {
</p>

<p>$oldExt = $ARGV[0];$newExt = $ARGV[1]; <TT CLASS="comment"># prefix each extension with $extSep
if it doesn't already start with it:</TT><br>
$extSep = &quot;.&quot;;
$oldExt = $extSep . $oldExt if (index($oldExt, $extSep) != 0);<br>
$newExt = $extSep . $newExt if (index($newExt, $extSep) != 0);<br>
# put all files in the current directory in @files:<br>
opendir(THEDIR, &quot;.&quot;) || die(&quot;Couldn't open current
directory\n&quot;);<br>
@files = readdir(THEDIR);<br>
closedir(THEDIR);<br>
# construct the $newName from the $oldName then rename $oldName to $newName:<br>
foreach $oldName (@files) {<br>
if ($oldName =~ <TT CLASS="regex">/(.*)$oldExt$/</TT>) {<br>
$newName = $1 . $newExt; system(&quot;mv $oldName $newName&quot;); } }<br>
my @tmp = split(/^/m, $list);<br>
$extras = join '', grep <TT CLASS="regex">/^[^0-9a-fA-F]/</TT>, @tmp; # items
that do NOT begin with 0-9, a-z, or A-Z ...<br>
local($_) = @_; # make stack passed parameter local ...<br>
<TT CLASS="regex">s/\s+//g</tt>; # strip white space<br>
if (<TT CLASS="regex">s/^([+-]?)0*(\d+)$/$1$2/</TT>) { # test if number<br>
substr($_,$[,0) = '+' unless $1; # Add missing sign<br>
<TT CLASS="regex">s/^-0/+0/</TT>;<br>
$_; # return number<br>
} else {'NaN';} # return NaN!<br>
local(@dirs) = grep(!-l, grep(!<TT CLASS="regex">/^\.\.?$/</TT>, grep(-d, readdir(THISDIR)))); # do all
directories, except DOT and DOUBLE-DOT!<br>
$newtext = &lt;READFILE&gt;;<br>
eval &quot;\$newtext =~ <TT CLASS="regex">s/\$oldstring/\$newstring/$global$ignore;&quot;</TT>;</p>

<p align="left">
<BR>
<a href="../cvineng2.htm">Back to cv</a> or <a href="../home2.htm">to Home Page</a>
</p>

<p align="left">Further references: <a href="http://www.sentex.net/~jmackay/software.html#PerlUtil">http://www.sentex.net/~jmackay/software.html#PerlUtil<br>
</a>
Yahoo search : perl reference documentation package<br>
<a href="http://www.rexswain.com/perl5.html">http://www.rexswain.com/perl5.html</a>
- Simple list style help ... no sample code ...<br>
<a href="http://search.cpan.org/src/LDS/CGI.pm-3.08/cgi_docs.html">http://search.cpan.org/src/LDS/CGI.pm-3.08/cgi_docs.html</a>
... CGI = creating HTML forms ... and ...<br>
<a href="http://search.cpan.org/src/LDS/CGI.pm-3.08/examples/">http://search.cpan.org/src/LDS/CGI.pm-3.08/examples/</a>
... various HTML creation examples ...<br>
<a href="http://aspn.activestate.com/ASPN/Perl">http://aspn.activestate.com/ASPN/Perl</a>
... ActivePerl documentation ...<br>
<a href="http://aspn.activestate.com/ASPN/docs/VisualPerl/readme.html#installation">http://aspn.activestate.com/ASPN/docs/VisualPerl/readme.html#installation</a>
... ActivePerl add-in for Visual Studio ...<br>
<a href="http://www.activestate.com/store/trial/register.plex?id=PerlDevKit">http://www.activestate.com/store/trial/register.plex?id=PerlDevKit</a>
... Get ActivePerl DK (formerly ASPN)...<br>
http://www.whitefire.com/programs/docs/MtmlParserDoc.html (broken!)
... A file parser ...<br>
http://www.whitefire.com/programs/ (broken!)
- MtmlParser-0.8.tar.gz and perltools.tar.gz This contains some useful perl
tools ...<br>
<a href="http://theoryx5.uwinnipeg.ca/modperl/docs/general/perl_reference/perl_reference.html">http://theoryx5.uwinnipeg.ca/modperl/docs/general/perl_reference/perl_reference.html</a>&nbsp;
...<br>
<a href="http://www.cs.fsu.edu/general/perl/doc/PerlDoc.txt">http://www.cs.fsu.edu/general/perl/doc/PerlDoc.txt</a>
- Big text list ... perl 5.005, patch 02 19/Jul/98 ...<br>
<a href="http://www.perl.org/">http://www.perl.org/</a> ... Current Release:
5.8.6, as of April, 2005!<br>
<a href="http://blob.perl.org/books/impatient-perl/iperl.html">http://blob.perl.org/books/impatient-perl/iperl.html</a>
... says, said ... [Originally, &quot;Pearl&quot; shortened to &quot;Perl&quot;
to gain status as a 4-letter word. Now considered an acronym for Practical
Extraction and Report Language, as well as Petty Ecclectic Rubbish Lister. The
name was invented first. The acronyms followed.]! ;=))<br>
<a href="http://perl.apache.org/docs/2.0/user/porting/compat.html">http://perl.apache.org/docs/2.0/user/porting/compat.html</a>
... mod_perl 1 to 2 migration ...<br>
<a href="http://www.perl.com/lpt/a/834">http://www.perl.com/lpt/a/834</a> ...
Book - Apocalypse 12 By Larry Wall April 16, 2004 ...<br>
<a href="http://sedition.com/perl/perlview.cgi?file=Class-Prototype.pm&amp;line=code">http://sedition.com/perl/perlview.cgi?file=Class-Prototype.pm&amp;line=code</a>
... A <b>Fish</b>y sample of a simple use base 'class::prototype' and a <b>Fish</b>
object ... use Fish; my $fish_obj = Fish-&gt;new(); # set favorite; $fish_obj-&gt;favorite(&quot;Kuhli Loach");
... etc... see testfish.pl, Fish.pm and class/prototype.pm for details ... in /tmp
...
</p>

<p align="left"><a href="http://homepages.wmich.edu/~l0lazaro/perld/fileio.html">http://homepages.wmich.edu/~l0lazaro/perld/fileio.html</a>
- File IO, and more ... or<br>
<a href="http://www.developingwebs.net/perl/file_handling.php">http://www.developingwebs.net/perl/file_handling.php</a>
- more FILE IO ... and other things ... few samples or<br>
<a href="http://cslibrary.stanford.edu/108/EssentialPerl.html#iofiles">http://cslibrary.stanford.edu/108/EssentialPerl.html#iofiles</a>
- more File IO ...<br>
<a href="http://asp-pro.com/Perl/File_delete.pro">http://asp-pro.com/Perl/File_delete.pro</a>
- Delete or rename a file ...</p>
<p align="left"><a href="http://www.datamystic.com/easypatterns_reference.html">http://www.datamystic.com/easypatterns_reference.html</a>
- this site offers another form of Regular Expression searching ... like it uses
<TT CLASS="regex">m/[digit]/</TT> rather than <TT CLASS="regex">m/[0-9]/</TT> ... replaces
the character-based learning curve
with a word-based one ... should work for some people ;=)) ... some they call
'Real-world patterns', like <TT CLASS="regex">[HTMLTag]</TT> vs <TT CLASS="regex">/&lt;[1+ not '&gt;']&gt;/</TT>, 
<TT CLASS="regex">[HTMLStartTag]</TT>
vs <TT CLASS="regex">/&lt;[not '/', 0+ not '&gt;']&gt;/</TT> (i.e. any tag except an end tag), or 
<TT CLASS="regex">[HTMLEndTag]</TT>
vs <TT CLASS="regex">/&lt;/[1+ not '&gt;']&gt;/</TT> ...<br>
<a href="http://aspn.activestate.com/ASPN/docs/ActivePython/2.4/python/lib/module-htmllib.html">http://aspn.activestate.com/ASPN/docs/ActivePython/2.4/python/lib/module-htmllib.html</a>
- Specific HTML stuff for ActivePython 2.4 ...<br>
<a href="http://virtual.park.uga.edu/humcomp/perl/regex2a.html">http://virtual.park.uga.edu/humcomp/perl/regex2a.html</a>
- A Perl Regular Expression Tutorial ...<br>
<a href="http://search.cpan.org/~gaas/HTML-Parser-3.35/Parser.pm">http://search.cpan.org/~gaas/HTML-Parser-3.35/Parser.pm</a>
- parsing a HTML file ...
</p>

<p align="left">email:<br>
&quot;b.g@ms.com&quot; =~ <TT CLASS="regex">m/^(\w|\.)+@(\w|\.)+$/</TT> ==&gt; TRUE , and<br>
&quot;b.g_emp@ms.com&quot; =~ <TT CLASS="regex">m/^[\w._-]+@[\w._-]+$/</TT> ==&gt;
TRUE, example -<br>
$str = 'blah blah nick@cs.stanford.edu, blah blah balh billg@microsoft.com blah
blah';<br>
while ($str =~ <TT CLASS="regex">/(([\w._-]+)\@([\w._-]+))/</TT>) { ## look for an email addr<br>
print &quot;user:$2 host:$3 all:$1\n&quot;; ## parts of the addr<br>
$str = $'; ## set the str to be the &quot;rest&quot; of the string<br>
}</p>
<p align="left"><a href="http://www.cs.wcupa.edu/~rkline/perl2php/">http://www.cs.wcupa.edu/~rkline/perl2php/</a>
- An excellent perl-2-php view ... a great comparison ... check it out ... <br>
<a href="http://www.tek-tips.com/viewthread.cfm?qid=760114">http://www.tek-tips.com/viewthread.cfm?qid=760114</a>
- A perl forum ... with an 'interesting' join-us dialog ... and you have to JOIN
to do a 'keyword-search' ;=((<br>
<a href="http://www.ebb.org/PickingUpPerl/pickingUpPerl.html">http://www.ebb.org/PickingUpPerl/pickingUpPerl.html</a>
- So many 'reference' sites ...<br>
<a href="http://www.cs.mcgill.ca/~abatko/computers/programming/perl/howto/hash/">http://www.cs.mcgill.ca/~abatko/computers/programming/perl/howto/hash/</a>
- more ...<br>
<a href="http://www.perlarchive.com/articles/perl/djm0001.shtml">http://www.perlarchive.com/articles/perl/djm0001.shtml</a>
- Say output a hash ...<br>
foreach my $key (keys %hash) { print &quot;$key = $hash{$key}\n&quot;; } or
while (($key,$value) = each %hash){ print &quot;$key = $value\n&quot;; }</p>

<p align="left">Perl seems to have a MASSIVE presence, when it come to search
engines, like, say, Yahoo! With a simple HOW TO thought, quite often, the answer
will be almost immediate. For example, how to get an array length? Using, for
example, a query of &quot;perl array length&quot; yields - <a href="http://www.unix.com/showthread.php?t=3149">http://www.unix.com/showthread.php?t=3149</a>
- the answer ... like &quot;Set a variable $a=@testarray, $a will be the number
of elements in the array.&quot; ... and that was only the first 'find' ... a few
down ...</p>
<p align="left"><a href="http://michael.mathews.net/perlcircus/site/arrays.html">http://michael.mathews.net/perlcircus/site/arrays.html</a>
- What a fantastic name '<b>Perl Circus</b>' ... with lots, and lots of helpful
samples ... even things you did not ask, but are good 'tutorial' examples -
Create an array from a hash<br>
$hash{&quot;apple&quot;} = &quot;pomme&quot;; $hash{&quot;book&quot;} = &quot;livre&quot;;
@arr = %hash; print &quot;@arr&quot;; ... then ..<br>
<a href="http://www.cs.mcgill.ca/~abatko/computers/programming/perl/howto/array/">http://www.cs.mcgill.ca/~abatko/computers/programming/perl/howto/array/</a>
- where it is spelled out, multiple times ;=)) ... Get the size of an array.<br>
Solution 1: If you just want to print the size, this is the simplest way.<br>
print &quot;size of array: &quot; . @array . &quot;.\n&quot;;<br>
Solution 2: If you want to retain the size in a variable, just evaluate the
array in implicit scalar context.<br>
$size = @array; print &quot;size of array: $size.\n&quot;;&nbsp;<br>
Explicit scalar context can be achieved by using the function scalar.<br>
$size = scalar @array; print &quot;size of array: $size.\n&quot;;<br>
Since the results are the same, I recommend the implicit solution.<br>
Solution 3: There are also a number of other methods of getting the array size.<br>
$size = $#array + 1; ... and ...<br>
<a href="http://www.sidhe.org/perldocs/lib/Pod/perlguts.html">http://www.sidhe.org/perldocs/lib/Pod/perlguts.html</a>
- has more details again ... and, of the original search, there are some half
million its to explore ;=))<br>
<a href="http://www-2.cs.cmu.edu/People/rgs/pl-exp-arr.html">http://www-2.cs.cmu.edu/People/rgs/pl-exp-arr.html</a>
- with simple code samples ... hash, as an array ...<br>
<a href="http://www.cs.mcgill.ca/~abatko/computers/programming/perl/howto/hash/">http://www.cs.mcgill.ca/~abatko/computers/programming/perl/howto/hash/</a>
- hash creation, manipulation ... returning a HASH reference, from a sub ...<br>
<a href="http://www.cs.rpi.edu/~hollingd/eiw/notes/PerlArrays/PerlArrays.html">http://www.cs.rpi.edu/~hollingd/eiw/notes/PerlArrays/PerlArrays.html</a>
&nbsp;- arrays continue ... EIW Fall 2004 Lecture Notes ...</p>
<p align="center"><a href="../cvineng2.htm">Back to cv</a> or <a href="../home2.htm">to Home Page</a></p>

<p>Perl and HTML</p>
<p><a href="http://www.hypernews.org/HyperNews/get/www/html/converters.html">http://www.hypernews.org/HyperNews/get/www/html/converters.html</a>
- offer some 'converters' ...</p>

<p>http://www.cclabs.missouri.edu/things/instruction/perl/perlcourse.html 
(broken!)
- A whole, quick course in perl ...</p>

<p>search : perl no strict refs<br>
<a href="http://readlist.com/lists/perl.org/beginners/0/146.html">http://readlist.com/lists/perl.org/beginners/0/146.html</a>
- 'hard' and 'soft' function references ... if, say, a function list is
auto-generated ...</p>

<p><a href="http://www.perl.com/pub/a/2002/10/01/hashes.html?page=2">http://www.perl.com/pub/a/2002/10/01/hashes.html?page=2</a>
- looking up a hash ...<br>
<a href="http://www.perl.com/lpt/a/2003/03/07/apocalypse6.html">http://www.perl.com/lpt/a/2003/03/07/apocalypse6.html</a>
- the future ...</p>

<p>A developing MS Word HTML modifier ... uses the HTML::Parser to load, and
modify the HTML output ... <a href="perl1.htm">stripms</a> ... *WIP ;=))* or a <a href="perl3.htm">more
references</a> ... Some perl code samples - <a href="perl4.htm">Socket Server</a> - perl-to-html
converter <a href="p2html8.htm">p2html8.htm</a> (old, very broken version <a href="perl5.htm">perl5.htm</a>)</p>

<p><a href="index.htm">Perl Index</a> *|* <a href="../cvineng2.htm">Back to cv</a> 
*|* <a href="../home2.htm">to Home Page</a> *|* <a href="perl.htm">Perl Next</a></p>

</body>

</html>