perl package question


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting perl package question
# 1  
Old 06-26-2007
perl package question

can someone tell me how below package command worked?

I understand how global1.pl works.. but i don't see how global3.pl is working..
Is package Fred command having first output look into $main:name???

[root@localhost perl]# cat global3.pl
#!/usr/bin/perl -w

#use strict;

$main::name = "Your name Here";
$Fred::name = "Fred Flintstone";
$Barney::name = "Barney Rubble";

print "\$name in package main is $name\n";
package Fred;
print "\$name in package Fred is $name\n";
package Barney;
print "\$name in package Barney is $name\n";
package main;
[root@localhost perl]# cat global1.pl
#!/usr/bin/perl -w

#use strict;

$main::name = "Your name Here";
$Fred::name = "Fred Flintstone";
$Barney::name = "Barney Rubble";

print "\$name in package main is $name\n";
print "\$name in package Fred is $Fred::name\n";
print "\$name in package Barney is $Barney::name\n";
[root@localhost perl]# ./global3.pl
$name in package main is Your name Here
$name in package Fred is Fred Flintstone
$name in package Barney is Barney Rubble
[root@localhost perl]# ./global1.pl
$name in package main is Your name Here
$name in package Fred is Fred Flintstone
$name in package Barney is Barney Rubble
# 2  
Old 06-26-2007
The "package" statement changes the default package used to resolve any names without explicit package qualification.

If you uncomment the "use strict" pragma, the interpreter will give you a warning.

For further details, please read the perlmod manpage:
http://perldoc.perl.org/perlmod.html...ariable-global
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

<<< Question related to making of RPM package >>>

Hi all, Pls provide your suggestions and advice for the below queries. I have a files like below sample $ ls -l /u01/app -rw-r--r-- 1 appusr appdba 4 Feb 20 21:35 test -rw-r--r-- 1 appusr appdba 4 Feb 20 21:35 test1 -rw-r--r-- 1 appusr appdba 4 Feb 20 21:35 test -... (1 Reply)
Discussion started by: kamauv234
1 Replies

2. Shell Programming and Scripting

Using localisation of a Perl package

I have a Perl package, which is widely used and tested, but recently a version in another language was added. The relevant po-files have been reviewed for this and are ready for testing. What are the steps to select the language by the user? From my understanding the language environment variable... (3 Replies)
Discussion started by: figaro
3 Replies

3. Cybersecurity

Question on a security package on linux

Hello everyone , I want to implement a new firewall, detection system on my network composed of some 200 computers as follows: The fire wall would be a linux box with router, L7 iptable and also snort as IDPS system. These are my questions: 1. Is there any security consideration regarding... (0 Replies)
Discussion started by: ahmedkamel
0 Replies

4. Shell Programming and Scripting

Java package restructuring using shell/sed/perl

Hi we are having more than 10k file source code clutterred across different directories. 1. we want to find duplicate file name 2. all java files and having having below content in various folder under /home/raxit/src --------- /*comment etc for few line */ package hello.a.b.c; ... (0 Replies)
Discussion started by: raxitsheth
0 Replies

5. Shell Programming and Scripting

perl for dbms_stats package

Hi, i am new to perl and i used to manullay gathering statistics since our database servers are 8i, could any body help to get the perl script or any link to automate this work. Thanks Prakash (1 Reply)
Discussion started by: prakash.gr
1 Replies

6. Linux

RPM Package question

Hi, I have built one RPM last year. now we have another version of that RPM. in previous release we had few extra files then now. so when user upgrade it those files get deleted by RPM package. We want to retain those files. now for workaround i thought of backing up those file during... (0 Replies)
Discussion started by: ajayyadavmca
0 Replies

7. UNIX for Dummies Questions & Answers

Question on install software package on Linux

Hello ALL, I am not very sure about the following two questions, I have install some packages on my Linux system, though. Q1. Should I log in as root to install a software package on a Linux system? Q2. If I log in as a common user, say 'Mike', and install a software on Mike's home... (1 Reply)
Discussion started by: cy163
1 Replies

8. Solaris

dsteam package question

Hi, What is the different between regular solaris package and dstream package? I am not sure about dsteam package. What is it? thanks in advance (2 Replies)
Discussion started by: mokkan
2 Replies

9. Solaris

solaris package question

I'm trying to install GNU C compiler. I have the binary downloaded, and add it using a pkgadd -d command. Is there anything else I need to do? Thanks. (7 Replies)
Discussion started by: ECBROWN
7 Replies

10. Shell Programming and Scripting

perl: globals and a package.

I am still learning perl and confused on this script I am revising at work. The original author uses a package, which I have left in the code; however, I cannot seem to access the global variable $dir. Code snippet: I have also tried using $RRD_MG::dir to no avail. Thank you. (6 Replies)
Discussion started by: effigy
6 Replies
Login or Register to Ask a Question