Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

path::dispatcher::rule(3pm) [debian man page]

Path::Dispatcher::Rule(3pm)				User Contributed Perl Documentation			       Path::Dispatcher::Rule(3pm)

NAME
Path::Dispatcher::Rule - predicate and codeblock SYNOPSIS
my $rule = Path::Dispatcher::Rule::Regex->new( regex => qr/^quit/, block => sub { die "Program terminated by user. " }, ); $rule->match("die"); # undef, because "die" !~ /^quit/ my $match = $rule->match("quit"); # creates a Path::Dispatcher::Match $match->run; # exits the program DESCRIPTION
A rule has a predicate and an optional codeblock. Rules can be matched (which checks the predicate against the path) and they can be ran (which invokes the codeblock). This class is not meant to be instantiated directly, because there is no predicate matching function. Instead use one of the subclasses such as Path::Dispatcher::Rule::Tokens. ATTRIBUTES
block An optional block of code to be run. Please use the "run" method instead of invoking this attribute directly. prefix A boolean indicating whether this rule can match a prefix of a path. If false, then the predicate must match the entire path. One use-case is that you may want a catch-all rule that matches anything beginning with the token "ticket". The unmatched, latter part of the path will be available in the match object. METHODS
match path -> match Takes a path and returns a Path::Dispatcher::Match object if it matched the predicate, otherwise "undef". The match object contains information about the match, such as the results (e.g. for regex, a list of the captured variables), the "leftover" path if "prefix" matching was used, etc. run Runs the rule's codeblock. If none is present, it throws an exception. perl v5.12.4 2011-08-30 Path::Dispatcher::Rule(3pm)

Check Out this Related Man Page

Path::Dispatcher::Rule::Under(3pm)			User Contributed Perl Documentation			Path::Dispatcher::Rule::Under(3pm)

NAME
Path::Dispatcher::Rule::Under - rules under a predicate SYNOPSIS
my $ticket = Path::Dispatcher::Rule::Tokens->new( tokens => [ 'ticket' ], prefix => 1, ); my $create = Path::Dispatcher::Rule::Tokens->new( tokens => [ 'create' ], block => sub { create_ticket() }, ); my $delete = Path::Dispatcher::Rule::Tokens->new( tokens => [ 'delete', qr/^d+$/ ], block => sub { delete_ticket(shift->pos(2)) }, ); my $rule = Path::Dispatcher::Rule::Under->new( predicate => $ticket, rules => [ $create, $delete ], ); $rule->match("ticket create"); $rule->match("ticket delete 3"); DESCRIPTION
Rules of this class have two-phase matching: if the predicate is matched, then the contained rules are matched. The benefit of this is less repetition of the predicate, both in terms of code and in matching it. ATTRIBUTES
predicate A rule (which must match prefixes) whose match determines whether the contained rules are considered. The leftover path of the predicate is used as the path for the contained rules. rules A list of rules that will be try to be matched only if the predicate is matched. perl v5.12.4 2011-08-30 Path::Dispatcher::Rule::Under(3pm)
Man Page

15 More Discussions You Might Find Interesting

1. Post Here to Contact Site Administrators and Moderators

Kelam_Magnus

Why did you close all my threads? I undstand that since you may be an advanced unix user, that my questions seem dumb. Hey, they probably are. But the title of the forum is " UNIX for Dummies Questions & Answers" and it says "All UNIX Newbies Welcome !!" So what is the prob? I dont think... (7 Replies)
Discussion started by: LANSTARR.COM
7 Replies

2. UNIX for Dummies Questions & Answers

Regex?? Please help

Ok, this has got to be simple, but I can't wrap my head around it. I'm trying to divid up different parts of a line being inputted. The reason is so I don't have to worry about what order the information is place, I can sort it before it's added to my file. the line would look something like... (7 Replies)
Discussion started by: lunac
7 Replies

3. UNIX for Dummies Questions & Answers

Path Environment

How do we change path environment? (2 Replies)
Discussion started by: mehmetned
2 Replies

4. UNIX for Dummies Questions & Answers

Broken the cardinal rule

