473,396 Members | 1,758 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Options for passing Hash to a subroutine.

Hi,

Another newbie question...

I have to write a program that process a huge amount of data; the end
results will be a number of different reports. I will prefer to write
a separate library/perl script for each of the reports to
separate/isolate them into their own files... However, how do I "pass"
this huge data to the "report_function" that is in their own file
without too much overhead... From what I understand, if I tried to
pass the "hash" as a parameter to the function, the function will
create a "copy" of it, which would be a significant overhead in terms
of memory and time since I am using multiple-level hash tables with
data in the Megs.... It seems that my only option is using "global",
but from what I read and also my personal experience, it seems that we
should avoid global variable as much as we can.... Can anyone give me
other options or alternatives?

Thanks....

--Chung

Jul 19 '05 #1
6 11491
ch*******@amd.com wrote:
From what I understand, if I tried to
pass the "hash" as a parameter to the function, the function will
create a "copy" of it


Pass a reference to the hash. For details, have a look at:

perldoc perlreftut
perldoc perldsc
perldoc perllol

sherm--

--
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org
Jul 19 '05 #2
ch*******@amd.com wrote:
Newsgroup: comp.lang.perl,comp.lang.perl.modules
The newsgroup comp.lang.perl ceased to exist some time in the previous
millenium. I suggest you break into your NNTP server admin's office and
remove the skeleton.
From what I understand, if I tried to
pass the "hash" as a parameter to the function, the function will
create a "copy" of it,
If you unroll it into a list yes, but see FAQ "How can I pass/return a
.... Hash...?"

Those who will not learn from the FAQ are comdemned to repeat it.
which would be a significant overhead in terms
of memory and time since I am using multiple-level hash tables with
data in the Megs....


But the copy would only be a shallow copy anyhow.

Jul 19 '05 #3
Thanks for the response... Sorry, I didn't read the FAQ close
enough... I somehow missed that...

By the way, do you have a recommendation for a good newsgroup for
begineers?

I will read up on what is a shallow copy...

Thanks again.

Jul 19 '05 #4
ch*******@amd.com wrote:
By the way, do you have a recommendation for a good newsgroup for
begineers?

http://www.nntp.perl.org/group/perl.beginners (though you'll probably
want to read it in a newsreader rather than the web interface)

and my old favorite:

http://groups.yahoo.com/group/perl-beginner/

HTH

jimk

Jul 19 '05 #5

ch*******@amd.com wrote:
Thanks for the response... Sorry, I didn't read the FAQ close
enough... I somehow missed that...
Fair enough, it happens.
By the way, do you have a recommendation for a good newsgroup for
begineers?


My advice to beginners is read the posting guidelines for this newsgroup
and stay here.

If you ask the occasional question that is off-topic or is a FAQ or is
documented in the obvioius place in the reference manuals we'll give you
a helpful but brusque answer. (Maybe just a pointer to the relevant
manual or a suggestion to go ask elsewhere).

If you take it like a man (as you did) then you'll fit in just fine here.

The people who have a problem here are the ones who go out of their way
to make it clear that they value the time of the people they are asking
to help them much less than they value their own.

The trouble with fora where this sort of behaviour is tollerated is that
those fora are unlickely attact all the best people to answer questions.
(Some of the best people do hang out it such fora - just not many and
usually not for long).

Jul 19 '05 #6
Brian McCauley <no****@mail.com> wrote in news:d2k2vn$iin$1
@sun3.bham.ac.uk:
If you take it like a man (as you did) then you'll fit in just fine here.


In the interest of non-sexism, how about making that "if you take it like
an adult" instead (since a man can differ from a non-man in two different
ways, and it's the "maturity" dimension that's relevant here).
Jul 19 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Casey | last post by:
Hi, I haven't being using perl for too long. Can someone explain the correct way to get the sort function to recognize an anonymous function declared as a hash value? Look at my sample code for...
2
by: Christopher | last post by:
I have a hash that is several levels deep. ie: 'vars' => { '$filers' => '10.10.10.10/32', '$networksa' => '10.10.10.10/32', '$networksb' => '10.50.0.0/16', '$wintel_boxes' =>...
6
by: Adrian | last post by:
I am trying to pass the address of a C++ function into a Fortran routine to enable the Fortran routine to call this C++ function. I have to do it this way as our build process does not allow...
1
by: Sam | last post by:
Hello all I have a two dimensional array (the dimensions are not known) that needs to be passed to fortran from c++, allocate the dimensions of the array in fortran code, do some filling up of...
3
by: Stephen Travis | last post by:
I'm trying to write a subroutine that will fill an array of some type with several objects of that type. The subroutine works fine if I directly reference the array but if I pass the array as an...
4
by: LyzH | last post by:
Someone else had a question on how to emulate a mouse click. I tried posting in that thread but I have something of a twist on this problem and I'm really in trouble here! If I don't get help...
2
by: mj.redfox.mj | last post by:
Hi, Pretty basic question, apologies but being a bit of a newbie I still don't know the answer to this kind of thing! I have a repeater which, upon databind calls a subroutine, as below: ...
2
by: luis | last post by:
I'm using ctypes to call a fortran dll from python. I have no problems passing integer and double arryas, but I have an error with str arrys. For example: ..... StringVector = c_char_p *...
1
by: pavanponnapalli | last post by:
hi , I have got a code as under : sub dbcall { my %hash; my $i=0; print "<<<<<<<@_>>>>>>> \n"; foreach(@_)
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.