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

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

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



Laurent_R
Veteran / Moderator

Oct 11, 2014, 3:59 AM


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

If this line:

Code
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:

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:

Code
$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