A problem with writeI2cEeprom.pl

45 getopt('at:'); 46 our ( $opt_a, $opt_t ); ... 75 } elsif ( $opt_a > $eeMax ) { ... 126 if ( $opt_a + $dataLen > $eeMax ) { 127 $dataLen = $dataLen - ( $opt_a + $dataLen - $eeMax ); 128 } 129 # 130 # convert start address if hex value used 131 if ( substr( $opt_a, 0, 2 ) == "0x" ) { 132 $opt_a = hex($opt_a); 133 }

If $opt_a contains, for example '0xAB', then lines 75, 126 and 127 will not work correctly.

Lines 130 to 133 should be moved before $opt_a is used in a mathematical context.

Some problems with readI2cEeprom.pl

36 getopt('alo:'); 37 # 38 our ( $opt_a, $opt_l, $opt_o, $opt_h, $opt_v ); ... 53 if ( $opt_a > $eeMax ) { ... 102 # convert start address if hex value used 103 if ( substr( $opt_a, 0, 2 ) == "0x" ) { 104 $opt_a = hex($opt_a); 105 }

Same problem as with the other file. Lines 102 to 105 should be moved before $opt_a is used in a mathematical context.

79 if ( !$opt_o == undef ) {

Incorrect use of undef. That should be if ( !defined $opt_o ) {

Naked blocks are fun! -- Randal L. Schwartz, Perl hacker

In reply to Re: EEPROM on i2c Real Time Clock Modules by jwkrahn
in thread EEPROM on i2c Real Time Clock Modules by anita2R

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.