Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: Sum to 100 at Rosetta Code

by karlgoethebier (Abbot)
on Feb 18, 2018 at 11:57 UTC ( [id://1209425]=note: print w/replies, xml ) Need Help??


in reply to Sum to 100 at Rosetta Code

But this code doesn't compile...

karls-mac-mini:playground karl$ perl -c ./choroba.pl Global symbol "$max_count" requires explicit package name (did you for +get to declare "my $max_count"?) at ./choroba.pl line 14. Global symbol "$sum" requires explicit package name (did you forget to + declare "my $sum"?) at ./choroba.pl line 14. Global symbol "%count" requires explicit package name (did you forget +to declare "my %count"?) at ./choroba.pl line 14. Global symbol "$sum" requires explicit package name (did you forget to + declare "my $sum"?) at ./choroba.pl line 14. Global symbol "%count" requires explicit package name (did you forget +to declare "my %count"?) at ./choroba.pl line 14. Global symbol "$max_count" requires explicit package name (did you for +get to declare "my $max_count"?) at ./choroba.pl line 14. Global symbol "$expression" requires explicit package name (did you fo +rget to declare "my $expression"?) at ./choroba.pl line 16. Global symbol "$sum" requires explicit package name (did you forget to + declare "my $sum"?) at ./choroba.pl line 16. Unmatched right curly bracket at ./choroba.pl line 17, at end of line syntax error at ./choroba.pl line 17, near "}" ./choroba.pl has too many errors.

Update: It compiles. I copied the code from the download link into an emacs buffer as i did it many thousand times before. For some unknown reason the result was broken. I never observed this before. I'm very sorry. And to be honest: I couldn't hardly imagine that choroba should have posted something that doesn't compile.

Best regards, Karl

«The Crux of the Biscuit is the Apostrophe»

perl -MCrypt::CBC -E 'say Crypt::CBC->new(-key=>'kgb',-cipher=>"Blowfish")->decrypt_hex($ENV{KARL});'Help

Replies are listed 'Best First'.
Re^2: Sum to 100 at Rosetta Code
by Athanasius (Archbishop) on Feb 18, 2018 at 12:57 UTC

    Strange. It compiles and runs for me under Windows 8.1, 64-bit:

    22:52 >perl 1870_Med.pl Show all solutions that sum to 100 123-45-67+89 12-3-4+5-6+7+89 12+3+4+5-6-7+89 123+4-5+67-89 -1+2-3+4+5+6+78+9 1+2+3-4+5+6+78+9 12+3-4+5+67+8+9 1+23-4+56+7+8+9 1+2+34-5+67-8+9 1+23-4+5+6+78-9 123+45-67+8-9 123-4-5-6-7+8-9 Show the sum that has the maximum number of solutions sum: 9; solutions: 46 Show the lowest positive sum that can't be expressed 211 Show the ten highest numbers that can be expressed 123456789 23456790 23456788 12345687 12345669 3456801 3456792 3456790 3456788 3456786 22:52 >perl -v This is perl 5, version 26, subversion 0 (v5.26.0) built for MSWin32-x +64-multi-thread-ld

    Have you double-checked the contents of your choroba.pl file?

    Update: FWIW, I get the same result under Cygwin:

    $ perl -v This is perl 5, version 22, subversion 4 (v5.22.4) built for cygwin-th +read-multi

    Athanasius <°(((><contra mundum Iustus alius egestas vitae, eros Piratica,

Re^2: Sum to 100 at Rosetta Code
by LanX (Saint) on Feb 18, 2018 at 14:05 UTC
    Does your Perl version support "say" ?

    update
    This looks like a runaway error in the first 4 lines.

    Cheers Rolf
    (addicted to the Perl Programming Language and ☆☆☆☆ :)
    Wikisyntax for the Monastery

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (7)
As of 2024-03-29 14:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found