use strict;
my $str = '#/usr/bin/python3
from bisect import bisect_right
def binary_search(vector,x):
i = bisect_right(vector,x)
if i != len(vector)+1 and vector[i-1] == x:
return i-1
return -1
def is_prime(vector,number):
return 1 if binary_search(vector,number) != -1 else 0
def prime_vector(num):
ret = []
for a in range(2,num+1):
if a == 2 or a == 3 or a == 5 or a == 7 or a == 11:
ret.append(a)
elif a %2 == 0 or a%3 == 0 or a%5 == 0 or a%7==0 or a%11 == 0:
continue
else:
ret.append(a)
return ret
number = int(input())
prime = prime_vector(number)
ret = []
p = 0
while number:
if is_prime(prime,number):
ret.append(number)
break
elif number%prime[p] == 0:
ret.append(prime[p])
number = int(number / prime[p])
else:
p = p + 1
for a in range((len(ret))):
print(ret[a],end=" ")
';
my $regex = qr/[\#(/)_\-\=\!\:]/mp;
if ( $str =~ /$regex/g ) {
print "Whole match is ${^MATCH} and its start/end positions can be obtained via \$-[0] and \$+[0]\n";
# print "Capture Group 1 is $1 and its start/end positions can be obtained via \$-[1] and \$+[1]\n";
# print "Capture Group 2 is $2 ... and so on\n";
}
# ${^POSTMATCH} and ${^PREMATCH} are also available with the use of '/p'
# Named capture groups can be called via $+{name}
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for Perl, please visit: http://perldoc.perl.org/perlre.html