You are doing two different things.

Here is your first case:
my $exp = YAPE::Regex::Explain->new($regex)->explain;
print $exp;  #this works

That is the same as this:
my $exp = YAPE::Regex::Explain->new($regex)
$exp = $exp->explain;
print $exp;  #this works

Note that $exp is the return value of explain(), and is *not* a
YAPE::Regex::Explain object.  In your second case you are calling explain()
which returns a string value... you aren't storing it though, so it just
gets thrown away.

Rob

-----Original Message-----
From: zentara [mailto:[EMAIL PROTECTED]]
Sent: Monday, January 14, 2002 3:30 PM
To: [EMAIL PROTECTED]
Subject: hash reference outputs from modules


Trying to figure out hash references and methods.

Why does the  "print $exp" work in case1,
while in case2 it only prints the hash reference?
Is it that critical that the explain method is on a separate line?
Or why does the print statement enable the "$exp->explain"
to work, as in the last line?

##################################################
#!/usr/bin/perl 
use warnings;
use strict;
use YAPE::Regex::Explain;

my $regex = 's/^(.{200}).*$/$1/';

#case1
################################################
my $exp = YAPE::Regex::Explain->new($regex)->explain;
print $exp;  #this works
###############################################


#case2
###############################################
my $exp = YAPE::Regex::Explain->new($regex);
$exp -> explain;
print $exp;  # this just gives the HASHreference
print $exp->explain;  #this works 
################################################





-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to