develooper Front page | perl.beginners | Postings from September 2009

Re: text html from file to a scalar and mail

Thread Previous | Thread Next
Jenda Krynicky
September 12, 2009 16:44
Re: text html from file to a scalar and mail
Message ID:
From: Shlomi Fish <>
> > use FileHandle;
> >    my $signature = new FileHandle;
> >       $signature->open("<$signature_file")or die "Could not open
> > file\n";
> You should use IO::Handle instead of File::Handle (or IO::File in your case), 
> and use the three args open. It's nice you've used die.

Nope. You should not be bothering with thatever class is at the 
moment behind the Perl filehandles and just use open() as a function. 
Not everything has to be an object

  open my $SIGNATURE, '<', $signature_file
    or die "Could not open '$signature_file': $^E\n";

> $signature is not a good name for a filehandle - better call it $signature_fh.

I use all capitals for filehandles. Both oldstyle and lexical.

> >  my $fileHandle = $_[0];
> Accessing $_[$idx] is not very robust - you should do:
> <<<
> my $fileHandle = shift;
> >>>
> Or:
> <<<
> my ($fileHandle) = @_;

Nope. Accessing $_[$idx] all over the place within the subroutine 
would be prone to errors and inconvenient (though sometimes 
necessary), what syntax do you use to copy the parameters into 
lexical variables is largely unimportant. And sometimes you can't 
just shift() off parameters from @_, you need to keep them there.

> > my $customer_msg_html = $customer_msgStart_html  . OrderFromForm_html()
> > . $customer_msgEnd_html . $scalar_sig;
> Your style is inconsistent between camelCase, and 
> underscore_separated_identifiers. 

Maybe there is a meaning to the underscores on some places and case 
change in others. Don't be so quick. The fact that you do not see a 
pattern from a very short example doesn't necessarily mean there 
isn't one. It may very well be too big to fit in the small cut hole 
that you see.

===== === =====
When it comes to wine, women and song, wizards are allowed 
to get drunk and croon as much as they like.
	-- Terry Pratchett in Sourcery

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About