Re: Getting a / when regex should produce nothing
See what happens if you replace the 2 lines between the "should be"s with if ($article_file =~ /^([a-zA-Z0-9_-]*\.html)$/) {$article_file = $1} I've can't recall seeing 'undef my' before. my $error = undef; is more typical. How is this routine executed? Under ModPerl::Registry? cmac On Apr 24, 2010, at 7:47 PM, Chris Bennett wrote: On 04/24/10 21:38, Chris Bennett wrote: When I run this first time, with no values from form, I get $article_file being a / when it should be nothing. I just can't see the error. I have tried variations with \w and dash at beginning and end, but no go. Debug shows blank at A, / at B #!/usr/bin/perl $VERSION = 1.0.0; use warnings; no warnings 'uninitialized'; use strict; #use Apache::Constants qw(:common); use Apache::Request(); #use Apache::Cookie(); use MyPerl::Articulator qw(get_template print_template print_text submit_changes backup_server see_html template_form load_template); our $debug = 1; delete $ENV{PATH}; my $r = Apache->request; my $q = Apache::Request->new($r, POST_MAX => 100, DISABLE_UPLOADS => 1); my $site_url = "www.example.com"; my $site_directory = "/var/www/htdocs/users/example.com"; my $site_name = "Example!"; my $secure = 1; my $article_directory = "articles"; undef my $error; undef my $article_title; undef my $article_backup_file; undef my $article_file; $article_file = $q->param("articlefilename"); if ($debug) { $error .= qq{$article_file};} should be if ($debug) { $error .= qq{A $article_file};} $article_file =~ m/^([a-zA-Z0-9_-]*\.html)$/; $article_file = $1; if ($debug) { $error .= qq{$article_file};} should be if ($debug) { $error .= qq{B $article_file};}
Re: Getting a / when regex should produce nothing
On 04/24/10 21:38, Chris Bennett wrote: When I run this first time, with no values from form, I get $article_file being a / when it should be nothing. I just can't see the error. I have tried variations with \w and dash at beginning and end, but no go. Debug shows blank at A, / at B #!/usr/bin/perl $VERSION = 1.0.0; use warnings; no warnings 'uninitialized'; use strict; #use Apache::Constants qw(:common); use Apache::Request(); #use Apache::Cookie(); use MyPerl::Articulator qw(get_template print_template print_text submit_changes backup_server see_html template_form load_template); our $debug = 1; delete $ENV{PATH}; my $r = Apache->request; my $q = Apache::Request->new($r, POST_MAX => 100, DISABLE_UPLOADS => 1); my $site_url = "www.example.com"; my $site_directory = "/var/www/htdocs/users/example.com"; my $site_name = "Example!"; my $secure = 1; my $article_directory = "articles"; undef my $error; undef my $article_title; undef my $article_backup_file; undef my $article_file; $article_file = $q->param("articlefilename"); if ($debug) { $error .= qq{$article_file};} should be if ($debug) { $error .= qq{A $article_file};} $article_file =~ m/^([a-zA-Z0-9_-]*\.html)$/; $article_file = $1; if ($debug) { $error .= qq{$article_file};} should be if ($debug) { $error .= qq{B $article_file};}
Getting a / when regex should produce nothing
When I run this first time, with no values from form, I get $article_file being a / when it should be nothing. I just can't see the error. I have tried variations with \w and dash at beginning and end, but no go. Debug shows blank at A, / at B #!/usr/bin/perl $VERSION = 1.0.0; use warnings; no warnings 'uninitialized'; use strict; #use Apache::Constants qw(:common); use Apache::Request(); #use Apache::Cookie(); use MyPerl::Articulator qw(get_template print_template print_text submit_changes backup_server see_html template_form load_template); our $debug = 1; delete $ENV{PATH}; my $r = Apache->request; my $q = Apache::Request->new($r, POST_MAX => 100, DISABLE_UPLOADS => 1); my $site_url = "www.example.com"; my $site_directory = "/var/www/htdocs/users/example.com"; my $site_name = "Example!"; my $secure = 1; my $article_directory = "articles"; undef my $error; undef my $article_title; undef my $article_backup_file; undef my $article_file; $article_file = $q->param("articlefilename"); if ($debug) { $error .= qq{$article_file};} $article_file =~ m/^([a-zA-Z0-9_-]*\.html)$/; $article_file = $1; if ($debug) { $error .= qq{$article_file};} $article_backup_file = $article_file; $article_backup_file =~ s/\.html$/_backup.html/; undef my $body; Thanks Chris Bennett -- A human being should be able to change a diaper, plan an invasion, butcher a hog, conn a ship, design a building, write a sonnet, balance accounts, build a wall, set a bone, comfort the dying, take orders, give orders, cooperate, act alone, solve equations, analyze a new problem, pitch manure, program a computer, cook a tasty meal, fight efficiently, die gallantly. Specialization is for insects. -- Robert Heinlein