CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Intermediate: Re: [sh0nuff] Issues fixing my old script: Edit Log

Veteran / Moderator

Oct 11, 2014, 3:59 AM

Views: 10497
Re: [sh0nuff] Issues fixing my old script

If this line:

if ($ccard =~ /(\d\d\d\d)[\-\s]?(\d\d\d\d)[\-\s]?(\d\d\d\d)[\-\s]?(\d\d\d\d)/) {

gives a successful match, then it will populate only $1, $2, $3 and $4, each with a group of four digits. So that $5 to $16 are uninitialized, which is the error that you get on the next line of code:

$foundcard = "$1$2$3$4$5$6$7$8$9$10$11$12$13$14$15$16";

Presumably what you want here is the 16 digits of the matched string, which you could do as follows:

$foundcard = "$1$2$3$4";

But that would not help for some code further down the stream, where you appear to be using $15, $13, etc. individually.

I find it very hard to believe that this script ever worked.

The script is generally poorly written, most of the code is just against all the good practices of the modern uses of Perl. If I were given such code to maintain, I would rewrite it completely. For example, I would be using arrays or hashes instead of variables having the same name with just a different number, which would avoid useless code repetition and cut down the code toprobably one third of its current length.

I can't say much more at this point, not knowing what this code is supposed to do.

(This post was edited by Laurent_R on Oct 11, 2014, 3:59 AM)

Edit Log:
Post edited by Laurent_R (Veteran) on Oct 11, 2014, 3:59 AM

Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives