Gossamer Forum
Home : General : Perl Programming :

Annoying....

Quote Reply
Annoying....
Ok, I know I'm not very good with Regex, but I can't work out why this bit won't work.

foreach $line (@htaccess)
{
if ($usernamenew =~ /^$line/) { &username_error; } else { print "ok"; }
}
}

The format of the .htaccess file is;

andy::password
test::somepassword
Test2::anotherpassword

Any ideas why this isn't working? Its got me stumped. I've been reading through my Perl book to try and work out why it won't work, but havn't had any success.

They say that using

$word = "hello";
$word =~ /^hell/;

will work, but my code doesn't seem to want to Frown

Any ideas?

Thanks

Andy

webmaster@ace-installer.com
http://www.ace-installer.com
Quote Reply
Re: Annoying.... In reply to
Think you may just have things 'round the wrong way.

if ($line =~ /^$usernamenew/)

- Mark

Astro-Boy!!
http://www.zip.com.au/~astroboy/
Quote Reply
Re: Annoying.... In reply to
Is the IF statement supposed to produce an error if the match succeeds coz thats what it is doing

Also I wouldn't have thought it's a good idea to open your .htaccess files every time the script is run.

Installs:http://wiredon.net/gt
FAQ:http://www.perlmad.com

Quote Reply
Re: Annoying.... In reply to
Paul, yes it is meant to produce an error. The reson I am doing the search is to see that the username doesn't already exist Wink

Mark, thanks, that worked great Smile Its funny how you never tihnk of the obviouse stuff when writing it yourself!

Andy

webmaster@ace-installer.com
http://www.ace-installer.com