Skip to content

Commit dc247f5

Browse files
committed
Prefer q{} over ''
1 parent d8ffd8d commit dc247f5

File tree

10 files changed

+32
-32
lines changed

10 files changed

+32
-32
lines changed

lib/WWW/Mechanize.pm

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1862,7 +1862,7 @@ sub form_with {
18621862
unless ( defined $spec{$_} ) { # case $attr => undef
18631863
qq{no $_};
18641864
}
1865-
elsif ( $spec{$_} eq '' ) { # case $attr=> ''
1865+
elsif ( $spec{$_} eq q{} ) { # case $attr=> ''
18661866
qq{empty $_};
18671867
}
18681868
else { # case $attr => $value
@@ -1871,7 +1871,7 @@ sub form_with {
18711871
} # case $attr => undef
18721872
sort keys %spec # sort keys to get deterministic messages
18731873
)
1874-
: ''
1874+
: q{}
18751875
)
18761876
. '. The first one was used.'
18771877
);
@@ -2244,7 +2244,7 @@ sub tick {
22442244
# Sometimes the HTML is malformed and there is no value for the check
22452245
# box, so we just return if the value passed is an empty string
22462246
# (and the form input is found)
2247-
if ($value eq '') {
2247+
if ($value eq q{}) {
22482248
$input->value($set ? $value : undef);
22492249
return;
22502250
}
@@ -2800,7 +2800,7 @@ sub save_content {
28002800
}
28012801

28022802
open( my $fh, '>', $filename ) or $self->die( "Unable to create $filename: $!" );
2803-
if ((my $binmode = delete($opts{binmode}) || '') || ($self->content_type() !~ m{^text/})) {
2803+
if ((my $binmode = delete($opts{binmode}) || q{}) || ($self->content_type() !~ m{^text/})) {
28042804
if (length($binmode) && (substr($binmode, 0, 1) eq ':')) {
28052805
binmode $fh, $binmode;
28062806
}
@@ -2828,7 +2828,7 @@ will be used as a file name.
28282828

28292829
sub _get_fh_default_stdout {
28302830
my $self = shift;
2831-
my $p = shift || '';
2831+
my $p = shift || q{};
28322832
if ( !$p ) {
28332833
return \*STDOUT;
28342834
} elsif ( !ref($p) ) {
@@ -2865,7 +2865,7 @@ sub dump_links {
28652865

28662866
for my $link ( $self->links ) {
28672867
my $url = $absolute ? $link->url_abs : $link->url;
2868-
$url = '' if not defined $url;
2868+
$url = q{} if not defined $url;
28692869
print {$fh} $url, "\n";
28702870
}
28712871
return;
@@ -2890,7 +2890,7 @@ sub dump_images {
28902890

28912891
for my $image ( $self->images ) {
28922892
my $url = $absolute ? $image->url_abs : $image->url;
2893-
$url = '' if not defined $url;
2893+
$url = q{} if not defined $url;
28942894
print {$fh} $url, "\n";
28952895
}
28962896
return;
@@ -3178,7 +3178,7 @@ sub _update_page {
31783178

31793179
$self->{status} = $res->code;
31803180
$self->{base} = $res->base;
3181-
$self->{ct} = $res->content_type || '';
3181+
$self->{ct} = $res->content_type || q{};
31823182

31833183
if ( $res->is_success ) {
31843184
$self->{uri} = $self->{redirected_uri};
@@ -3225,7 +3225,7 @@ sub _taintedness {
32253225
return $_taintbrush if tainted( $_taintbrush );
32263226

32273227
# Let's try again. Maybe somebody cleaned those.
3228-
$_taintbrush = substr(join('', grep { defined } @ARGV, %ENV), 0, 0);
3228+
$_taintbrush = substr(join(q{}, grep { defined } @ARGV, %ENV), 0, 0);
32293229
return $_taintbrush if tainted( $_taintbrush );
32303230

32313231
# If those don't work, go try to open some file from some unsafe
@@ -3485,7 +3485,7 @@ sub _link_from_token {
34853485
my $name;
34863486
if ( $tag eq 'a' ) {
34873487
$text = $parser->get_trimmed_text("/$tag");
3488-
$text = '' unless defined $text;
3488+
$text = q{} unless defined $text;
34893489

34903490
my $onClick = $attrs->{onclick};
34913491
if ( $onClick && ($onClick =~ /^window\.open\(\s*'([^']+)'/) ) {

t/form_with_fields.t

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ ok( $mech->success, "Fetched $uri" ) or die q{Can't get test page};
111111
like(
112112
exception {
113113
$mech->submit_form(
114-
with_fields => { 'xx' => '' },
114+
with_fields => { 'xx' => q{} },
115115
);
116116
},
117117
qr/There is no form with the requested fields/,
@@ -124,7 +124,7 @@ ok( $mech->success, "Fetched $uri" ) or die q{Can't get test page};
124124
like(
125125
exception {
126126
$mech->submit_form(
127-
with_fields => { '1a' => '' },
127+
with_fields => { '1a' => q{} },
128128
form_number => 2,
129129
);
130130
},
@@ -165,7 +165,7 @@ ok( $mech->success, "Fetched $uri" ) or die q{Can't get test page};
165165
is(
166166
exception {
167167
$mech->submit_form(
168-
with_fields => { 'x' => '' },
168+
with_fields => { 'x' => q{} },
169169
form_name => '3rd_form_ambiguous',
170170
);
171171
},
@@ -179,7 +179,7 @@ ok( $mech->success, "Fetched $uri" ) or die q{Can't get test page};
179179
is(
180180
exception {
181181
$mech->submit_form(
182-
with_fields => { '1b' => '', 'opt[2]' => '' },
182+
with_fields => { '1b' => q{}, 'opt[2]' => q{} },
183183
);
184184
},
185185
undef,

t/form_with_fields_passthrough_params.t

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ ok( $mech->success, "Fetched $uri" ) or die q{Can't get test page};
7171
like(
7272
exception {
7373
$mech->submit_form(
74-
with_fields => { 'xx' => '' },
74+
with_fields => { 'xx' => q{} },
7575
);
7676
},
7777
qr/There is no form with the requested fields/,
@@ -84,7 +84,7 @@ ok( $mech->success, "Fetched $uri" ) or die q{Can't get test page};
8484
like(
8585
exception {
8686
$mech->submit_form(
87-
with_fields => { '1a' => '' },
87+
with_fields => { '1a' => q{} },
8888
form_number => 2,
8989
);
9090
},
@@ -125,7 +125,7 @@ ok( $mech->success, "Fetched $uri" ) or die q{Can't get test page};
125125
is(
126126
exception {
127127
$mech->submit_form(
128-
with_fields => { 'x' => '' },
128+
with_fields => { 'x' => q{} },
129129
form_name => '3rd_form_ambiguous',
130130
);
131131
},
@@ -139,7 +139,7 @@ ok( $mech->success, "Fetched $uri" ) or die q{Can't get test page};
139139
is(
140140
exception {
141141
$mech->submit_form(
142-
with_fields => { '1b' => '', 'opt[2]' => '' },
142+
with_fields => { '1b' => q{}, 'opt[2]' => q{} },
143143
);
144144
},
145145
undef,

t/image-parse.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ $mech->get( $uri );
8383
ok( $mech->success, "Fetched $uri" ) or die q{Can't get test page};
8484

8585
eval { @images = $mech->find_all_images(); };
86-
is($@,'','survived eval');
86+
is($@,q{},'survived eval');
8787
is( scalar @images, 2, 'Exactly two images' );
8888

8989
my $css_first = $images[0];

t/local/LocalServer.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ sub spawn {
9999
close $fh;
100100
push @{$self->{delete}},$logfile;
101101
$self->{logfile} = $logfile;
102-
my $web_page = delete $args{file} || "";
102+
my $web_page = delete $args{file} || q{};
103103

104104
my $server_file = path('t/local/log-server')->absolute;
105105
my @opts;

t/local/form.t

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,12 @@ is( $mech->current_form, $form_number_1,
8989

9090
my $form_number_2 = $mech->form_number(2);
9191
$form_with =
92-
$mech->form_with( class => 'test', foo => '', bar => undef, { n => 2 } );
92+
$mech->form_with( class => 'test', foo => q{}, bar => undef, { n => 2 } );
9393
is( $form_with, $form_number_2, 'Can select nth form with ambiguous criteria' );
9494

9595
is( scalar @warnings, 0, 'no warnings so far' );
9696
$mech->quiet(0);
97-
$form_with = $mech->form_with( class => 'test', foo => '', bar => undef );
97+
$form_with = $mech->form_with( class => 'test', foo => q{}, bar => undef );
9898
is( $form_with, $form_number_1,
9999
'form_with - can select form with ambiguous criteria' );
100100
is( scalar @warnings, 1, 'form_with - got one warning' );

t/local/select_multiple.t

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ eval {
4949
}
5050
);
5151
};
52-
is( $@, '', 'submit_form, second value' );
52+
is( $@, q{}, 'submit_form, second value' );
5353
like( $mech->uri, qr/chanId=119/, '... and the second value was set');
5454

5555
eval {
@@ -58,7 +58,7 @@ eval {
5858
chanId => 119,
5959
);
6060
};
61-
is( $@, '', 'set_fields, second value' );
61+
is( $@, q{}, 'set_fields, second value' );
6262
like( $mech->uri, qr/chanId=119/, '... and the second value was set');
6363

6464

@@ -70,7 +70,7 @@ eval {
7070
}
7171
);
7272
};
73-
is( $@, '', 'submit_form, second value as array' );
73+
is( $@, q{}, 'submit_form, second value as array' );
7474
like( $mech->uri, qr/chanId=119/, '... and the second value was set');
7575

7676

@@ -81,7 +81,7 @@ eval {
8181
);
8282
$mech->submit;
8383
};
84-
is( $@, '', 'field, second value' );
84+
is( $@, q{}, 'field, second value' );
8585
like( $mech->uri, qr/chanId=119/, '... and the second value was set');
8686

8787

@@ -92,7 +92,7 @@ eval {
9292
);
9393
$mech->submit;
9494
};
95-
is( $@, '', 'field, second value as array' );
95+
is( $@, q{}, 'field, second value as array' );
9696
like( $mech->uri, qr/chanId=119/, '... and the second value was set');
9797

9898

@@ -104,7 +104,7 @@ eval {
104104
}
105105
);
106106
};
107-
is( $@, '', 'submit_form, first value' );
107+
is( $@, q{}, 'submit_form, first value' );
108108
like( $mech->uri, qr/chanId=130/, '... and the first value was set');
109109

110110

t/local/submit.t

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ is( $mech->uri, $server->url, 'Got the correct page' );
2525
ok( $response->is_success, 'Got local page' ) or die 'cannot even fetch local page';
2626
ok( $mech->is_html, 'is HTML' );
2727

28-
is( $mech->value('upload'), '', 'Hopefully no upload happens');
28+
is( $mech->value('upload'), q{}, 'Hopefully no upload happens');
2929

3030
$mech->field(query => 'foo'); # Filled the 'q' field
3131

@@ -35,7 +35,7 @@ ok( $response->is_success, 'Can click "submit" ("submit" button)');
3535

3636
like($mech->content, qr/\bfoo\b/i, 'Found "Foo"');
3737

38-
is( $mech->value('upload'), '', 'No upload happens' );
38+
is( $mech->value('upload'), q{}, 'No upload happens' );
3939

4040
SKIP: {
4141
skip 'Test::Memory::Cycle not installed', 1 unless $canTMC;

t/save_content.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,5 +54,5 @@ sub slurp {
5454
my $name = shift;
5555

5656
open( my $fh, '<', $name ) or die "Can't open $name: $!\n";
57-
return join '', <$fh>;
57+
return join q{}, <$fh>;
5858
}

t/tick.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ $mech->tick('foo','hello');
2222
$mech->tick('foo','bye');
2323
$mech->untick('foo','hello');
2424

25-
$mech->tick('no_value', '');
25+
$mech->tick('no_value', q{});
2626

2727
my $form = $mech->form_number(1);
2828
isa_ok( $form, 'HTML::Form' );

0 commit comments

Comments
 (0)