perl

Accessing IPv6 resolvable URL with port (e.g. localhost:12345) results in Bad Address in Strawberry Perl 5.30.1

可紊 提交于 2021-02-07 16:20:30
问题 When using strawberry perl 5.30.1 under Windows 10 with IPv6 enabled, URLs with Portnumbers cannot be resolved properly due to what appears to be a bug in the DNS parser of Perl. For the following test, we have a simple webserver listening on Port 8810 for all interfaces. Port 12345 does NOT host anything. Following is the script we use for reproduction: use strict; use warnings; use LWP::UserAgent; my $ua = LWP::UserAgent->new(); my $result=$ua->get("http://localhost:8810/"); print "(DNS

Accessing IPv6 resolvable URL with port (e.g. localhost:12345) results in Bad Address in Strawberry Perl 5.30.1

时光怂恿深爱的人放手 提交于 2021-02-07 16:06:01
问题 When using strawberry perl 5.30.1 under Windows 10 with IPv6 enabled, URLs with Portnumbers cannot be resolved properly due to what appears to be a bug in the DNS parser of Perl. For the following test, we have a simple webserver listening on Port 8810 for all interfaces. Port 12345 does NOT host anything. Following is the script we use for reproduction: use strict; use warnings; use LWP::UserAgent; my $ua = LWP::UserAgent->new(); my $result=$ua->get("http://localhost:8810/"); print "(DNS

Google BigQuery possible to do Case-Insensitive REGEXP_Match?

天大地大妈咪最大 提交于 2021-02-07 13:46:00
问题 In Google BigQuery I wanted to check for 'confirm' or 'Confirm': REGEXP_CONTAINS(h.page.PagePath, r'Confirm') or REGEXP_CONTAINS(h.page.PagePath, r'confirm')) I am a Perl person and in Perl we do $foo =~ /confirm/i # case-insensitive Does Google BigQuery have any flags to modify REGEXP_MATCH? I did not see any examples in their online docs. 回答1: REGEXP_CONTAINS uses RE2 library, so you may use inline modifiers like this: REGEXP_CONTAINS(h.page.PagePath, r'(?i)confirm') ^^^^ See RE2 docs: (

Google BigQuery possible to do Case-Insensitive REGEXP_Match?

本秂侑毒 提交于 2021-02-07 13:45:39
问题 In Google BigQuery I wanted to check for 'confirm' or 'Confirm': REGEXP_CONTAINS(h.page.PagePath, r'Confirm') or REGEXP_CONTAINS(h.page.PagePath, r'confirm')) I am a Perl person and in Perl we do $foo =~ /confirm/i # case-insensitive Does Google BigQuery have any flags to modify REGEXP_MATCH? I did not see any examples in their online docs. 回答1: REGEXP_CONTAINS uses RE2 library, so you may use inline modifiers like this: REGEXP_CONTAINS(h.page.PagePath, r'(?i)confirm') ^^^^ See RE2 docs: (

how to get rid of `Wide character in print at`?

北慕城南 提交于 2021-02-07 13:24:59
问题 I have file /tmp/xxx with next content: 00000000 D0 BA D0 B8 │ D1 80 D0 B8 │ D0 BB D0 B8 │ D0 BA к и р и л и к When I read content of file and print it I get the error: Wide character in print at ... The source is: use utf8; open my $fh, '<:encoding(UTF-8)', '/tmp/xxx'; print scalar <$fh> The output from print is: кирилик 回答1: You're printing to STDOUT which isn't expecting UTF8. Add binmode(STDOUT, "encoding(UTF-8)"); to change that on the already opened handle. 回答2: The use utf8 means Perl

how to get rid of `Wide character in print at`?

混江龙づ霸主 提交于 2021-02-07 13:24:32
问题 I have file /tmp/xxx with next content: 00000000 D0 BA D0 B8 │ D1 80 D0 B8 │ D0 BB D0 B8 │ D0 BA к и р и л и к When I read content of file and print it I get the error: Wide character in print at ... The source is: use utf8; open my $fh, '<:encoding(UTF-8)', '/tmp/xxx'; print scalar <$fh> The output from print is: кирилик 回答1: You're printing to STDOUT which isn't expecting UTF8. Add binmode(STDOUT, "encoding(UTF-8)"); to change that on the already opened handle. 回答2: The use utf8 means Perl

Does perlbrew work on Windows?

烈酒焚心 提交于 2021-02-07 13:13:10
问题 Using ActiveState 5.8.8 on Windows XP, I would like to install a more recent Perl for testing/migration. 回答1: Someday, we'll be out of the days when we thought we were limited to only one computer. When I want to test this sort of stuff, I make virtual machines. I keep a clean, base installation around, make copies of that stuff, configure them in multiple ways, and blow them up however I like. If I do something bad, I can either go back to the base installation easily or revert to a snapshot

How do you check the success of open (file) in Perl?

孤人 提交于 2021-02-07 11:32:37
问题 The following (not very Perl-ish) code #!/usr/bin/perl if (! -e "mydir/") { print "directory doesn't exist.\n"; } open (my $fh, ">", "mydir/file.txt"); if ($fh) { print "file opened.\n"; print $fh; print $fh "some text\n" or die "failed to write to file.\n"; close ($fh); } else { print "failed to open file.\n"; } produces the output such as this directory doesn't exist. file opened. failed to write to file. GLOB(0x...some-hex-digits...) Why is $fh not equivalent to false following the open

How do you check the success of open (file) in Perl?

血红的双手。 提交于 2021-02-07 11:32:33
问题 The following (not very Perl-ish) code #!/usr/bin/perl if (! -e "mydir/") { print "directory doesn't exist.\n"; } open (my $fh, ">", "mydir/file.txt"); if ($fh) { print "file opened.\n"; print $fh; print $fh "some text\n" or die "failed to write to file.\n"; close ($fh); } else { print "failed to open file.\n"; } produces the output such as this directory doesn't exist. file opened. failed to write to file. GLOB(0x...some-hex-digits...) Why is $fh not equivalent to false following the open

What is happening when my() is conditional?

南笙酒味 提交于 2021-02-07 11:22:29
问题 Compare using perl -w -Mstrict : # case Alpha print $c; ... # case Bravo if (0) { my $c = 1; } print $c; ... # case Charlie my $c = 1 if 0; print $c; Alpha and Bravo both complain about the global symbol not having an explicit package name, which is to be expected. But Charlie does not give the same warning, only that the value is uninitialized, which smells a lot like: # case Delta my $c; print $c; What exactly is going on under the hood? (Even though something like this should never be