The result of this, by using draw twice, is that both file1.rrd and
file2.rrd are charted by graph().

I want to build up a list of files dynamically and pass that list into
the graph method but am struggling to do this .
IE what goes in [>>> here <<<]

$rrd->graph(
image => $image_file_name,
[ >>>>> multiple draw's , one each for each of the multiple user
defined files to chart <<<<<]
);

I want the user to define the list of files to be charted and pass them
to chart() method. I'm no expert in OO perl clearly. I've tried a
number of different ways of doing this such as passing arrays of hashes
by reference, or not, etc etc but to no avail and usually ending up
with a 'Reference found where even-sized list expected' error.

Advertisements

"eatmoreoats" <> wrote in
news::
> The general question
>
> In general how do I pass into an object's method a variable set of
> values ?
>
>
> The actual scenario
>
> There is an object that I am using that has a method, called graph(),
> which can take multiple files to chart out :
>
> ...
> $rrd->graph(
> image => $image_file_name,
> draw => {
> file => "file1.rrd",
> legend => "First Source"
> },
> draw => {
> file => "file2.rrd",
> legend => "Second Source"
> }
> );
> ...
>
> The result of this, by using draw twice, is that both file1.rrd and
> file2.rrd are charted by graph().

I am a little puzzled by that. I do not see any code in the source code
for that module that would have emitted draw => HASH(0x96afcf0)draw =>
HASH(0x99104dc). It would be useful if you posted a short but complete
script instead of snippets.
> Also - dumb question but how do I push another anonymous hash into
> @from_user, for say, file3.rrd ?

On 21 Feb 2006 16:52:15 -0800, "eatmoreoats" <> wrote:
>Thanks for the response.
>
>I tried the method you described above, including the correction to
>map. Here is the code now :
>
>...
>my @from_user = (
> { file => 'file1.rrd', legend => 'First Source' },
> { file => 'file2.rrd', legend => 'Second Source' },
>);
>
>$rrd->graph(
> image => $image_file_name,
> map {+ draw => $_ } @from_user,
Why do you play such a dangerous game in your function call with
map? You need to "pull" all those shortcuts "out" into the open
ahead of time and prove them there, ahead of time, before you can do them inside
calls. Then move them one by one inside/and or make shortcuts.
Don't pile drive the Perl stack and expect it to work righ away.
Its ludicruis to even attempt such a thing. Utterly absurd!!!
There is not time saving involved. Use Benchmark if your not sure.
Bizzar ....
>);
>...
>
>When running, I get this problem :
>
>draw => HASH(0x96afcf0)draw => HASH(0x99104dc)Illegal parameter '1' in
>graph() at ./grapher.pl line (some line #)
>
>Any ideas why ?
>
>Also - dumb question but how do I push another anonymous hash into
>@from_user, for say, file3.rrd ?
>
>Thanks again for helping - really appreciate it.
>-dom

Why are there quotation marks surrounding draw => $_? You have just
created a string instead of the key => anonymous hash ref that you need
to pass. The '1' in the error message is the return value of the print.

I am really baffled. Do you have to introduce random crap into the
suggestion I posted, and then lie about it in your follow-up post?
> Rob

If you are referring to robic0, well, you might want to stay away from
that unbalanced person. On the other hand, after you wasted my time like
this, I feel like you guys deserve each other.

On 21 Feb 2006 18:25:00 -0800, "eatmoreoats" <> wrote:
>Sinan, Chris,
>
>opps that was my mistake - that was from earlier
>testing/experimentation. doh!
>
>yup - all seems to work - thanks very much for helping everyone.
>
>-d
Sinan is the apparent map expert. Don't worry they won't they won't you,
you don't know me and have never sold me drugs right?

Formally admit that now, and never ever, acknowledge any follow up I may
reply to your posts, even with a Rob. Because, something is wrong with this
forum. See, you don't know me, but I replied with a sensible aproach.
Since you had'nt figured out your dilema (haden't u?) you would cry for help
in that regard. I replied, you responded to multiple posts. I think you tried
Sinans method, but it didn't work (some mistake you made?) so you grabbed for
anything you could (to save your job?). Now you try to make restitution.

I wish you lick (I mean luck). All you have to do is state you will put me
on your exclusion list and all is well with Sinan. Either that or publicall state
to me personally I am something that will separate you from me in the mind of Sinan.

To do that you will have to publically state, in short form, you wish not to
get responses on any of your questions, by myself. It might help if you also state
that you are putting me on your exclusion list in your reader. Any posts by me do
not show up on your reader (whats that called?)

Then you will be the "one" and only who has done that. I mean its been done,
but undone faster than a bear shits in the woods.

Sinan is a regular responder. And you shouldn't get on his bad side. I am a regular
developer and couldn't give a rats ass about such a puny mind.

Thems the facts ma'm, whish you luck.
Oh and btw, thanks for the lunch last Thurs!

Share This Page

Welcome to The Coding Forums!

Welcome to the Coding Forums, the place to chat about anything related to programming and coding languages.

Please join our friendly community by clicking the button below - it only takes a few seconds and is totally free. You'll be able to ask questions about coding or chat with the community and help others.
Sign up now!