Hello Dave,

I made successfully seek routine, and almost convert this code, but my problems now are in "sprintf", take a little look in my (newbie) perl code:
#!/usr/bin/perl -w use warnings; use Fcntl qw(:seek); my $key = ""; my $read = ""; my @list; # getting value from /dev/mem open(MEM, "< /dev/mem") or die "Error while opening /dev/mem"; seek(MEM, 0xFFFF2, SEEK_SET); sysread(MEM, $read, 14); close(MEM); @list = split('', $read); foreach (@list) { $key = sprintf("%s%2.2x", $key, $_); print $key, "\n"; }
and:
$ sudo perl seek.pl Argument "à" isn't numeric in sprintf at seek.pl line 20. 00 Argument "\0" isn't numeric in sprintf at seek.pl line 20. 0000 Argument "ð" isn't numeric in sprintf at seek.pl line 20. 000000 00000000 0000000009 Argument "/" isn't numeric in sprintf at seek.pl line 20. 000000000900 00000000090000 0000000009000002 Argument "/" isn't numeric in sprintf at seek.pl line 20. 000000000900000200 00000000090000020000 0000000009000002000004 Argument "\0" isn't numeric in sprintf at seek.pl line 20. 000000000900000200000400 Argument "ü" isn't numeric in sprintf at seek.pl line 20. 00000000090000020000040000 Argument "Ä" isn't numeric in sprintf at seek.pl line 20. 0000000009000002000004000000
Should I use pack function or something like ?

thank's

In reply to Re^2: Translating ANSI C to Perl by otaviof
in thread Translating ANSI C to Perl by otaviof

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.