Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Thank you for your quick and thorough reply. After looking through your revision I can quickly see how my nested control structures were exaggerated nearly to the point of obnoxious. In particular I really liked your use of:
for my $i (map {$_ * 2} 0 .. $#cardNum / 2) { $cardNum[$i] *= 2; $cardNum[$i] -= 9 if $cardNum[$i] >= 10; }
to cycle through @cardNum. I had thought of trying to use map, but wasn't quite sure how to pick every other element. The only part I don't quite understand is:
return <<INFO; Card Number: $cardNum Issuer: $issuers{$iDigit} INFO
I can see that the subroutine is returning a block called INFO, but I don't quite get the syntax behind the way you defined that block. Is there a name for this style of definition that I can research for a better understanding? Thank you again for reviewing my code. I'm a bit disappointed with myself looking back, but I suppose sophisticated code comes with time and practice.

In reply to Re^2: Code Review: Simple Credit Card Number Validation by marquezc329
in thread Code Review: Simple Credit Card Number Validation by marquezc329

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (1)
As of 2024-04-23 16:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found