Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Constructing a scalar reference

Reply
Thread Tools

Constructing a scalar reference

 
 
Chet Butcher
Guest
Posts: n/a
 
      06-07-2009
Hi

In the following sequence

$r = {}; # a hashref
$r = []; # an arrayref
$r = ?; # a scalar ref

What is ? ? I want to pass a ref to a scalar (pass by reference)
without resorting to

my $r;
mySub( \$r );

I just want to use

my $r = (something);
mySub( $r );

to be consistent with

my $r = {}; # or my $r = [];
mySub( $r );

I know it's not a big drama on the surface, but I'm trying to overload
the method to return various results depending on the reference type,
and I dont want the \ in some calls and not others.

Thanks

 
Reply With Quote
 
 
 
 
Tad J McClellan
Guest
Posts: n/a
 
      06-07-2009
Chet Butcher <(E-Mail Removed)> wrote:

> In the following sequence
>
> $r = {}; # a hashref
> $r = []; # an arrayref
> $r = ?; # a scalar ref
>
> What is ? ?



Troll alert!

This was posted here in August 2006 and again last January...


--
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"
 
Reply With Quote
 
 
 
 
Keith Thompson
Guest
Posts: n/a
 
      06-07-2009
Chet Butcher <(E-Mail Removed)> writes:
> In the following sequence
>
> $r = {}; # a hashref
> $r = []; # an arrayref
> $r = ?; # a scalar ref
>
> What is ? ? I want to pass a ref to a scalar (pass by reference)
> without resorting to
>
> my $r;
> mySub( \$r );
>
> I just want to use
>
> my $r = (something);
> mySub( $r );
>
> to be consistent with
>
> my $r = {}; # or my $r = [];
> mySub( $r );
>
> I know it's not a big drama on the surface, but I'm trying to overload
> the method to return various results depending on the reference type,
> and I dont want the \ in some calls and not others.


Why did you redirect followups to comp.lang.c?

--
Keith Thompson (The_Other_Keith) http://www.velocityreviews.com/forums/(E-Mail Removed) <http://www.ghoti.net/~kst>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
 
Reply With Quote
 
Phil Carmody
Guest
Posts: n/a
 
      06-09-2009
Chet Butcher <(E-Mail Removed)> writes:
[SNIP - nothing of interest to the newsgroup where you directed follow-ups]

Hello "tea pot". You're still an idiot, even after you've morphed.
What a sad and sorry life you must lead.

Phil
--
Marijuana is indeed a dangerous drug.
It causes governments to wage war against their own people.
-- Dave Seaman (sci.math, 19 Mar 2009)
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Constructing a scalar reference Chet Butcher Perl Misc 4 01-31-2009 05:19 PM
constructing a scalar reference Dibosia Perl Misc 11 08-22-2006 05:59 PM
object reference handle (like perl's reference to scalar) Eric Mahurin Ruby 4 05-06-2005 05:30 PM
Replace scalar in another scalar Mark Perl Misc 4 01-27-2005 02:48 PM
Shorthand for($scalar) loops and resetting pos($scalar) Clint Olsen Perl Misc 6 11-13-2003 12:50 AM



Advertisments