Browse Source

fragments: argv.pl, bad-regex.pl

argv.pl: Print out the arguments to a script.

bad-regex.pl: What happens when you compile a broken regex?
master
Brennen Bearnes 1 year ago
parent
commit
99706feed3
2 changed files with 24 additions and 0 deletions
  1. +9
    -0
      home/fragments/argv.pl
  2. +15
    -0
      home/fragments/bad-regex.pl

+ 9
- 0
home/fragments/argv.pl View File

@ -0,0 +1,9 @@
#!/usr/bin/env perl
use warnings;
use strict;
use 5.10.0;
for (@ARGV) {
say;
}

+ 15
- 0
home/fragments/bad-regex.pl View File

@ -0,0 +1,15 @@
#!/usr/bin/env perl
use warnings;
use strict;
use 5.10.0;
my $intentionally_broken_regex = '[';
my $compiled_regex;
eval {
$compiled_regex = qr/$intentionally_broken_regex/;
};
if ($@) {
# There should be an error, so let's just quote everything:
$compiled_regex = qr/\Q$intentionally_broken_regex\E/
}

Loading…
Cancel
Save