Somethign about hashes

Discussion in 'Perl Misc' started by Nikos, May 2, 2005.

  1. Nikos

    Nikos Guest

    while( $row = $sth->fetchrow_hashref )
    {
    print table( {class=>'user_form'},

    Tr(
    td( {-width=>'25%'}, {class=>'name'}, $row->{name} ),
    td( {-width=>'50%'}, {class=>'email'}, $row->{email} ),
    td( {-width=>'25%'}, {class=>'date'}, $row->{date} )
    ),

    {snip more code]


    I use the above code when i retrives rows of information from my mysql
    database but in the print output a see soemthing like hash(0x0A8B)and
    after that the data when what i only want is the actual data itself.

    The code is correct but why does those hashed appear?



    --
    "Of course I cant stop you. And that would really bum me out
    if that were my job. But my job isnt to stop you, its to
    make it as difficult as possible, for as many as possible,
    for as long as possible ."
     
    Nikos, May 2, 2005
    #1
    1. Advertising

  2. Nikos

    Peter Wyzl Guest

    "Nikos" <> wrote in message
    news:d5567p$9r6$...
    : while( $row = $sth->fetchrow_hashref )
    : {
    : print table( {class=>'user_form'},
    :
    : Tr(
    : td( {-width=>'25%'}, {class=>'name'}, $row->{name} ),
    : td( {-width=>'50%'}, {class=>'email'}, $row->{email} ),
    : td( {-width=>'25%'}, {class=>'date'}, $row->{date} )
    : ),
    :
    : {snip more code]
    :
    :
    : I use the above code when i retrives rows of information from my mysql
    : database but in the print output a see soemthing like hash(0x0A8B)and
    : after that the data when what i only want is the actual data itself.
    :
    : The code is correct but why does those hashed appear?


    The output code is wrong. Therefore posting the input code is not much
    help.

    P
     
    Peter Wyzl, May 2, 2005
    #2
    1. Advertising

  3. Nikos

    Greg Bacon Guest

    In article <d5567p$9r6$>,
    Nikos <> wrote:

    : while( $row = $sth->fetchrow_hashref )
    : {
    : print table( {class=>'user_form'},
    :
    : Tr(
    : td( {-width=>'25%'}, {class=>'name'}, $row->{name} ),
    : td( {-width=>'50%'}, {class=>'email'}, $row->{email} ),
    : td( {-width=>'25%'}, {class=>'date'}, $row->{date} )
    : ),
    :
    : {snip more code]
    :
    : I use the above code when i retrives rows of information from my mysql
    : database but in the print output a see soemthing like hash(0x0A8B)and
    : after that the data when what i only want is the actual data itself.
    :
    : The code is correct but why does those hashed appear?

    If the code were correct, the hashes wouldn't appear.

    The problem with your code is that it has the class attribute values in
    separate hashes, but they're supposed to be in a single hash per element
    as in the following code:

    #! /usr/local/bin/perl

    use warnings;
    use strict;

    package FakeSth;

    sub new { bless {} => shift }

    {
    my $counter;
    sub fetchrow_hashref {
    return unless $counter++ < 3;

    return {
    name => "name" . $counter,
    email => "email" . $counter,
    date => "date" . $counter,
    };
    }
    }

    package main;

    use CGI qw/ :html /;

    my $sth = new FakeSth;

    my $row;
    while( $row = $sth->fetchrow_hashref )
    {
    print table( {class=>'user_form'},

    Tr(
    td( {-width=>'25%', class=>'name'}, $row->{name} ),
    td( {-width=>'50%', class=>'email'}, $row->{email} ),
    td( {-width=>'25%', class=>'date'}, $row->{date} ),
    ),
    );
    }

    Hope this helps,
    Greg
    --
    Life, faculties, production -- in other words, individuality, liberty,
    property -- this is man. And in spite of the cunning of artful political
    leaders, these three gifts from God precede all human legislation, and are
    superior to it. -- Frederic Bastiat, *The Law*
     
    Greg Bacon, May 2, 2005
    #3
  4. Nikos

    Nikos Guest

    Greg Bacon wrote:

    > The problem with your code is that it has the class attribute values in
    > separate hashes, but they're supposed to be in a single hash per element
    > as in the following code:



    Yes that was the mistake. thank you for pinting this out. :)

    --
    "Of course I cant stop you. And that would really bum me out
    if that were my job. But my job isnt to stop you, its to
    make it as difficult as possible, for as many as possible,
    for as long as possible ."
     
    Nikos, May 2, 2005
    #4
  5. Nikos

    Nikos Guest

    Maybe you can help me with this too:


    print span( {class=>'tip'}, "Some Greek Text!" );

    ========================
    span.tip {
    text-align: center;
    font: 20px comic;
    color: lime;
    }
    ========================

    Although i have specified a style and iam using it the print the text
    aint being centered.

    What am i doing wrong?


    --
    "Of course I cant stop you. And that would really bum me out
    if that were my job. But my job isnt to stop you, its to
    make it as difficult as possible, for as many as possible,
    for as long as possible ."
     
    Nikos, May 2, 2005
    #5
  6. Nikos wrote:
    >
    > print span( {class=>'tip'}, "Some Greek Text!" );
    >
    > ========================
    > span.tip {
    > text-align: center;
    > font: 20px comic;
    > color: lime;
    > }
    > ========================
    >
    > Although i have specified a style and iam using it the print the text
    > aint being centered.
    >
    > What am i doing wrong?


    You are using CSS while refusing to study the docs for it.

    --
    Gunnar Hjalmarsson
    Email: http://www.gunnar.cc/cgi-bin/contact.pl
     
    Gunnar Hjalmarsson, May 2, 2005
    #6
  7. Nikos <> wrote in news:d55b7b$ebt$:

    > text aint being centered.


    It takes exactly as many characters to write "isn't" as it does to type
    "ain't".

    --
    A. Sinan Unur <>
    (reverse each component and remove .invalid for email address)

    comp.lang.perl.misc guidelines on the WWW:
    http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html
     
    A. Sinan Unur, May 2, 2005
    #7
  8. Nikos <> wrote:


    > span.tip {
    > text-align: center;
    > font: 20px comic;
    > color: lime;
    > }


    > What am i doing wrong?



    Posting CSS questions in a Perl newsgroup.

    Please stop abusing our newsgroup.


    --
    Tad McClellan SGML consulting
    Perl programming
    Fort Worth, Texas
     
    Tad McClellan, May 2, 2005
    #8
  9. Nikos

    Nikos Guest

    Tad McClellan wrote:
    > Nikos <> wrote:
    >
    >
    >
    >>span.tip {
    >> text-align: center;
    >> font: 20px comic;
    >> color: lime;
    >>}

    >
    >
    >>What am i doing wrong?

    >
    >
    >
    > Posting CSS questions in a Perl newsgroup.
    >
    > Please stop abusing our newsgroup.
    >
    >


    They dont answer.

    --
    "Of course I cant stop you. And that would really bum me out
    if that were my job. But my job isnt to stop you, its to
    make it as difficult as possible, for as many as possible,
    for as long as possible ."
     
    Nikos, May 2, 2005
    #9
  10. Nikos <> wrote:
    > Tad McClellan wrote:
    >> Nikos <> wrote:


    >>>What am i doing wrong?

    >>
    >> Posting CSS questions in a Perl newsgroup.
    >>
    >> Please stop abusing our newsgroup.
    >>

    >
    > They dont answer.



    That's too bad, but it does not change a CSS question
    into a Perl question.

    PLEASE STOP ABUSING OUR NEWSGROUP!


    --
    Tad McClellan SGML consulting
    Perl programming
    Fort Worth, Texas
     
    Tad McClellan, May 2, 2005
    #10
  11. Nikos <> wrote in news:d55hp7$k8g$:

    > Tad McClellan wrote:
    >> Nikos <> wrote:
    >>
    >>>span.tip {
    >>> text-align: center;
    >>> font: 20px comic;
    >>> color: lime;
    >>>}

    >>
    >>>What am i doing wrong?

    >>
    >> Posting CSS questions in a Perl newsgroup.
    >>
    >> Please stop abusing our newsgroup.

    >
    > They dont answer.


    You are making false statements again:

    <URL: http://groups-beta.google.com/group/alt.html/browse_thread/thread/e23f2ce89b2db30d/0bd488c7cab7d760#0bd488c7cab7d760>

    It seems like you got useful answers. The fact that you don't
    like them, and you want others to do your work does not change
    that fact.

    Now, try to remember what we call people who insist on making
    false statements?

    Sinan
     
    A. Sinan Unur, May 2, 2005
    #11
  12. Nikos

    Nikos Guest

    A. Sinan Unur wrote:
    > You are making false statements again:
    >
    > <URL: http://groups-beta.google.com/group/alt.html/browse_thread/thread/e23f2ce89b2db30d/0bd488c7cab7d760#0bd488c7cab7d760>
    >
    > It seems like you got useful answers. The fact that you don't
    > like them, and you want others to do your work does not change
    > that fact.
    >
    > Now, try to remember what we call people who insist on making
    > false statements?


    Ah, so they did answer there.....
    Thats nice to hear, iw aited 2 days but i didnt got any response and
    today morning i unsubscribed from alt.html considering that after what
    grg said they will never anser.

    Now with the url you pointed to me i just saw their new responses.

    Sorry about that but once again iam i am a vivtim of circumstances....


    --
    "Of course I cant stop you. And that would really bum me out
    if that were my job. But my job isnt to stop you, its to
    make it as difficult as possible, for as many as possible,
    for as long as possible ."
     
    Nikos, May 2, 2005
    #12
  13. Nikos

    Nikos Guest

    Tad McClellan wrote:

    > That's too bad, but it does not change a CSS question
    > into a Perl question.
    >
    > PLEASE STOP ABUSING OUR NEWSGROUP!


    Its not completely irrelevant with Perl since it embeds the use of cgi.pm

    --
    "Of course I cant stop you. And that would really bum me out
    if that were my job. But my job isnt to stop you, its to
    make it as difficult as possible, for as many as possible,
    for as long as possible ."
     
    Nikos, May 2, 2005
    #13
  14. Nikos <> wrote in news:d55kv9$n1e$:

    > Tad McClellan wrote:
    >
    >> That's too bad, but it does not change a CSS question
    >> into a Perl question.
    >>
    >> PLEASE STOP ABUSING OUR NEWSGROUP!

    >
    > Its not completely irrelevant with Perl since it embeds the use of cgi.pm


    No, it is completely irrelevant.

    Sinan
     
    A. Sinan Unur, May 2, 2005
    #14
  15. Nikos wrote:

    > Tad McClellan wrote:
    >
    >> That's too bad, but it does not change a CSS question
    >> into a Perl question.
    >>
    >> PLEASE STOP ABUSING OUR NEWSGROUP!

    >
    > Its not completely irrelevant with Perl since it embeds the use of cgi.pm
    >

    Tell me, if you drove your car to the supermarket and they were out
    of milk, would you regard this as a matter to take up with your
    mechanic? After all, it happened while you were on a trip with
    your car!

    --
    Christopher Mattern

    "Which one you figure tracked us?"
    "The ugly one, sir."
    "...Could you be more specific?"
     
    Chris Mattern, May 2, 2005
    #15
  16. Nikos

    Nikos Guest

    Chris Mattern wrote:

    > Tell me, if you drove your car to the supermarket and they were out
    > of milk, would you regard this as a matter to take up with your
    > mechanic? After all, it happened while you were on a trip with
    > your car!
    >


    lol! :)

    ok, but it wouldnt be much of a trouble if you helped me a little on the
    styling since little details are confusing me, would it?

    if yes, the ignore my question.

    --
    "Of course I cant stop you. And that would really bum me out
    if that were my job. But my job isnt to stop you, its to
    make it as difficult as possible, for as many as possible,
    for as long as possible ."
     
    Nikos, May 2, 2005
    #16
  17. Nikos

    Tintin Guest

    "Nikos" <> wrote in message
    news:d55kta$n1e$...
    > A. Sinan Unur wrote:
    >> You are making false statements again:
    >>
    >> <URL:
    >> http://groups-beta.google.com/group/alt.html/browse_thread/thread/e23f2ce89b2db30d/0bd488c7cab7d760#0bd488c7cab7d760>
    >>
    >> It seems like you got useful answers. The fact that you don't
    >> like them, and you want others to do your work does not change
    >> that fact.
    >>
    >> Now, try to remember what we call people who insist on making false
    >> statements?

    >
    > Ah, so they did answer there.....
    > Thats nice to hear, iw aited 2 days but i didnt got any response and today
    > morning i unsubscribed from alt.html considering that after what grg said
    > they will never anser.
    >
    > Now with the url you pointed to me i just saw their new responses.
    >
    > Sorry about that but once again iam i am a vivtim of circumstances....


    More a victim of your own impatience and lazyness.
     
    Tintin, May 2, 2005
    #17
  18. Nikos

    Nikos Guest

    Tintin wrote:

    >>Now with the url you pointed to me i just saw their new responses.
    >>
    >>Sorry about that but once again iam i am a vivtim of circumstances....

    >
    >
    > More a victim of your own impatience and lazyness.


    Yes, unforunately.

    --
    "Of course I cant stop you. And that would really bum me out
    if that were my job. But my job isnt to stop you, its to
    make it as difficult as possible, for as many as possible,
    for as long as possible ."
     
    Nikos, May 2, 2005
    #18
  19. Nikos <> wrote:


    > but once again iam i am a vivtim of circumstances....



    Once, twice, thrice maybe.

    But you've done it DOZENS of times!

    The root of the problem here is that you do not respect
    the other people on this newsgroup.


    --
    Tad McClellan SGML consulting
    Perl programming
    Fort Worth, Texas
     
    Tad McClellan, May 3, 2005
    #19
  20. Nikos <> wrote:
    > Chris Mattern wrote:
    >
    >> Tell me, if you drove your car to the supermarket and they were out
    >> of milk, would you regard this as a matter to take up with your
    >> mechanic? After all, it happened while you were on a trip with
    >> your car!
    >>

    >
    > lol! :)
    >
    > ok, but it wouldnt be much of a trouble if you helped me a little on the
    > styling since little details are confusing me, would it?



    But then someone else will see that they can get CSS and web server
    and MySQL problems answered here, and they will post _their_ questions.

    If we let you throw trash in our park without complaint, then we
    will end up with LOTS more trash in the park.

    We like our park. We don't like you trashing it, so please stop doing that.


    --
    Tad McClellan SGML consulting
    Perl programming
    Fort Worth, Texas
     
    Tad McClellan, May 3, 2005
    #20
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ben Holness

    Hashes of Hashes via subs

    Ben Holness, Oct 5, 2003, in forum: Perl
    Replies:
    8
    Views:
    575
    Ben Holness
    Oct 8, 2003
  2. Steven Arnold

    using hashes as keys in hashes

    Steven Arnold, Nov 23, 2005, in forum: Ruby
    Replies:
    3
    Views:
    173
    Mauricio Fernández
    Nov 23, 2005
  3. kazaam
    Replies:
    12
    Views:
    281
    Matthias Wächter
    Sep 13, 2007
  4. Neela megha shyam Chivukula

    On Hashes - How the hashes printing works?

    Neela megha shyam Chivukula, May 27, 2009, in forum: Ruby
    Replies:
    4
    Views:
    251
    Markus Schirp
    May 28, 2009
  5. Tim O'Donovan

    Hash of hashes, of hashes, of arrays of hashes

    Tim O'Donovan, Oct 27, 2005, in forum: Perl Misc
    Replies:
    5
    Views:
    220
Loading...

Share This Page