A Stupid question.

Discussion in 'Perl Misc' started by Mark Healey, May 8, 2004.

  1. Mark Healey

    Mark Healey Guest

    For some reason I can't find the answer to this question in the
    O'Reily books I have.

    How to I pass an array or hash to a function?

    --
    Mark Heaely
    marknews(at)healeyonline(dot)com
     
    Mark Healey, May 8, 2004
    #1
    1. Advertising

  2. Mark Healey

    Matt Garrish Guest

    "Mark Healey" <> wrote in message
    news:02.pacbell.net...
    > For some reason I can't find the answer to this question in the
    > O'Reily books I have.
    >
    > How to I pass an array or hash to a function?
    >


    O'Reilly's books are much better... ; )

    In answer to your question, just pass a reference to your hash or array:

    mysub(\@array, \%hash);

    sub mysub {

    my ($aref, $href) = @_;

    }

    Matt
     
    Matt Garrish, May 8, 2004
    #2
    1. Advertising

  3. Mark Healey

    Sam Holden Guest

    On Sat, 08 May 2004 20:07:40 GMT, Mark Healey <> wrote:
    > For some reason I can't find the answer to this question in the
    > O'Reily books I have.
    >
    > How to I pass an array or hash to a function?


    sub foo {
    my ($arg1, $arg2, @array) = @_;
    }

    sub bar {
    my ($arg1, %hash) = @_;
    }

    foo($a_scalar, $another, @an_array);
    bar($a_scalar, %a_hash);

    If you want to pass more than one array or hash then see
    perldoc perlsub
    Of particular interest will be the section which begins:

    Pass by Reference

    If you want to pass more than one array or hash into a
    function--or return them from it--and have them maintain
    their integrity, then you're going to have to use an
    explicit pass-by-reference.

    Reading the documentation that comes with perl is usually a good
    first step when wanting to know how to do something in perl.
     
    Sam Holden, May 8, 2004
    #3
  4. Mark Healey

    John Bokma Guest

    Purl Gurl wrote:

    > Purl Gurl wrote:
    >
    >
    >>Mark Healey wrote:

    >
    >>>How to I pass an array or hash to a function?

    >
    >> http: etc...

    >
    > That link doesn't lead where I would like.


    That's an URI for you :-D

    > You will end up
    > on my Perl FAQ 7 page rather than the actual FAQ answer
    > because of frames.


    That's why frames are often such a bad idea

    > Follow the link to,
    >
    > Perl FAQ 7
    >
    > Then click on this,
    >
    > How can I pass/return a {Function, FileHandle, Array, Hash, Method, Regex}?


    And make a little dance and shout "Goeba Goeba" three times :-D.

    --
    John MexIT: http://johnbokma.com/mexit/
    personal page: http://johnbokma.com/
    Experienced Perl programmer available: http://castleamber.com/
     
    John Bokma, May 9, 2004
    #4
  5. Mark Healey

    David Oswald Guest

    "Mark Healey" <> wrote:

    > For some reason I can't find the answer to this question in the
    > O'Reily books I have.
    >
    > How to I pass an array or hash to a function?


    What books are you looking in, Javascript and Sendmail?

    See "Programming Perl, 3rd Edition" (the Camel book) chapter 6.

    See the "Perl Cookbook, 1st Edition" (the Ram book) Chapter 10.
     
    David Oswald, May 9, 2004
    #5
  6. Mark Healey

    John Bokma Guest

    Purl Gurl wrote:

    > John Bokma wrote:
    >
    >>Purl Gurl wrote:


    >>>You will end up
    >>>on my Perl FAQ 7 page rather than the actual FAQ answer
    >>>because of frames.

    >
    >>That's why frames are often such a bad idea

    >
    > Turns out is not frames related. It is darn anchor #
    > syntax usage. My Perl documentation is a blend of


    What's wrong with it?

    > Perl 5.6 and 5.8 versions, factory condition.
    >
    > This documentation is proving challenging. I have


    Yeah, I have seen some errors in the ActiveState version too.

    > been working for months recreating missing pages
    > in documentation as found, not found, at almost
    > all Perl documentation sites.


    Cool

    > Only method I have of finding missing pages is
    > parse for 404 Page Not Found errors, then try
    > to find the path to the path to the path to the
    > path to the bad link. Grrrrr....


    linkchecker? Believe there is one at sourceforge.

    And you don't have the referer in the access_log?

    >>And make a little dance and shout "Goeba Goeba" three times :-D.

    >
    > Save the dancing for later.


    Ok, just the shouting then :-D.

    > There is a benefit. We are now out of the non-commercial
    > block which serves thousands of home users running boxes
    > infected with all kinds of virii, which bang away at our
    > server, thousands of times a day.


    But that is worth a big dance :-D.

    --
    John MexIT: http://johnbokma.com/mexit/
    personal page: http://johnbokma.com/
    Experienced Perl programmer available: http://castleamber.com/
     
    John Bokma, May 9, 2004
    #6
  7. Mark Healey

    John Bokma Guest

    Purl Gurl wrote:

    > John Bokma wrote:


    [ # URI fragment problem ]

    > I will have to look closer when time allows. This


    Kay, I am curious :-D

    >>linkchecker? Believe there is one at sourceforge.

    >
    > I have considered a link checker which will recurse
    > at least ten to fifteen links deep. Not sure how
    > effective this will be because some of the links
    > are circular in nature, more of a "swirl candy"


    Most link checkers keep a "cache" of pages already fetched, so circular
    refs shouldn't be a problem.

    http://validator.w3.org/checklink

    But probably with a huge depths and many documents the report is quite
    impressive.

    > Search engine spider bots do a darn good job of
    > locating those missing pages!


    Yup, if the page is not there, 404 :-D

    >>And you don't have the referer in the access_log?

    >
    > Many browsers do not provide referrer data.


    Many others do. If a browser get a 404, you can check the referring page
    for the link. If the link is there, then the page has a broken link.

    > Our new static ip address has only propagated for
    > a matter of a few hours and already we are being
    > slammed with Swen 32 virii email. Similar, several
    > hundred Sasser worm attacks on port 445. Lot of
    > dumb internet users out there without sense enough
    > to slip condoms over their machines.


    Yup, and this will always be the case. I won't call them dumb, because
    many are smart in other ways, just not with computers. And no, when you
    are good at Y doesn't mean you are good at Z too.

    --
    John MexIT: http://johnbokma.com/mexit/
    personal page: http://johnbokma.com/
    Experienced Perl programmer available: http://castleamber.com/
     
    John Bokma, May 10, 2004
    #7
  8. Purl Gurl wrote:
    >
    > Computer virii is such widespread common knowledge,
    > a person would have to be dumb to not know of
    > computer virii, and exceptionally dumb to not
    > take precautionary measures for protection.

    The plural of "virus" is "viruses".

    Mark
     
    Mark Clements, May 10, 2004
    #8
  9. Mark Clements wrote:
    > The plural of "virus" is "viruses".
    >
    > Mark


    Thank you for your insightful comment. How could my life be complete
    without a spelling lawyer, btw virii has a usage as the plural of virus
    going back to the 1990s and no one but a pedant has problems with this.

    disk, disc, disk, disc, disk, disc, disk, disc, disk, disc, disk, disc,
    disk, disc, disk, disc, disk, disc, disk, disc, disk, disc, disk, disc,
    disk, disc, disk, disc, disk, disc, disk, disc, disk, disc, disk, disc,
    disk, disc, disk, disc, disk, disc, disk, disc, disk, disc, disk, disc,
    disk, disc, disk, disc, disk, disc, disk, disc, disk, disc, disk, disc,
    disk, disc, disk, disc, disk, disc, disk, disc, disk, disc, disk, disc,
    disk, disc...

    That should keep you happy for hours.
     
    Peter Hickman, May 10, 2004
    #9
  10. Peter Hickman wrote:
    >
    > Thank you for your insightful comment. How could my life be complete
    > without a spelling lawyer, btw virii has a usage as the plural of virus
    > going back to the 1990s and no one but a pedant has problems with this.

    Ouch are my knuckles rapped. A precedent going back to the 90s does not make it correct usage.
    PG is normally a stickler for precise definition; I was merely helping her along her merry way.

    I am guilty as charged on the pedant front.

    Mark
     
    Mark Clements, May 10, 2004
    #10
  11. Purl Gurl <> wrote in news:409F91DF.E07997C3
    @purlgurl.net:

    > Mark Clements wrote:
    >
    >> Purl Gurl wrote:

    >
    >> > Computer virii is such widespread common knowledge,
    >> > a person would have to be dumb to not know of
    >> > computer virii, and exceptionally dumb to not
    >> > take precautionary measures for protection.

    >
    >> The plural of "virus" is "viruses".

    >
    > Is that so?


    http://www.bennetyee.org/http_webster.cgi?virus&method=exact

    --
    A. Sinan Unur
    (reverse each component for email address)
     
    A. Sinan Unur, May 10, 2004
    #11
  12. Mark Healey

    Geoff Guest

    On Mon, 10 May 2004 07:29:51 -0700, Purl Gurl <> wrote:

    >Mark Clements wrote:
    >
    >> Purl Gurl wrote:

    >
    >> > Computer virii is such widespread common knowledge,
    >> > a person would have to be dumb to not know of
    >> > computer virii, and exceptionally dumb to not
    >> > take precautionary measures for protection.

    >
    >> The plural of "virus" is "viruses".

    >
    >Is that so?
    >
    >Google will display close to three-hundred-thousand
    >entries which disagree with you.


    And there are 5,550,000 entries for "viruses" so if your criterion
    for correct usage is frequency of occurrence, then viruses wins.

    >
    >Perhaps you are confusing technological jargon
    >with the the Queen's proper English?


    The Queen has nothing to do with it. Virus is Latin.
    See below.

    >
    >A rather prickly subject much like cacti, yes?
    >
    >Clearly you are not a wordjones, and perhaps
    >an acluistic alphageek.
    >


    In Latin the word virus is already plural, so strictly speaking
    both viruses and virii are incorrect usage. Common usage has us
    saying "My computer has been infected with a virus." When in fact
    we should be saying "Virus have infected my computer."
    But this is pedantic.

    http://dictionary.reference.com/search?q=virii no entries.
    http://dictionary.reference.com/search?q=virus noun, plural is viruses.
     
    Geoff, May 10, 2004
    #12
  13. Mark Healey

    Geoff Guest

    On Mon, 10 May 2004 08:36:15 -0700, Purl Gurl <> wrote:

    >Geoff wrote:
    >
    >> Purl Gurl wrote:
    >> > Mark Clements wrote:
    >> >> Purl Gurl wrote:

    >
    >(snipped)
    >
    >> for correct usage is frequency of occurrence, then viruses wins.

    >
    >Oh my! Such a testosterone induced behavioral display!
    >
    >Boys fist fight. Girls verbally negotiate.
    >Boys win or lose. Girls win-win.
    >


    My search is bigger that your search. Don't you have search envy? :D
     
    Geoff, May 10, 2004
    #13
  14. Purl Gurl wrote:

    > Mark Clements wrote:
    >
    >> The plural of "virus" is "viruses".

    >
    > Is that so?
    >
    > Google will display close to three-hundred-thousand
    > entries which disagree with you.


    viruses 5,530,000
    "computer viruses" 657,000
    virii 284,000

    --
    It is awfully hard work doing nothing. -- Oscar Wilde
     
    Marcus Stollsteimer, May 10, 2004
    #14
  15. Mark Healey

    CodeSprite Guest

    "A. Sinan Unur" <> wrote in
    news:Xns94E57460ADD8Easu1cornelledu@132.236.56.8:

    > Purl Gurl <> wrote in news:409F91DF.E07997C3
    > @purlgurl.net:
    >
    >> Mark Clements wrote:
    >>
    >>> Purl Gurl wrote:

    >>
    >>> > Computer virii is such widespread common knowledge,
    >>> > a person would have to be dumb to not know of
    >>> > computer virii, and exceptionally dumb to not
    >>> > take precautionary measures for protection.

    >>
    >>> The plural of "virus" is "viruses".

    >>
    >> Is that so?

    >
    > http://www.bennetyee.org/http_webster.cgi?virus&method=exact
    >


    I was rooting for the plural to be virii (glorious word), but I found
    this on http://en.wikipedia.org/wiki/Virus_(biology) :

    Etymology
    The word comes from the Latin virus, referring to poison and other
    noxious things. Today it is used to describe the biological viruses
    discussed above and also as a metaphor for other parasitically-
    reproducing things, such as ideas. The term computer virus has become
    another well-defined sense of the word. The word virion or viron is used
    to refer to a single infective viral particle.

    Despite frequent claims to the contrary, the only correct English plural
    of the word for any of these senses is viruses. The Latin word does not
    appear to have had a plural. Virii would be the plural of the word
    virius, and viri was the plural of the word vir, meaning man.
     
    CodeSprite, May 10, 2004
    #15
  16. Purl Gurl wrote:
    > http://www.google.com/search?hl=en&ie=ISO-8859-1&oe=ISO-8859-1&q=virii


    That proves nothing but that other people are as ignorant as you are.

    "Virii" is not a word. If it were a word, it would be the plural of
    "virius", which is also not a word.

    The Latin word "virus" has no plural; it is grammatically irregular,
    being a 2nd Declension neuter noun ending in "-us", so that a plural for
    it cannot be constructed by rule; and it doesn't need a plural, being a
    mass noun meaning "poison in general", as in "Poison is bad for you."
    The English word "virus" has only one plural: "viruses".

    --
    John W. Kennedy
    "You can, if you wish, class all science-fiction together; but it is
    about as perceptive as classing the works of Ballantyne, Conrad and W.
    W. Jacobs together as the 'sea-story' and then criticizing _that_."
    -- C. S. Lewis. "An Experiment in Criticism"
     
    John W. Kennedy, May 10, 2004
    #16
  17. Geoff wrote:
    > In Latin the word virus is already plural,



    Not so. (You're probably thinking of "ignoramus", which is a different
    problem.)

    > so strictly speaking
    > both viruses and virii are incorrect usage.


    No, because the English word "virus" doesn't mean the same thing as the
    Latin word "virus". The Latin word doesn't need a plural because it is
    a mass noun, and cannot be given a plural by standard grammatical rules
    because it's a grammatical freak. The English word does need a plural,
    and has one: "viruses".

    --
    John W. Kennedy
    "Those in the seat of power oft forget their failings and seek only the
    obeisance of others! Thus is bad government born! Hold in your heart
    that you and the people are one, human beings all, and good government
    shall arise of its own accord! Such is the path of virtue!"
    -- Kazuo Koike. "Lone Wolf and Cub: Thirteen Strings" (tr. Dana Lewis)
     
    John W. Kennedy, May 10, 2004
    #17
  18. Purl Gurl wrote:

    > Geoff wrote:
    >
    >
    >>Purl Gurl wrote:
    >>
    >>>Mark Clements wrote:
    >>>
    >>>>Purl Gurl wrote:

    >
    >
    > (snipped)
    >
    >
    >>for correct usage is frequency of occurrence, then viruses wins.

    >
    >
    > Oh my! Such a testosterone induced behavioral display!
    >
    > Boys fist fight. Girls verbally negotiate.
    > Boys win or lose. Girls win-win.


    So on top of everything else, you're a hypocrite.

    --
    John W. Kennedy
    "Compact is becoming contract,
    Man only earns and pays."
    -- Charles Williams. "Bors to Elayne: On the King's Coins"
     
    John W. Kennedy, May 10, 2004
    #18
  19. Peter Hickman wrote:

    > Mark Clements wrote:
    >
    >> The plural of "virus" is "viruses".
    >>
    >> Mark

    >
    >
    > Thank you for your insightful comment. How could my life be complete
    > without a spelling lawyer, btw virii has a usage as the plural of virus
    > going back to the 1990s and no one but a pedant has problems with this.


    Moron.

    --
    John W. Kennedy
    Read the remains of Shakespeare's lost play, now annotated!
    http://pws.prserv.net/jwkennedy/Double Falshood.html
     
    John W. Kennedy, May 10, 2004
    #19
  20. Purl Gurl wrote:

    > Marcus Stollsteimer wrote:
    >
    >> Purl Gurl wrote:
    >> > Mark Clements wrote:

    >
    > (snipped)
    >
    >> viruses 5,530,000
    >> "computer viruses" 657,000
    >> virii 284,000

    >
    > "purlgurl" 1,090
    > "purl gurl" 538
    > "marcus stollsteimer" 86


    which only confirms my point of view:
    *I* do not believe in Google;
    you apparently do, ergo: good bye 'virii' ... ;)

    Marcus

    --
    The truth isn't quite the sort of thing one tells to
    a nice, sweet, refined girl. -- Oscar Wilde
     
    Marcus Stollsteimer, May 10, 2004
    #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. Michael W Cocke

    Stupid RE question

    Michael W Cocke, Dec 27, 2004, in forum: Perl
    Replies:
    2
    Views:
    440
    Michael W Cocke
    Dec 28, 2004
  2. Steve

    Is this a stupid question?

    Steve, Jul 17, 2003, in forum: ASP .Net
    Replies:
    6
    Views:
    358
    Mario Vargas
    Jul 17, 2003
  3. Will

    Stupid C# question Please help!

    Will, Aug 8, 2003, in forum: ASP .Net
    Replies:
    3
    Views:
    454
    carlos medina
    Aug 9, 2003
  4. Brandon McCombs
    Replies:
    4
    Views:
    525
    Richard Wheeldon
    Aug 28, 2006
  5. rincewind

    stupid, STUPID question!

    rincewind, Apr 19, 2009, in forum: HTML
    Replies:
    25
    Views:
    1,039
Loading...

Share This Page