Perl IO vs GLOB symbols


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Perl IO vs GLOB symbols
# 1  
Old 07-03-2008
Error Perl IO vs GLOB symbols

Hi,

Can someone please clarify how we are able to use both IO and GLOB symbols of a package variable interchangeably?

Please consider the following code:
Code:
open(FH,"myfile") || die "Unable to open file myfile:$@";
my $glob_var = *main::FH{GLOB};
my $io_var = *main::FH{IO};
print $glob_var "From glob\n";
print $io_var "From IO\n";
close FH;

Now 'myfile' contains,
Code:
From glob
From IO

Thanks,
Srini
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Issue with user input including * (glob) and sed

Hello All, I have created a script that searches for different things and "sanitizes" the findings from files. Currently the user is required to put in a hostname (server.serverfarm.abc) one at a time to replace. I would like the user be able to use *.*.abc in grep and then pipe into sed to... (1 Reply)
Discussion started by: jvezinat
1 Replies

2. Shell Programming and Scripting

Use ./*glob*

I used this site to check a script. ShellCheck - shell script analysis tool Line 57: zip -u -q Desktop_Items.zip *.desktop ^-- SC2035: Use ./*glob* or -- *glob* so names with dashes won't become options. I do not understand what is wrong with my zip... (6 Replies)
Discussion started by: drew77
6 Replies

3. Shell Programming and Scripting

Using glob() in python script in Linux

Hi I need some suggestion on glob function. I am trying to write a python program to grep some specific files in a particular directory. In the directory i have some files like below abc.log abc.pid abc.tar gadd.tar gat.log gat.tar in this directory i need to grep onlu my hostname files,... (1 Reply)
Discussion started by: kumar85shiv
1 Replies

4. Shell Programming and Scripting

Python - glob () - How to grep same files with different extension files

Hi I Have a directory and i have some files below abc.txt abc.gif gtee.txt ghod.pid umni.log unmi.tar How can use glob function to grep abc files , i have created a variable "text" and i assigned value as "abc", please suggest me how can we use glob.glob( ) to get the output as below... (2 Replies)
Discussion started by: kumar85shiv
2 Replies

5. Shell Programming and Scripting

Need to extract only decimal numbers for a glob of text

If you have a look at this thread, you'll see that users have been posting the output a script which are numbers that range from 2 to 5 decimal places. If I dump this entire thread to txt file, how can I: 1) Delete everything except for numbers of the following formats (where 'x' is a digit and... (5 Replies)
Discussion started by: graysky
5 Replies

6. Shell Programming and Scripting

glob not matching all files in perl

I encountered a weird issue with globbing in perl not returning all files, while I was testing out a script for recursive dir-processing on my Synology NAS. Basically it didn't show (/match?) all the files in a specific directory. If I move the file to a different directory or even rename it, it... (2 Replies)
Discussion started by: odyssey
2 Replies

7. UNIX for Dummies Questions & Answers

Help with understanding the symbols '~#' and '~$'

I noticed that sometimes there is "~#" or "~$" in the terminal. What is that? I can't make any research in google because I don't know what are they called. I even tried reading pdf's or books but unfortunately, I wasn't lucky to find out. Maybe I was not persistent enough but I am really... (3 Replies)
Discussion started by: chams
3 Replies

8. Shell Programming and Scripting

Perl: How to Print symbols like " and ;

Hi, How do I print a line with symbols in a file? Exp: If I want to print line: Hi "Lisa;John" Command: print FILE "Hi "Lisa;John""; - will give me error Bareword found where operator expected... Can someone advise how can I print any line consiting symbols like example above. Thanks... (3 Replies)
Discussion started by: SSGKT
3 Replies

9. Programming

cc -- Unsatisfied symbols -- on HP-UX 10.2

Greetings, I am slowly learning a few things but am far from being an expert. I am at the point now that I would like to be able write some ANSI C code on HP-UX 10.2. Just a hobbie... I am just using cc, which came with the HP-UX 10.2 ... I don't have the manuals for the development... (7 Replies)
Discussion started by: Dirk_
7 Replies

10. Shell Programming and Scripting

redirecting symbols

Can anyone please tell me what the following do 1. < 2. << Thanks Calypso (1 Reply)
Discussion started by: Calypso
1 Replies
Login or Register to Ask a Question
Devel::Symdump(3)					User Contributed Perl Documentation					 Devel::Symdump(3)

NAME
Devel::Symdump - dump symbol names or the symbol table SYNOPSIS
# Constructor require Devel::Symdump; @packs = qw(some_package another_package); $obj = Devel::Symdump->new(@packs); # no recursion $obj = Devel::Symdump->rnew(@packs); # with recursion # Methods @array = $obj->packages; @array = $obj->scalars; @array = $obj->arrays; @array = $obj->hashes; @array = $obj->functions; @array = $obj->filehandles; # deprecated, use ios instead @array = $obj->dirhandles; # deprecated, use ios instead @array = $obj->ios; @array = $obj->unknowns; $string = $obj->as_string; $string = $obj->as_HTML; $string = $obj1->diff($obj2); $string = Devel::Symdump->isa_tree; # or $obj->isa_tree $string = Devel::Symdump->inh_tree; # or $obj->inh_tree # Methods with autogenerated objects # all of those call new(@packs) internally @array = Devel::Symdump->packages(@packs); @array = Devel::Symdump->scalars(@packs); @array = Devel::Symdump->arrays(@packs); @array = Devel::Symdump->hashes(@packs); @array = Devel::Symdump->functions(@packs); @array = Devel::Symdump->ios(@packs); @array = Devel::Symdump->unknowns(@packs); Incompatibility with versions before 2.00 Perl 5.003 already offered the opportunity to test for the individual slots of a GLOB with the *GLOB{XXX} notation. Devel::Symdump version 2.00 uses this method internally which means that the type of undefined values is recognized in general. Previous versions couldn't deter- mine the type of undefined values, so the slot unknowns was invented. From version 2.00 this slot is still present but will usually not contain any elements. The interface has changed slightly between the perl versions 5.003 and 5.004. To be precise, from perl5.003_11 the names of the members of a GLOB have changed. "IO" is the internal name for all kinds of input-output handles while "FILEHANDLE" and "DIRHANDLE" are deprecated. "Devel::Symdump" accordingly introduces the new method ios() which returns filehandles and directory handles. The old methods filehandles() and dirhandles() are still supported for a transitional period. They will probably have to go in future versions. DESCRIPTION
This little package serves to access the symbol table of perl. "Devel::Symdump->rnew(@packages)" returns a symbol table object for all subtrees below @packages. Nested Modules are analyzed recursively. If no package is given as argument, it defaults to "main". That means to get the whole symbol table, just do a "rnew" without arguments. "Devel::Symdump->new(@packages)" does not go into recursion and only analyzes the packages that are given as arguments. The methods packages(), scalars(), arrays(), hashes(), functions(), ios(), and unknowns() each return an array of fully qualified symbols of the specified type in all packages that are held within a Devel::Symdump object, but without the leading "$", "@" or "%". In a scalar context, they will return the number of such symbols. Unknown symbols are usually either formats or variables that haven't yet got a defined value. As_string() and as_HTML() return a simple string/HTML representations of the object. Diff() prints the difference between two Devel::Symdump objects in human readable form. The format is similar to the one used by the as_string method. Isa_tree() and inh_tree() both return a simple string representation of the current inheritance tree. The difference between the two meth- ods is the direction from which the tree is viewed: top-down or bottom-up. As I'm sure, many users will have different expectation about what is top and what is bottom, I'll provide an example what happens when the Socket module is loaded: % print Devel::Symdump->inh_tree AutoLoader DynaLoader Socket DynaLoader Socket Exporter Carp Config Socket The inh_tree method shows on the left hand side a package name and indented to the right the packages that use the former. % print Devel::Symdump->isa_tree Carp Exporter Config Exporter DynaLoader AutoLoader Socket Exporter DynaLoader AutoLoader The isa_tree method displays from left to right ISA relationships, so Socket IS A DynaLoader and DynaLoader IS A AutoLoader. (Actually, they were at the time this manpage was written) You may call both methods, isa_tree() and inh_tree(), with an object. If you do that, the object will store the output and retrieve it when you call the same method again later. The typical usage would be to use them as class methods directly though. SUBCLASSING
The design of this package is intentionally primitive and allows it to be subclassed easily. An example of a (maybe) useful subclass is Devel::Symdump::Export, a package which exports all methods of the Devel::Symdump package and turns them into functions. AUTHORS
Andreas Koenig <andk@cpan.org> and Tom Christiansen <tchrist@perl.com>. Based on the old dumpvar.pl by Larry Wall. perl v5.8.0 2002-04-18 Devel::Symdump(3)