in reply to Re: Convert time string to seconds
in thread Convert time string to seconds

For less typing, tighter "scope" and to avoid suppressing other warnings at the same time, you can simply say $1||0, or in this case ($+{'min'}||0).

Replies are listed 'Best First'.
Re^3: Convert time string to seconds
by moritz (Cardinal) on Aug 16, 2010 at 13:51 UTC
    I knew somebody would suggest this method :-)

    It's just that when I add code to surpress a warning, "switch off the warning" feels more direct to me than "avoid the warnings".

    Since it's not an error, but a warning, using undef as 0 is legitime, and I find avoiding the feature at all rather backwards. After all warnings should help me write better code, not force me to write different application logic.

    Perl 6 - links to (nearly) everything that is Perl 6.

      I'm sure there is a place for both.

      In the case of a multiline block, usually there are other variables that you really do want to hear about being undeffed, regardless of the fact that you don't want to hear about a couple specific ones... On the other hand, in a tiny block, typing out the whole no warnings 'uninitialized'; seems excessive.

      For me, at least, the middle ground that calls for "no warnings" is fairly narrow but does exist.