If I run this script as it is, it works.
But why does this not work with cgi?
When I use _\01_ instead of _\00_ it works with cgi too.
#!/usr/bin/env perl
use warnings;
use 5.012;
### script_1.cgi #########################################
my @array = ( '1524', '2.18 MB', '09/23/03', '_cool_name_', 'type' );
my $row = join "_\00_", @array;
say $row;
# submit $row to script_2.cgi
### script_2.cgi #########################################
# ...
# my $row = $cgi->param('row');
# my $name;
if ( $row =~ /_\00_([^\00]+)_\00_type\z/ ) {
# $name = $1;
say "Name: <$1>";
} else {
die "<$row> $!";
}
# Software error:
# <1524_�_2.18 MB_�_09/23/03_�__cool_name__�_type> at script_2.cgi line of "die "<$row> $!";"
Works for me, says
_cool_name_. You’re probably running afoul of CGI.pm using\0already for itself, but since you did not post your complete code, no one can say for sure.I’ll use the opportunity to unask the question. The lessons you should learn are: