on Wed, 04 Sep 2002 07:44:01 GMT, [EMAIL PROTECTED]
(David Samuelsson) wrote:
[Why are you quoting yourself in an original post?]
>> I want tips, on
>> optimizing, and things that can be done smaller and better.
>> Changes goes inside the box.
>> use strict;
>> my (@vobs,$vob,$view,$text,@views,@sviews,$viewname,$viewinfo);
I usually declare my variables close to where I first need them.
>> $a = localtime(time);
Don't use '$a' (or '$b'). These are special variables for use with the
'sort' function. Did you notice how the undeclared variable '$a'
doesn't generate an error, although strictures are turned on?
>> `del $errors`;
There is no need to spawn another process to delete a file. Perl has
the 'unlink' function. See perldoc -f unlink.
>> open (HTML,">$html") or die "error: $!";
>> print HTML "<html>\n<head>\n<title>ClearCase Views with
You could use a here-document, or the construct
print HTML qq{
A lot of
HTML lines
to print
};
to avoid the repetition of 'print HTML' statements
>> @vobs = `cleartool lsvob -s`;
>> foreach $vob (@vobs)
my @vobs = `cleartool lsvob -s`;
foreach my $vob (@vobs) {
as explained above
>> {
>> chomp $vob;
>> print "checkin $vob\n";
>> open (A, "cleartool desc -l vob:$vob |");
Always, yes always check the return value of a system call
>> while (<A>)
>> {
>> if ($_ =~ /.uuid./i)
>> {
>> chomp $_;
>> $_ =~ s/.*\[uuid (.*)\]/$1/;
>> $view = `cleartool lsview -s -uuid $_ 2>&1`;
>> chomp $view;
>> if ($view =~ /.Error:./)
>> {
>> open (LOGFILE, ">>$errors") or die "cant
>> open $!"; print LOGFILE "ERROR IN $vob:
>> $view\n";
>> }
>> else
>> {
>> $text = "$view $vob\n";
>> push (@views,$text);
>> }
>> }
>> }
>> }
>> @sviews = sort {lc $a cmp lc $b}@views;
Your original $a variable to which you assigned the localtime is now
gone.
>> print "Printing HTML to $html\n";
>> foreach $view (@sviews)
>> {
>> ($viewname, $vob) = split (/\s+/, $view);
>> $viewinfo = `cleartool lsview -l $viewname`;
>> if ($viewinfo =~ /snapshot/)
>> {
>> print HTML "<tr>\n\t<tr
>> bgcolor\=\"\#FFFF99\">\n\t<td>$viewname</td>\n
>> \t<td>Snapshot</td>\n\t<td>$vob</td>";
>> }
>> else
>> {
>> print HTML "<tr>\n\t<tr
>> bgcolor\=\"\#FFFF99\">\n\t<td>$viewname</td>\n
>> \t<td>Dynamic</td>\n\t<td>$vob</td>";
>> }
>> }
If you use
print qq{You don't have to escape your "quotes"};
--
felix
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]