Re: 2 questions please, one on scope and one on regex

2008-12-22 Thread John W. Krahn
Eric Krause wrote: Hello all, Hello, I have two quick questions that I would love some help on. I have looked at the manual (Programming Perl) and I didn't get it, hence my email. Question 1 - How can I make variables in a function (subroutine) global (accessible from other functions)? A

Re: 2 questions please, one on scope and one on regex

2008-12-22 Thread Mr. Shawn H. Corey
On Mon, 2008-12-22 at 15:18 -0700, Eric Krause wrote: > Hello all, > I have two quick questions that I would love some help on. I have looked > at the manual (Programming Perl) and I didn't get it, hence my email. > > Question 1 - How can I make variables in a function (subroutine) global > (acc

Re: 2 questions

2002-04-02 Thread Eric Plowe
sheesh - that's a lot easier then the way I do it :P thanks. ~Eric On Tuesday, April 2, 2002, at 07:09 PM, John W. Krahn wrote: > Glenn Cannon wrote: >> >> Hi all, > > Hello, > >> Couple of questions from a newbie... >> >> 1) How can I print the current directory name? > > use Cwd; > my $dir =

Re: 2 questions

2002-04-02 Thread John W. Krahn
Glenn Cannon wrote: > > Hi all, Hello, > Couple of questions from a newbie... > > 1) How can I print the current directory name? use Cwd; my $dir = cwd; print "The current directory is $dir\n"; > 2) How can I check to see if a file I know the name of exists? if ( -e $filename ) { pri

RE: 2 questions

2002-04-02 Thread Timothy Johnson
PROTECTED] Subject: Re: 2 questions Glenn.. to print the current directory name...try --- #!/usr/bin/perl -w use strict; use Cwd; $curr = cwd(); print "$curr\n"; easy enough this is bit longer example.. you could prolly do it another way..but this is how *I* would do it --- #!/usr/b

Re: 2 questions

2002-04-02 Thread Eric Plowe
Glenn.. to print the current directory name...try --- #!/usr/bin/perl -w use strict; use Cwd; $curr = cwd(); print "$curr\n"; easy enough this is bit longer example.. you could prolly do it another way..but this is how *I* would do it --- #!/usr/bin/perl -w use strict; use Cwd; my $cur

Re: 2 questions

2002-01-29 Thread Curtis Poe
--- Naveen Parmar <[EMAIL PROTECTED]> wrote: > 1) How do you define global & lexical variables in Perl? > 2) Is the arrow (->) a commonly used Perl operator? > > TIA, > - NP Global variables may be defined in several different manners. 1. Fully qualified with package name: package Foo;

RE: 2 questions

2002-01-29 Thread Hanson, Robert
All variables are global in nature unless you declare them in a lexical scope. $foo = "Hello Naveen"; if ( 1 ) { my $x = 1; } In this example $foo is global, and $x is local to the if-block only. And yes, -> is used quite often when you start using references or classes (a module that acts l

RE: 2 Questions

2002-01-14 Thread McCollum, Frank
1) if you open it from a shell and type "perl" infront of the file name it will keep it. 2) I could be wrong, but I think "" = nothing and "<>" = diamond operator which is used to take input. i.e. while (<>) { $_ = $firstLineOfFile } -Original Message- From: N

RE: 2 Questions

2002-01-14 Thread Dean Theophilou
:34 PM To: Naveen Parmar; [EMAIL PROTECTED] Subject: RE: 2 Questions > 1) Double clicking my Perl file within Windows Explorer opens within the DOS > window, but then closes immediately after execution. > > It flashes up on the screen and closes itself. Can I prevent this auto &

RE: 2 Questions

2002-01-14 Thread Gary Hawkins
> 1) Double clicking my Perl file within Windows Explorer opens within the DOS > window, but then closes immediately after execution. > > It flashes up on the screen and closes itself. Can I prevent this auto > termination? `pause`; or: system "pause"; Although pause is not documented in eithe

Re: 2 questions on perl.

2001-10-18 Thread Brett W. McCoy
On Thu, 18 Oct 2001, Amit Joshi wrote: > Q1: Do we have a standard way to generate random numbers in perl ? perldoc -f rand perldoc -q random > Q2: How do we run system commands from a perl program ? perldoc -f system perldoc -q system (perldoc -f gives you information on the usage of a speci