in reply to Re^2: XML::Twig Support for Parameter Entities (installed?)
in thread XML::Twig Support for Parameter Entities

I did look at Corelist and got the impression that none of these are "core" modules. But I didn't look at what non-"core" modules Strawberry includes by default.

Looking at the code for _use():

sub _use ## no critic (Subroutines::ProhibitNestedSubs); { my( $module, $version)= @_; ... if( eval "require $module") { ...

Perhaps they have something loaded that is changing the return value from 'require'? It is pretty darn rare for people to care about the return value from a 'require', which is why I'd write such code as:

if( eval "require $module; 1" ) { ...

I'd also try "require LWP" and see what Perl says in response. It would be good to change Twig so that $@ from one of the _use() calls would be appended to the "cannot expand %dtd; - cannot load 'http://127.0.0.1:5000/parameterEntity_core.dtd'" error messages. [ People often seem to underrate the value of error messages. :) ]

- tye        

Replies are listed 'Best First'.
Re^4: XML::Twig Support for Parameter Entities (require)
by shmem (Chancellor) on Aug 13, 2015 at 07:03 UTC
    It is pretty darn rare for people to care about the return value from a 'require'

    I used that quite often, as in

    use Data::Dumper; sub DEVEL() { 1 }; # get sample data my hashref = DEVEL ? require 'sampledata.pl' : do_something_costly(); # later on if ( DEVEL ) { open my $fh, 'sampledata.pl' or die "sampledata.pl: $!"; print Dumper($hashref); }

    Also, I use function files for autoloading (function.al) which return an anonymous sub and encapsulate private data in their lexical file scope (see also AutoReloader).

    perl -le'print map{pack c,($-++?1:13)+ord}split//,ESEL'

      Maybe you should stop, then. There is good reason for most people not paying attention to the return value from 'require'.

      For your use case, 'do' would be more appropriate than 'require'.

      $ echo 13 > lucky.pl $ perl -l print do 'lucky.pl'; print require 'lucky.pl'; print do 'lucky.pl'; __END__ 13 1 13 $

      Which actually makes me a little sad. Being able to reasonably use the return value from 'require' would have some nice benefits.

      - tye        

        Yes, of course :-) do updates %INC, and a subsequent require will just return 1, telling that the file has already been loaded. This is actually a feature, it is a conditional do.

        $ echo 13 > lucky.pl $ perl -l print do 'lucky.pl'; if (1 == require 'lucky.pl') { print "already loaded."; delete $INC{"lucky.pl"}; } print require 'lucky.pl'; print do 'lucky.pl'; __END__ 13 already loaded. 13 13

        update: updated code with conditional block

        perl -le'print map{pack c,($-++?1:13)+ord}split//,ESEL'
Re^4: XML::Twig Support for Parameter Entities (errors)
by dtdattacks (Initiate) on Aug 13, 2015 at 07:49 UTC
    Hi, I use LWP in my unit tests.
    Example code:
    require LWP::UserAgent; [other stuff] #reset the counter $ua = LWP::UserAgent->new; $request = $ua->get($URL.'/reset'); [other stuff]
    However I also included "require LWP;" in my sample code.
    I get no error messages/warnings; The code still works fine. Chris