Hash

[b][red]This message was edited by davidrtg at 2003-11-6 9:5:47[/red][/b][hr]
Is there any way to print out the value in a hash memory location or am I way off? When I print a scalar I get a HASH value but I would like to see what that value is literally?

ie.
print "$hash"; this prints HASH(0x83b482c)
$value = HASH(0x83b482c); print "$value";


Comments

  • : Is there any way to print out the value in a hash memory location or
    : am I way off?
    Yeah, sounds like it.

    : When I print a scalar I get a HASH value but I would like to see
    : what that value is literally?
    :
    : ie.
    : print "$hash"; this prints HASH(0x83b482c)
    : $value = HASH(0x83b482c); print "$value";
    Hmmm...$hash actually contains a reference to a hash. I am 99% certain that assigning the value that is printing will not work. Otherwise, you'd be able to do direct memory access in Perl!!!

    If you can give me a bit more context about the problem you're trying to solve I might just be able to tell you something useful... ;-)

    Jonathan

    ###
    for(74,117,115,116){$::a.=chr};(($_.='qwertyui')&&
    (tr/yuiqwert/her anot/))for($::b);for($::c){$_.=$^X;
    /(p.{2}l)/;$_=$1}$::b=~/(..)$/;print("$::a$::b $::c hack$1.");

  • : : Is there any way to print out the value in a hash memory location or
    : : am I way off?
    : Yeah, sounds like it.
    :
    : : When I print a scalar I get a HASH value but I would like to see
    : : what that value is literally?
    : :
    : : ie.
    : : print "$hash"; this prints HASH(0x83b482c)
    : : $value = HASH(0x83b482c); print "$value";
    : Hmmm...$hash actually contains a reference to a hash. I am 99% certain that assigning the value that is printing will not work. Otherwise, you'd be able to do direct memory access in Perl!!!
    :
    : If you can give me a bit more context about the problem you're trying to solve I might just be able to tell you something useful... ;-)
    :
    : Jonathan
    :
    : ###
    : for(74,117,115,116){$::a.=chr};(($_.='qwertyui')&&
    : (tr/yuiqwert/her anot/))for($::b);for($::c){$_.=$^X;
    : /(p.{2}l)/;$_=$1}$::b=~/(..)$/;print("$::a$::b $::c hack$1.");
    :
    :

    What is going on is we are running an xmlrpc to update information on a website (from what I understand).

    [code]
    use Frontier::Client;
    $uri = 'http://xmlrpc.website.com/updates/';
    $server = Frontier::Client->new(url => $uri);
    $server->call($method, $args);
    [/code]
    $method is a method call and $args is a bunch of arguments ie. (argument1 => $argument...)the method uses. There is something wrong with a/some value(s) in $args and causing the call() to fail. When I print out the values in $args some of them come out as HASH(). I'm trying to see what those values are to make sure they are formated correctly.

    I'm thinking i'm going to have to go back in the code and print things out there. Would be easier if I was "able to do direct memory access in Perl!!!" but it doesn't seem that way?

  • : What is going on is we are running an xmlrpc to update information
    : on a website (from what I understand).
    :
    : [code]
    : use Frontier::Client;
    : $uri = 'http://xmlrpc.website.com/updates/';
    : $server = Frontier::Client->new(url => $uri);
    : $server->call($method, $args);
    : [/code]
    : $method is a method call and $args is a bunch of arguments ie.
    : (argument1 => $argument...)the method uses. There is something wrong
    : with a/some value(s) in $args and causing the call() to fail. When I
    : print out the values in $args some of them come out as HASH(). I'm
    : trying to see what those values are to make sure they are formated
    : correctly.
    OK, what happens if you do:-
    print $args;
    I'm guessing you get the HASH(0xSomeAddress)? In that case, $args is not a hash, but a hashref (a reference to a hash). So, you need to dereference it.

    my %arghash = %$args;

    Or you can use the -> operator to access a particular key:-

    print $args->{'somekey'};

    Or print all entries like this:-

    print "$_ = $args->{$_}

    " for (sort keys %$args);

    : I'm thinking i'm going to have to go back in the code and print
    : things out there. Would be easier if I was "able to do direct memory
    : access in Perl!!!" but it doesn't seem that way?
    Hehe...well, direct memory access in Perl wuoldn't really do what you think/want in this context anyway. But I'd rather not think about Perl 5 internals. Nor would most people, thus the current rewrite for Perl 6. C is a language where you can do direct memory access, and you reap the rewards, including segfaults when you miscode stuff. :-)

    Jonathan

    ###
    for(74,117,115,116){$::a.=chr};(($_.='qwertyui')&&
    (tr/yuiqwert/her anot/))for($::b);for($::c){$_.=$^X;
    /(p.{2}l)/;$_=$1}$::b=~/(..)$/;print("$::a$::b $::c hack$1.");

  • : : What is going on is we are running an xmlrpc to update information
    : : on a website (from what I understand).
    : :
    : : [code]
    : : use Frontier::Client;
    : : $uri = 'http://xmlrpc.website.com/updates/';
    : : $server = Frontier::Client->new(url => $uri);
    : : $server->call($method, $args);
    : : [/code]
    : : $method is a method call and $args is a bunch of arguments ie.
    : : (argument1 => $argument...)the method uses. There is something wrong
    : : with a/some value(s) in $args and causing the call() to fail. When I
    : : print out the values in $args some of them come out as HASH(). I'm
    : : trying to see what those values are to make sure they are formated
    : : correctly.
    : OK, what happens if you do:-
    : print $args;
    : I'm guessing you get the HASH(0xSomeAddress)? In that case, $args is not a hash, but a hashref (a reference to a hash). So, you need to dereference it.
    :
    : my %arghash = %$args;
    :
    : Or you can use the -> operator to access a particular key:-
    :
    : print $args->{'somekey'};
    :
    : Or print all entries like this:-
    :
    : print "$_ = $args->{$_}
    " for (sort keys %$args);

    That is what I was looking for!

    :
    : : I'm thinking i'm going to have to go back in the code and print
    : : things out there. Would be easier if I was "able to do direct memory
    : : access in Perl!!!" but it doesn't seem that way?
    : Hehe...well, direct memory access in Perl wuoldn't really do what you think/want in this context anyway.

    Yah, I was thinking something else =P

    But I'd rather not think about Perl 5 internals. Nor would most people, thus the current rewrite for Perl 6. C is a language where you can do direct memory access, and you reap the rewards, including segfaults when you miscode stuff. :-)

    Haven't touched C in over 4 years now but I liked it back then =)
    :
    : Jonathan
    :
    : ###
    : for(74,117,115,116){$::a.=chr};(($_.='qwertyui')&&
    : (tr/yuiqwert/her anot/))for($::b);for($::c){$_.=$^X;
    : /(p.{2}l)/;$_=$1}$::b=~/(..)$/;print("$::a$::b $::c hack$1.");
    :
    :

    Thanks again for the help Jonathan!
  • : : print "$_ = $args->{$_}
    " for (sort keys %$args);
    : That is what I was looking for!
    Great. I figured at least one of them would do what you were after! :-)

    : : Hehe...well, direct memory access in Perl wuoldn't really do what
    : : you think/want in this context anyway.
    : Yah, I was thinking something else =P
    Mmmmmm...so was I...ooops!

    : Haven't touched C in over 4 years now but I liked it back then =)
    I'm learning it at the mo - I'm at the stage where I know how to do most things (e.g. enough to write an instruction file parser and audio engine thingy), but have yet to explore the dustier corners of the language. I used the O'Reilly "Practical C Programming" book and it was brilliant on what it did cover, but once you get onto topics like function pointers (which I do know about) or unions (which I don't) they aren't in there. So now I just need one that covers the more advanced topics. :-)

    Anyways...

    Jonathan

    ###
    for(74,117,115,116){$::a.=chr};(($_.='qwertyui')&&
    (tr/yuiqwert/her anot/))for($::b);for($::c){$_.=$^X;
    /(p.{2}l)/;$_=$1}$::b=~/(..)$/;print("$::a$::b $::c hack$1.");

  • : : : print "$_ = $args->{$_}
    " for (sort keys %$args);
    : : That is what I was looking for!
    : Great. I figured at least one of them would do what you were after! :-)
    :
    : : : Hehe...well, direct memory access in Perl wuoldn't really do what
    : : : you think/want in this context anyway.
    : : Yah, I was thinking something else =P
    : Mmmmmm...so was I...ooops!
    :
    : : Haven't touched C in over 4 years now but I liked it back then =)
    : I'm learning it at the mo - I'm at the stage where I know how to do most things (e.g. enough to write an instruction file parser and audio engine thingy), but have yet to explore the dustier corners of the language. I used the O'Reilly "Practical C Programming" book and it was brilliant on what it did cover, but once you get onto topics like function pointers (which I do know about) or unions (which I don't) they aren't in there. So now I just need one that covers the more advanced topics. :-)

    The book I used to learn C was The Waite Group's C Primer Plus - Third Edition (http://www.amazon.com/exec/obidos/tg/detail/-/1571691618/103-6624709-5205436?v=glance). It covers pretty much everything although i'm looking at it now for info on unions and there are only 3 pages on it. Doesn't get into a whole lot of detail but you get the gist of it.

    :
    : Anyways...
    :
    : Jonathan
    :
    : ###
    : for(74,117,115,116){$::a.=chr};(($_.='qwertyui')&&
    : (tr/yuiqwert/her anot/))for($::b);for($::c){$_.=$^X;
    : /(p.{2}l)/;$_=$1}$::b=~/(..)$/;print("$::a$::b $::c hack$1.");
    :
    :

  • : The book I used to learn C was The Waite Group's C Primer Plus -
    : Third Edition (http://www.amazon.com/exec/obidos/tg/detail/-
    : /1571691618/103-6624709-5205436?v=glance). It covers pretty much
    : everything although i'm looking at it now for info on unions and
    : there are only 3 pages on it. Doesn't get into a whole lot of detail
    : but you get the gist of it.
    Thanks for the suggestion, I'll take a look at that in a few weeks (at the moment, I know getting a C book would distract me from all the things I've supposed to be doing at uni!).

    Jonathan


    ###
    for(74,117,115,116){$::a.=chr};(($_.='qwertyui')&&
    (tr/yuiqwert/her anot/))for($::b);for($::c){$_.=$^X;
    /(p.{2}l)/;$_=$1}$::b=~/(..)$/;print("$::a$::b $::c hack$1.");

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories