Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7895487
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T07:39:19+00:00 2026-06-03T07:39:19+00:00

What do I gain if I write to a real reference like \*STDOUT instead

  • 0

What do I gain if I write to a real reference like \*STDOUT instead of a typeglob like *STDOUT?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T07:39:20+00:00Added an answer on June 3, 2026 at 7:39 am

    One is a typeglob, another is a reference to it.

    As far as I know, the main practical difference is that you can NOT bless a typeglob into an object, but you CAN bless the typeglob reference (which is what IO::Handle does)

    This distinction is discussed in detail in “Perl Cookbook”, Recipe 7.16. “Storing Filehandles in Variable”.


    Another difference is that assigning a glob creates an alias to the ENTIRE glob, whereas assigning a glob reference does the expected (as discussed in perldoc perlmod, "Symbol Tables" section. To illustrate:

    @STDOUT=(5);
    $globcopy1 = *STDOUT; # globcopy1 is aliased to the entire STDOUT glob, 
                          # including alias to array @STDOUT
    $globcopy2 = \*STDOUT; # globcopy2 merely stores a reference to a glob, 
                           # and doesn't have anything to do with @STDOUT
    
    print $globcopy1 "TEST print to globcopy1/STDOUT as filehandle\n";
    print "TEST print of globcopy1/STDOUT as array: $globcopy1->[0]\n\n";
    print $globcopy2 "TEST print to globcopy2/STDOUT as filehandle\n";
    print "TEST print of globcopy2/STDOUT as array: $globcopy2->[0]\n\n";
    

    Produces:

    TEST print to globcopy1/STDOUT as filehandle
    TEST print of globcopy1/STDOUT as array: 5
    
    TEST print to globcopy2/STDOUT as filehandle
    Not an ARRAY reference at line 8.
    

    As a side note, a rumor that the typeglob reference is the only way to pass the filehandle into a function is not the case:

    sub pfh { my $fh = $_[0]; print $fh $_[1]; }
    
    pfh(*STDOUT, "t1\n");
    pfh(\*STDOUT, "t2\n");
    
    # Output:
    # t1
    # t2
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'd like to get into ejb3 to gain some practice in writing for it.
I would like to write an application, for my own interest, that graphically visualizes
To gain the root permission of android, we usually do like this: Process p=Runtime.getRuntime().exec(su);
I would like to write a query that simply returns 1 or 0 depending
Hi i want my java program to show a popup and gain read,write,delete file,folder
With PHP5 using copy on write and passing by reference causing more of a
I work for an audio recorder app and would like to add gain control
I need to gain access to the list of most recently used programs and
Is there any gain to combining all of the classes for a project into
I'm trying to gain a basic understanding of what is meant by a Windows

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.