Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister

Re^11: can't import using exporter

by Corion (Pope)
on Mar 16, 2012 at 07:56 UTC ( #959931=note: print w/replies, xml ) Need Help??

in reply to Re^10: can't import using exporter
in thread can't import using exporter

... Sorry. Breaking apart a 800 line perl prog that was a 185 line shell script , into a 10-15 file perl monster is messed up. ... The problem with simplifying all those pesky aliases and RO var, is that oft' times the problem becomes induplicable. ...

This process is called debugging. If you are programming, you should familiarize yourself with it. If the problem becomes "induplicable", that means you have just eliminated one source of your problems. But it feels to me that you prefer others to put effort in solving your problems over cleaning your room first before asking for help.

... you put 90% of the the program in BEGIN{}. ... You can't develop a program entirely in Begin.

My approach mechanically reproduces what use does. If that does not suit you, then you will have to restructure your code in a way that it does not rely on how use works. I'm not sure why you are hell-bent on doing things the way you do them, but I showed you where your approach fails and how you need to modify your approach to get to a result. Your impression that "standard methods" don't work is owed to the fact that you did not present the relevant code and did not show how you tried to rely on symbol exports happening at the right time. The "standard methods" rely on the programmer understanding Perl and understanding how and when symbols are exported from modules. I suggest that you learn more Perl.

Also, it may surprise you, but you can easily develop a program entirely in BEGIN blocks, as long as you understand what BEGIN blocks are and what they do.

The module suggested doesn't run on 5.14 without errors -- indicating that 5.14 has now broken it as well.

Again, extraordinary claims require extraordinary evidence. The CPAN tester Matrix for Module::Util shows no breakage, and you have shown lots of broken code that you produce, and concepts that you misunderstand or ignore. In so far, I really, really recommend that you don't claim things that you do not have a program with less than 10 short lines for to reproduce them.

Your program is a onerous, though proven, workaround, but it also gives ample fodder to any perl-hater out there about how broken a language perl is, because having to do that to have multiple classes in the same file is broken.

No. You don't need to do any of that to have multiple classes in the same file. This only shows that you don't understand what you are doing. You are not declaring a single class in your code. As you claim to be educated by merlyn and brian d foy, it would amuse me if you found a section in their books or a statement by them where they claim that your shown approach is somehow object oriented and has entities where "class" would be an appropriate moniker. Especially the lack of the bless keyword is a certain indicator that you are not dealing with objects and classes in your code.

Replies are listed 'Best First'.
Re^12: can't import using exporter
by perl-diddler (Hermit) on Mar 16, 2012 at 09:01 UTC

    > "module_notational_filename" is not exported by the Module::Runtime mo +dule Can't continue after import errors at ./ line 4. BEGIN failed--compilation aborted at ./ line 4. Ishtar:/Audio/scripts> ^C Ishtar:/Audio/scripts> cat #!/usr/bin/perl -w use strict; use Module::Runtime qw(module_notational_filename); <p> <p> You can't say I didn't pare down my test program... right? It's does have some fluff. a blank line. sorry, I'm just lazy. <p> <p> Maybe you can get off your extraordinary high horse and realize that s +imple usage as documented in the manpage isn't tested in the CPAN Mat +rix, because I've given you extraordinary evidence that functionality + in that module is broken and Guess what -- that KEYWORD is in a @EXPORT_OK line -- so the evidence just rose extraordinarily that so +mething broke in 6.5.14 that this module relied on -- that has now ch +anged. <p> Are you still in denial or how many modules do I have to find I had an +other program that worked fine in 6.5.12, -- fails to work now with s +imilar errors as the one above. <code> Useless use of multiplication (*) in void context at /home/law/bin/ded +up line 664. String found where operator expected at /home/law/bin/dedup line 762, +near "Warn "Cannot cache scan results in %s: %s\n"" (Do you need to predeclare Warn?) String found where operator expected at /home/law/bin/dedup line 776, +near "Error "No Cached scan file in $scan_res_path to use.\n"" (Do you need to predeclare Error?) String found where operator expected at /home/law/bin/dedup line 780, +near "Warn "Ignoring cached results file '$scan_res_path'.\n"" (Do you need to predeclare Warn?) String found where operator expected at /home/law/bin/dedup line 787, +near "Warn "Cannot cache scan results in %s: %s\n"" (Do you need to predeclare Warn?) String found where operator expected at /home/law/bin/dedup line 820, +near "Error "FATAL: Starting paths must be on same device.\n"" (Do you need to predeclare Error?) String found where operator expected at /home/law/bin/dedup line 827, +near "Warn "$_: neither file nor dir. Ignoring in scan.\n"" (Do you need to predeclare Warn?) String found where operator expected at /home/law/bin/dedup line 833, +near "Error "$_ not readable; pathname blocking further examination\n +"" (Do you need to predeclare Error?) String found where operator expected at /home/law/bin/dedup line 849, +near "Debug "Got %d paths from command line\n"" (Do you need to predeclare Debug?) String found where operator expected at /home/law/bin/dedup line 862, +near "safe_printf "debug=%s, verbose=%s, scandev=%04x; "" (Do you need to predeclare safe_printf?) syntax error at /home/law/bin/dedup line 743, near "confess sprintf" syntax error at /home/law/bin/dedup line 762, near "Warn "Cannot cache + scan results in %s: %s\n"" syntax error at /home/law/bin/dedup line 776, near "Error "No Cached s +can file in $scan_res_path to use.\n"" syntax error at /home/law/bin/dedup line 780, near "Warn "Ignoring cac +hed results file '$scan_res_path'.\n"" syntax error at /home/law/bin/dedup line 787, near "Warn "Cannot cache + scan results in %s: %s\n"" syntax error at /home/law/bin/dedup line 820, near "Error "FATAL: Star +ting paths must be on same device.\n"" syntax error at /home/law/bin/dedup line 827, near "Warn "$_: neither +file nor dir. Ignoring in scan.\n"" syntax error at /home/law/bin/dedup line 833, near "Error "$_ not read +able; pathname blocking further examination\n"" syntax error at
    It's like stops exporting things reliably in larger, non-trivial programs.

    But of course trivial ones still work, so people can prove it works... *BROKEN*

      As Anonymous Monk already pointed out, your are misreading/mistyping the Module::Runtime documentation and trying to import a function that does not exist. Instead of looking for errors with Perl, maybe consider actually reading the error message and comparing it to the documentation. But as you seem to have a penchant for ignoring replies or not reading them, I will repeat it again:

      Module::Runtime does not export a function named module_notational_filename. It is only documented to export a function named module_notional_filename.

      As for your other "evidence", again, you don't show any code, you still do not seem to have a grasp as to how to debug things. I am not joking about the maximum of 10 lines for a program to demonstrate your extraordinary findings. Please put in the effort to reduce your programs, and consider splitting up the large program of over 800 lines into more manageable modules in separate files. This will not only help you in finding the errors, it will also limit the damage you can do by editing a single file to exactly that file, and keep lots of red herrings out of your mind. Also, this will likely limit the side effects of ill-advised changes or misunderstood documentation to a short and manageable file instead of showing error message in an 800 lines file.

        You actually replied? For what purpose?

        Penchant for beating dead cows much?

        p.s. the documented spelling for 'the word after 800 in your last paragraph is 'line', no 's', please make a note of it. If it wasn't used as an adjective phrase for the next word, then the 's' would be appropriate. Guess we all can make spelling mistakes -- though as I stated earlier and you ignored, the word in the dictionary is spelled notational. The fact that the author misspelled it is a "UI" bug (i.e. the user-interface to the function causes confusion due to word misspelling or non-standard word usage).

      Like tobyink answered That's because it's called module_notional_filename

      You typed module_notational_filename but didn't copy/paste module_notional_filename

      $ perl -MModule::Runtime=module_notational_filename -e 1 "module_notational_filename" is not exported by the Module::Runtime mo +dule Can't continue after import errors at -e line 0. BEGIN failed--compilation aborted. $ perl -MModule::Runtime=module_notional_filename -e 1
        Oi vey... It's spelled notation, not notion (synonym for naming or naming convention)... guess spelling errors aren't exactly program bugs... but regardless, definitely not caused by anything in 5.6.14. Still, In the manpage for module::runtime, it documents naming related changed affecting modules between 5.8->5.10 5.10->5.12 5.12->5.14. If one doesn't catch you...
        Core bugs worked around [Note -- change from 5.10 -> 5.12 ] The first bug worked around is core bug [perl #68590], which ca +uses lexical state in one file to leak into another that is "require"d/"use"d from it. This bug is present from Perl 5.6 u +p to Perl 5.10, and is fixed in Perl 5.11.0. From Perl 5.9.4 up to +Perl 5.10.0 no satisfactory workaround is possible in pure Perl. Th +e workaround means that modules loaded via this module don't suff +er this pollution of their lexical state. Modules loaded in other ways +, or via this module on the Perl versions where the pure Perl workaround + is impossible, remain vulnerable. The module Lexical::SealRequire +Hints provides a complete workaround for this bug. [Note change from 5.8 - > 5.10] The second bug worked around causes some kinds of failure in mo +dule loading, principally compilation errors in the loaded module, t +o be recorded in %INC as if they were successful, so later attempts +to load the same module immediately indicate success. This bug is pres +ent up to Perl 5.8.9, and is fixed in Perl 5.9.0. The workaround mean +s that a compilation error in a module loaded via this module won't be c +ached as a success. Modules loaded in other ways remain liable to produ +ce bogus %INC entries, and if a bogus entry exists then it will mislead +this module if it is used to re-attempt loading. [Note change from 5.12->5.14] The third bug worked around causes the wrong context to be seen + at file scope of a loaded module, if "require" is invoked in a location + that inherits context from a higher scope. This bug is present up t +o Perl 5.11.2, and is fixed in Perl 5.11.3. The workaround means that + a module loaded via this module will always see the correct conte +xt. Modules loaded in other ways remain vulnerable.
        I don't see it being a far stretch to think 5.14 isn't perfect after all that -- or, especially, that those changes broke programs that may have *unknowingly* been affected by them.

        In fact, From the above, it looks like major changes are in for 5.18 as well.

        FWIW, After fixing the spelling error in my program, I now get the errors I got in response ^5:

        > cnvWav2Flac Global symbol "$Filename2Fields" requires explicit package name at ./c +nvWav2Flac line 119. Global symbol "$Filename2Fields" requires explicit package name at ./c +nvWav2Flac line 127. Global symbol "$Filename2Fields" requires explicit package name at ./c +nvWav2Flac line 133. Global symbol "$Filename2Fields" requires explicit package name at ./c +nvWav2Flac line 137. Global symbol "$Filename2Fields" requires explicit package name at ./c +nvWav2Flac line 141. Global symbol "$Filename2Fields" requires explicit package name at ./c +nvWav2Flac line 145. Use of uninitialized value at ./cnvWav2Flac line 153.
        At this point, it looks like exporting vars just doesn't work right, as it isn't saying it's not defined --- and it should be imported, as I use Debug, and it is has the ISA line for Exporter, and the EXPORTS line for Filename2Fields -- with 'use', there is no need for a Begin block -- so it should be working...

        At this point I need to go look at the code some more, I still see no reason why Exporter isn't exporting the varname?...

        Thanks for a *helpful* post... a 2nd set of eyes is 75% of the reason I come here, having written in perl for over a's not like I hven't heard arguments about why one should do XYZY, but it's not how I want to design, and the language claims to allow otherwise, so I'm on the limits.../edge (in more ways than one)...


Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://959931]
Corion quivers with antici...
[choroba]: if you turn off autocommit and run a prepared statement which fails, the transaction is automatically rolled back, at least in DBD::Pg
[erix]: at least, I'll know where to find the documentation :P
[choroba]: but if there's no prepared statement, there's no rollback
[choroba]: the rollback happens when deallocating the prepared statement in error state.
[choroba]: is this something that Pg enforces, or just a consequence of the Perl implementation?
[choroba]: also, does it make any sense? We run different statements generated from input structures, sometimes prepared statements are involved, sometimes not. We want the behaviour to be consistent.
[erix]: I'm not sure. I suppose you could compare behavior via DBD::Pg with behaviour of the naked SQL

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (9)
As of 2017-09-19 13:00 GMT
Find Nodes?
    Voting Booth?
    During the recent solar eclipse, I:

    Results (220 votes). Check out past polls.