Ask a Question related to PERL Beginners, Design and Development.
-
Robin Sheat #1
Checking for calling context
Hey there,
I have a set of functions that send an XML element, wait for a response,
parse the response, and return it. However, there are often cases where
the resulting XML is never used, and so parsing it is pointless. Is
there a way that a sub can tell where the result is going to go, so that
it can not do the parsing if the result is going to be immediatly
discarded?
Something like this:
foo(a,b,c);
%result = foo(c,d,e);
sub foo {
...do stuff...
if (-result isn't discarded-) {
return parseResult($result);
}
}
--
Robin <robin@kallisti.net.nz> JabberID: <eythian@jabber.org>
Hostes alienigeni me abduxerunt. Qui annus est?
PGP Key 0x776DB663 Fingerprint=DD10 5C62 1E29 A385 9866 0853 CD38 E07A 776D B663
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)
iD8DBQFALcGvzTjgendttmMRAjEQAJ9gyOal/1b4kQDlCOIk9VHXZHKEJACcCyjo
G1OZ0yBz6rMSi6gr7Arh8ks=
=hyRD
-----END PGP SIGNATURE-----
Robin Sheat Guest
-
I can't use the context menu
:confused; Hi, everyone. I have seen that many people has some problems with the right click options. In my case, the context menu appears... -
Context Menu
How can I completely hide context menu if click right button of a mouse? -
context root
I have CF7 enterprise and win2003 server sp1 I wish to get following configuration: https://secure.domain.com/my_cf7_instance1/hello.cfm and... -
Response is not available in this context
As soon as you return to the client the context is gone Can you respond to the client then make the client automatically check back ( Meta Tag or... -
No Right Context Menu
Hi, I'm running Windows XP Pro on a Fujitsu laptop. When I click Srart and move over any previous used program program in the start menu,(I use the... -
Wolf Blaum #2
Re: Checking for calling context
> Hey there,
HiIf you are asking how to teel between:> I have a set of functions that send an XML element, wait for a response,
> parse the response, and return it. However, there are often cases where
> the resulting XML is never used, and so parsing it is pointless. Is
> there a way that a sub can tell where the result is going to go, so that
> it can not do the parsing if the result is going to be immediatly
> discarded?
>
$var=⊂
and
⊂
- not that I know.
However, there is a way to tell who asked for the result:
read perldoc -f caller
but why dont you pass a parameter to the sub that tells it?
Wolf
Wolf Blaum Guest
-
Robin Sheat #3
Re: Checking for calling context
On Sat, Feb 14, 2004 at 08:19:20AM +0100, wolf blaum wrote:
Pretty much, from the point of view of sub.> If you are asking how to teel between:
> $var=⊂
> and
> ⊂
Not really what I want.> However, there is a way to tell who asked for the result:
> read perldoc -f caller
Because there are about a dozen subs and I didn't want to change the API> but why dont you pass a parameter to the sub that tells it?
on all of them, along with all the places they are being called from.
However, I resolved it, not quite so elegantly, but introducing a
'keepResults' method to the class that has the subs, which allows it to
be toggled. In my optimisation attempts I ended up stumbling into
another issue however, somewhat unrelated.
I set it up, so that if the results aren't needed, they aren't even read
from the network socket. This means that if the remote program is taking
its time to generate them, the Perl program doesn't have to wait for
data it'll be throwing away. I added a counter to see how much data we
are ignoring, so that when we finally do need something, we know how
much to discard. However, I found that if the the queue of data got
above one, one of two things happens: either the Java program at the
other end discards the extra XML elements sent to it while processing
ones that take a while, or replies get lost. Either way, the Perl end
sits there waiting for data that never arrives. If I can be bothered, I
might put debugging code into the Java to see whats happening, at that
end.
However, if anyone has a clue as to what's going please let me know (the
more data I can safely ignore, the faster my program can run :)
--
Robin <robin@kallisti.net.nz> JabberID: <eythian@jabber.org>
Hostes alienigeni me abduxerunt. Qui annus est?
PGP Key 0x776DB663 Fingerprint=DD10 5C62 1E29 A385 9866 0853 CD38 E07A 776D B663
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)
iD8DBQFALc+BzTjgendttmMRAgzjAJ4t3P4uuWDt6Kgn/bqe6LWz+GMbxQCfev/d
u7Vogq2O/hjZsOsGoOngB10=
=d7cF
-----END PGP SIGNATURE-----
Robin Sheat Guest
-
Jeff 'Japhy' Pinyan #4
Re: Checking for calling context
On Feb 14, Robin Sheat said:
Yes, use wantarray().>I have a set of functions that send an XML element, wait for a response,
>parse the response, and return it. However, there are often cases where
>the resulting XML is never used, and so parsing it is pointless. Is
>there a way that a sub can tell where the result is going to go, so that
>it can not do the parsing if the result is going to be immediatly
>discarded?
sub foo {
if (not defined wantarray) { print "void context\n" }
elsif (wantarray) { print "list context\n" }
else { print "scalar context\n" }
}
foo();
$x = foo();
@y = foo();
--
Jeff "japhy" Pinyan [email]japhy@pobox.com[/email] [url]http://www.pobox.com/~japhy/[/url]
RPI Acacia brother #734 [url]http://www.perlmonks.org/[/url] [url]http://www.cpan.org/[/url]
<stu> what does y/// stand for? <tenderpuss> why, yansliterate of course.
[ I'm looking for programming work. If you like my work, let me know. ]
Jeff 'Japhy' Pinyan Guest
-
Robin Sheat #5
Re: Checking for calling context
On Sat, Feb 14, 2004 at 03:44:38AM -0500, Jeff 'japhy' Pinyan wrote:
Aha! Thanks :)> Yes, use wantarray().
--
Robin <robin@kallisti.net.nz> JabberID: <eythian@jabber.org>
Hostes alienigeni me abduxerunt. Qui annus est?
PGP Key 0x776DB663 Fingerprint=DD10 5C62 1E29 A385 9866 0853 CD38 E07A 776D B663
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)
iD8DBQFALomRzTjgendttmMRAo1fAJkBYkm7aqajxwoCGONOVD unfMT+bwCgpqxq
hvPRsQv4jOe2U+ghJ65prLI=
=fUEO
-----END PGP SIGNATURE-----
Robin Sheat Guest



Reply With Quote