Hello guys, I have broken the cardinal rule - not creating normal user and working as Root - and as such deleted the /var/adm/messages directory. Is there any way possible to recover this. Kind regards, Dudley. (4 Replies)
Discussion started by: BigTool4u2
4 Replies

5. Shell Programming and Scripting

NAWK - looping with match() function

i'm trying to use the "before" output from the match() function as part of the results of each Regex match... but... My input data: (from an input file) i only show the first record in my file.. all other records are similar. mds_ar/bin/uedw92wp.ksh:cat $AI_SQL/wkly_inqry.sql... (2 Replies)
Discussion started by: danmauer
2 Replies

6. UNIX for Dummies Questions & Answers

regex - display all occurrences of match

i don't want to display the whole line but i want to display all the string(s) that match the Regex, even if their are more then one match per line in my file. data: mds_ar/bin/uedw92wp.ksh:cat $AI_SQL/wkly_inqry.sql $AI_SQL/wkly_inqry_trtry.sql $AI_SQL/wkly_nb_trtry.sql \... (18 Replies)
Discussion started by: danmauer
18 Replies

7. IP Networking

Gigabit Link throughput

As a rule of thumb in doing calculations, what figure would you use in Mbytes/sec? I know the answer varies grealty on the topolgy of the network but I wonde what newteok engineers use a rough rule of thumb? Many thanks. (1 Reply)
Discussion started by: debd
1 Replies

8. UNIX for Dummies Questions & Answers

Path Name

Is there a way I can display the directory and its size, without displaying the entire path my command is du -h | sort -nr | head -10 for example my output is 504K ./vpworkspace/.vpprefdata/LayoutPerspectiveData I want it to be 504K .vpworkspace (3 Replies)
Discussion started by: desai.rishabh
3 Replies

9. UNIX for Advanced & Expert Users

Regex to match IP address

What do you think of this regex to match IP address? I have been reading up on regex and have seen some really long ones for IP. Would this fail in any scenarios? (+\.){3}* (5 Replies)
Discussion started by: glev2005
5 Replies

10. Shell Programming and Scripting

Help regarding a Perl Program

I want to traverse a durectory for a particular file. Situataion is like this. Path is ABC/a/c/g. it has around 100 folders in it. Search a directory which has word "*latest*" in its path. and then from the latest go through z/x/c to file final.html. In total, i want it to go through... (4 Replies)
Discussion started by: hemasid
4 Replies

11. What is on Your Mind?

Career Path

First I like to say hi to all the people in this community. The reason I am here is because I am lost and looking for advice on my career path. Here is a short history. I worked in the IT industry for about 10 yrs, sys admin, QA, and developer. During 911 I lost my job. Since then I have... (4 Replies)
Discussion started by: navy
4 Replies

12. Shell Programming and Scripting

Regex based Rule engine.

Hi, Greetings. We need to make a regexp based rule engine. The rules would be applied to any file specified and the data not matching should be logged. Would awk be the right scripting language. Regards, Dikesh Shah. (2 Replies)
Discussion started by: dikesm
2 Replies

13. Shell Programming and Scripting

How to make working this regex in perl?

Hello to all, The Regex below is supposed to match all strings except RR45. I've tested in regex101.com and it works, butwhen I try to use it with the perl command below I get the error shown. Regex=(?<=^|RR45)(?!RR45).+?(?=RR45|$) How to fix this? I'm using Cygwin. $ echo... (9 Replies)
Discussion started by: Ophiuchus
9 Replies

14. Shell Programming and Scripting

Match and subtract two fields

Not sure quite how to do this, but I am trying to use $1 of LCH.txt (exact match) to look for a match in $1 of genes.txt. If a match is found then in a new file match.txt $1 $2 ($4-$3) are copied. Example, the first record in LCH is PPT1 and that matches row 713, column 1 of genes.txt. ... (2 Replies)
Discussion started by: cmccabe
2 Replies

15. UNIX for Dummies Questions & Answers

Regex for CAR- and CAR_

I am trying to find a Regex match for a string: CAR- and CAR_ So I need to match only the letters CAR or a / or a -. So if the word CAR ends in - I need to match it or if it ends in _ I need to match it. Anyone know this regex? (1 Reply)
Discussion started by: newbie2010
1 Replies