Re: text html from file to a scalar and mail

2009-09-14 Thread Shlomi Fish
On Sunday 13 September 2009 02:43:52 Jenda Krynicky wrote:
 From: Shlomi Fish shlo...@iglu.org.il
 
   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;
 

Indeed. No need to call $SIGNATURE with all-caps. $signature_fh is good 
enough. I should note that if you do use IO::Handle; at the top, then you 
can all methods on $signature_fh.

  $signature is not a good name for a filehandle - better call it
  $signature_fh.
 
 I use all capitals for filehandles. Both oldstyle and lexical.

I dislike all-capitals because it's like shouting and are harder to read. But 
this is a colour of the bike-shed argument:

http://bikeshed.com/

 
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.
 

Generally, I sometimes use something like:

sub my_method
{
my $self = shift;

my ($param1, $param2, $param3) = @_;

.
.
.
if (COND())
{
return $self-other_method(@_);
}
}

Normally I don't like using $_[0], $_[1], etc. directly. The only use I can 
think for them is to modify them in place using aliases. But in this case it 
is better and safer to pass them as references.

   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.


Maybe. It's still hard to read.

Regards,

Shlomi Fish
 
 Jenda
 = je...@krynicky.cz === http://Jenda.Krynicky.cz =
 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
 

-- 
-
Shlomi Fish   http://www.shlomifish.org/
Freecell Solver - http://fc-solve.berlios.de/

Chuck Norris read the entire English Wikipedia in 24 hours. Twice.

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Ternary operator

2009-09-14 Thread Randal L. Schwartz
 Telemachus == Telemachus  telemac...@arpinum.org writes:

Telemachus Unfortunately, it seems like O'Reilly has given up on Perl...

Absolutely not.  Just that the costs of *updating* a book often approach the
costs of initial development for many of the overhead activities.

You lept to a conclusion that was unfounded.

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
mer...@stonehenge.com URL:http://www.stonehenge.com/merlyn/
Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
See http://methodsandmessages.vox.com/ for Smalltalk and Seaside discussion

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Giving away my code

2009-09-14 Thread Steve Bertrand
Ok.

Some of you have probably come across my post on monks, but I ask here
with a bit more detail.

My project is a suite for Internet Service Provider management. The core
engine is topped off with a web gui interface. This project contains
about 7,800 lines of code, POD and unit tests.

The HTML/email templates are separate, but I do intend to integrate them
into the core of the project.

There are also a few other personal packages which I've written that I
tap into, but they are better left separate ( RadiusMgmt, EmailMgmt
etc). These will be re-written, because what I know now, I didn't know then.

The company that employs me is very small, and although I don't believe
there will ever be a problem with giving my code away, I want to take
advantage of the fact that I have never signed anything to say I
``can't'' give it away. I'm at a stage where some of our staff is
testing, so before the powers-that-be decide that this is company code:

What is the quickest and easiest way to ensure my code is truly licensed
as public domain, if I don't feel that the code is quite CPAN worthy?

Do I put it somewhere with a license in it? Can I simply share it with
someone else, with a license in it?

Steve


smime.p7s
Description: S/MIME Cryptographic Signature


Re: Ternary operator

2009-09-14 Thread Tim Bowden
On Mon, 2009-09-14 at 09:32 -0700, Randal L. Schwartz wrote:
  Telemachus == Telemachus  telemac...@arpinum.org writes:
 
 Telemachus Unfortunately, it seems like O'Reilly has given up on Perl...
 
 Absolutely not.  Just that the costs of *updating* a book often approach the
 costs of initial development for many of the overhead activities.

Oh good, O'Reilly hasn't given up.  Is there some uncertainty as to the
success a future version might have?  Or is it a question of the right
resources being available and willing to undertake the task?  Or has it
been put on the backburner for Perl6?  I suspect there is a significant
level of latent demand for an update after so many years and Perl
versions.

Regards in anticipation of an eventual update,
Tim Bowden


-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Giving away my code

2009-09-14 Thread Raymond Wan


Hi Steve,


Steve Bertrand wrote:

The company that employs me is very small, and although I don't believe
there will ever be a problem with giving my code away, I want to take
advantage of the fact that I have never signed anything to say I
``can't'' give it away. I'm at a stage where some of our staff is
testing, so before the powers-that-be decide that this is company code:



I hope you double-check this as sometimes the powers-that-be slip this 
in without you noticing.  It might be folded into your job contract, 
etc.  One could argue that you did that work while under their 
employment (as opposed to doing it at home in the evenings or on 
weekends).  I honestly do not know -- but it might even be in Canadian 
labor laws?  I'm not saying that you can't release it; but just be careful.


That said, some of what I've done is released to the public, but when 
you're paid by tax payers, I think it is slightly easier to argue for.




What is the quickest and easiest way to ensure my code is truly licensed
as public domain, if I don't feel that the code is quite CPAN worthy?



Perl aside, one thing you might want to look into is the documentation 
for the GPL license to see if that is a license you want to attach to 
your code.  If so, then there are steps that it says you should do 
(include the license with the archive, etc.).


In fact, Wikipedia has a list of software licenses:

http://en.wikipedia.org/wiki/Comparison_of_free_software_licences

Instead of GPL, you might want to see what you like and then do what it 
says.  Of course, assigning a license is different from distribution 
(putting it on CPAN, on your homepage, etc.).


Ray



--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Giving away my code

2009-09-14 Thread Tim Bowden
On Mon, 2009-09-14 at 21:14 -0400, Steve Bertrand wrote:

 The company that employs me is very small, and although I don't believe
 there will ever be a problem with giving my code away, I want to take
 advantage of the fact that I have never signed anything to say I
 ``can't'' give it away. I'm at a stage where some of our staff is
 testing, so before the powers-that-be decide that this is company code:
 

If the code is valuable enough to be fighting over, I'd get an explicit
understanding of what's yours and what's the companies.  Gentlemen's
agreements get ugly when there's enough money involved.  Actually, I'd
do that anyway, but that's just me. 

 What is the quickest and easiest way to ensure my code is truly licensed
 as public domain, if I don't feel that the code is quite CPAN worthy?
 
There is no such thing.  Public domain means 'no one owns it' (subject
to whatever legal domain you happen to be in; All sorts of wrinkles
there depending on the local legal system from what I understand).  In
order to license something, you must own it (or 'own' rights to license
it).  Yes, I'm being pedantic, but if you want clean licensing of your
code, you need to get it right.

 Do I put it somewhere with a license in it? Can I simply share it with
 someone else, with a license in it?

If the license is short and sweet (BSD style) perhaps include the
license text inline at the start of the file along with a copyright
statement (which *must* have the year of copyright as I understand it),
or refer to 'license.txt' and include the license in the file.  Each
file in the release should have a copyright notice and the license or a
reference to the license file.  If you really are putting the code in
the public domain, a short statement saying so should suffice (in which
case you can't add license terms or claim copyright).

 
 Steve

Not giving legal advice and most certainly not an expert,
Tim Bowden


-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/