|
From: Abigail on 14 Feb 2007 16:55 use 5.9.5; # In fact, you need the newest blead. my $email_address = qr { (?(DEFINE) (?<addr_spec> (?&local_part) \@ (?&domain)) (?<local_part> (?&dot_atom) | (?"ed_string)) (?<domain> (?&dot_atom) | (?&domain_literal)) (?<domain_literal> (?&CFWS)? \[ (?: (?&FWS)? (?&dcontent))* (?&FWS)? \] (?&CFWS)?) (?<dcontent> (?&dtext) | (?"ed_pair)) (?<dtext> (?&NO_WS_CTL) | [\x21-\x5a\x5e-\x7e]) (?<atext> (?&ALPHA) | (?&DIGIT) | [!#\$%&'*+-/=?^_`{|}~]) (?<atom> (?&CFWS)? (?&atext)+ (?&CFWS)?) (?<dot_atom> (?&CFWS)? (?&dot_atom_text) (?&CFWS)?) (?<dot_atom_text> (?&atext)+ (?: \. (?&atext)+)*) (?<text> [\x01-\x09\x0b\x0c\x0e-\x7f]) (?<quoted_pair> \\ (?&text)) (?<qtext> (?&NO_WS_CTL) | [\x21\x23-\x5b\x5d-\x7e]) (?<qcontent> (?&qtext) | (?"ed_pair)) (?<quoted_string> (?&CFWS)? (?&DQUOTE) (?:(?&FWS)? (?&qcontent))* (?&FWS)? (?&DQUOTE) (?&CFWS)?) (?<word> (?&atom) | (?"ed_string)) (?<phrase> (?&word)+) # Folding white space (?<FWS> (?: (?&WSP)* (?&CRLF))? (?&WSP)+) (?<ctext> (?&NO_WS_CTL) | [\x21-\x27\x2a-\x5b\x5d-\x7e]) (?<ccontent> (?&ctext) | (?"ed_pair) | (?&comment)) (?<comment> \( (?: (?&FWS)? (?&ccontent))* (?&FWS)? \) ) (?<CFWS> (?: (?&FWS)? (?&comment))* (?: (?:(?&FWS)? (?&comment)) | (?&FWS))) # No whitespace control (?<NO_WS_CTL> [\x01-\x08\x0b\x0c\x0e-\x1f\x7f]) (?<ALPHA> [A-Za-z]) (?<DIGIT> [0-9]) (?<CRLF> \x0d \x0a) (?<DQUOTE> ") (?<WSP> [\x20\x09]) ) (?&addr_spec) }x; Abigail -- perl -wlpe '}{$_=$.}{' file # Count the number of lines.
From: john.swilting on 14 Feb 2007 22:56 Abigail wrote: > > use 5.9.5; # In fact, you need the newest blead. > > > my $email_address = qr { > (?(DEFINE) > (?<addr_spec> (?&local_part) \@ (?&domain)) > (?<local_part> (?&dot_atom) | (?"ed_string)) > (?<domain> (?&dot_atom) | (?&domain_literal)) > (?<domain_literal> (?&CFWS)? \[ (?: (?&FWS)? (?&dcontent))* > (?&FWS)? > \] (?&CFWS)?) > (?<dcontent> (?&dtext) | (?"ed_pair)) > (?<dtext> (?&NO_WS_CTL) | [\x21-\x5a\x5e-\x7e]) > > (?<atext> (?&ALPHA) | (?&DIGIT) | [!#\$%&'*+-/=?^_`{|}~]) > (?<atom> (?&CFWS)? (?&atext)+ (?&CFWS)?) > (?<dot_atom> (?&CFWS)? (?&dot_atom_text) (?&CFWS)?) > (?<dot_atom_text> (?&atext)+ (?: \. (?&atext)+)*) > > (?<text> [\x01-\x09\x0b\x0c\x0e-\x7f]) > (?<quoted_pair> \\ (?&text)) > > (?<qtext> (?&NO_WS_CTL) | [\x21\x23-\x5b\x5d-\x7e]) > (?<qcontent> (?&qtext) | (?"ed_pair)) > (?<quoted_string> (?&CFWS)? (?&DQUOTE) (?:(?&FWS)? (?&qcontent))* > (?&FWS)? (?&DQUOTE) (?&CFWS)?) > > (?<word> (?&atom) | (?"ed_string)) > (?<phrase> (?&word)+) > > # Folding white space > (?<FWS> (?: (?&WSP)* (?&CRLF))? (?&WSP)+) > (?<ctext> (?&NO_WS_CTL) | [\x21-\x27\x2a-\x5b\x5d-\x7e]) > (?<ccontent> (?&ctext) | (?"ed_pair) | (?&comment)) > (?<comment> \( (?: (?&FWS)? (?&ccontent))* (?&FWS)? \) ) > (?<CFWS> (?: (?&FWS)? (?&comment))* > (?: (?:(?&FWS)? (?&comment)) | (?&FWS))) > > # No whitespace control > (?<NO_WS_CTL> [\x01-\x08\x0b\x0c\x0e-\x1f\x7f]) > > (?<ALPHA> [A-Za-z]) > (?<DIGIT> [0-9]) > (?<CRLF> \x0d \x0a) > (?<DQUOTE> ") > (?<WSP> [\x20\x09]) > ) > > (?&addr_spec) > }x; > > > > > Abigail it is incredible
From: cmic on 15 Feb 2007 17:42 Hello On 14 fév, 22:55, Abigail <abig...(a)abigail.be> wrote: > use 5.9.5; # In fact, you need the newest blead. > ....skipped > -- > perl -wlpe '}{$_=$.}{' file # Count the number of lines. ^^^^^^^^^^^^^ As a Perl beginner, i'm a bit surprised to see this working. Could you explain why (and how) these "counter-intuitive" } and { works ? And how come you found out this trick ? Very very curious about this. TIA -- Michel Marcon, SysAdmin & Perl learner
From: Darren Dunham on 15 Feb 2007 19:15 cmic <cmic(a)caramail.com> wrote: > On 14 f�v, 22:55, Abigail <abig...(a)abigail.be> wrote: >> use 5.9.5; # In fact, you need the newest blead. >> > ...skipped >> -- >> perl -wlpe '}{$_=$.}{' file # Count the number of lines. > ^^^^^^^^^^^^^ > As a Perl beginner, i'm a bit surprised to see this working. Could you > explain why (and how) these "counter-intuitive" } and { works ? And > how come you found out this trick ? Very very curious about this. Take a look at the 'perlrun' perldoc for an explanation of the -p flag. You'll note that code you supply is already within a set of brackets. Does that make sense? -- Darren Dunham ddunham(a)taos.com Senior Technical Consultant TAOS http://www.taos.com/ Got some Dr Pepper? San Francisco, CA bay area < This line left intentionally blank to confuse you. >
From: Abigail on 16 Feb 2007 03:23 cmic (cmic(a)caramail.com) wrote on MMMMCMXVI September MCMXCIII in <URL:news:1171579379.110397.135680(a)v33g2000cwv.googlegroups.com>: :: Hello :: :: On 14 f�v, 22:55, Abigail <abig...(a)abigail.be> wrote: :: > use 5.9.5; # In fact, you need the newest blead. :: > :: ...skipped :: > -- :: > perl -wlpe '}{$_=$.}{' file # Count the number of lines. :: ^^^^^^^^^^^^^ :: :: As a Perl beginner, i'm a bit surprised to see this working. Could you :: explain why (and how) these "counter-intuitive" } and { works ? And See perlrun, or do a google search for it. It has been explained many times. :: how come you found out this trick ? Very very curious about this. A remark Chip Salzenberg once (in the previous century) made in The Perl Journal. Abigail -- perl -wle'print"���������������������"^"\x80"x24'
|
Next
|
Last
Pages: 1 2 3 4 Prev: waitpid woes on Solaris, Perl 5.8.8 Next: pattern serach over many files |