Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: function prototyping & perl 5.8.20

by topherv (Initiate)
on Aug 01, 2018 at 11:28 UTC ( #1219641=note: print w/replies, xml ) Need Help??


in reply to function prototyping & perl 5.8.20

Hi monks, I figured I’d share my learnings. When I rolled up to perl 5.8.20, a few of my modules gave errors. The errors pointed at the function declaration lines. I changed:
Sub function() {
To:
Sub function() {
After making these changes, there was one more fix:
foreach my $key qw( id group title rank )
To:
foreach my $key (qw( id group title rank ))
I saw many other places where my functions were defined with the ‘{‘ on the next line. But, things were running. I wondered if I removed the “use strict”, if the function errors would go away. So, I undid the function changes. The code still worked!

This means the functions weren’t my problem at all, just the foreach line. But the compiler could not point to that line until I corrected all the functions. So, having the ‘{‘ on the same line as the sub is good coding practice, but not required for perl 5.8.20

Thanks for you help!

Replies are listed 'Best First'.
Re^2: function prototyping & perl 5.8.20
by Tux (Abbot) on Aug 01, 2018 at 14:00 UTC
    $ perl5.12.5 -we'for my $k qw(a b) {$_=$k}' $ perl5.14.0 -we'for my $k qw(a b) {$_=$k}' Use of qw(...) as parentheses is deprecated at -e line 1. $ perl5.16.3 -we'for my $k qw(a b) {$_=$k}' Use of qw(...) as parentheses is deprecated at -e line 1. $ $ perl5.18.0 -we'for my $k qw(a b) {$_=$k}' syntax error at -e line 1, near "$k qw(a b)" Execution of -e aborted due to compilation errors.

    If you upgrade, you might as well read the release notes. Oké, if you take big steps, there are a lot of changes to read, but all of this is documented.

    See the 5.14.0 delta entry:

    And the 5.18.0 delta entry:

    Which makes me think you made a move from perl-5.10.1 to perl-5.18.0 or newer. As you state 5.8.20 (which never existed), I assume you mean 5.28.0.


    Enjoy, Have FUN! H.Merijn
Re^2: function prototyping & perl 5.8.20
by dave_the_m (Monsignor) on Aug 01, 2018 at 13:09 UTC
    Note that there's no such perl version as 5.8.20. perhaps you mean 5.20.0???

    Dave.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1219641]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (4)
As of 2019-07-24 07:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    If you were the first to set foot on the Moon, what would be your epigram?






    Results (32 votes). Check out past polls.

    Notices?