Hello all;

I am not new to perl but I am no where near great.

I was wondering if you could help me revise this so I am not getting the Hash depreciation error?

The following code works, but I still receive an error.

#!/usr/bin/perl -w use strict; use IO::Socket::INET; $| = 1; my @bin_data; my @hex; my $count; my %h2b = (0 => "0000", 1 => "0001", 2 => "0010", 3 => "0011", 4 => "0100", 5 => "0101", 6 => "0110", 7 => "0111", 8 => "1000", 9 => "1001", a => "1010", b => "1011", c => "1100", d => "1101", e => "1110", f => "1111", A => "1010", B => "1011", C => "1100", D => "1101", E => "1110", F => "1111", ); my $out = "12315141800F1F5F3F3F63410026DE8F45"; print "hex string = $out\n"; my $c=0; for ($count = 0; $count + 2 <= length($out); $count += 2) { $hex[$c] = substr($out,$count,2); $bin_data[$c] = %h2b->{substr($hex[$c],0,1)}.%h2b->{substr($he +x[$c],1,1)}; print "count=$c hex=$hex[$c] bin=$bin_data[$c]\n"; $c++; }

when i run it this is the output and error i receive.

Using a hash as a reference is deprecated at ./hexconvt.pl line 27. Using a hash as a reference is deprecated at ./hexconvt.pl line 27. hex string = 12315141800F1F5F3F3F63410026DE8F45 count=0 hex=12 bin=00010010 count=1 hex=31 bin=00110001 count=2 hex=51 bin=01010001 count=3 hex=41 bin=01000001 count=4 hex=80 bin=10000000 count=5 hex=0F bin=00001111 count=6 hex=1F bin=00011111 count=7 hex=5F bin=01011111 count=8 hex=3F bin=00111111 count=9 hex=3F bin=00111111 count=10 hex=63 bin=01100011 count=11 hex=41 bin=01000001 count=12 hex=00 bin=00000000 count=13 hex=26 bin=00100110 count=14 hex=DE bin=11011110 count=15 hex=8F bin=10001111 count=16 hex=45 bin=01000101

Any help would be greatly appreciated not depreciated.

Thanks in advance.


In reply to Hash Depriciated by Thresh

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.