Skip to content

Commit

Permalink
no need to support older Perl versions
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Oct 28, 2011
1 parent 8721e7e commit 17d597a
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 25 deletions.
8 changes: 4 additions & 4 deletions lib/Mojo/Cookie.pm
Expand Up @@ -42,15 +42,15 @@ sub _tokenize {
while ($string) {

# Name
if ($string =~ s/$NAME_RE//o) {
if ($string =~ s/$NAME_RE//) {
my $name = $+{name};

# "expires" is a special case, thank you Netscape...
$string =~ s/^([^\;\,]+\,?[^\;\,]+)/"$1"/ if $name =~ /^expires$/i;

# Value
my $value;
if ($string =~ s/$VALUE_RE//o) {
if ($string =~ s/$VALUE_RE//) {
$value = $+{value};
unquote $value;
}
Expand All @@ -59,8 +59,8 @@ sub _tokenize {
push @token, [$name, $value];

# Separator
$string =~ s/$SEPARATOR_RE//o;
if ($string =~ s/$COOKIE_SEPARATOR_RE//o) {
$string =~ s/$SEPARATOR_RE//;
if ($string =~ s/$COOKIE_SEPARATOR_RE//) {
push @tree, [@token];
@token = ();
}
Expand Down
10 changes: 5 additions & 5 deletions lib/Mojo/DOM/CSS.pm
Expand Up @@ -87,7 +87,7 @@ sub _compile {

# Tokenize
my $pattern = [[]];
while ($css =~ /$TOKEN_RE/og) {
while ($css =~ /$TOKEN_RE/g) {
my ($separator, $element, $pc, $attrs, $combinator) =
($+{separator}, $+{element} // '', $+{pc}, $+{attrs}, $+{combinator});

Expand All @@ -104,7 +104,7 @@ sub _compile {

# Element
my $tag = '';
$element =~ s/$ELEMENT_RE//o and $tag = $self->_unescape($+{element});
$element =~ s/$ELEMENT_RE// and $tag = $self->_unescape($+{element});

# Subject
$selector->[0] = 'subject' if $tag =~ s/^\$//;
Expand All @@ -114,7 +114,7 @@ sub _compile {
push @$selector, ['tag', $tag];

# Class or ID
while ($element =~ /$CLASS_ID_RE/og) {
while ($element =~ /$CLASS_ID_RE/g) {

# Class
push @$selector, ['attribute', 'class', $self->_regex('~', $+{class})]
Expand All @@ -126,7 +126,7 @@ sub _compile {
}

# Pseudo classes
while ($pc =~ /$PSEUDO_CLASS_RE/og) {
while ($pc =~ /$PSEUDO_CLASS_RE/g) {

# "not"
if ($+{class} eq 'not') {
Expand All @@ -139,7 +139,7 @@ sub _compile {
}

# Attributes
while ($attrs =~ /$ATTR_RE/og) {
while ($attrs =~ /$ATTR_RE/g) {
my $key = $self->_unescape($+{key});
my $op = $+{op} // '';
my $value = $+{escaped} // $+{unescaped};
Expand Down
4 changes: 2 additions & 2 deletions lib/Mojo/DOM/HTML.pm
Expand Up @@ -100,7 +100,7 @@ sub parse {
# Tokenize
my $tree = ['root'];
my $current = $tree;
while ($html =~ m/\G$TOKEN_RE/ogcs) {
while ($html =~ m/\G$TOKEN_RE/gcs) {
my ($text, $pi, $comment, $cdata, $doctype, $tag) =
(@+{qw/text pi comment cdata doctype tag/});

Expand Down Expand Up @@ -137,7 +137,7 @@ sub parse {

# Attributes
my $attrs = {};
while ($attr =~ /$ATTR_RE/og) {
while ($attr =~ /$ATTR_RE/g) {
my $key = $cs ? $+{key} : lc($+{key});
my $value = $+{quoted} // $+{quoted_too} // $+{unquoted};

Expand Down
26 changes: 13 additions & 13 deletions lib/Mojo/JSON.pm
Expand Up @@ -61,7 +61,7 @@ sub decode {
$self->error('Missing or empty input.') and return unless $string;

# Remove BOM
$string =~ s/^$BOM_RE//go;
$string =~ s/^$BOM_RE//g;

# Wide characters
$self->error('Wide character in input.') and return
Expand All @@ -82,7 +82,7 @@ sub decode {
local $_ = $string;

# Leading whitespace
m/\G$WHITESPACE_RE/xogc;
m/\G$WHITESPACE_RE/xgc;

# Array
my $ref;
Expand All @@ -95,7 +95,7 @@ sub decode {
else { _exception('Expected array or object') }

# Leftover data
unless (m/\G$WHITESPACE_RE\z/xogc) {
unless (m/\G$WHITESPACE_RE\z/xgc) {
my $got = ref $ref eq 'ARRAY' ? 'array' : 'object';
_exception("Unexpected data after $got");
}
Expand Down Expand Up @@ -124,16 +124,16 @@ sub true {$TRUE}

sub _decode_array {
my @array;
until (m/\G$WHITESPACE_RE\]/xogc) {
until (m/\G$WHITESPACE_RE\]/xgc) {

# Value
push @array, _decode_value();

# Separator
redo if m/\G$WHITESPACE_RE,/xogc;
redo if m/\G$WHITESPACE_RE,/xgc;

# End
last if m/\G$WHITESPACE_RE\]/xogc;
last if m/\G$WHITESPACE_RE\]/xgc;

# Invalid character
_exception('Expected comma or right square bracket while parsing array');
Expand All @@ -144,27 +144,27 @@ sub _decode_array {

sub _decode_object {
my %hash;
until (m/\G$WHITESPACE_RE\}/xogc) {
until (m/\G$WHITESPACE_RE\}/xgc) {

# Quote
m/\G$WHITESPACE_RE"/xogc
m/\G$WHITESPACE_RE"/xgc
or _exception("Expected string while parsing object");

# Key
my $key = _decode_string();

# Colon
m/\G$WHITESPACE_RE:/xogc
m/\G$WHITESPACE_RE:/xgc
or _exception('Expected colon while parsing object');

# Value
$hash{$key} = _decode_value();

# Separator
redo if m/\G$WHITESPACE_RE,/xogc;
redo if m/\G$WHITESPACE_RE,/xgc;

# End
last if m/\G$WHITESPACE_RE\}/xogc;
last if m/\G$WHITESPACE_RE\}/xgc;

# Invalid character
_exception(q/Expected comma or right curly bracket while parsing object/);
Expand Down Expand Up @@ -238,7 +238,7 @@ sub _decode_string {
sub _decode_value {

# Leading whitespace
m/\G$WHITESPACE_RE/xogc;
m/\G$WHITESPACE_RE/xgc;

# String
return _decode_string() if m/\G"/gc;
Expand Down Expand Up @@ -341,7 +341,7 @@ sub _encode_values {
sub _exception {

# Leading whitespace
m/\G$WHITESPACE_RE/xogc;
m/\G$WHITESPACE_RE/xgc;

# Context
my $context = 'Malformed JSON: ' . shift;
Expand Down
2 changes: 1 addition & 1 deletion lib/Mojo/Util.pm
Expand Up @@ -426,7 +426,7 @@ sub punycode_decode {
my @output;

# Delimiter
if ($_[0] =~ s/(.*)$DELIMITER//os) { push @output, split //, $1 }
if ($_[0] =~ s/(.*)$DELIMITER//s) { push @output, split //, $1 }

# Decode (direct translation of RFC 3492)
while (length $_[0]) {
Expand Down

0 comments on commit 17d597a

Please sign in to comment.