Eric

I'm in a pretty-code-mode at the moment, my  apologies for the overkill.

> #location contains the path for the report to be stored
> $report_location = $location;
> $report_location =~ s/\//\\/;
To make this regex look a bit better you can use a different delimiter
rather than "/". Also you probably want to replace all "\" chars with "/" in
which case you need a 'g' at the end to make it a global replacement. Perl
has a much faster construct for replacing one character with another, i.e.
"tr".

$report_location =~ s!\/!\\!g;  # better
$report_location =~ tr!\\!//!;  # best;

See "perlop" for more info on "s" and "tr"

> $report_location = "$report_location" . "\\Reports";

A more explicit way of saying this using the ".=" construct. It saves you
having to double check that your left hand side is exactly the same as you
right hand side. It seems trivial here but is a godsend when debugging
something like $x[10101]{$y[101]]}= $x[10101]{$y[101]]} + $y[101];

$report_location.="\\Reports"  

> unless( -e $report_location) ){
>   mkdir( $report_location ) or die "died creating Report Directory";
> }
The -e operator tells you that a file exists. We have inherited from Unix
that a directory is a file. You might also want to check that
$report_location exists and is a directory. Id also suggest being a little
more informative to your users. Tell them what went wrong with the $!
variable. Also the idiom _this_ or _that_ can be IMHO elegantly extended
here 

-d $report_location or
        mkdir $report_location  or 
        die "died creating Report Directory '$report_location': $!";

> #open Report HTML file
> open( FILE, "> 
> $report_location\\$year_$month_$date_Report.htm" ) or die
> "Dead creating Report";

Note that perl will interpret this as "$year_"."$month_" etc. You probably
called your variables $year $month etc. So, to force perl to recognise where
the end of you variables are use {}'s. Make sure you put "use strict;" at
the top of your code and "my" all your variables otherwise perl will
silently evaluate them to "".

my $report_name=$report_location\\${year}_${month}_${date}_Report.htm";
open  FILE, ">$report_name") or 
        die "Cannot write to $report_name : $!";

> #print intial html to report file
> print FILE
> "<html>\n<head>\n<title>$year_$month_$date_report</title>\n</h
> ead>\n<body>\n
> ";

A more elegant construct for printing long strings is the "<<HERE"  syntax 

print FILE <<END_OF_HTML_HEADER;
<html>
<head>
<title>$year_$month_$date_report</title>
Etc,
END_OF_HTML_HEADER

<snip>

> foreach $project_file ( @file_paths ){
>   #grep Status line from $project_file 
>   @status_line = grep /^Status/, $project_file;
> }

Note, $project_file will be a file name, not the contents of that file. You
need to open it and read :
foreach my $project_file ( @file_paths ){
        open  PROJFILE, $project_file or die "Cannot read $project_file :
$!";
        my @status_lines = grep /^Status/,  <PROJFILE>; # Using the file in
an array context;
        close PROJFILE;
        DoStuff(@status_lines);
}

HTH


Alistair


-----------------------------------------------------------------------


Registered Office:
Marks & Spencer p.l.c
Michael House, Baker Street,
London, W1U 8EP
Registered No. 214436 in England and Wales.

Telephone (020) 7935 4422 
Facsimile (020) 7487 2670

www.marksandspencer.com

Please note that electronic mail may be monitored.

This e-mail is confidential. If you received it by mistake, please let us know and 
then delete it from your system; you should not copy, disclose, or distribute its 
contents to anyone nor act in reliance on this e-mail, as this is prohibited and may 
be unlawful.

The registered office of Marks and Spencer Financial Services PLC, Marks and Spencer 
Unit Trust Management Limited, Marks and Spencer Life Assurance Limited and Marks and 
Spencer Savings and Investments Limited is Kings Meadow, Chester, CH99 9FB.

_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to