05-22-2016
Hello Corona688(One of the Gems of this forum),
First of all a big THANK YOU for writing this brilliant code
(fan of you always). Could you please post a example or complex example for a Input_file and code too here, I apologies to bother you on same but it will be helpful for us to understand the code more clearly. I will be grateful to you if you could do so.
Thanks,
R. Singh
This User Gave Thanks to RavinderSingh13 For This Post:
7 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
Does anyone have any scripts or suggestions on a general purpose Unix/Linux monitoring tool? (5 Replies)
Discussion started by: darthur
5 Replies
2. Shell Programming and Scripting
I am trying to divide a xml file(my.xml) like this:
<?xml version="1.0" encoding="UTF-8"?>
<Proto PName="hmmmmmmm">
<Menu id="A" ver="1">
<P>
<P name="AA" Type="X"/>
<P name="BB" Type="Y"/>
<P name="CC" Type="Z"/>
</P>
... (4 Replies)
Discussion started by: demoprog
4 Replies
3. Shell Programming and Scripting
Hi,
i am really fresh with shell scripting and programming,
i have an issue i am not able to solve to populate data on my server for Cisco IP phones.
I have CSV file within the following format:
;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;... (9 Replies)
Discussion started by: angel2008
9 Replies
4. Programming
Hi everyone,
I have Xml files in a folder, I need to extract some attribute values form xml files and store in a hash. My xml file look like this.
<?xml version="1.0" encoding="UTF-8"?>
<Servicelist xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"... (0 Replies)
Discussion started by: pavani reddy
0 Replies
5. Shell Programming and Scripting
I need to get all session_ID 's for product="D-0002" from a XML file:
Sample input:
<session session_ID="6411206" create_date="2012-04-10-10.22.13.000000">
<marketing_info>
<program_id>D4AWFU</program_id>
<subchannel_id>abc</subchannel_id>
</marketing_info>
... (1 Reply)
Discussion started by: karumudi7
1 Replies
6. Shell Programming and Scripting
With the following input sample extracted from a xml file
<rel ver="123">
<mod name="on">
<node env="ac" env="1">
<ins ip="10.192.0.1"/>
<ins ip="10.192.0.2"/>
... (1 Reply)
Discussion started by: cabrao
1 Replies
7. UNIX for Beginners Questions & Answers
There must be thousands of one-off solutions scattered around this forum. GNU Date is so handy because it's general but if they're asking they probably don't have it. We have some nice scripts but they tend to need dates formatted in a very particular way.
This is a rough approximation which... (18 Replies)
Discussion started by: Corona688
18 Replies
LEARN ABOUT DEBIAN
router::simple::cookbook
Router::Simple::Cookbook(3pm) User Contributed Perl Documentation Router::Simple::Cookbook(3pm)
NAME
Router::Simple::Cookbook - The Router::Simple Cookbook
FAQ
How to create Sinatra-ish framework with Router::Simple?
Please read the following example code.
package MySinatraish;
use Router::Simple;
use Plack::Request;
sub import {
my $pkg = caller(0);
my $router = Router::Simple->new();
my $any = sub ($$;$) {
my ($pattern, $dest, $opt) = do {
if (@_ == 3) {
my ($methods, $pattern, $code) = @_;
($pattern, {code => $code}, +{method => [ map { uc $_ } @$methods ]});
} else {
my ($pattern, $code) = @_;
($pattern, {code => $code}, +{});
}
};
$router->connect(
$pattern,
$dest,
$opt,
);
};
no strict 'refs';
# any [qw/get post delete/] => '/bye' => sub { ... };
# any '/bye' => sub { ... };
*{"${pkg}::any"} = $any;
*{"${pkg}::get"} = sub {
$any->([qw/GET HEAD/], $_[0], $_[1]);
};
*{"${pkg}::post"} = sub {
$any->([qw/POST/], $_[0], $_[1]);
};
*{"${pkg}::as_psgi_app"} = sub {
return sub {
if (my $p = $router->match($_[0])) {
[200, [], [$p->{code}->()]];
} else {
[404, [], ['not found']];
}
}
};
}
package MyApp;
use MySinatraish;
get '/' => sub {
'top';
};
post '/new' => sub {
'posted';
};
as_psgi_app;
How to switch from HTTPx::Dispatcher?
HTTPx::Dispatcher is class specific declararative router.
package MyApp::Dispatcher;
use HTTPx::Dspatcher;
connect '/', {controller => 'foo', action => 'bar'};
1;
The following script is same as above.
package MyApp::Dispatcher;
use Router::Simple::Declare;
my $router = router {
connect '/', {controller => 'foo', action => 'bar'};
};
sub match { $router->match() }
How to use Router::Simple with non-strictly-MVC application?
use Router::Simple::Declare;
my $router = router {
connect '/foo/bar/' => { 'target' => '/foobar.asp' };
connect '/topics/:topic' => { target => '/my-topic.asp' };
connect '/products/{Category:.*}' => { target => '/products.asp', Category => 'All' };
connect '/zipcode/{zip:[0-9]{5,5}}' => {target => '/zipcode.asp' };
};
You can pass the target path as destination.
AUTHOR
Tokuhiro Matsuno <tokuhirom AAJKLFJEF GMAIL COM>
LICENSE
Copyright (C) Tokuhiro Matsuno
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
SEE ALSO
Router::Simple
perl v5.14.2 2011-05-15 Router::Simple::Cookbook(3pm)