[ create a new paste ] login | about

Link: http://codepad.org/HTQe15Vs    [ raw code | output | fork ]

Perl, pasted on Mar 8:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#!perl
use strict;
use warnings;
my $str = <<EOT;
first
second
third
EOT

for my $re ( qr/^(.*?)$/, qr/^(.*?)$/m, qr/^(.*?)$/s, qr/^(.*?)$/ms ) {
    my $s = $str;
    print "\$re = $re\n";
    $s =~ s{$re}{print "<$1>"}eg;
    print "\n";
}


Output:
1
2
3
4
5
6
7
8
9
10
$re = (?-xism:^(.*?)$)

$re = (?m-xis:^(.*?)$)
<first><second><third>
$re = (?s-xim:^(.*?)$)
<first
second
third>
$re = (?ms-xi:^(.*?)$)
<first><second><third>


Create a new paste based on this one


Comments: