A Stupid question.

M

Mark Healey

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?
 
M

Matt Garrish

Mark Healey said:
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
 
S

Sam Holden

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.
 
J

John Bokma

Purl said:
Purl Gurl wrote:




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.
 
D

David Oswald

Mark Healey said:
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.
 
J

John Bokma

Purl said:
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?
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.
 
J

John Bokma

Purl said:
John Bokma wrote:

[ # URI fragment problem ]
I will have to look closer when time allows. This

Kay, I am curious :-D
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
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.
 
M

Mark Clements

Purl said:
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
 
P

Peter Hickman

Mark said:
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.
 
M

Mark Clements

Peter said:
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
 
G

Geoff

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.
 
G

Geoff

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
 
M

Marcus Stollsteimer

Purl said:
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
 
C

CodeSprite


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.
 
J

John W. Kennedy

Purl said:

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"
 
J

John W. Kennedy

Geoff said:
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)
 
J

John W. Kennedy

Purl said:
Geoff wrote:




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.
 
J

John W. Kennedy

Peter said:
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.
 
M

Marcus Stollsteimer

Purl said:
"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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top