Re[8]: Популяризация

Dmitrii q7u5 at ukr.net
Sun Aug 8 14:00:07 PDT 2010


        MVC Catalyst  вариант Catalyst::DispatchType::Chained    этого я не видел, в других некоторый фреймфорках, например,  Symfony php - это выглядит очень тупиково....    sub blog : Chained PathPart('blog') CaptureArgs(0) { }    
  sub user : Chained('blog') PathPart('user') CaptureArgs(1) {    
  my ( $self, $c, $id_un ) = @_;    
  $c->stash->{ message } = "Hello 2";    
  $c->stash->{ arg_sum }->[0] = $id_un;    
  }    
  sub view : Chained('user') PathPart('view') CaptureArgs(1) {    
  my ( $self, $c, $id ) = @_;    
  $c->stash->{ message } .= "World!";    
  $c->stash->{ arg_sum }->[1] = $id;    
  }    
  sub view_page_off : Chained('view') PathPart('') Args(1) {    
  my ( $self, $c, $page ) = @_;    
       
  $c->stash->{ arg_sum }->[2] = $page;    
       
  $c->forward( 'view_blog_message', $c->stash->{ arg_sum } );    
       
  }    
      
      
  sub view_off : Chained('view') PathPart('') Args(0) {    
  my ( $self, $c ) = @_;    
  $c->forward( 'view_blog_message', [ $c->stash->{ arg_sum } );    
       
  }    
  sub view_page_user : Chained('user') PathPart('') Args(1) {    
  my ( $self, $c, $page ) = @_;    
  $c->stash->{ arg_sum }->[1] = $page;    
       
# print '666';    
  $c->forward( 'view_blog',  $c->stash->{ arg_sum } );    
       
  }    
      
  sub view_user : Chained('user') PathPart('') Args(0) {    
  my ( $self, $c ) = @_;    
  $c->forward( 'view_blog', $c->stash->{ arg_sum } );    
       
       
  }    
      
    
    ===============================    | Path Spec | Private |    
+-------------------------------------+--------------------------------------+    
| /blog/user/*/view/* | /blog/blog (0) |    
| | -> /blog/user (1) |    
| | -> /blog/view (1) |    
| | => /blog/view_off |    
| /blog/user/*/view/*/* | /blog/blog (0) |    
| | -> /blog/user (1) |    
| | -> /blog/view (1) |    
| | => /blog/view_page_off |    
| /blog/user/*/* | /blog/blog (0) |    
| | -> /blog/user (1) |    
| | => /blog/view_page_user |    
| /blog/user/* | /blog/blog (0) |    
| | -> /blog/user (1) |    
| | => /blog/view_user |    
'-------------------------------------+--------------------------------------'    
    
    
        
--- Исходное сообщение ---    
От кого: Евгений Карпенко <notformat at gmail.com>    
Кому: kiev-perl-users-group at googlegroups.com    
Дата: 8 августа, 23:08:33    
Тема: Re: Re: Re: Re[4]: Популяризация    
    
    >    
> Более интересный пример: IP-адреса, Perl5    
> файл IPType.pm    
>    
> package IPType;    
> use Regexp::Common 2.105;    
> use MooseX::Types::Moose qw( Str );    
> use MooseX::Types -declare => [ qw(IP) ];    
>    
> subtype IP, as Str, where {    
> $_ =~ /\A $RE{net}{IPv4} \z/msx    
> }, message {    
> "'$_' is not a valid IP";    
> };    
>    
> файл typed.pl    
>    
> use IPType qw/IP/;    
> use MooseX::Lexical::Types qw/IP/;    
>    
> my IP $foo; # declare typed variable    
> $foo = '192.168.1.1'; # works    
> $foo = 'bar'; # fails    
    
import java.util.regex.*;    
    
public class TestRegexp {    
public static final Pattern pattern = Pattern.compile    
("[a-zA-Z]{1}[a-zA-Z\d\u002E\u005F]+@([a-zA-Z]+\u002E){1,2}((net)|(com)|(org))");    
    
public static void doMatch(String word) {    
String output = "Validation for " + word;    
Matcher matcher = pattern.matcher(word);    
if (matcher.matches())    
output += " passed."    
else    
output += " not passed."    
System.out.println(output);    
}    
    
public static void main(String[] args) {    
doMatch("c0nst at money.simply.net");    
doMatch("somebody at dev.com.ua");    
doMatch("Name.Sur_name at gmail.com");    
doMatch("useR33 at somewhere.in.the.net");    
}    
    
}    
Не в тему АЙПИ а в тему регулярных выражений.    
    
  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.pm.org/pipermail/kiev-pm/attachments/20100809/9d16aac0/attachment.html>


More information about the Kiev-pm mailing list