[25452] in Perl-Users-Digest
Perl-Users Digest, Issue: 7697 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jan 26 18:10:25 2005
Date: Wed, 26 Jan 2005 15:10:17 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Wed, 26 Jan 2005 Volume: 10 Number: 7697
Today's topics:
Re: how to use callback function (Anno Siegel)
Re: how to use callback function <bdu@iastate.edu>
Re: how to use callback function xhoster@gmail.com
Re: how to use callback function (Anno Siegel)
Re: how to use callback function <bdu@iastate.edu>
Re: how to use callback function <bdu@iastate.edu>
Re: how to use callback function <spamtrap@dot-app.org>
Re: how to use callback function <1usa@llenroc.ude.invalid>
Re: how to use callback function (Anno Siegel)
Re: how to use callback function <bdu@iastate.edu>
Re: Net::SSH::Perl sending output to STDOUT <yyusenet@yahoo.com>
Re: Old tutorial - now corrected binnyva@hotmail.com
Re: Old tutorial - now corrected (Anno Siegel)
Re: Old tutorial - now corrected <flavell@ph.gla.ac.uk>
Re: pattern matching <abigail@abigail.nl>
Re: Printing After A While Loop (Jay Tilton)
pulling apart a blessed hash <skendric@fhcrc.org>
Re: pulling apart a blessed hash <nobull@mail.com>
Re: pulling apart a blessed hash xhoster@gmail.com
Re: pulling apart a blessed hash (Gary E. Ansok)
Re: qiuckie for creating a file with date in name <tintin@invalid.invalid>
Re:[newbie] rename not working <mstep@t-online.de>
Re: RegEx... <toreau@gmail.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 26 Jan 2005 19:12:20 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: how to use callback function
Message-Id: <ct8q2k$1ah$1@mamenchi.zrz.TU-Berlin.DE>
bingster <bdu@iastate.edu> wrote in comp.lang.perl.misc:
> Actually, my question should be how to pass an object to a sub-routine?
No, that's not your question. The sub message() is a callback routine.
It is called for you, and any object-passing is done by your friendly
module.
> bingster wrote:
>
> > I'm stuck.
> > http://search.cpan.org/~reatmon/Net-XMPP-1.0/lib/Net/XMPP/Message.pm is
> > the manual page for the Net::XMPP::Message module.
> >
> > What I need to do is to retrieve the 'from' part from the following
> > message:
> >
> > <message type='groupchat' to='room@host.my.edu'
> > from='room@host.my.edu'><body>foo has left: Logged out</body><x
> > xmlns='jabber:x:delay' from='room@host.my.edu'
> > stamp='20050119T13:27:58'/></message>
> >
> > The DESCRIPTION part of the module manual shows:
> >
> > ============
> > use Net::XMPP;
> >
> > sub message {
> > my ($sid,$Mess) = @_;
> > .
> > .
> > .
> > }
> >
> > You now have access to all of the retrieval functions available.
> > ============
> >
> > And the METHODS section shows the usage of the following retrieval
> > function:
> >
> > ======
> > GetFrom() - returns the value in the from='' attribute for the
> > GetFrom("jid") <message/>. If you specify "jid" as an argument
> > then a Net::XMPP::JID object is returned and
> > you can easily parse the parts of the JID.
> >
> > $from = $Mess->GetFrom();
> > $fromJID = $Mess->GetFrom("jid");
> > ======
> >
> > My question is how I should pass that <message type=....></message> to
> > the callback function as an object? I'm not able to find any detailed
> > example code.
You don't. The nature of a callback is that it is called for you. What
*you* do is write the subroutine message() accordingly (untested):
sub message {
my ( $id, $msg) = @_
my $from = $msg->from;
# now do with $from what you want to do
}
At least that's how I read the documentation you quote.
Anno
------------------------------
Date: Wed, 26 Jan 2005 14:04:07 -0600
From: bingster <bdu@iastate.edu>
Subject: Re: how to use callback function
Message-Id: <35qbdoF4qdr2cU1@individual.net>
Anno Siegel wrote:
> bingster <bdu@iastate.edu> wrote in comp.lang.perl.misc:
>
>>Actually, my question should be how to pass an object to a sub-routine?
>
>
> No, that's not your question. The sub message() is a callback routine.
> It is called for you, and any object-passing is done by your friendly
> module.
>
>
>>bingster wrote:
>>
>>
>>>I'm stuck.
>>>http://search.cpan.org/~reatmon/Net-XMPP-1.0/lib/Net/XMPP/Message.pm is
>>>the manual page for the Net::XMPP::Message module.
>>>
>>>What I need to do is to retrieve the 'from' part from the following
>>>message:
>>>
>>><message type='groupchat' to='room@host.my.edu'
>>>from='room@host.my.edu'><body>foo has left: Logged out</body><x
>>>xmlns='jabber:x:delay' from='room@host.my.edu'
>>>stamp='20050119T13:27:58'/></message>
>>>
>>>The DESCRIPTION part of the module manual shows:
>>>
>>>============
>>>use Net::XMPP;
>>>
>>> sub message {
>>> my ($sid,$Mess) = @_;
>>> .
>>> .
>>> .
>>> }
>>>
>>> You now have access to all of the retrieval functions available.
>>>============
>>>
>>>And the METHODS section shows the usage of the following retrieval
>>>function:
>>>
>>>======
>>>GetFrom() - returns the value in the from='' attribute for the
>>>GetFrom("jid") <message/>. If you specify "jid" as an argument
>>> then a Net::XMPP::JID object is returned and
>>> you can easily parse the parts of the JID.
>>>
>>> $from = $Mess->GetFrom();
>>> $fromJID = $Mess->GetFrom("jid");
>>>======
>>>
>>>My question is how I should pass that <message type=....></message> to
>>>the callback function as an object? I'm not able to find any detailed
>>>example code.
>
>
> You don't. The nature of a callback is that it is called for you. What
> *you* do is write the subroutine message() accordingly (untested):
>
> sub message {
> my ( $id, $msg) = @_
> my $from = $msg->from;
> # now do with $from what you want to do
> }
>
> At least that's how I read the documentation you quote.
>
> Anno
Bare with me. But I still don't understand how callback function should
work. How is the 'message' sub-routine called? This is what I've tried.
========
#!/usr/bin/perl
use Net::XMPP;
use Net::XMPP::Message;
$mess = "<message type='groupchat' to='room@host.my.edu'
from='room@host.my.edu'><body>foo has left: Logged out</body><x
xmlns='jabber:x:delay' from='room@host.my.edu'
stamp='20050119T13:27:58'/></message>";
&message(0,$mess);
sub message {
my ($sid,$Mess) = @_;
$from = $Mess->GetFrom();
print "to is $to\n";
}
=========
The 'GetFrom()' is a method definded in the Net::XMPP::Message module.
It returned Can't call method "GetFrom" without a package or object
reference at ./test.pl line 12.
Should I do '$mess = new Net::XMPP::Message()' to create an object in
the main script? How should I pass that '<message....></message>'
string to the $mess object?
Thanks a lot for the help,
Bing
------------------------------
Date: 26 Jan 2005 20:29:37 GMT
From: xhoster@gmail.com
Subject: Re: how to use callback function
Message-Id: <20050126152937.467$Xl@newsreader.com>
bingster <bdu@iastate.edu> wrote:
>
> Bare with me. But I still don't understand how callback function should
> work. How is the 'message' sub-routine called? This is what I've tried.
If message is a call-back, then presumable you don't call it--the module
does. Usually, that means you would at point take a ref to the sub and
pass that ref into a constructor or something. The documenation doesn't
seem very good one this point, but it does say "There is are example
scripts in the example directory that provide you with examples of very
simple XMPP programs."
Looking at those example programs should clear things up.
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
------------------------------
Date: 26 Jan 2005 20:41:15 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: how to use callback function
Message-Id: <ct8v9b$49q$1@mamenchi.zrz.TU-Berlin.DE>
bingster <bdu@iastate.edu> wrote in comp.lang.perl.misc:
> Anno Siegel wrote:
> > bingster <bdu@iastate.edu> wrote in comp.lang.perl.misc:
> >>>My question is how I should pass that <message type=....></message> to
> >>>the callback function as an object? I'm not able to find any detailed
> >>>example code.
> >
> >
> > You don't. The nature of a callback is that it is called for you. What
> > *you* do is write the subroutine message() accordingly (untested):
> >
> > sub message {
> > my ( $id, $msg) = @_
> > my $from = $msg->from;
> > # now do with $from what you want to do
> > }
> >
> > At least that's how I read the documentation you quote.
> >
> > Anno
>
> Bare with me.
Thanks, but no :)
> But I still don't understand how callback function should
> work. How is the 'message' sub-routine called? This is what I've tried.
>
> ========
> #!/usr/bin/perl
>
> use Net::XMPP;
> use Net::XMPP::Message;
>
> $mess = "<message type='groupchat' to='room@host.my.edu'
> from='room@host.my.edu'><body>foo has left: Logged out</body><x
> xmlns='jabber:x:delay' from='room@host.my.edu'
> stamp='20050119T13:27:58'/></message>";
>
> &message(0,$mess);
$mess is a plain string here, not a Net::XMPP::Message object, as
required.
> sub message {
> my ($sid,$Mess) = @_;
> $from = $Mess->GetFrom();
> print "to is $to\n";
> }
> =========
>
> The 'GetFrom()' is a method definded in the Net::XMPP::Message module.
>
> It returned Can't call method "GetFrom" without a package or object
> reference at ./test.pl line 12.
Sure. You didn't pass an object in.
> Should I do '$mess = new Net::XMPP::Message()' to create an object in
> the main script? How should I pass that '<message....></message>'
> string to the $mess object?
I don't know. See if there's a documented creator for Net::XMPP::Message
objects. If the documentation doesn't mention one, there is none. If
the module is any good, that means that you don't need one in normal
operation. Otherwise, proceed as documented.
> Thanks a lot for the help,
I can't give you any more specific help -- I don't know Net::XMPP, not
to mention XMPP itself.
Unspecifically, I have the impression you got something backwards.
The message() callback would be called (I'm speculating a bit here)
when a message *arrives*, whatever that means in XMPP. Then you get a
ready-made message object in $Mess and can call the methods. But that
would be a message that comes from somewhere else. You don't (normally)
get to set it up in the same part of the program that receives it.
So, either you have to arrange for the specific message you want to
analyze to arrive and trigger a callback.
Or forget about the callback and see if you can create a message object
directly. Then you can apply methods like ->GetFrom to that object
without the help of message(). Unless this is for experimentation,
it looks a bit futile -- presumably you know what you have put in the
"From" slot when you created the object.
Anno
------------------------------
Date: Wed, 26 Jan 2005 15:06:18 -0600
From: bingster <bdu@iastate.edu>
Subject: Re: how to use callback function
Message-Id: <35qf2cF4n7tu5U1@individual.net>
xhoster@gmail.com wrote:
> If message is a call-back, then presumable you don't call it--the module
> does. Usually, that means you would at point take a ref to the sub and
> pass that ref into a constructor or something. The documenation doesn't
> seem very good one this point, but it does say "There is are example
> scripts in the example directory that provide you with examples of very
> simple XMPP programs."
>
> Looking at those example programs should clear things up.
>
> Xho
>
Speaking of the example programs, if I had had access to any example
code, I would not have come here to bother you guys. I saw the manual
mentioned the example directory as well. However I've searched my
system from root, but did not find any related example code. I e-mailed
the author of the module. But got no response. Also searching
Net::XMPP in this newsgroup returns nothing but my posts. Anyway,
thanks a lot for looking.
Bing
------------------------------
Date: Wed, 26 Jan 2005 15:18:00 -0600
From: bingster <bdu@iastate.edu>
Subject: Re: how to use callback function
Message-Id: <35qfoaF4q6movU1@individual.net>
Anno Siegel wrote:
> The message() callback would be called (I'm speculating a bit here)
> when a message *arrives*, whatever that means in XMPP. Then you get a
> ready-made message object in $Mess and can call the methods. But that
> would be a message that comes from somewhere else. You don't (normally)
> get to set it up in the same part of the program that receives it.
>
That makes some sense.
> So, either you have to arrange for the specific message you want to
> analyze to arrive and trigger a callback.
>
Dunno how to do it at this point.
> Or forget about the callback and see if you can create a message object
> directly. Then you can apply methods like ->GetFrom to that object
> without the help of message(). Unless this is for experimentation,
> it looks a bit futile -- presumably you know what you have put in the
> "From" slot when you created the object.
>
This is something I want to try, that is, forget about the callback and
create a message object directly. Any quick pointers that can show me
how to create a message object directly?
THANKS!
Bing
------------------------------
Date: Wed, 26 Jan 2005 16:23:37 -0500
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: how to use callback function
Message-Id: <XaGdnTF_At_Bl2XcRVn-1A@adelphia.com>
bingster wrote:
> Speaking of the example programs, if I had had access to any example
> code, I would not have come here to bother you guys. I saw the manual
> mentioned the example directory as well. However I've searched my
> system from root, but did not find any related example code.
The 'examples/' subdirectory is not installed on your system, it's part of
the module source. Just go to CPAN and download the module tarball and
unpack it. Or use 'look' in the CPAN shell to do the same thing.
I didn't look very closely at the example, but client.pl looks promising -
there's a call to SetCallbacks(), and implementations of callback methods.
sherm--
--
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org
------------------------------
Date: Wed, 26 Jan 2005 21:24:51 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: how to use callback function
Message-Id: <Xns95EAA70318324asu1cornelledu@127.0.0.1>
bingster <bdu@iastate.edu> wrote in news:35qf2cF4n7tu5U1@individual.net:
> Speaking of the example programs, if I had had access to any example
> code, I would not have come here to bother you guys. I saw the manual
> mentioned the example directory as well. However I've searched my
> system from root, but did not find any related example code. I e-mailed
> the author of the module. But got no response. Also searching
> Net::XMPP in this newsgroup returns nothing but my posts. Anyway,
> thanks a lot for looking.
Oh, c'mon ...
http://search.cpan.org/src/REATMON/Net-XMPP-1.0/examples/
The steps it took to find it:
1. http://search.cpan.org/
2. Type xmpp in the search box
3. Follow < Net::XMPP >
4. Follow < Net-XMPP-1.0 >
5. Follow < Browse >
6. Look in the examples directory
I am not sure which one of these steps is not obvious.
Sinan
------------------------------
Date: 26 Jan 2005 21:27:47 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: how to use callback function
Message-Id: <ct920j$49q$3@mamenchi.zrz.TU-Berlin.DE>
bingster <bdu@iastate.edu> wrote in comp.lang.perl.misc:
> Anno Siegel wrote:
[...]
> > Or forget about the callback and see if you can create a message object
> > directly. Then you can apply methods like ->GetFrom to that object
> > without the help of message(). Unless this is for experimentation,
> > it looks a bit futile -- presumably you know what you have put in the
> > "From" slot when you created the object.
> >
>
> This is something I want to try, that is, forget about the callback and
Seems reasonable.
> create a message object directly. Any quick pointers that can show me
> how to create a message object directly?
No. At this point, that would mean I'd read the documentation for you.
If you have specific questions about parts of the doc, you're welcome
back.
Anno
------------------------------
Date: Wed, 26 Jan 2005 16:17:56 -0600
From: bingster <bdu@iastate.edu>
Subject: Re: how to use callback function
Message-Id: <35qj8lF4ne9r4U1@individual.net>
Sherm Pendley wrote:
> The 'examples/' subdirectory is not installed on your system, it's part of
> the module source. Just go to CPAN and download the module tarball and
> unpack it. Or use 'look' in the CPAN shell to do the same thing.
>
Thanks a bunch, Sherm, for jumping in at the right time! I did not know
examples/ was not installed. Following what you said, I'm able to see
the example programs now. That's a really big help.
> I didn't look very closely at the example, but client.pl looks promising -
> there's a call to SetCallbacks(), and implementations of callback methods.
>
> sherm--
>
Yup. It absolutely let me see some light at the end of the tunnel.
Bing
------------------------------
Date: Wed, 26 Jan 2005 15:34:06 -0700
From: YYusenet <yyusenet@yahoo.com>
Subject: Re: Net::SSH::Perl sending output to STDOUT
Message-Id: <ct95ss$qak$1@news.xmission.com>
ryanmhuc@yahoo.com wrote:
> I'm using Net::SSH::Perl to connect to remote server but when every I
> run commands it is sending output to STDOUT.
>
> $ssh = Net::SSH::Perl->new($ip);
> $ssh->login($user, $pass);
> ($out, $err, $ext) = $ssh->cmd("ls -l");
>
> So when I run the command instead of the the command output being put
> into $out it goes straight to STDOUT. Furthermore if the password is
> incorrect the $ssh->cmd stops my program. Anyone know how to get
> around this?
>
Are you using 'print OUT "what to send";' ? And it would help to see
the code that you are trying to run.
****************
k g a b e r t (at) x m i s s i o n (dot) c o m
------------------------------
Date: 26 Jan 2005 11:08:42 -0800
From: binnyva@hotmail.com
Subject: Re: Old tutorial - now corrected
Message-Id: <1106766522.966545.9750@z14g2000cwz.googlegroups.com>
I admit that I should correct those scirpts - I will.
But please not that those are functional scirpt -
just not perfect. They have some bugs. The most
noted problem was that I did not use CGI.pm
module. One should remember that not everyone
has the CGI.pm module. They should be having it -
but its not a perlfect(sic) world.
But I promise that I will correct the bugs as soon
as possible.
Thank you,
Binny V A
http://www.geocities.com/binnyva/code
------------------------------
Date: 26 Jan 2005 19:25:21 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Old tutorial - now corrected
Message-Id: <ct8qr1$1ah$2@mamenchi.zrz.TU-Berlin.DE>
<binnyva@hotmail.com> wrote in comp.lang.perl.misc:
> I admit that I should correct those scirpts - I will.
> But please not that those are functional scirpt -
^^^
That must be a Freudian slip. They're probably as functional as M*tt's
Script Archive.
If the bit of date manipulation code that was shown here is any indication,
you are *way* too inexperienced in Perl, and programming in general, to be
publishing code. Stop it.
Anno
------------------------------
Date: Wed, 26 Jan 2005 19:55:51 +0000
From: "Alan J. Flavell" <flavell@ph.gla.ac.uk>
Subject: Re: Old tutorial - now corrected
Message-Id: <Pine.LNX.4.61.0501261951030.20593@ppepc56.ph.gla.ac.uk>
On Wed, 26 Jan 2005 binnyva@hotmail.com wrote:
> The scripts are not the part of the tutorial
Look, give it a rest already. You're quite dangerous to be let loose
on beginners, but you don't seem to want to recognise the fact.
If you /really/ took the advice you're getting here, you'd take that
stuff off the web for the time being. But you seem to be deaf to that
part of the advice (and to too much of the rest too). I suppose all
we can do is offer a "c.l.p.m health warning" and hope that it'll
reach at least some of your intended audience.
Don't take this wrong - we all have to start somewhere, and there's no
shame in being a beginner - but that doesn't mean rushing right out
and publishing a premature tutorial.
------------------------------
Date: 26 Jan 2005 19:30:54 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: pattern matching
Message-Id: <slrncvfrve.ev3.abigail@alexandra.abigail.nl>
yusufdestina (joericochuyt@msn.com) wrote on MMMMCLXVI September MCMXCIII
in <URL:news:454a6f50ab99b7d642ae3e7bcb6fa820@localhost.talkaboutprogramming.com>:
:) hi all,
:) I'm stuck on this one...
:) How do I retrieve the content of the next string inside the ' signs??
:) example:
:) $text = "This is \'very important\'";
:) Do I have to use split for this?
use Regexp::Common;
my ($inside_quotes) = $text =~ /$RE{delimited}{-delim => "'"}{-keep}/;
Abigail
--
sub _ {$_ = shift and y/b-yB-Y/a-yB-Y/ xor !@ _?
exit print :
print and push @_ => shift and goto &{(caller (0)) [3]}}
split // => "KsvQtbuf fbsodpmu\ni flsI " xor & _
------------------------------
Date: Wed, 26 Jan 2005 22:23:32 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: Printing After A While Loop
Message-Id: <41f81614.171011431@news.erols.com>
tiltonj@erols.com (Jay Tilton) wrote:
: print SNMPLOG
: { FAILURE => ' 0 ', SUCCESS => ' 1 ' } -> { $status{$_} }
: for sort keys %status;
Or using hash slices:
print SNMPLOG
@{{ FAILURE=>' 0 ', SUCCESS=>' 1 ' }}
{@status{ sort keys %status }};
That's probably going one step too far into obfuscation country.
------------------------------
Date: 26 Jan 2005 11:43:37 -0800
From: "sbk" <skendric@fhcrc.org>
Subject: pulling apart a blessed hash
Message-Id: <1106768617.508745.203270@c13g2000cwb.googlegroups.com>
hi,
i'm using a module which returns a reference to a blessed hash, and i'm
having trouble figuring out how to pull apart this data structure.
guru% cat test
#!/usr/bin/perl
use strict;
use warnings;
use Data::Dumper;
use Net::NBName;
my $ip = "10.1.2.3";
my $nb = Net::NBName->new;
my $ns = $nb->node_status($ip);
print Dumper($ns);
guru% ./test
$VAR1 = bless( {
'mac_address' => '8C-6B-20-5C-00-00',
[...]
but of course, i don't want use Dumper in my real program ... i want to
extract the values in this blessed hash and do useful things with them.
i haven't figured out the syntax i would need to do this.
the following seemed reasonable to be ... but they didn't work ... so
much for my sense of reasonableness:
my $temp = $ns->mac_address;
print "$temp\n";
or
my $temp = $ns->{'mac_address'};
print "$temp\n";
would anyone be willing to offer me alternate syntax?
--sk
stuart kendrick
fhcrc
------------------------------
Date: Wed, 26 Jan 2005 19:56:29 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: pulling apart a blessed hash
Message-Id: <ct8sbd$rv1$1@sun3.bham.ac.uk>
sbk wrote:
> hi,
>
> i'm using a module which returns a reference to a blessed hash, and i'm
> having trouble figuring out how to pull apart this data structure.
Blessing does not change how you can get at the internals.
However, unless the module documentation says you are allowed to access
the internals of the object directly you should not do so as subsequent
realease of the module may change the internals.
> print Dumper($ns);
> $VAR1 = bless( {
> 'mac_address' => '8C-6B-20-5C-00-00',
> [...]
> the following seemed reasonable to be ... but they didn't work ...
> my $temp = $ns->{'mac_address'};
That should work. Please genereate a minimal but complete script to
illustrate your claim that it does not.
> would anyone be willing to offer me alternate syntax?
Well, if you insist.
$$ns{mac_address}
But I still think the syntax with -> looks better.
------------------------------
Date: 26 Jan 2005 20:21:28 GMT
From: xhoster@gmail.com
Subject: Re: pulling apart a blessed hash
Message-Id: <20050126152128.837$PC@newsreader.com>
"sbk" <skendric@fhcrc.org> wrote:
> hi,
>
> i'm using a module which returns a reference to a blessed hash, and i'm
> having trouble figuring out how to pull apart this data structure.
You aren't supposed to pull apart those data structures. If you are
getting an object, you should almost certainly use it like an object.
> my $nb = Net::NBName->new;
> my $ns = $nb->node_status($ip);
> but of course, i don't want use Dumper in my real program ... i want to
> extract the values in this blessed hash and do useful things with them.
Why not use the object methods provided? Any decent module will provide
you with the methods you need to access the data. And I try not to use
indecent modules in the first place.
>
> the following seemed reasonable to be ... but they didn't work ... so
> much for my sense of reasonableness:
>
...
> my $temp = $ns->{'mac_address'};
> print "$temp\n";
What, exactly, do you mean by "didn't work"?
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
------------------------------
Date: Wed, 26 Jan 2005 21:28:31 +0000 (UTC)
From: ansok@alumni.caltech.edu (Gary E. Ansok)
Subject: Re: pulling apart a blessed hash
Message-Id: <ct921v$3q6$1@naig.caltech.edu>
In article <1106768617.508745.203270@c13g2000cwb.googlegroups.com>,
sbk <skendric@fhcrc.org> wrote:
>hi,
>
>i'm using a module which returns a reference to a blessed hash, and i'm
>having trouble figuring out how to pull apart this data structure.
>
>i haven't figured out the syntax i would need to do this.
>
>the following seemed reasonable to be ... but they didn't work ... so
>much for my sense of reasonableness:
>
>my $temp = $ns->mac_address;
>print "$temp\n";
This should work, assuming that $ns is a reference to a Net::NBName::NodeStatus
object. I'm not familiar with the Net::NBName module, though.
This would generally be the preferred syntax, although personally I'd find
$ns->mac_address() a little clearer.
>my $temp = $ns->{'mac_address'};
>print "$temp\n";
This should also work, although you're more likely to have potential
problems caused by future changes to the module. The quotes around
mac_address aren't needed in this example.
When you say "didn't work", what happened? Did you get an error message
or warning? What did the message say? Did you get output different
than what you expected? What did you get, and what did you expect?
Did you check to make sure that both $nb and $ns are defined?
>would anyone be willing to offer me alternate syntax?
foreach my $key (keys %$ns) {
print "$key => '$ns->{$key}'\n";
}
Gary Ansok
--
Any attempt to brew coffee with a teapot should result in the error code
"418 I'm a teapot". The resulting entity body MAY be short and stout.
-- RFC 2324, Hyper Text Coffee Pot Control Protocol (HTCPCP)/1.0
------------------------------
Date: Thu, 27 Jan 2005 08:24:22 +1300
From: "Tintin" <tintin@invalid.invalid>
Subject: Re: qiuckie for creating a file with date in name
Message-Id: <35q8voF4p7faeU1@individual.net>
<laredotornado@zipmail.com> wrote in message
news:1106683549.598578.240080@c13g2000cwb.googlegroups.com...
> Hi, This group has been pretty unbelievable at coming up with quick one
> or two line solutions to questions so I thought I'd throw this one out
> there. I want to create a file containing a single word "Done" for
> contents but I would like the file name to be of the form:
>
> File_YYYYMMDD_HHMMSS.done
>
> where YYYY is the four year date, MM is the month number, and so on..
> What's the quickest way I could do this?
use POSIX 'strftime';
my $file = strftime('File_%Y%m%d_%H%M%S.done',localtime);
open FILE, ">$file" or die "Could not create $file $!\n";
------------------------------
Date: Wed, 26 Jan 2005 23:31:23 +0100
From: Marek Stepanek <mstep@t-online.de>
Subject: Re:[newbie] rename not working
Message-Id: <BE1DD8CB.EF70%mstep@t-online.de>
On 25.01.2005 21:58, in article
Pine.LNX.4.61.0501251445570.9364@johann.blauedonau.com, "terry l. ridder"
<terrylr@blauedonau.com> wrote:
> snip
Thanx for your great response. You gave me great stuff to digest. I am
feeling bad, because this were obvious logical errors; but also to think
logic and perlish you have to learn and train it.
greetings from Munich
marek
--
______________________________________________________________________
___PODIUM_INTERNATIONAL_//_the_embassy_for_talented_young_musicians___
_______Marek_Stepanek__mstep_[at]_PodiumInternational_[dot]_org_______
__________________http://www.PodiumInternational.org__________________
______________________________________________________________________
------------------------------
Date: Wed, 26 Jan 2005 23:48:32 +0100
From: Tore Aursand <toreau@gmail.com>
Subject: Re: RegEx...
Message-Id: <27VJd.6151$Sl3.148015@news4.e.nsc.no>
wizgod@yahoo.com wrote:
> To All hello. I am trying to grab a specific portion of the e-mail
> address from
> a string on the fly and for some reason It's(That is perl is not liking
> what ever I Do.) I would appreciate your guidance oh great perl gurus
> of the internet....:)
>
> my $messageid = ( $string =~ m{Message-ID:
> \<Somoneewhere@news.someplace.org>});
> ^^^^^^^^^^^^---This is
> what I want.
Use the 'Mail::Address' module from CPAN. From the top of my head, it
works something like this;
#!/usr/bin/perl
#
use strict;
use warnings;
use Mail::Address;
my $string = 'Message-ID: <Somoneewhere@news.someplace.org>';
my @addresses = Mail::Address->parse( $string );
foreach ( @addresses ) {
print $_->user() . "\n";
}
--
Tore Aursand <tore@aursand.no>
"I didn't have time to write a short letter, so I wrote a long one
instead." (Mark Twain)
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc. For subscription or unsubscription requests, send
#the single line:
#
# subscribe perl-users
#or:
# unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.
#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V10 Issue 7697
***************************************