view release on metacpan or search on metacpan
cpan/Config-Perl-V/t/28_plv52201w.t view on Meta::CPAN
cc='gcc', ccflags =' -s -O2 -DWIN32 -DWIN64 -DCONSERVATIVE -DPERL_TEXTMODE_SCRIPTS -DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS -fwrapv -fno-strict-aliasing -mms-bitfields',
optimize='-s -O2',
cppflags='-DWIN32'
ccversion='', gccversion='4.9.2', gccosandvers=''
intsize=4, longsize=4, ptrsize=8, doublesize=8, byteorder=12345678, doublekind=3
d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=8, longdblkind=3
ivtype='long long', ivsize=8, nvtype='double', nvsize=8, Off_t='long long', lseeksize=8
alignbytes=8, prototype=define
Linker and Libraries:
ld='g++', ldflags ='-s -L"D:\Strawberry\perl\lib\CORE" -L"D:\Strawberry\c\lib"'
libpth=D:\Strawberry\c\lib D:\Strawberry\c\x86_64-w64-mingw32\lib D:\Strawberry\c\lib\gcc\x86_64-w64-mingw32\4.9.2
libs=-lmoldname -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32 -lshell32 -lole32 -loleaut32 -lnetapi32 -luuid -lws2_32 -lmpr -lwinmm -lversion -lodbc32 -lodbccp32
-lcomctl32
perllibs=-lmoldname -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32 -lshell32 -lole32 -loleaut32 -lnetapi32 -luuid -lws2_32 -lmpr -lwinmm -lversion -lodbc32 -lodbc
cp32 -lcomctl32
libc=, so=dll, useshrplib=true, libperl=libperl522.a
gnulibc_version=''
Dynamic Linking:
dlsrc=dl_win32.xs, dlext=xs.dll, d_dlsymun=undef, ccdlflags=' '
cccdlflags=' ', lddlflags='-mdll -s -L"D:\Strawberry\perl\lib\CORE" -L"D:\Strawberry\c\lib"'
cpan/ExtUtils-MakeMaker/lib/ExtUtils/Liblist.pm view on Meta::CPAN
When using GCC, that entry specifies that MakeMaker should first look
for C<libgl.a> (followed by C<gl.a>) in all the locations specified by
C<$Config{libpth}>.
When using a compiler other than GCC, the above entry will search for
C<gl.lib> (followed by C<libgl.lib>).
If the library happens to be in a location not in C<$Config{libpth}>,
you need:
LIBS => ['-Lc:\gllibs -lgl']
Here is a less often used example:
LIBS => ['-lgl', ':nosearch -Ld:\mesalibs -lmesa -luser32']
This specifies a search for library C<gl> as before. If that search
fails to find the library, it looks at the next item in the list. The
C<:nosearch> flag will prevent searching for the libraries that follow,
so it simply returns the value as C<-Ld:\mesalibs -lmesa -luser32>,
since GCC can use that value as is with its linker.
cpan/Pod-Simple/lib/Pod/Simple/RTF.pm view on Meta::CPAN
sub doc_init {
return <<'END';
{\rtf1\ansi\deff0
END
}
sub color_table {
return <<'END';
{\colortbl;\red255\green0\blue0;\red0\green0\blue255;}
END
}
sub doc_info {
my $self = $_[0];
my $class = ref($self) || $self;
my $tag = __PACKAGE__ . ' ' . $VERSION;
cpan/Pod-Simple/t/rtf_utf8.t view on Meta::CPAN
{\*\cs26 \additive \f1\lang1024\noproof\sbasedon25 pod-codelbock-ital;}
{\*\cs27 \additive \f1\lang1024\noproof\sbasedon25 pod-codelbock-bold;}
{\*\cs28 \additive \f1\lang1024\noproof\sbasedon25 pod-codelbock-bold-ital;}
{\s31\ql \keepn\sb90\sa180\f2\fs32\ul\sbasedon0 \snext0 pod-head1;}
{\s32\ql \keepn\sb90\sa180\f2\fs28\ul\sbasedon0 \snext0 pod-head2;}
{\s33\ql \keepn\sb90\sa180\f2\fs25\ul\sbasedon0 \snext0 pod-head3;}
{\s34\ql \keepn\sb90\sa180\f2\fs22\ul\sbasedon0 \snext0 pod-head4;}
}
{\colortbl;\red255\green0\blue0;\red0\green0\blue255;}
{VARIANT TEXT DELETED{\company [see doc]}{\operator [see doc]}
}
\deflang1033\plain\lang1033\widowctrl
{\header\pard\qr\plain\f2\fs17
W\uc1\u346?R\'d3D NOCNEJ CISZY \_\_ explicitly utf8 test document in Polish,
p.\chpgn\par}
\fs25
cpan/Test-Simple/t/Test2/behavior/trace_signature.t view on Meta::CPAN
}->();
};
my $sigpass = $events->[0]->trace->signature;
my $sigfail = $events->[1]->trace->signature;
ok($sigpass ne $sigfail, "Each tool got a new signature");
is($events->[$_]->trace->signature, $sigfail, "Diags share failed ok's signature") for 2 .. $#$events;
like($sigpass, qr/$$~${ \get_tid() }~\d+~\d+:$$:\Q${ \get_tid() }:${ \__FILE__ }:$line\E$/, "signature is sane");
my $trace = Test2::EventFacet::Trace->new(frame => ['main', 'foo.t', 42, 'xxx']);
delete $trace->{cid};
is($trace->signature, undef, "No signature without a cid");
is($events->[0]->related($events->[1]), 0, "event 0 is not related to event 1");
is($events->[1]->related($events->[2]), 1, "event 1 is related to event 2");
my $e = Test2::Event::Ok->new(pass => 1);
is($e->related($events->[0]), undef, "Cannot check relation, invalid trace");
cpan/perlfaq/lib/perlfaq4.pod view on Meta::CPAN
This won't expand C<"\n"> or C<"\t"> or any other special escapes.
=head2 How do I remove consecutive pairs of characters?
(contributed by brian d foy)
You can use the substitution operator to find pairs of characters (or
runs of characters) and replace them with a single instance. In this
substitution, we find a character in C<(.)>. The memory parentheses
store the matched character in the back-reference C<\g1> and we use
that to require that the same thing immediately follow it. We replace
that part of the string with the character in C<$1>.
s/(.)\g1/$1/g;
We can also use the transliteration operator, C<tr///>. In this
example, the search list side of our C<tr///> contains nothing, but
the C<c> option complements that so it contains everything. The
replacement list also contains nothing, so the transliteration is
almost a no-op since it won't do any replacements (or more exactly,
replace the character with itself). However, the C<s> option squashes
duplicated and consecutive characters in the string so a character
does not show up next to itself
cpan/perlfaq/lib/perlfaq4.pod view on Meta::CPAN
A nice general-purpose fixer-upper function for indented here documents
follows. It expects to be called with a here document as its argument.
It looks to see whether each line begins with a common substring, and
if so, strips that substring off. Otherwise, it takes the amount of leading
whitespace found on the first line and removes that much off each
subsequent line.
sub fix {
local $_ = shift;
my ($white, $leader); # common whitespace and common leading string
if (/^\s*(?:([^\w\s]+)(\s*).*\n)(?:\s*\g1\g2?.*\n)+$/) {
($white, $leader) = ($2, quotemeta($1));
} else {
($white, $leader) = (/^(\s+)/, '');
}
s/^\s*?$leader(?:$white)?//gm;
return $_;
}
This works with leading special strings, dynamically determined:
cpan/perlfaq/lib/perlfaq6.pod view on Meta::CPAN
line breaks (but not paragraph ones). For this example, we don't need
C</s> because we aren't using dot in a regular expression that we want
to cross line boundaries. Neither do we need C</m> because we don't
want caret or dollar to match at any point inside the record next
to newlines. But it's imperative that $/ be set to something other
than the default, or else we won't actually ever have a multiline
record read in.
$/ = ''; # read in whole paragraph, not just one line
while ( <> ) {
while ( /\b([\w'-]+)(\s+\g1)+\b/gi ) { # word starts alpha
print "Duplicate $1 at paragraph $.\n";
}
}
Here's some code that finds sentences that begin with "From " (which would
be mangled by many mailers):
$/ = ''; # read in whole paragraph, not just one line
while ( <> ) {
while ( /^From /gm ) { # /m makes ^ match next to \n
ext/File-Glob/t/case.t view on Meta::CPAN
@a = csh_glob($pat);
is(scalar @a, 0, 'None should be uppercase');
@a = bsd_glob($pat, GLOB_NOCASE);
cmp_ok(scalar @a, '>=', 3, 'explicit use of the GLOB_NOCASE flag');
# Test Win32 backslash nastiness...
SKIP: {
skip 'Not Win32', 3 unless $^O eq 'MSWin32';
@a = File::Glob::bsd_glob("op\\g*.t");
cmp_ok(scalar @a, '>=', 8);
mkdir "[]", 0;
@a = File::Glob::bsd_glob("\\[\\]", GLOB_QUOTE);
rmdir "[]";
is(scalar @a, 1);
@a = bsd_glob("op\\*", GLOB_QUOTE);
isnt(scalar @a, 0);
}
pod/perl5100delta.pod view on Meta::CPAN
quantifiers. (Yves Orton)
=item Backtracking control verbs
The regex engine now supports a number of special-purpose backtrack
control verbs: (*THEN), (*PRUNE), (*MARK), (*SKIP), (*COMMIT), (*FAIL)
and (*ACCEPT). See L<perlre> for their descriptions. (Yves Orton)
=item Relative backreferences
A new syntax C<\g{N}> or C<\gN> where "N" is a decimal integer allows a
safer form of back-reference notation as well as allowing relative
backreferences. This should make it easier to generate and embed patterns
that contain backreferences. See L<perlre/"Capture buffers">. (Yves Orton)
=item C<\K> escape
The functionality of Jeff Pinyan's module Regexp::Keep has been added to
the core. In regular expressions you can now use the special escape C<\K>
as a way to do something like floating length positive lookbehind. It is
also useful in substitutions like:
pod/perl5340delta.pod view on Meta::CPAN
like C<m/x{,3}/> meaning C<m/x{0,3}/>
=cut
=head2 Blanks freely allowed within but adjacent to curly braces
(in double-quotish contexts and regular expression patterns)
This means you can write things like S<C<\x{ FFFC }>> if you like. This
applies to all such constructs, namely C<\b{}>, C<\g{}>, C<\k{}>,
C<\N{}>, C<\o{}>, and C<\x{}>; as well as the regular expression
quantifier C<{I<m>,I<n>}>. C<\p{}> and C<\P{}> retain their
already-existing, even looser, rules mandated by the Unicode standard
(see L<perluniprops/Properties accessible through \p{} and \P{}>).
This ability is in effect regardless of the presence of the C</x>
regular expression pattern modifier.
Additionally, the comma in a regular expression braced quantifier may
have blanks (tabs or spaces) before and/or after the comma, like
pod/perlcheat.pod view on Meta::CPAN
/o compile pat once () capture
DEBUG (?:p) no capture
-MO=Deparse REGEX CHARCLASSES (?#t) comment
-MO=Terse . [^\n] (?=p) ZW pos ahead
-D## \s whitespace (?!p) ZW neg ahead
-d:Trace \w word chars (?<=p) ZW pos behind \K
\d digits (?<!p) ZW neg behind
CONFIGURATION \pP named property (?>p) no backtrack
perl -V:ivsize \h horiz.wh.space (?|p|p)branch reset
\R linebreak (?<n>p)named capture
\S \W \D \H negate \g{n} ref to named cap
\K keep left part
FUNCTION RETURN LISTS
stat localtime caller SPECIAL VARIABLES
0 dev 0 second 0 package $_ default variable
1 ino 1 minute 1 filename $0 program name
2 mode 2 hour 2 line $/ input separator
3 nlink 3 day 3 subroutine $\ output separator
4 uid 4 month-1 4 hasargs $| autoflush
5 gid 5 year-1900 5 wantarray $! sys/libcall error
6 rdev 6 weekday 6 evaltext $@ eval error
pod/perldiag.pod view on Meta::CPAN
(W misc) You have attempted to weaken a reference that is already weak.
Doing so has no effect.
=item Reference is not weak
(W misc) You have attempted to unweaken a reference that is not weak.
Doing so has no effect.
=item Reference to invalid group 0 in regex; marked by S<<-- HERE> in m/%s/
(F) You used C<\g0> or similar in a regular expression. You may refer
to capturing parentheses only with strictly positive integers
(normal backreferences) or with strictly negative integers (relative
backreferences). Using 0 does not make sense.
=item Reference to nonexistent group in regex; marked by S<<-- HERE> in
m/%s/
(F) You used something like C<\7> in your regular expression, but there are
not at least seven sets of capturing parentheses in the expression. If
you wanted to have the character with ordinal 7 inserted into the regular
pod/perldiag.pod view on Meta::CPAN
expression, but there is no corresponding named capturing parentheses
such as C<(?'NAME'...)> or C<< (?<NAME>...) >>. Check if the name has been
spelled correctly both in the backreference and the declaration.
The S<<-- HERE> shows whereabouts in the regular expression the problem was
discovered.
=item Reference to nonexistent or unclosed group in regex; marked by
S<<-- HERE> in m/%s/
(F) You used something like C<\g{-7}> in your regular expression, but there
are not at least seven sets of closed capturing parentheses in the
expression before where the C<\g{-7}> was located.
The S<<-- HERE> shows whereabouts in the regular expression the problem was
discovered.
=item regexp memory corruption
(P) The regular expression engine got confused by what the regular
expression compiler gave it.
=item Regexp modifier "/%c" may appear a maximum of twice
pod/perldiag.pod view on Meta::CPAN
(F) This message occurs when a here document label has an initial
quotation mark but the final quotation mark is missing. Perhaps
you wrote:
<<"foo
instead of:
<<"foo"
=item Unterminated \g... pattern in regex; marked by S<<-- HERE> in m/%s/
=item Unterminated \g{...} pattern in regex; marked by S<<-- HERE> in m/%s/
(F) In a regular expression, you had a C<\g> that wasn't followed by a
proper group reference. In the case of C<\g{>, the closing brace is
missing; otherwise the C<\g> must be followed by an integer. Fix the
pattern and retry.
=item Unterminated <> operator
(F) The lexer saw a left angle bracket in a place where it was expecting
a term, so it's looking for the corresponding right angle bracket, and
not finding it. Chances are you left some needed parentheses out
earlier in the line, and you really meant a "less than".
=item Unterminated verb pattern argument in regex; marked by S<<-- HERE> in
pod/perlre.pod view on Meta::CPAN
\L lowercase until \E (think vi)
\U uppercase until \E (think vi)
\Q quote (disable) pattern metacharacters until \E
\E end either case modification or quoted section, think vi
Details are in L<perlop/Quote and Quote-like Operators>.
=head3 Character Classes and other Special Escapes
In addition, Perl defines the following:
X<\g> X<\k> X<\K> X<backreference>
Sequence Note Description
[...] [1] Match a character according to the rules of the
bracketed character class defined by the "...".
Example: [a-z] matches "a" or "b" or "c" ... or "z"
[[:...:]] [2] Match a character according to the rules of the POSIX
character class "..." within the outer bracketed
character class. Example: [[:upper:]] matches any
uppercase character.
(?[...]) [8] Extended bracketed character class
pod/perlre.pod view on Meta::CPAN
\W [3] Match a non-"word" character
\s [3] Match a whitespace character
\S [3] Match a non-whitespace character
\d [3] Match a decimal digit character
\D [3] Match a non-digit character
\pP [3] Match P, named property. Use \p{Prop} for longer names
\PP [3] Match non-P
\X [4] Match Unicode "eXtended grapheme cluster"
\1 [5] Backreference to a specific capture group or buffer.
'1' may actually be any positive integer.
\g1 [5] Backreference to a specific or previous group,
\g{-1} [5] The number may be negative indicating a relative
previous group and may optionally be wrapped in
curly brackets for safer parsing.
\g{name} [5] Named backreference
\k<name> [5] Named backreference
\k'name' [5] Named backreference
\k{name} [5] Named backreference
\K [6] Keep the stuff left of the \K, don't include it in $&
\N [7] Any character but \n. Not affected by /s modifier
\v [3] Vertical whitespace
\V [3] Not vertical whitespace
\h [3] Horizontal whitespace
\H [3] Not horizontal whitespace
\R [4] Linebreak
pod/perlre.pod view on Meta::CPAN
$_ = "123456789";
pos = 6;
s/.(?=.\G)/X/g;
print; # prints 1234X6789, not XXXXX6789
=head3 Capture groups
The grouping construct C<( ... )> creates capture groups (also referred to as
capture buffers). To refer to the current contents of a group later on, within
the same pattern, use C<\g1> (or C<\g{1}>) for the first, C<\g2> (or C<\g{2}>)
for the second, and so on.
This is called a I<backreference>.
X<regex, capture buffer> X<regexp, capture buffer>
X<regex, capture group> X<regexp, capture group>
X<regular expression, capture buffer> X<backreference>
X<regular expression, capture group> X<backreference>
X<\g{1}> X<\g{-1}> X<\g{name}> X<relative backreference> X<named backreference>
X<named capture buffer> X<regular expression, named capture buffer>
X<named capture group> X<regular expression, named capture group>
X<%+> X<$+{name}> X<< \k<name> >>
There is no limit to the number of captured substrings that you may use.
Groups are numbered with the leftmost open parenthesis being number 1, I<etc>. If
a group did not match, the associated backreference won't match either. (This
can happen if the group is optional, or in a different branch of an
alternation.)
You can omit the C<"g">, and write C<"\1">, I<etc>, but there are some issues with
this form, described below.
You can also refer to capture groups relatively, by using a negative number, so
that C<\g-1> and C<\g{-1}> both refer to the immediately preceding capture
group, and C<\g-2> and C<\g{-2}> both refer to the group before it. For
example:
/
(Y) # group 1
( # group 2
(X) # group 3
\g{-1} # backref to group 3
\g{-3} # backref to group 1
)
/x
would match the same as C</(Y) ( (X) \g3 \g1 )/x>. This allows you to
interpolate regexes into larger regexes and not have to worry about the
capture groups being renumbered.
You can dispense with numbers altogether and create named capture groups.
The notation is C<(?E<lt>I<name>E<gt>...)> to declare and C<\g{I<name>}> to
reference. (To be compatible with .Net regular expressions, C<\g{I<name>}> may
also be written as C<\k{I<name>}>, C<\kE<lt>I<name>E<gt>> or C<\k'I<name>'>.)
I<name> must not begin with a number, nor contain hyphens.
When different groups within the same pattern have the same name, any reference
to that name assumes the leftmost defined group. Named groups count in
absolute and relative numbering, and so can also be referred to by those
numbers.
(It's possible to do things with named capture groups that would otherwise
require C<(??{})>.)
Capture group contents are dynamically scoped and available to you outside the
pattern until the end of the enclosing block or until the next successful
match in the same scope, whichever comes first.
See L<perlsyn/"Compound Statements"> and
L<perlvar/"Scoping Rules of Regex Variables"> for more details.
You can access the contents of a capture group by absolute number (using
C<"$1"> instead of C<"\g1">, I<etc>); or by name via the C<%+> hash,
using C<"$+{I<name>}">.
Braces are required in referring to named capture groups, but are optional for
absolute or relative numbered ones. Braces are safer when creating a regex by
concatenating smaller strings. For example if you have C<qr/$x$y/>, and C<$x>
contained C<"\g1">, and C<$y> contained C<"37">, you would get C</\g137/> which
is probably not what you intended.
If you use braces, you may also optionally add any number of blank
(space or tab) characters within but adjacent to the braces, like
S<C<\g{ -1 }>>, or S<C<\k{ I<name> }>>.
The C<\g> and C<\k> notations were introduced in Perl 5.10.0. Prior to that
there were no named nor relative numbered capture groups. Absolute numbered
groups were referred to using C<\1>,
C<\2>, I<etc>., and this notation is still
accepted (and likely always will be). But it leads to some ambiguities if
there are more than 9 capture groups, as C<\10> could mean either the tenth
capture group, or the character whose ordinal in octal is 010 (a backspace in
ASCII). Perl resolves this ambiguity by interpreting C<\10> as a backreference
only if at least 10 left parentheses have opened before it. Likewise C<\11> is
a backreference only if at least 11 left parentheses have opened before it.
And so on. C<\1> through C<\9> are always interpreted as backreferences.
There are several examples below that illustrate these perils. You can avoid
the ambiguity by always using C<\g{}> or C<\g> if you mean capturing groups;
and for octal constants always using C<\o{}>, or for C<\077> and below, using 3
digits padded with leading zeros, since a leading zero implies an octal
constant.
The C<\I<digit>> notation also works in certain circumstances outside
the pattern. See L</Warning on \1 Instead of $1> below for details.
Examples:
s/^([^ ]*) *([^ ]*)/$2 $1/; # swap first two words
/(.)\g1/ # find first doubled char
and print "'$1' is the first doubled character\n";
/(?<char>.)\k<char>/ # ... a different way
and print "'$+{char}' is the first doubled character\n";
/(?'char'.)\g1/ # ... mix and match
and print "'$1' is the first doubled character\n";
if (/Time: (..):(..):(..)/) { # parse out values
$hours = $1;
$minutes = $2;
$seconds = $3;
}
/(.)(.)(.)(.)(.)(.)(.)(.)(.)\g10/ # \g10 is a backreference
/(.)(.)(.)(.)(.)(.)(.)(.)(.)\10/ # \10 is octal
/((.)(.)(.)(.)(.)(.)(.)(.)(.))\10/ # \10 is a backreference
/((.)(.)(.)(.)(.)(.)(.)(.)(.))\010/ # \010 is octal
$x = '(.)\1'; # Creates problems when concatenated.
$y = '(.)\g{1}'; # Avoids the problems.
"aa" =~ /${x}/; # True
"aa" =~ /${y}/; # True
"aa0" =~ /${x}0/; # False!
"aa0" =~ /${y}0/; # True
"aa\x08" =~ /${x}0/; # True!
"aa\x08" =~ /${y}0/; # False
Several special variables also refer back to portions of the previous
match. C<$+> returns whatever the last bracket match matched.
C<$&> returns the entire matched string. (At one point C<$0> did
pod/perlre.pod view on Meta::CPAN
$pattern = "foobar";
if ( /$pattern/i ) { }
# more flexible:
$pattern = "(?i)foobar";
if ( /$pattern/ ) { }
These modifiers are restored at the end of the enclosing group. For example,
( (?i) blah ) \s+ \g1
will match C<blah> in any case, some spaces, and an exact (I<including the case>!)
repetition of the previous word, assuming the C</x> modifier, and no C</i>
modifier outside this group.
These modifiers do not carry over into named subpatterns called in the
enclosing group. In other words, a pattern such as C<((?i)(?&I<NAME>))> does not
change the case-sensitivity of the I<NAME> pattern.
A modifier is overridden by later occurrences of this construct in the
pod/perlre.pod view on Meta::CPAN
=back
=item C<< (?<I<NAME>>I<pattern>) >>
=item C<(?'I<NAME>'I<pattern>)>
X<< (?<NAME>) >> X<(?'NAME')> X<named capture> X<capture>
A named capture group. Identical in every respect to normal capturing
parentheses C<()> but for the additional fact that the group
can be referred to by name in various regular expression
constructs (like C<\g{I<NAME>}>) and can be accessed by name
after a successful match via C<%+> or C<%->. See L<perlvar>
for more details on the C<%+> and C<%-> hashes.
If multiple distinct capture groups have the same name, then
C<$+{I<NAME>}> will refer to the leftmost defined group in the match.
The forms C<(?'I<NAME>'I<pattern>)> and C<< (?<I<NAME>>I<pattern>) >>
are equivalent.
B<NOTE:> While the notation of this construct is the same as the similar
pod/perlre.pod view on Meta::CPAN
since the match of the subgroup C<a*> is influenced by the following
group C<ab> (see L</"Backtracking">). In particular, C<a*> inside
C<a*ab> will match fewer characters than a standalone C<a*>, since
this makes the tail match.
C<< (?>I<pattern>) >> does not disable backtracking altogether once it has
matched. It is still possible to backtrack past the construct, but not
into it. So C<< ((?>a*)|(?>b*))ar >> will still match "bar".
An effect similar to C<< (?>I<pattern>) >> may be achieved by writing
C<(?=(I<pattern>))\g{-1}>. This matches the same substring as a standalone
C<a+>, and the following C<\g{-1}> eats the matched string; it therefore
makes a zero-length assertion into an analogue of C<< (?>...) >>.
(The difference between these two constructs is that the second one
uses a capturing group, thus shifting ordinals of backreferences
in the rest of a regular expression.)
Consider this pattern:
m{ \(
(
[^()]+ # x+
pod/perlre.pod view on Meta::CPAN
Perl-specific syntax, the following are also accepted:
=over 4
=item C<< (?PE<lt>I<NAME>E<gt>I<pattern>) >>
Define a named capture group. Equivalent to C<< (?<I<NAME>>I<pattern>) >>.
=item C<< (?P=I<NAME>) >>
Backreference to a named capture group. Equivalent to C<< \g{I<NAME>} >>.
=item C<< (?P>I<NAME>) >>
Subroutine call to a named capture group. Equivalent to C<< (?&I<NAME>) >>.
=back
=head1 BUGS
There are a number of issues with regard to case-insensitive matching
pod/perlrebackslash.pod view on Meta::CPAN
\A Beginning of string. Not in [].
\b{}, \b Boundary. (\b is a backspace in []).
\B{}, \B Not a boundary. Not in [].
\cX Control-X.
\d Match any digit character.
\D Match any character that isn't a digit.
\e Escape character.
\E Turn off \Q, \L and \U processing. Not in [].
\f Form feed.
\F Foldcase till \E. Not in [].
\g{}, \g1 Named, absolute or relative backreference.
Not in [].
\G Pos assertion. Not in [].
\h Match any horizontal whitespace character.
\H Match any character that isn't horizontal whitespace.
\k{}, \k<>, \k'' Named backreference. Not in [].
\K Keep the stuff left of \K. Not in [].
\l Lowercase next character. Not in [].
\L Lowercase till \E. Not in [].
\n (Logical) newline character.
\N Match any character but newline. Not in [].
pod/perlrebackslash.pod view on Meta::CPAN
my $pat = "(" x 999;
$pat .= "a";
$pat .= ")" x 999;
/^($pat)\1000$/; # Matches 'aa'; there are 1000 capture groups.
/^$pat\1000$/; # Matches 'a@0'; there are 999 capture groups
# and \1000 is seen as \100 (a '@') and a '0'.
=back
You can force a backreference interpretation always by using the C<\g{...}>
form. You can the force an octal interpretation always by using the C<\o{...}>
form, or for numbers up through \077 (= 63 decimal), by using three digits,
beginning with a "0".
=head3 Hexadecimal escapes
Like octal escapes, there are two forms of hexadecimal escapes, but both start
with the sequence C<\x>. This is followed by either exactly two hexadecimal
digits forming a number, or a hexadecimal number of arbitrary length surrounded
by curly braces. The hexadecimal number is the code point of the character you
pod/perlrebackslash.pod view on Meta::CPAN
If capturing parenthesis are used in a regular expression, we can refer
to the part of the source string that was matched, and match exactly the
same thing. There are three ways of referring to such I<backreference>:
absolutely, relatively, and by name.
=for later add link to perlrecapture
=head3 Absolute referencing
Either C<\gI<N>> (starting in Perl 5.10.0), or C<\I<N>> (old-style) where I<N>
is a positive (unsigned) decimal number of any length is an absolute reference
to a capturing group.
I<N> refers to the Nth set of parentheses, so C<\gI<N>> refers to whatever has
been matched by that set of parentheses. Thus C<\g1> refers to the first
capture group in the regex.
The C<\gI<N>> form can be equivalently written as C<\g{I<N>}>
which avoids ambiguity when building a regex by concatenating shorter
strings. Otherwise if you had a regex C<qr/$x$y/>, and C<$x> contained
C<"\g1">, and C<$y> contained C<"37">, you would get C</\g137/> which is
probably not what you intended.
In the C<\I<N>> form, I<N> must not begin with a "0", and there must be at
least I<N> capturing groups, or else I<N> is considered an octal escape
(but something like C<\18> is the same as C<\0018>; that is, the octal escape
C<"\001"> followed by a literal digit C<"8">).
Mnemonic: I<g>roup.
=head4 Examples
/(\w+) \g1/; # Finds a duplicated word, (e.g. "cat cat").
/(\w+) \1/; # Same thing; written old-style.
/(\w+) \g{1}/; # Same, using the safer braced notation
/(\w+) \g{ 1 }/;# Same, showing optional blanks adjacent to the braces
/(.)(.)\g2\g1/; # Match a four letter palindrome (e.g. "ABBA").
=head3 Relative referencing
C<\g-I<N>> (starting in Perl 5.10.0) is used for relative addressing. (It can
be written as C<\g{-I<N>}>.) It refers to the I<N>th group before the
C<\g{-I<N>}>.
The big advantage of this form is that it makes it much easier to write
patterns with references that can be interpolated in larger patterns,
even if the larger pattern also contains capture groups.
=head4 Examples
/(A) # Group 1
( # Group 2
(B) # Group 3
\g{-1} # Refers to group 3 (B)
\g{-3} # Refers to group 1 (A)
\g{ -3 } # Same, showing optional blanks adjacent to the braces
)
/x; # Matches "ABBA".
my $qr = qr /(.)(.)\g{-2}\g{-1}/; # Matches 'abab', 'cdcd', etc.
/$qr$qr/ # Matches 'ababcdcd'.
=head3 Named referencing
C<\g{I<name>}> (starting in Perl 5.10.0) can be used to back refer to a
named capture group, dispensing completely with having to think about capture
buffer positions.
To be compatible with .Net regular expressions, C<\g{name}> may also be
written as C<\k{name}>, C<< \k<name> >> or C<\k'name'>.
To prevent any ambiguity, I<name> must not start with a digit nor contain a
hyphen.
=head4 Examples
/(?<word>\w+) \g{word}/ # Finds duplicated word, (e.g. "cat cat")
/(?<word>\w+) \k{word}/ # Same.
/(?<word>\w+) \g{ word }/ # Same, showing optional blanks adjacent to
# the braces
/(?<word>\w+) \k{ word }/ # Same.
/(?<word>\w+) \k<word>/ # Same. There are no braces, so no blanks
# are permitted
/(?<letter1>.)(?<letter2>.)\g{letter2}\g{letter1}/
# Match a four letter palindrome (e.g.
# "ABBA")
=head2 Assertions
Assertions are conditions that have to be true; they don't actually
match parts of the substring. There are six assertions that are written as
backslash sequences.
=over 4
pod/perlrebackslash.pod view on Meta::CPAN
See also L<C<\b{gcb}>|/\b{}, \b, \B{}, \B>.
Mnemonic: eI<X>tended Unicode character.
=back
=head4 Examples
$str =~ s/foo\Kbar/baz/g; # Change any 'bar' following a 'foo' to 'baz'
$str =~ s/(.)\K\g1//g; # Delete duplicated characters.
"\n" =~ /^\R$/; # Match, \n is a generic newline.
"\r" =~ /^\R$/; # Match, \r is a generic newline.
"\r\n" =~ /^\R$/; # Match, \r\n is a generic newline.
"P\x{307}" =~ /^\X$/ # \X matches a P with a dot above.
=cut
pod/perlrequick.pod view on Meta::CPAN
If the groupings in a regex are nested, C<$1> gets the group with the
leftmost opening parenthesis, C<$2> the next opening parenthesis,
etc. For example, here is a complex regex and the matching variables
indicated below it:
/(ab(cd|ef)((gi)|j))/;
1 2 34
Associated with the matching variables C<$1>, C<$2>, ... are
the B<backreferences> C<\g1>, C<\g2>, ... Backreferences are
matching variables that can be used I<inside> a regex:
/(\w\w\w)\s\g1/; # find sequences like 'the the' in string
C<$1>, C<$2>, ... should only be used outside of a regex, and C<\g1>,
C<\g2>, ... only inside a regex.
=head2 Matching repetitions
The B<quantifier> metacharacters C<?>, C<*>, C<+>, and C<{}> allow us
to determine the number of repeats of a portion of a regex we
consider to be a match. Quantifiers are put immediately after the
character, character class, or grouping that we want to specify. They
have the following meanings:
=over 4
pod/perlrequick.pod view on Meta::CPAN
=item *
C<a{n}> = match exactly C<n> times
=back
Here are some examples:
/[a-z]+\s+\d*/; # match a lowercase word, at least some space, and
# any number of digits
/(\w+)\s+\g1/; # match doubled words of arbitrary length
$year =~ /^\d{2,4}$/; # make sure year is at least 2 but not more
# than 4 digits
$year =~ /^\d{ 4 }$|^\d{2}$/; # better match; throw out 3 digit dates
These quantifiers will try to match as much of the string as possible,
while still allowing the regex to match. So we have
$x = 'the cat in the hat';
$x =~ /^(.*)(at)(.*)$/; # matches,
# $1 = 'the cat in the h'
pod/perlreref.pod view on Meta::CPAN
^ Matches at the beginning of the string (or line, if /m is used)
$ Matches at the end of the string (or line, if /m is used)
* Matches the preceding element 0 or more times
+ Matches the preceding element 1 or more times
? Matches the preceding element 0 or 1 times
{...} Specifies a range of occurrences for the element preceding it
[...] Matches any one of the characters contained within the brackets
(...) Groups subexpressions for capturing to $1, $2...
(?:...) Groups subexpressions without capturing (cluster)
| Matches either the subexpression preceding or following it
\g1 or \g{1}, \g2 ... Matches the text from the Nth group
\1, \2, \3 ... Matches the text from the Nth group
\g-1 or \g{-1}, \g-2 ... Matches the text from the Nth previous group
\g{name} Named backreference
\k<name> Named backreference
\k'name' Named backreference
(?P=name) Named backreference (python syntax)
=head2 ESCAPE SEQUENCES
These work as in normal strings.
\a Alarm (beep)
\e Escape
pod/perlretut.pod view on Meta::CPAN
For convenience, Perl sets C<$+> to the string held by the highest numbered
C<$1>, C<$2>,... that got assigned (and, somewhat related, C<$^N> to the
value of the C<$1>, C<$2>,... most-recently assigned; I<i.e.> the C<$1>,
C<$2>,... associated with the rightmost closing parenthesis used in the
match).
=head2 Backreferences
Closely associated with the matching variables C<$1>, C<$2>, ... are
the I<backreferences> C<\g1>, C<\g2>,... Backreferences are simply
matching variables that can be used I<inside> a regexp. This is a
really nice feature; what matches later in a regexp is made to depend on
what matched earlier in the regexp. Suppose we wanted to look
for doubled words in a text, like "the the". The following regexp finds
all 3-letter doubles with a space in between:
/\b(\w\w\w)\s\g1\b/;
The grouping assigns a value to C<\g1>, so that the same 3-letter sequence
is used for both parts.
A similar task is to find words consisting of two identical parts:
% simple_grep '^(\w\w\w\w|\w\w\w|\w\w|\w)\g1$' /usr/dict/words
beriberi
booboo
coco
mama
murmur
papa
The regexp has a single grouping which considers 4-letter
combinations, then 3-letter combinations, I<etc>., and uses C<\g1> to look for
a repeat. Although C<$1> and C<\g1> represent the same thing, care should be
taken to use matched variables C<$1>, C<$2>,... only I<outside> a regexp
and backreferences C<\g1>, C<\g2>,... only I<inside> a regexp; not doing
so may lead to surprising and unsatisfactory results.
=head2 Relative backreferences
Counting the opening parentheses to get the correct number for a
backreference is error-prone as soon as there is more than one
capturing group. A more convenient technique became available
with Perl 5.10: relative backreferences. To refer to the immediately
preceding capture group one now may write C<\g-1> or C<\g{-1}>, the next but
last is available via C<\g-2> or C<\g{-2}>, and so on.
Another good reason in addition to readability and maintainability
for using relative backreferences is illustrated by the following example,
where a simple pattern for matching peculiar strings is used:
$a99a = '([a-z])(\d)\g2\g1'; # matches a11a, g22g, x33x, etc.
Now that we have this pattern stored as a handy string, we might feel
tempted to use it as a part of some other pattern:
$line = "code=e99e";
if ($line =~ /^(\w+)=$a99a$/){ # unexpected behavior!
print "$1 is valid\n";
} else {
print "bad line: '$line'\n";
}
But this doesn't match, at least not the way one might expect. Only
after inserting the interpolated C<$a99a> and looking at the resulting
full text of the regexp is it obvious that the backreferences have
backfired. The subexpression C<(\w+)> has snatched number 1 and
demoted the groups in C<$a99a> by one rank. This can be avoided by
using relative backreferences:
$a99a = '([a-z])(\d)\g{-1}\g{-2}'; # safe for being interpolated
=head2 Named backreferences
Perl 5.10 also introduced named capture groups and named backreferences.
To attach a name to a capturing group, you write either
C<< (?<name>...) >> or C<< (?'name'...) >>. The backreference may
then be written as C<\g{name}>. It is permissible to attach the
same name to more than one group, but then only the leftmost one of the
eponymous set can be referenced. Outside of the pattern a named
capture group is accessible through the C<%+> hash.
Assuming that we have to match calendar dates which may be given in one
of the three formats yyyy-mm-dd, mm/dd/yyyy or dd.mm.yyyy, we can write
three suitable patterns where we use C<'d'>, C<'m'> and C<'y'> respectively as the
names of the groups capturing the pertaining components of a date. The
matching operation combines the three patterns as alternatives:
pod/perlretut.pod view on Meta::CPAN
=back
If you like, you can add blanks (tab or space characters) within the
braces, but adjacent to them, and/or next to the comma (if any).
Here are some examples:
/[a-z]+\s+\d*/; # match a lowercase word, at least one space, and
# any number of digits
/(\w+)\s+\g1/; # match doubled words of arbitrary length
/y(es)?/i; # matches 'y', 'Y', or a case-insensitive 'yes'
$year =~ /^\d{2,4}$/; # make sure year is at least 2 but not more
# than 4 digits
$year =~ /^\d{ 2, 4 }$/; # Same; for those who like wide open
# spaces.
$year =~ /^\d{2, 4}$/; # Same.
$year =~ /^\d{4}$|^\d{2}$/; # better match; throw out 3-digit dates
$year =~ /^\d{2}(\d{2})?$/; # same thing written differently.
# However, this captures the last two
# digits in $1 and the other does not.
% simple_grep '^(\w+)\g1$' /usr/dict/words # isn't this easier?
beriberi
booboo
coco
mama
murmur
papa
For all of these quantifiers, Perl will try to match as much of the
string as possible, while still allowing the regexp to succeed. Thus
with C</a?.../>, Perl will first try to match the regexp with the C<'a'>
pod/perlretut.pod view on Meta::CPAN
code assertion (discussed in the next section). The third set of forms
provides tests that return true if the expression is executed within
a recursion (C<(R)>) or is being called from some capturing group,
referenced either by number (C<(R1)>, C<(R2)>,...) or by name
(C<(R&I<name>)>).
The integer or name form of the C<condition> allows us to choose,
with more flexibility, what to match based on what matched earlier in the
regexp. This searches for words of the form C<"$x$x"> or C<"$x$y$y$x">:
% simple_grep '^(\w+)(\w+)?(?(2)\g2\g1|\g1)$' /usr/dict/words
beriberi
coco
couscous
deed
...
toot
toto
tutu
The lookbehind C<condition> allows, along with backreferences,
pod/perlretut.pod view on Meta::CPAN
hitherto required a recursive parser.
To illustrate this feature, we'll design a pattern that matches if
a string contains a palindrome. (This is a word or a sentence that,
while ignoring spaces, interpunctuation and case, reads the same backwards
as forwards. We begin by observing that the empty string or a string
containing just one word character is a palindrome. Otherwise it must
have a word character up front and the same at its end, with another
palindrome in between.
/(?: (\w) (?...Here be a palindrome...) \g{ -1 } | \w? )/x
Adding C<\W*> at either end to eliminate what is to be ignored, we already
have the full pattern:
my $pp = qr/^(\W* (?: (\w) (?1) \g{-1} | \w? ) \W*)$/ix;
for $s ( "saippuakauppias", "A man, a plan, a canal: Panama!" ){
print "'$s' is a palindrome\n" if $s =~ /$pp/;
}
In C<(?...)> both absolute and relative backreferences may be used.
The entire pattern can be reinserted with C<(?R)> or C<(?0)>.
If you prefer to name your groups, you can use C<(?&I<name>)> to
recurse into that group.
pod/perlsyn.pod view on Meta::CPAN
Perl can process line directives, much like the C preprocessor. Using
this, one can control Perl's idea of filenames and line numbers in
error or warning messages (especially for strings that are processed
with C<eval()>). The syntax for this mechanism is almost the same as for
most C preprocessors: it matches the regular expression
# example: '# line 42 "new_filename.plx"'
/^\# \s*
line \s+ (\d+) \s*
(?:\s("?)([^"]+)\g2)? \s*
$/x
with C<$1> being the line number for the next line, and C<$3> being
the optional filename (specified with or without quotes). Note that
no whitespace may precede the C<< # >>, unlike modern C preprocessors.
There is a fairly obvious gotcha included with the line directive:
Debuggers and profilers will only show the last source line to appear
at a particular line number in a given file. Care should be taken not
to cause line number collisions in code you'd like to debug later.
break;
}
RETURN_FAIL_ON_RESTART_FLAGP(flagp);
/* Here, evaluates to a single code point. Go get that */
RExC_parse_set(atom_parse_start);
goto defchar;
case 'k': /* Handle \k<NAME> and \k'NAME' and \k{NAME} */
parse_named_seq: /* Also handle non-numeric \g{...} */
{
char ch;
if ( RExC_parse >= RExC_end - 1
|| (( ch = RExC_parse[1]) != '<'
&& ch != '\''
&& ch != '{'))
{
RExC_parse_inc_by(1);
/* diag_listed_as: Sequence \%s... not terminated in regex; marked by <-- HERE in m/%s/ */
vFAIL2("Sequence %.2s... not terminated", atom_parse_start);
* handle it there */
if (! isDIGIT(*s)) {
goto parse_named_seq;
}
do {
s++;
} while isDIGIT(*s);
RExC_parse_set(s);
vFAIL("Unterminated \\g{...} pattern");
}
s++; /* Past the '{' */
while (isBLANK(*s)) {
s++;
}
/* Ignore trailing blanks */
e = endbrace;
}
RExC_parse_set(s);
num = S_backref_value(RExC_parse, RExC_end);
if (num == 0)
vFAIL("Reference to invalid group 0");
else if (num == I32_MAX) {
if (isDIGIT(*RExC_parse))
vFAIL("Reference to nonexistent group");
else
vFAIL("Unterminated \\g... pattern");
}
if (isrel) {
num = RExC_npar - num;
if (num < 1)
vFAIL("Reference to nonexistent or unclosed group");
}
else
if (num < RExC_logical_npar) {
num = RExC_logical_to_parno[num];
num = RExC_logical_to_parno[num];
} else {
num = -1;
}
} else {
REQUIRE_PARENS_PASS;
}
}
/* At this point RExC_parse points at a numeric escape like
* \12 or \88 or the digits in \g{34} or \g34 or something
* similar, which we should NOT treat as an octal escape. It
* may or may not be a valid backref escape. For instance
* \88888888 is unlikely to be a valid backref.
*
* We've already figured out what value the digits represent.
* Now, move the parse to beyond them. */
if (endbrace) {
RExC_parse_set(endbrace + 1);
}
else while (isDIGIT(*RExC_parse)) {
}
prev_gcb = cur_gcb;
locinput += UTF8SKIP(locinput);
}
}
break;
case REFFLN: /* /\g{name}/il */
{ /* The capture buffer cases. The ones beginning with N for the
named buffers just convert to the equivalent numbered and
pretend they were called as the corresponding numbered buffer
op. */
/* don't initialize these in the declaration, it makes C++
unhappy */
const char *s;
char type;
re_fold_t folder;
const U8 *fold_array;
UV utf8_fold_flags;
CHECK_AND_WARN_PROBLEMATIC_LOCALE_;
folder = Perl_foldEQ_locale;
fold_array = PL_fold_locale;
type = REFFL;
utf8_fold_flags = FOLDEQ_LOCALE;
goto do_nref;
case REFFAN: /* /\g{name}/iaa */
folder = Perl_foldEQ_latin1;
fold_array = PL_fold_latin1;
type = REFFA;
utf8_fold_flags = FOLDEQ_UTF8_NOMIX_ASCII;
goto do_nref;
case REFFUN: /* /\g{name}/iu */
folder = Perl_foldEQ_latin1;
fold_array = PL_fold_latin1;
type = REFFU;
utf8_fold_flags = 0;
goto do_nref;
case REFFN: /* /\g{name}/i */
folder = Perl_foldEQ;
fold_array = PL_fold;
type = REFF;
utf8_fold_flags = 0;
goto do_nref;
case REFN: /* /\g{name}/ */
type = REF;
folder = NULL;
fold_array = NULL;
utf8_fold_flags = 0;
do_nref:
/* For the named back references, find the corresponding buffer
* number */
n = reg_check_named_buff_matched(rex,scan);
fresh_perl_is(
qq'"ab}"ax;&{+z}\x8Ao}\x82x;', <<gibberish,
Bareword found where operator expected (Missing operator before "ax"?) at - line 1, near ""ab}"ax"
syntax error at - line 1, near ""ab}"ax"
Execution of - aborted due to compilation errors.
gibberish
{ stderr => 1 },
'gibberish containing &{+z} - used to crash [perl #123753]'
);
fresh_perl_is(
"\@{\327\n", <<\gibberisi,
Unrecognized character \xD7; marked by <-- HERE after @{<-- HERE near column 3 at - line 1.
gibberisi
{ stderr => 1 },
'@ { \327 \n - used to garble output (or fail asan) [perl #128951]'
);
}
fresh_perl_is(
'/$a[/<<a',
"Missing right curly or square bracket at - line 1, within pattern\n" .
t/op/lvref.t view on Meta::CPAN
like $@, qr/^Assigned value is not a CODE reference at/,
'list-assigning non-code ref to package code ref';
eval '(\do{}) = 42';
like $@, qr/^Can't modify reference to do block in list assignment at /,
"Can't modify reference to do block in list assignment";
eval '(\pos) = 42';
like $@,
qr/^Can't modify reference to match position in list assignment at /,
"Can't modify ref to some scalar-returning op in list assignment";
eval '(\glob) = 42';
like $@,
qr/^Can't modify reference to glob in list assignment at /,
"Can't modify reference to some list-returning op in list assignment";
eval '\pos = 42';
like $@,
qr/^Can't modify reference to match position in scalar assignment at /,
"Can't modify ref to some scalar-returning op in scalar assignment";
eval '\(local @b) = 42';
like $@,
qr/^Can't modify reference to localized parenthesized array in list(?x:
# bug #22719
runperl(prog => 'sub f { my $x = shift; *z = $x; } f({}); f();');
is ($?, 0, 'coredump on typeglob = (SvRV && !SvROK)');
# bug #27268: freeing self-referential typeglobs could trigger
# "Attempt to free unreferenced scalar" warnings
is (runperl(
prog => 'use Symbol;my $x=bless \gensym,q{t}; print;*$$x=$x',
stderr => 1
), '', 'freeing self-referential typeglob');
# using a regex in the destructor for STDOUT segfaulted because the
# REGEX pad had already been freed (ithreads build only). The
# object is required to trigger the early freeing of GV refs to STDOUT
TODO: {
local $TODO = "works but output through pipe is mangled" if $^O eq 'VMS';
like (runperl(
t/re/pat_advanced.t view on Meta::CPAN
{
my $v;
($v = 'bar') =~ /(\w+)/g;
$v = 'foo';
is("$1", 'bar',
'$1 is safe after /g - may fail due to specialized config in pp_hot.c');
}
{
my $message = "http://nntp.perl.org/group/perl.perl5.porters/118663";
my $qr_barR1 = qr/(bar)\g-1/;
like("foobarbarxyz", $qr_barR1, $message);
like("foobarbarxyz", qr/foo${qr_barR1}xyz/, $message);
like("foobarbarxyz", qr/(foo)${qr_barR1}xyz/, $message);
like("foobarbarxyz", qr/(foo)(bar)\g{-1}xyz/, $message);
like("foobarbarxyz", qr/(foo${qr_barR1})xyz/, $message);
like("foobarbarxyz", qr/(foo(bar)\g{-1})xyz/, $message);
}
{
my $message = '$REGMARK';
our @r = ();
local $REGMARK;
local $REGERROR;
like('foofoo', qr/foo (*MARK:foo) (?{push @r,$REGMARK}) /x, $message);
is("@r","foo", $message);
is($REGMARK, "foo", $message);
t/re/pat_advanced.t view on Meta::CPAN
my $z="q!$a_grave! =~ m!(?^i)[$A_grave]!";
print eval $z, "\n";',
1,
{}, "GH #17278");
}
for my $try ( 1 .. 10 ) {
# GH $19350 assertion fails - run 10 times as this bug is a heisenbug
# and does not always fail, but should fail at least once in 10 tries.
fresh_perl_is('use re Debug=>"ALL";qr{(?{a})(?<b>\g{c}})',
<<'EOF_DEBUG_OUT',
Assembling pattern from 2 elements
Compiling REx "(?{a})(?<b>\g{c}"
Starting parse and generation
<(?{a})(?<b>>...| 1| reg
| | brnc
| | piec
| | atom
<?{a})(?<b>\>...| | reg
<(?<b>\g{c}> | 4| piec
| | atom
<?<b>\g{c}> | | reg
| | Setting open paren #1 to 4
<\g{c}> | 6| brnc
| | piec
| | atom
<> | 9| tail~ OPEN1 'b' (4) -> REFN
| | Setting close paren #1 to 9
| 11| lsbr~ tying lastbr REFN <1> (6) to ender CLOSE1 'b' (9) offset 3
| | tail~ REFN <1> (6) -> CLOSE
Unmatched ( in regex; marked by <-- HERE in m/(?{a})( <-- HERE ?<b>\g{c}/ at - line 1.
Freeing REx: "(?{a})(?<b>\g{c}"
EOF_DEBUG_OUT
{rtrim_result=>1},
"Github Issue #19350, assert fail in "
. "Debug => 'ALL' from malformed qr// (heisenbug try $try)");
}
{ # Related to GH $19350 but segfaults instead of asserts, and does so reliably, not randomly.
# use re Debug => "PARSE" is similar to "ALL", but does not include the optimize info, so we
# do not need to deal with normlazing memory addresses in the output.
fresh_perl_is(
'use re Debug=>"PARSE";qr{(?<b>\g{c})(?<c>x)(?&b)}',
<<'EOF_DEBUG_OUT',
Assembling pattern from 1 elements
Compiling REx "(?<b>\g{c})(?<c>x)(?&b)"
Starting parse and generation
<(?<b>\g{c})>...| 1| reg
| | brnc
| | piec
| | atom
<?<b>\g{c})(>...| | reg
<\g{c})(?<c>>...| 3| brnc
| | piec
| | atom
<)(?<c>x)(?&b)> | 6| tail~ OPEN1 'b' (1) -> REFN
| 8| lsbr~ tying lastbr REFN <1> (3) to ender CLOSE1 'b' (6) offset 3
| | tail~ REFN <1> (3) -> CLOSE
<(?<c>x)(?&b)> | | piec
| | atom
<?<c>x)(?&b)> | | reg
<x)(?&b)> | 10| brnc
| | piec
t/re/pat_advanced.t view on Meta::CPAN
| | ~ CLOSE2 'c' (12) -> GOSUB
| 18| lsbr~ tying lastbr OPEN1 'b' (1) to ender END (17) offset 16
| | tail~ OPEN1 'b' (1)
| | ~ REFN <1> (3)
| | ~ CLOSE1 'b' (6)
| | ~ OPEN2 'c' (8)
| | ~ EXACT <x> (10)
| | ~ CLOSE2 'c' (12)
| | ~ GOSUB1[+0:14] 'b' (14) -> END
Need to redo parse
Freeing REx: "(?<b>\g{c})(?<c>x)(?&b)"
Starting parse and generation
<(?<b>\g{c})>...| 1| reg
| | brnc
| | piec
| | atom
<?<b>\g{c})(>...| | reg
<\g{c})(?<c>>...| 3| brnc
| | piec
| | atom
<)(?<c>x)(?&b)> | 6| tail~ OPEN1 'b' (1) -> REFN
| 8| lsbr~ tying lastbr REFN2 'c' <1> (3) to ender CLOSE1 'b' (6) offset 3
| | tail~ REFN2 'c' <1> (3) -> CLOSE
<(?<c>x)(?&b)> | | piec
| | atom
<?<c>x)(?&b)> | | reg
<x)(?&b)> | 10| brnc
| | piec
t/re/pat_advanced.t view on Meta::CPAN
| 18| lsbr~ tying lastbr OPEN1 'b' (1) to ender END (17) offset 16
| | tail~ OPEN1 'b' (1)
| | ~ REFN2 'c' <1> (3)
| | ~ CLOSE1 'b' (6)
| | ~ OPEN2 'c' (8)
| | ~ EXACT <x> (10)
| | ~ CLOSE2 'c' (12)
| | ~ GOSUB1[+0:14] 'b' (14) -> END
Required size 17 nodes
first at 3
Freeing REx: "(?<b>\g{c})(?<c>x)(?&b)"
EOF_DEBUG_OUT
{rtrim_result=>1},
"Related to Github Issue #19350, forward \\g{x} pattern segv under use re Debug => 'PARSE'");
}
{ # perl-security#140, read/write past buffer end
fresh_perl_like('qr/\p{utf8::perl x}/',
qr/Illegal user-defined property name "utf8::perl x" in regex/,
{}, "perl-security#140");
fresh_perl_is('qr/\p{utf8::_perl_surrogate}/', "",
{}, "perl-security#140");
}
t/re/re_tests view on Meta::CPAN
(.*)c(.*) abcde y $&-$1-$2 abcde-ab-de
\((.*), (.*)\) (a, b) y ($2, $1) (b, a)
[k] ab n - -
abcd abcd y $&-\$&-\\$& abcd-\$&-\\abcd
a(bc)d abcd y $1-\$1-\\$1 bc-\$1-\\bc
a[-]?c ac y $& ac
(abc)\1 abcabc y $1 abc
([a-c]*)\1 abcabc y $1 abc
\1 - c - Reference to nonexistent group
\2 - c - Reference to nonexistent group
\g1 - c - Reference to nonexistent group
\g-1 - c - Reference to nonexistent or unclosed group
\g{1} - c - Reference to nonexistent group
\g{ 1 } - c - Reference to nonexistent group
\g{-1} - c - Reference to nonexistent or unclosed group
\g{ -1 } - c - Reference to nonexistent or unclosed group
\g0 - c - Reference to invalid group 0
\g-0 - c - Reference to invalid group 0
\g{0} - c - Reference to invalid group 0
\g{ 0 } - c - Reference to invalid group 0
\g{-0} - c - Reference to invalid group 0
\g{ -0 } - c - Reference to invalid group 0
(a)|\1 a y - -
(a)|\1 x n - Reference to group in different branch
(?:(b)?a)\1 a n - Reference to group that did not match
(a)|\2 - c - Reference to nonexistent group
(([a-c])b*?\2)* ababbbcbc y $&-$1-$2 ababb-bb-b
(([a-c])b*?\2){3} ababbbcbc y $&-$1-$2 ababbbcbc-cbc-c
((\3|b)\2(a)x)+ aaxabxbaxbbx n - -
((\3|b)\2(a)x)+ aaaxabaxbaaxbbax y $&-$1-$2-$3 bbax-bbax-b-a
((\3|b)\2(a)){2,} bbaababbabaaaaabbaaaabba y $&-$1-$2-$3 bbaaaabba-bba-b-a
#Bug #3589 - up to perl-5.6.0 matches incorrectly, from 5.6.1 not anymore
t/re/re_tests view on Meta::CPAN
a*(*FAIL) aaaab n - -
a*(*F) aaaab n - -
(A(A|B(*ACCEPT)|C)D)(E) AB y $1 AB
(A(A|B(*ACCEPT)|C)D)(E) ACDE y $1$2$3 ACDCE
(a)(?:(?-1)|(?+1))(b) aab y $&-$1-$2 aab-a-b
(a)(?:(?-1)|(?+1))(b) abb y $1-$2 a-b
(a)(?:(?-1)|(?+1))(b) acb n - -
(foo)(\g-2) foofoo y $1-$2 foo-foo
(foo)(\g-2)(foo)(\g-2) foofoofoofoo y $1-$2-$3-$4 foo-foo-foo-foo
(([abc]+) \g-1)(([abc]+) \g{-1}) abc abccba cba y $2-$4 abc-cba
(a)(b)(c)\g1\g2\g3 abcabc y $1$2$3 abc
# \k<n> preceded by a literal
/(?'n'foo) \k<n>/ ..foo foo.. y $1 foo
/(?'n'foo) \k<n>/ ..foo foo.. yM $+{n} foo miniperl cannot load Tie::Hash::NamedCapture
/(?<n>foo) \k'n'/ ..foo foo.. y $1 foo
/(?<n>foo) \k'n'/ ..foo foo.. yM $+{n} foo miniperl cannot load Tie::Hash::NamedCapture
/(?'a1'foo) \k'a1'/ ..foo foo.. yM $+{a1} foo miniperl cannot load Tie::Hash::NamedCapture
/(?<a1>foo) \k<a1>/ ..foo foo.. yM $+{a1} foo miniperl cannot load Tie::Hash::NamedCapture
/(?'_'foo) \k'_'/ ..foo foo.. yM $+{_} foo miniperl cannot load Tie::Hash::NamedCapture
/(?<_>foo) \k<_>/ ..foo foo.. yM $+{_} foo miniperl cannot load Tie::Hash::NamedCapture
t/re/re_tests view on Meta::CPAN
/foo \k'1a'/ - c - Group name must start with a non-digit word character
/foo \k<1a>/ - c - Group name must start with a non-digit word character
/foo \k''/ - c - Group name must start with a non-digit word character
/foo \k<>/ - c - Group name must start with a non-digit word character
/(?<as>as) (\w+) \k<as> (\w+)/ as easy as pie y $1-$2-$3 as-easy-pie
/(?<as>as) (\w+) \k{as} (\w+)/ as easy as pie y $1-$2-$3 as-easy-pie
/(?<as>as) (\w+) \k'as' (\w+)/ as easy as pie y $1-$2-$3 as-easy-pie
/(?<as>as) (\w+) \k{ as } (\w+)/ as easy as pie y $1-$2-$3 as-easy-pie
/(?<as>as) (\w+) \k< as> (\w+)/ as easy as pie c - Group name must start with a non-digit word character
# \g{...} with a name as the argument
/(?'n'foo) \g{n}/ ..foo foo.. y $1 foo
/(?'n'foo) \g{ n }/ ..foo foo.. y $1 foo
/(?'n'foo) \g{n}/ ..foo foo.. yM $+{n} foo miniperl cannot load Tie::Hash::NamedCapture
/(?<n>foo) \g{n}/ ..foo foo.. y $1 foo
/(?<n>foo) \g{n}/ ..foo foo.. yM $+{n} foo miniperl cannot load Tie::Hash::NamedCapture
/(?<as>as) (\w+) \g{as} (\w+)/ as easy as pie y $1-$2-$3 as-easy-pie
# Python style named capture buffer stuff
/(?P<n>foo)(?P=n)/ ..foofoo.. y $1 foo
/(?P<n>foo)(?P=n)/ ..foofoo.. yM $+{n} foo miniperl cannot load Tie::Hash::NamedCapture
/(?:(?P<n>foo)|(?P<n>bar))(?P=n)/ ..barbar.. yM $+{n} bar miniperl cannot load Tie::Hash::NamedCapture
/^(?P<PAL>(?P<CHAR>.)((?P>PAL)|.?)(?P=CHAR))$/ madamimadam y $& madamimadam
/^(?P<PAL>(?P<CHAR>.)((?P>PAL)|.?)(?P=CHAR))$/ madamiamadam n - -
/(?P<n>foo) (?P=n)/ ..foo foo.. y $1 foo
/(?P<n>foo) (?P=n)/ ..foo foo.. yM $+{n} foo miniperl cannot load Tie::Hash::NamedCapture
/(?P<as>as) (\w+) (?P=as) (\w+)/ as easy as pie y $1-$2-$3 as-easy-pie
t/re/re_tests view on Meta::CPAN
[a\o{400}] \x{100} y $& \x{100}
[a\o{1000}] \x{200} y $& \x{200}
# The below were inserting a NULL
\87 87 c - Reference to nonexistent group in regex
a\87 a87 c - Reference to nonexistent group in regex
a\97 a97 c - Reference to nonexistent group in regex
# avoid problems with 32-bit signed integer overflow
(.)\g2147483648} x c - Reference to nonexistent group in regex
(.)\g2147483649} x c - Reference to nonexistent group in regex
(.)\g2147483650} x c - Reference to nonexistent group in regex
(.)\g4294967296} x c - Reference to nonexistent group in regex
(.)\g4294967297} x c - Reference to nonexistent group in regex
(.)\g4294967298} x c - Reference to nonexistent group in regex
a(.)\g2147483648} x c - Reference to nonexistent group in regex
a(.)\g2147483649} x c - Reference to nonexistent group in regex
a(.)\g2147483650} x c - Reference to nonexistent group in regex
a(.)\g4294967296} x c - Reference to nonexistent group in regex
a(.)\g4294967297} x c - Reference to nonexistent group in regex
a(.)\g4294967298} x c - Reference to nonexistent group in regex
(.)\g{2147483648} x c - Reference to nonexistent group in regex
(.)\g{ 2147483648 } x c - Reference to nonexistent group in regex
(.)\g{2147483649} x c - Reference to nonexistent group in regex
(.)\g{2147483650} x c - Reference to nonexistent group in regex
(.)\g{4294967296} x c - Reference to nonexistent group in regex
(.)\g{4294967297} x c - Reference to nonexistent group in regex
(.)\g{4294967298} x c - Reference to nonexistent group in regex
a(.)\g{2147483648} x c - Reference to nonexistent group in regex
a(.)\g{2147483649} x c - Reference to nonexistent group in regex
a(.)\g{2147483650} x c - Reference to nonexistent group in regex
a(.)\g{4294967296} x c - Reference to nonexistent group in regex
a(.)\g{4294967297} x c - Reference to nonexistent group in regex
a(.)\g{4294967298} x c - Reference to nonexistent group in regex
(.)\2147483648 b\o{214}7483648 ya $1 b \d not converted to native; \o{} is
(.)\2147483649 b\o{214}7483649 ya $1 b \d not converted to native; \o{} is
(.)\2147483650 b\o{214}7483650 ya $1 b \d not converted to native; \o{} is
(.)\4294967296 b\o{42}94967296 ya $1 b \d not converted to native; \o{} is
(.)\4294967297 b\o{42}94967297 ya $1 b \d not converted to native; \o{} is
(.)\4294967298 b\o{42}94967298 ya $1 b \d not converted to native; \o{} is
a(.)\2147483648 ab\o{214}7483648 ya $1 b \d not converted to native; \o{} is
a(.)\2147483649 ab\o{214}7483649 ya $1 b \d not converted to native; \o{} is
a(.)\2147483650 ab\o{214}7483650 ya $1 b \d not converted to native; \o{} is
t/re/reg_mesg.t view on Meta::CPAN
'/x[/' => 'Unmatched [ {#} m/x[{#}/',
'/*/', => 'Quantifier follows nothing {#} m/*{#}/',
'/\p{x/' => 'Missing right brace on \p{} {#} m/\p{{#}x/',
'/[\p{x]/' => 'Missing right brace on \p{} {#} m/[\p{{#}x]/',
'/(x)\2/' => 'Reference to nonexistent group {#} m/(x)\2{#}/',
'/\g/' => 'Unterminated \g... pattern {#} m/\g{#}/',
'/\g{1/' => 'Unterminated \g{...} pattern {#} m/\g{1{#}/',
'/\g{-abc}/' => 'Group name must start with a non-digit word character {#} m/\g{-{#}abc}/',
'/(?<;x/' => 'Group name must start with a non-digit word character {#} m/(?<;{#}x/',
'my $m = "\\\"; $m =~ $m', => 'Trailing \ in regex m/\/',
'/\x{ 1 /' => 'Missing right brace on \x{} {#} m/\x{ 1{#} /',
'/\x{X/' => 'Missing right brace on \x{} {#} m/\x{{#}X/',
'/[\x{X]/' => 'Missing right brace on \x{} {#} m/[\x{{#}X]/',
'/[\x{ A ]/' => 'Missing right brace on \x{} {#} m/[\x{ A{#} ]/',
t/re/reg_mesg.t view on Meta::CPAN
'm/a\87/' => 'Reference to nonexistent group {#} m/a\87{#}/',
'm/a\97/' => 'Reference to nonexistent group {#} m/a\97{#}/',
'm/(*DOOF)/' => 'Unknown verb pattern \'DOOF\' {#} m/(*DOOF){#}/',
'm/(?&a/' => 'Sequence (?&... not terminated {#} m/(?&a{#}/',
'm/(?P=/' => 'Sequence ?P=... not terminated {#} m/(?P={#}/',
"m/(?'/" => "Sequence (?'... not terminated {#} m/(?'{#}/",
"m/(?</" => "Sequence (?<... not terminated {#} m/(?<{#}/",
'm/(?&/' => 'Sequence (?&... not terminated {#} m/(?&{#}/',
'm/(?(</' => 'Sequence (?(<... not terminated {#} m/(?(<{#}/',
"m/(?('/" => "Sequence (?('... not terminated {#} m/(?('{#}/",
'm/\g{/' => 'Sequence \g{... not terminated {#} m/\g{{#}/',
'm/\k</' => 'Sequence \k<... not terminated {#} m/\k<{#}/',
'/((?# This is a comment in the middle of a token)?:foo)/' => 'In \'(?...)\', the \'(\' and \'?\' must be adjacent {#} m/((?# This is a comment in the middle of a token)?{#}:foo)/',
'/((?# This is a comment in the middle of a token)*FAIL)/' => 'In \'(*VERB...)\', the \'(\' and \'*\' must be adjacent {#} m/((?# This is a comment in the middle of a token)*{#}FAIL)/',
'/((?# This is a comment in the middle of a token)*script_run:foo)/' => 'In \'(*...)\', the \'(\' and \'*\' must be adjacent {#} m/((?# This is a comment in the middle of a token)*{#}script_run:foo)/',
'/(*script_runfoo)/' => 'Unknown \'(*...)\' construct \'script_runfoo\' {#} m/(*script_runfoo){#}/',
'/(*srfoo)/' => 'Unknown \'(*...)\' construct \'srfoo\' {#} m/(*srfoo){#}/',
'/(*script_run)/' => '\'(*script_run\' requires a terminating \':\' {#} m/(*script_run{#})/',
'/(*sr)/' => '\'(*sr\' requires a terminating \':\' {#} m/(*sr{#})/',
'/(*pla)/' => '\'(*pla\' requires a terminating \':\' {#} m/(*pla{#})/',
t/re/reg_mesg.t view on Meta::CPAN
'/ã**ã/' => 'Nested quantifiers {#} m/ã**{#}ã/',
'/ã[ã/' => 'Unmatched [ {#} m/ã[{#}ã/',
'/*ã/', => 'Quantifier follows nothing {#} m/*{#}ã/',
'/ã\p{ã/' => 'Missing right brace on \p{} {#} m/ã\p{{#}ã/',
'/(ã)\2ã/' => 'Reference to nonexistent group {#} m/(ã)\2{#}ã/',
'/\g{ã/; #no latin1' => 'Sequence \g{... not terminated {#} m/\g{ã{#}/',
'my $m = "ã\\\"; $m =~ $m', => 'Trailing \ in regex m/ã\/',
'/\x{ã/' => 'Missing right brace on \x{} {#} m/\x{{#}ã/',
'/ã[\x{ã]ã/' => 'Missing right brace on \x{} {#} m/ã[\x{{#}ã]ã/',
'/ã[\x{ã]/' => 'Missing right brace on \x{} {#} m/ã[\x{{#}ã]/',
'/ã\o{ã/' => 'Missing right brace on \o{} {#} m/ã\o{{#}ã/',
'/[ã-a]ã/' => 'Invalid [] range "ã-a" {#} m/[ã-a{#}]ã/',
win32/GNUmakefile view on Meta::CPAN
endif
# Set the install location of the compiler headers/libraries.
# These are saved into $Config{incpath} and $Config{libpth}.
ifneq ($(GCCCROSS),)
CCINCDIR := $(CCHOME)\$(GCCCROSS)\include
CCLIBDIR := $(CCHOME)\$(GCCCROSS)\lib
ARCHPREFIX := $(GCCCROSS)-
else ifeq ($(CCTYPE),GCC)
CCINCDIR := $(CCHOME)\include
CCLIBDIR := $(CCHOME)\lib;$(CCHOME)\$(GCCTARGET)\lib;$(CCHOME)\lib\gcc\$(GCCTARGET)\$(GCCVER)
ARCHPREFIX :=
else
CCINCDIR := $(CCHOME)\include
ifeq ($(CCTYPE),MSVC140)
ifeq ($(WIN64),define)
CCLIBDIR := $(CCHOME)\lib\amd64
else
CCLIBDIR := $(CCHOME)\lib
endif
else
win32/GNUmakefile view on Meta::CPAN
HAVEMINIPERL = ..\lib\buildcustomize.pl
# contains config.h for the full perl build
FULLDIR = full
MINIDIR = mini
PERLEXE = ..\perl.exe
WPERLEXE = ..\wperl.exe
PERLEXESTATIC = ..\perl-static.exe
STATICDIR = .\static.tmp
GLOBEXE = ..\perlglob.exe
CONFIGPM = ..\lib\Config.pm
GENUUDMAP = ..\generate_uudmap.exe
ifeq ($(BUILD_STATIC),define)
PERLSTATIC = static
else
ifeq ($(ALL_STATIC),define)
PERLSTATIC = static
else
PERLSTATIC =
endif
endif
win32/GNUmakefile view on Meta::CPAN
..\regcomp_invlist.c \
..\regcomp_study.c \
..\regexec.c \
..\op.c \
..\sv.c \
..\pp.c \
..\pp_ctl.c \
..\pp_sys.c \
..\pp_pack.c \
..\pp_hot.c \
..\gv.c \
..\perl.c \
..\utf8.c \
..\dump.c \
..\hv.c \
..\av.c \
..\builtin.c \
..\caretx.c \
..\class.c \
..\deb.c \
..\doio.c \
..\doop.c \
..\dquote.c \
..\globals.c \
..\mro_core.c \
..\locale.c \
..\keywords.c \
..\mathoms.c \
..\mg.c \
..\numeric.c \
..\pad.c \
..\peep.c \
..\perly.c \
..\pp_sort.c \
win32/GNUmakefile view on Meta::CPAN
.\win32thread.c \
.\fcrypt.c
CORE_NOCFG_H = \
..\av.h \
..\cop.h \
..\cv.h \
..\dosish.h \
..\embed.h \
..\form.h \
..\gv.h \
..\handy.h \
..\hv.h \
..\hv_func.h \
..\iperlsys.h \
..\mg.h \
..\nostdio.h \
..\op.h \
..\opcode.h \
..\perl.h \
..\perlapi.h \
win32/GNUmakefile view on Meta::CPAN
..\perlvars.h \
..\intrpvar.h \
.\include\dirent.h \
.\include\netdb.h \
.\include\sys\errno2.h \
.\include\sys\socket.h \
.\win32.h
CONFIG_H = $(FULLDIR)\config.h
MINI_CONFIG_H = $(MINIDIR)\config.h
CORE_H = $(CORE_NOCFG_H) $(CONFIG_H) ..\git_version.h
UUDMAP_H = ..\uudmap.h
BITCOUNT_H = ..\bitcount.h
MG_DATA_H = ..\mg_data.h
GENERATED_HEADERS = $(UUDMAP_H) $(BITCOUNT_H) $(MG_DATA_H)
HAVE_COREDIR = .coreheaders
MICROCORE_OBJ = $(MICROCORE_SRC:.c=$(o))
CORE_OBJ = $(MICROCORE_OBJ) $(EXTRACORE_SRC:.c=$(o))
win32/GNUmakefile view on Meta::CPAN
..\regcomp_debug$(o) : ..\regcomp.h ..\regcomp_internal.h ..\regnodes.h ..\regcharclass.h
..\regcomp_invlist$(o) : ..\regcomp.h ..\regcomp_internal.h ..\regnodes.h ..\regcharclass.h
..\regcomp_study$(o) : ..\regcomp.h ..\regcomp_internal.h ..\regnodes.h ..\regcharclass.h
..\regcomp_trie$(o) : ..\regcomp.h ..\regcomp_internal.h ..\regnodes.h ..\regcharclass.h
..\regexec$(o) : ..\regnodes.h ..\regcharclass.h
reonly : ..\regnodes.h $(CONFIG_H) ..\git_version.h $(GLOBEXE) $(HAVEMINIPERL)\
$(CONFIGPM) $(UNIDATAFILES) $(PERLEXE) \
Extensions_reonly
static: $(PERLEXESTATIC)
#----------------------------------------------------------------
$(GLOBEXE) : perlglob.c
ifeq ($(CCTYPE),GCC)
$(LINK32) $(EXTRACFLAGS) $(OPTIMIZE) $(BLINK_FLAGS) -mconsole -o $@ perlglob.c $(LIBFILES)
else
$(CC) $(EXTRACFLAGS) $(OPTIMIZE) $(PDBOUT) -Fe$@ perlglob.c -link $(BLINK_FLAGS) \
setargv$(o) $(LIBFILES)
endif
..\git_version.h : $(HAVEMINIPERL) ..\make_patchnum.pl
$(MINIPERL) -I..\lib ..\make_patchnum.pl
# make sure that we recompile perl.c if the git version changes
..\perl$(o) : ..\git_version.h
..\config.sh : $(CFGSH_TMPL) config_sh.PL FindExt.pm $(HAVEMINIPERL)
$(MINIPERL) -I..\lib config_sh.PL -o ..\config.sh $(CFG_VARS) $(CFGSH_TMPL)
# This target is for when changes to the main config.sh happen.
# Edit config.gc, then make perl using GCC in a minimal configuration (i.e.
# with MULTI, ITHREADS, IMP_SYS, LARGE_FILES and PERLIO off), then make
# this target to regenerate config_H.gc.
regen_config_h:
$(MINIPERL) -I..\lib config_sh.PL --prebuilt $(CFG_VARS) $(CFGSH_TMPL) > ..\config.sh
$(MINIPERL) -I..\lib ..\configpm --chdir=..
-del /f $(CFGH_TMPL)
-$(MINIPERL) -I..\lib config_h.PL "ARCHPREFIX=$(ARCHPREFIX)"
rename config.h $(CFGH_TMPL)
$(CONFIGPM): ..\config.sh config_h.PL ..\git_version.h
$(MINIPERL) -I..\lib ..\configpm --chdir=..
if not exist "$(FULLDIR)" mkdir "$(FULLDIR)"
$(MINIPERL) -I..\lib config_h.PL "CONFIG_H=$(CONFIG_H)" "ARCHPREFIX=$(ARCHPREFIX)"
$(CONFIG_H) : $(CONFIGPM)
# See the comment in Makefile.SH explaining this seemingly cranky ordering
..\lib\buildcustomize.pl : $(MINI_OBJ) ..\write_buildcustomize.pl
ifeq ($(CCTYPE),GCC)
$(LINK32) -mconsole -o $(MINIPERL) $(BLINK_FLAGS) $(MINI_OBJ) $(LIBFILES)
win32/GNUmakefile view on Meta::CPAN
$(ARCHPREFIX)ar q ..\$@ *$(o) && \
cd .. && rmdir /s /q $(STATICDIR)
else
$(LIB32) $(LIB_FLAGS) -out:$@ @Extensions_static \
$(PERLDLL_OBJ)
endif
$(XCOPY) $(PERLSTATICLIB) $(COREDIR)
$(PERLEXE_RES): perlexe.rc $(PERLEXE_MANIFEST) $(PERLEXE_ICO)
$(MINIDIR)\globals$(o) : $(GENERATED_HEADERS)
$(UUDMAP_H) $(MG_DATA_H) : $(BITCOUNT_H)
$(BITCOUNT_H) : $(GENUUDMAP)
$(GENUUDMAP) $(GENERATED_HEADERS)
$(GENUUDMAP) : ..\mg_raw.h
ifeq ($(CCTYPE),GCC)
$(LINK32) $(CFLAGS_O) -o..\generate_uudmap.exe ..\generate_uudmap.c \
$(BLINK_FLAGS) $(LIBFILES)
else
$(CC) $(CFLAGS_O) $(PDBOUT) -Fe..\generate_uudmap.exe ..\generate_uudmap.c -link $(LIBFILES) $(BLINK_FLAGS)
endif
.PHONY: MakePPPort
MakePPPort : $(HAVEMINIPERL) $(CONFIGPM)
$(MINIPERL) -I..\lib ..\mkppport
# also known as $(HAVE_COREDIR)
.coreheaders : $(CORE_H)
$(XCOPY) *.h $(COREDIR)\\*.*
win32/GNUmakefile view on Meta::CPAN
cd ..\t && perl.exe harness $(TEST_ARGS) $(TEST_SWITCHES) $(TEST_FILES)
_clean :
-@erase miniperlmain$(o)
-@erase $(MINIPERL)
-@erase perlglob$(o)
-@erase perlmain$(o)
-@erase perlmainst$(o)
-@erase /f $(CONFIG_H)
-if exist $(FULLDIR) rmdir /s /q $(FULLDIR)
-@erase /f ..\git_version.h
-@erase $(GLOBEXE)
-@erase $(PERLEXE)
-@erase $(WPERLEXE)
-@erase $(PERLEXESTATIC)
-@erase $(PERLSTATICLIB)
-@erase $(PERLDLL)
-@erase $(CORE_OBJ)
-@erase $(GENUUDMAP) $(GENUUDMAP_OBJ) $(GENERATED_HEADERS)
-@erase .coreheaders
-if exist $(MINIDIR) rmdir /s /q $(MINIDIR)
win32/Makefile view on Meta::CPAN
MINIPERL = ..\miniperl.exe
# contains config.h for the full perl build
FULLDIR = .\full
MINIDIR = .\mini
PERLEXE = ..\perl.exe
WPERLEXE = ..\wperl.exe
PERLEXESTATIC = ..\perl-static.exe
GLOBEXE = ..\perlglob.exe
CONFIGPM = ..\lib\Config.pm ..\lib\Config_heavy.pl
GENUUDMAP = ..\generate_uudmap.exe
!IF "$(BUILD_STATIC)" == "define" || "$(ALL_STATIC)" == "define"
PERLSTATIC = static
!ELSE
PERLSTATIC =
!ENDIF
# Unicode data files generated by mktables
FIRSTUNIFILE = ..\lib\unicore\Decomposition.pl
UNIDATAFILES = ..\lib\unicore\Decomposition.pl \
..\lib\unicore\CombiningClass.pl ..\lib\unicore\Name.pl \
win32/Makefile view on Meta::CPAN
MICROCORE_SRC = \
..\av.c \
..\caretx.c \
..\class.c \
..\builtin.c \
..\deb.c \
..\doio.c \
..\doop.c \
..\dquote.c \
..\dump.c \
..\globals.c \
..\gv.c \
..\mro_core.c \
..\hv.c \
..\locale.c \
..\keywords.c \
..\mathoms.c \
..\mg.c \
..\numeric.c \
..\op.c \
..\pad.c \
..\peep.c \
win32/Makefile view on Meta::CPAN
.\win32thread.c \
.\fcrypt.c
CORE_NOCFG_H = \
..\av.h \
..\cop.h \
..\cv.h \
..\dosish.h \
..\embed.h \
..\form.h \
..\gv.h \
..\handy.h \
..\hv.h \
..\hv_func.h \
..\iperlsys.h \
..\mg.h \
..\nostdio.h \
..\op.h \
..\opcode.h \
..\perl.h \
..\perlapi.h \
win32/Makefile view on Meta::CPAN
..\perlvars.h \
..\intrpvar.h \
.\include\dirent.h \
.\include\netdb.h \
.\include\sys\errno2.h \
.\include\sys\socket.h \
.\win32.h
CONFIG_H = $(FULLDIR)\config.h
MINI_CONFIG_H = $(MINIDIR)\config.h
CORE_H = $(CORE_NOCFG_H) $(CONFIG_H) ..\git_version.h
UUDMAP_H = ..\uudmap.h
BITCOUNT_H = ..\bitcount.h
MG_DATA_H = ..\mg_data.h
GENERATED_HEADERS = $(UUDMAP_H) $(BITCOUNT_H) $(MG_DATA_H)
MICROCORE_OBJ = $(MICROCORE_SRC:.c=.obj)
CORE_OBJ = $(MICROCORE_OBJ) $(EXTRACORE_SRC:.c=.obj)
WIN32_OBJ = $(WIN32_SRC:.c=.obj)
MINICORE_OBJ = $(MICROCORE_OBJ:..\=.\mini\) \
win32/Makefile view on Meta::CPAN
"default_inc_excludes_dot=$(DEFAULT_INC_EXCLUDES_DOT)" \
"LINK_FLAGS=$(LINK_FLAGS:"=\")" \
"optimize=$(OPTIMIZE:"=\")" \
"WIN64=$(WIN64)" \
"SKIP_CCHOME_CHECK=$(SKIP_CCHOME_CHECK)"
#
# Top targets
#
all : ..\git_version.h $(GLOBEXE) $(CONFIGPM) \
$(UNIDATAFILES) MakePPPort $(PERLEXE) Extensions_nonxs Extensions \
$(PERLSTATIC)
@echo Everything is up to date. '$(MAKE_BARE) test' to run test suite.
regnodes : ..\regnodes.h
..\regcomp$(o) : ..\regcomp.h ..\regcomp_internal.h ..\regnodes.h ..\regcharclass.h
..\regcomp_debug$(o) : ..\regcomp.h ..\regcomp_internal.h ..\regnodes.h ..\regcharclass.h
..\regcomp_invlist$(o) : ..\regcomp.h ..\regcomp_internal.h ..\regnodes.h ..\regcharclass.h
..\regcomp_study$(o) : ..\regcomp.h ..\regcomp_internal.h ..\regnodes.h ..\regcharclass.h
..\regcomp_trie$(o) : ..\regcomp.h ..\regcomp_internal.h ..\regnodes.h ..\regcharclass.h
..\regexec$(o) : ..\regnodes.h ..\regcharclass.h
reonly : regnodes $(CONFIG_H) ..\git_version.h $(GLOBEXE) $(CONFIGPM) \
$(UNIDATAFILES) $(PERLEXE) Extensions_reonly
@echo Perl and 're' are up to date.
static: $(PERLEXESTATIC)
#------------------------------------------------------------
$(GLOBEXE) : perlglob$(o)
$(LINK32) $(BLINK_FLAGS) $(LIBFILES) -out:$@ \
perlglob$(o) setargv$(o)
perlglob$(o) : perlglob.c
..\git_version.h : $(MINIPERL) ..\make_patchnum.pl
cd .. && miniperl -Ilib make_patchnum.pl && cd win32
# make sure that we recompile perl.c if the git version changes
..\perl$(o) : ..\git_version.h
..\config.sh : $(CFGSH_TMPL) config_sh.PL FindExt.pm $(MINIPERL)
$(MINIPERL) -I..\lib config_sh.PL -o ..\config.sh $(CFG_VARS) $(CFGSH_TMPL)
# This target is for when changes to the main config.sh happen.
# Edit config.vc, then make perl in a minimal configuration (i.e. with MULTI,
# ITHREADS, IMP_SYS and LARGE_FILES off), then make this target
# to regenerate config_H.vc.
regen_config_h:
$(MINIPERL) -I..\lib config_sh.PL --prebuilt $(CFG_VARS) $(CFGSH_TMPL) > ..\config.sh
$(MINIPERL) -I..\lib ..\configpm --chdir=..
-del /f $(CFGH_TMPL)
-$(MINIPERL) -I..\lib config_h.PL
rename config.h $(CFGH_TMPL)
$(CONFIGPM) : $(MINIPERL) ..\config.sh config_h.PL ..\git_version.h
$(MINIPERL) -I..\lib ..\configpm --chdir=..
$(XCOPY) ..\*.h $(COREDIR)\*.*
$(XCOPY) *.h $(COREDIR)\*.*
$(RCOPY) include $(COREDIR)\*.*
if not exist "$(FULLDIR)" mkdir "$(FULLDIR)"
$(MINIPERL) -I..\lib config_h.PL "CONFIG_H=$(CONFIG_H)"
$(CONFIG_H) : $(CONFIGPM)
# See the comment in Makefile.SH explaining this seemingly cranky ordering
win32/Makefile view on Meta::CPAN
$(CC) -c -I$(FULLDIR) -I. $(CFLAGS_O) $(CXX_FLAG) $(OBJOUT_FLAG)$@ perllib.c
!ENDIF
# We can't have miniperl.exe depend on git_version.h, as miniperl creates it
$(MINI_OBJ) : $(MINIDIR)\.exists $(CORE_NOCFG_H)
$(WIN32_OBJ) : $(CORE_H)
$(CORE_OBJ) : $(CORE_H)
$(DLL_OBJ) : $(CORE_H)
perldll.def : $(MINIPERL) $(CONFIGPM) ..\embed.fnc ..\makedef.pl create_perllibst_h.pl ..\git_version.h
$(MINIPERL) -I..\lib create_perllibst_h.pl
$(MINIPERL) -I..\lib -w ..\makedef.pl PLATFORM=win32 CONFIG_H=$(CONFIG_H) $(OPTIMIZE) $(DEFINES) $(BUILDOPT) \
CCTYPE=$(CCTYPE) TARG_DIR=..\ > perldll.def
$(PERLDLL): perldll.def $(PERLDLL_OBJ) $(PERLDLL_RES) Extensions_static
$(LINK32) -dll -def:perldll.def -out:$@ @Extensions_static @<<
$(BLINK_FLAGS) $(DELAYLOAD) $(LIBFILES) $(PERLDLL_OBJ) $(PERLDLL_RES)
<<
$(XCOPY) $(PERLIMPLIB) $(COREDIR)
$(PERLSTATICLIB): Extensions_static
$(LIB32) $(LIB_FLAGS) -out:$@ @Extensions_static @<<
$(PERLDLL_OBJ)
<<
$(XCOPY) $(PERLSTATICLIB) $(COREDIR)
$(PERLEXE_RES): perlexe.rc $(PERLEXE_MANIFEST) $(PERLEXE_ICO)
$(MINIDIR)\globals$(o) : $(GENERATED_HEADERS)
$(UUDMAP_H) $(MG_DATA_H) : $(BITCOUNT_H)
$(BITCOUNT_H) : $(GENUUDMAP)
$(GENUUDMAP) $(GENERATED_HEADERS)
$(GENUUDMAP_OBJ) : ..\mg_raw.h
$(GENUUDMAP) : $(GENUUDMAP_OBJ)
$(LINK32) -out:$@ @<<
win32/Makefile view on Meta::CPAN
installhtml : doc
$(RCOPY) $(HTMLDIR)\*.* $(INST_HTML)\*.*
inst_lib : $(CONFIGPM)
$(RCOPY) ..\lib $(INST_LIB)\*.*
$(UNIDATAFILES) ..\pod\perluniprops.pod : $(MINIPERL) $(CONFIGPM) ..\lib\unicore\mktables Extensions_nonxs
cd ..\lib\unicore && \
..\$(MINIPERL) -I.. mktables -P ..\..\pod -maketest -makelist -p -check $@ $(FIRSTUNIFILE)
minitest : $(CONFIG_H) $(MINIPERL) ..\git_version.h $(GLOBEXE) $(CONFIGPM) $(UNIDATAFILES)
$(XCOPY) $(MINIPERL) ..\t\$(NULL)
if exist ..\t\perl.exe del /f ..\t\perl.exe
rename ..\t\miniperl.exe perl.exe
$(XCOPY) $(GLOBEXE) ..\t\$(NULL)
# Note this perl.exe is miniperl
cd ..\t && perl.exe TEST base/*.t comp/*.t cmd/*.t run/*.t io/*.t re/*.t opbasic/*.t op/*.t uni/*.t perf/*.t pragma/*.t
test-prep : all utils ../pod/perltoc.pod
$(XCOPY) $(PERLEXE) ..\t\$(NULL)
$(XCOPY) $(PERLDLL) ..\t\$(NULL)
win32/Makefile view on Meta::CPAN
perl.exe harness $(TEST_ARGS) $(TEST_SWITCHES) $(TEST_FILES)
cd ..\win32
_clean :
-@$(DEL) miniperlmain$(o)
-@$(DEL) $(MINIPERL)
-@$(DEL) perlglob$(o)
-@$(DEL) perlmain$(o)
-@$(DEL) perlmainst$(o)
-@$(DEL) config.h
-@$(DEL) ..\git_version.h
-@$(DEL) $(GLOBEXE)
-@$(DEL) $(PERLEXE)
-@$(DEL) $(WPERLEXE)
-@$(DEL) $(PERLEXESTATIC)
-@$(DEL) $(PERLSTATICLIB)
-@$(DEL) $(PERLDLL)
-@$(DEL) $(CORE_OBJ)
-@$(DEL) $(GENUUDMAP) $(GENUUDMAP_OBJ) $(GENERATED_HEADERS)
-if exist $(MINIDIR) rmdir /s /q $(MINIDIR)
-if exist $(UNIDATADIR1) rmdir /s /q $(UNIDATADIR1)