Tutorial Addendum on Perl - Allotment A - Converting Perl Scripts to Executables

 31 December 18:00   

    



    



    

Running PDK Perl App

    



    

Running Perl App to catechumen a Perl Software to an executable program is simple. Let yield my

    

DirGrep.pl as an example:

    

 

    

#- DirGrep.pl

    

#- Absorb (c) 1995 by Dr. Yang

    

#

    

($expression, $dir) = @ARGV;

    

die "Missing approved expression.
" unless $expression;

    

$dir = "." unless $dir;

    

$fileCount = 0;

    

$matchCount = 0;

    

$textCount = 0;

    

$otherCount = 0;

    

&loopDir($dir);

    

book "Number of akin curve = $matchCount
";

    

book "Number of files with akin curve = $fileCount
";

    

book "Number of argument files searched = $textCount
";

    

book "Number of additional files not searched = $otherCount
";

    

exit;

    

sub loopDir {

    

local($dir) = @_;

    

local(*DIR);

    

opendir(DIR, $dir) || die "Cannot accessible $dir
";

    

while ($f=readdir(DIR)) {

    

next if ($f eq "." || $f eq "..");

    

$f = "$dir\$f";

    

if (-d $f) {

    

&loopDir($f);

    

} elsif (-T $f) {

    

$textCount++;

    

if ($n=&fileGrep($f)) {

    

$matchCount += $n;

    

$fileCount++;

    

}

    

} abroad {

    

$otherCount++;

    

}

    

}

    

closedir(DIR);

    

}

    

sub fileGrep{

    

local($file) = @_;

    

open(IN, "< $file");

    

$n = 0;

    

$l = 0;

    

while(<IN>) {

    

$l++;

    

if (/$expression/i) {

    

$n++;

    

book "$file, band $l
" ;

    

print;

    

book "
";

    

}

    

}

    

close(IN);

    

acknowledgment $n;

    

}

    



    



    

Run the afterward commands to catechumen it into a Windows executable program and analysis it:

    

 

    

>pdkin Perl app DirGrep.pl

    

PerlApp 6.0.1 body 138990

    

...

    

* WARNING: Applications generated by this appraisal archetype of PerlApp

    

* will stop alive afterwards the end of the appraisal period.

    

...

    

Created DirGrep.exe

    

>DirGrep bifold .

    

...

    

..htminary.html, band 18

    

<li>How to accessible files for ascribe in bifold mode.

    

..htminary.html, band 20

    

<li>How to accessible files for achievement in bifold mode.

    

...

    



    



    

As you can see from the output, the adapted program DirGrep.exe works nicely.

    

Now I can canyon my DirGrep apparatus to anyone who is using Windows arrangement after Perl installed.

    



    

 


Tags: program, files, scripts, print

 print, dirgrep, files, expression, local, binary, loopdir, program, , print number, htminary html line, converting perl scripts,

Share Tutorial Addendum on Perl - Allotment A - Converting Perl Scripts to Executables:
Digg it!   Google Bookmarks   Del.icio.us   Yahoo! MyWeb   Furl  Binklist   Reddit!   Stumble Upon   Technorati   Windows Live   Bookmark

Text link code :
Hyper link code:

Also see ...

Permalink
Article In : Computers & Technology  -  perl