Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: Using function modules and passing arguments by parsing an XML.

by tangent (Priest)
on Apr 11, 2012 at 11:46 UTC ( #964520=note: print w/replies, xml ) Need Help??


in reply to Using function modules and passing arguments by parsing an XML.

I'm not quite sure of your requirement but this may help:
sub startElement { my( $parseinst, $element, %attrs ) = @_; SWITCH: { # ... if ($element eq "step") { my $command = $attrs{command}; $command =~ s/\s+//g; # get rid of spaces if ($command eq 'LaunchApp') { MyModule::LaunchApp(%attrs); } elsif ($command eq 'Changemode') { MyModule::Changemode(%attrs); } # and so on for each command last SWITCH; } } } # This is your functions module package MyModule; sub LaunchApp { my %attrs = @_; print "\n----\nIn Sub MyModule::LaunchApp\n"; for my $attr (keys %attrs) { print "$attr: $attrs{$attr}\n"; } print "Leaving Sub MyModule::LaunchApp\n----\n"; } sub Changemode { my %attrs = @_; print "\n----\nIn Sub MyModule::Changemode\n"; for my $attr (keys %attrs) { print "$attr: $attrs{$attr}\n"; } print "Leaving Sub MyModule::Changemode\n----\n"; } 1;
  • Comment on Re: Using function modules and passing arguments by parsing an XML.
  • Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://964520]
help
Chatterbox?
[Corion]: But yes, in general, my approach will be "split the URL into another set of parameters, generate an array of allowed values for each parameter and then NestedLoops() over the set"
[choroba]: hmm... so you need something like bag from Test::Deep, but not for checking, but for generation
[Corion]: This has the dual use of easily requesting sequential URLs and also being suitable for testing
[Corion]: For testing, I want to skip all tests with the same value(s) once one test fails to cut down on the number of failing tests
[Corion]: choroba: Yes, in a way I
[Corion]: ... I'm treating the incoming value sets as bags... Maybe I'll just put the burden on the user, at least in the first attempt at a full API. generate( headers => [{ 'Content-Type' => 'text/plain' }, {'Content-Type' => 'text/json' ] ), even ...
[Corion]: ... if that is cumbersome for the caller to specify. On the other hand, maybe there isn't that big a need for permuting the header values

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (4)
As of 2017-01-17 08:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you watch meteor showers?




    Results (152 votes). Check out past polls.