ׁHi Ynon,
On Fri, 4 May 2012 15:26:30 +0300
ynon perek <[email protected]> wrote:
> And, since you only use $self once, the variable (and the return statement)
> are dispensable
>
> sub GetFileName {
> shift->{cf}
> }
>
I don't like using shift like that (though I've done it a few times for some
short methods when I was lazy). Furthermore, Perl Best Practices and my own
http://perl-begin.org/tutorials/bad-elements/#explicit_return mandate
an explicit return for every subroutine, so I need a return there.
Regards,
Shlomi Fish
> On 4 May 2012 12:57, Shlomi Fish <[email protected]> wrote:
>
> > Hi all,
> >
> > in reflection about Gabor’s talk yesterday, I’ve been spending some time
> > refactoring the code of the Config::IniFiles CPAN module, of which I am a
> > co-maintainer, and which I adopted because I’ve made use of it for one
> > project.
> >
> > While doing that I’ve ran into this gem:
> >
> > sub GetFileName
> > {
> > my $self = shift;
> > my $filename;
> > if (exists $self->{cf}) {
> > $filename = $self->{cf};
> > } else {
> > undef $filename;
> > }
> > return $filename;
> > }
> >
> > It's indicative of a lot of ignorance of how Perl 5 works.
> >
> > This ended up being shortened into:
> >
> > sub GetFileName
> > {
> > my $self = shift;
> >
> > return $self->{cf};
> > }
--
-----------------------------------------------------------------
Shlomi Fish http://www.shlomifish.org/
Understand what Open Source is - http://shlom.in/oss-fs
There is an IGLU Cabal, but its only purpose is to deny the existence of an
IGLU Cabal.
— Martha Greenberg
Please reply to list if it's a mailing list post - http://shlom.in/reply .
_______________________________________________
Perl mailing list
[email protected]
http://mail.perl.org.il/mailman/listinfo/perl