Re: perl default variable question

2007-09-18 Thread John W. Krahn
Ryan Moszynski wrote: hi, Hello, i'm using a perl script i found You should be careful with stuff you find lying around. to change the names of batches of files. The program works as is but it's giving me a weird warning. I'm familiar with $_, but not $_[3]. Can someone explain what $_[

Re: perl default variable question

2007-09-18 Thread Ryan Moszynski
to:[EMAIL PROTECTED] > > Sent: 18 September 2007 15:12 > > To: beginners@perl.org > > Subject: perl default variable question > > > > hi, > > i'm using a perl script i found to change the names of batches of files. > > The program works as is but it'

Re: perl default variable question

2007-09-18 Thread Tom Phoenix
On 9/18/07, Ryan Moszynski <[EMAIL PROTECTED]> wrote: > i'm using a perl script i found to change the names of batches of > files. The program works as is but it's giving me a weird warning. > I'm familiar with $_, but not $_[3]. Can someone explain what $_[3] > is, and how i can get this script

Re: perl default variable question

2007-09-18 Thread Rob Coops
:-) $_ is basically the first variable of @_ which is the array that Perl is currently working on. So when your script is complaining about something in $_[3] what it is saying is that the 4th variable (Perl starts counting at 0) in the @_ array is making the compiler unhappy. I hope this helps

perl default variable question

2007-09-18 Thread Ryan Moszynski
hi, i'm using a perl script i found to change the names of batches of files. The program works as is but it's giving me a weird warning. I'm familiar with $_, but not $_[3]. Can someone explain what $_[3] is, and how i can get this script to stop throwning the warning? Thanks, Ryan i found the

Re: $_ variable question

2002-09-09 Thread RTO RTO
Michael -- As I had earlier posited, it was just out of curiosity and the question was more in tune with academic curiosity rather than pragmatic correctiveness. I always used to have "named iterators", but when I was programming without them today, this question came up to my mind instantaneou

Re: $_ variable question

2002-09-09 Thread Michael Fowler
On Mon, Sep 09, 2002 at 02:29:24PM -0700, RTO RTO wrote: > $_ variable points to list in the outer-loop or > inner-loop depending upon the scope. I prefer to not > use aliases. In such a case, when I am in the scope of > inner loop, can I access the looping variable on the > outer without using an

Fwd: RE: $_ variable question

2002-09-09 Thread RTO RTO
Note: forwarded message attached. __ Do You Yahoo!? Yahoo! Finance - Get real-time stock quotes http://finance.yahoo.com --- Begin Message --- Tim -- Thanks for your rejoinder. Mostly, I do use 'aliased' variables within nested loops. However, t

RE: $_ variable question

2002-09-09 Thread Timothy Johnson
m: RTO RTO [mailto:[EMAIL PROTECTED]] Sent: Monday, September 09, 2002 2:33 PM To: [EMAIL PROTECTED] Subject: $_ variable question Friends: I have an outerloop with a list and so do I have an inner loop with another list. $_ variable points to list in the outer-loop or inner-loop depending upon the

$_ variable question

2002-09-09 Thread RTO RTO
Friends: I have an outerloop with a list and so do I have an inner loop with another list. $_ variable points to list in the outer-loop or inner-loop depending upon the scope. I prefer to not use aliases. In such a case, when I am in the scope of inner loop, can I access the looping variable on

$_ variable question

2002-09-09 Thread RTO RTO
Friends: I have an outerloop with a list and so do I have an inner loop with another list. $_ variable points to list in the outer-loop or inner-loop depending upon the scope. I prefer to not use aliases. In such a case, when I am in the scope of inner loop, can I access the looping variable on

RE: Variable question

2002-04-17 Thread Timothy Johnson
7, 2002 11:45 AM To: [EMAIL PROTECTED] Subject: Variable question Hi everyone. I was wondering how you would determine whether a variable is a number or not. I want to do an if statement such as if ($variable is a number) {... Any help is great. Thanx,

Re: Variable question

2002-04-17 Thread Michael Fowler
On Wed, Apr 17, 2002 at 02:44:32PM -0400, Helen Dynah wrote: > I was wondering how you would determine whether a variable is a number or > not. Use a regex, see perldoc -q 'is a number' or http://www.perldoc.com/perl5.6.1/pod/perlfaq4.html, second question in the "Data: Misc" section. Michael

Variable question

2002-04-17 Thread Helen Dynah
Hi everyone. I was wondering how you would determine whether a variable is a number or not. I want to do an if statement such as if ($variable is a number) {... Any help is great. Thanx, Helen - Find, Connect, Date! Yahoo! Canada Personals

Re: Variable question

2002-04-16 Thread Chas Owens
On Wed, 2002-04-10 at 11:10, Randal L. Schwartz wrote: > > "Bob" == Bob Ackerman <[EMAIL PROTECTED]> writes: > > >> At no point do you have an "array" in a scalar context, or a "list" > >> in a scalar context. Really. You don't. Ever. Get it? > >> > >> And why I'm harping on this is that

Re: Variable question

2002-04-10 Thread Randal L. Schwartz
> "Bob" == Bob Ackerman <[EMAIL PROTECTED]> writes: >> At no point do you have an "array" in a scalar context, or a "list" >> in a scalar context. Really. You don't. Ever. Get it? >> >> And why I'm harping on this is that I've seen this myth continue to >> perpetuate, started from some b

Re: Variable question

2002-04-08 Thread bob ackerman
On Monday, April 8, 2002, at 12:15 PM, Randal L. Schwartz wrote: >> "Chas" == Chas Owens <[EMAIL PROTECTED]> writes: > > Chas> I emphasize again, that is how I _read_ it. I know that there is no > Chas> array() and I know why, but that doesn't change how I read things. > This > Chas> hac

Re: Variable question

2002-04-08 Thread Randal L. Schwartz
> "Chas" == Chas Owens <[EMAIL PROTECTED]> writes: Chas> I emphasize again, that is how I _read_ it. I know that there is no Chas> array() and I know why, but that doesn't change how I read things. This Chas> hack forces the far left hand bit to return as a list (by making Chas> wantarray r

RE: Variable question

2002-04-08 Thread David Gray
> $count = () = $string =~ /,/g; > >> > >> $string =~ /,/g; > >> > >> assigns the result in a list context - the anonymous list '()'. by > >> assigning this to a scalar, $count, we get a value that is > the size > >> of the list, which is the number of matches that the regex > made. that

Re: Variable question

2002-04-08 Thread Chas Owens
On Mon, 2002-04-08 at 14:37, Randal L. Schwartz wrote: > > "Chas" == Chas Owens <[EMAIL PROTECTED]> writes: > > >> There is no meaning for "list in a scalar context", so your statement > >> makes no sense. > > Chas> my $some_scalar = () = /\s/g; > > Chas> I emphasize again, that is how I _r

Re: Variable question

2002-04-08 Thread Randal L. Schwartz
> "Chas" == Chas Owens <[EMAIL PROTECTED]> writes: >> There is no meaning for "list in a scalar context", so your statement >> makes no sense. Chas> my $some_scalar = () = /\s/g; Chas> I emphasize again, that is how I _read_ it. I know that there is no Chas> array() and I know why, but tha

Re: Variable question

2002-04-08 Thread Randal L. Schwartz
> "Chas" == Chas Owens <[EMAIL PROTECTED]> writes: Chas> With the downside that you have an array that you never use. Using () Chas> to force list context is one of those strange little quirks that you Chas> just get used to. These days I read () as the array equivalent of Chas> scalar().

Re: Variable question

2002-04-08 Thread bob ackerman
On Monday, April 8, 2002, at 10:40 AM, Chas Owens wrote: > On Mon, 2002-04-08 at 12:00, bob ackerman wrote: >> >> On Monday, April 8, 2002, at 06:24 AM, David Gray wrote: >> I believe it is as simple as: $count = () = $string =~ /,/g; >>> >>> I can't seem to get my brain around

Re: Variable question

2002-04-08 Thread Chas Owens
On Mon, 2002-04-08 at 12:00, bob ackerman wrote: > > On Monday, April 8, 2002, at 06:24 AM, David Gray wrote: > > >> I believe it is as simple as: > >> > >> $count = () = $string =~ /,/g; > > > > I can't seem to get my brain around what's happening here... would > > someone be kind enough to ex

Re: Variable question

2002-04-08 Thread bob ackerman
On Monday, April 8, 2002, at 06:24 AM, David Gray wrote: >> I believe it is as simple as: >> >> $count = () = $string =~ /,/g; > > I can't seem to get my brain around what's happening here... would > someone be kind enough to explain? > > -dave $string =~ /,/g; that finds all occurrences of

RE: Variable question

2002-04-08 Thread David Gray
> I believe it is as simple as: > > $count = () = $string =~ /,/g; I can't seem to get my brain around what's happening here... would someone be kind enough to explain? -dave -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Re: Variable question

2002-04-07 Thread Paul Johnson
On Sat, Apr 06, 2002 at 11:32:01PM -0800, John W. Krahn wrote: > And if you really want to get cute you can put it all on one line: > > substr( $ARGV[0], $_, 1 ) eq $ARGV[1] and $cnt++ for 0 .. length( > $ARGV[0] ) - 1; > print $cnt; I count two lines ;-) Both of these are a little obfuscated,

Re: Variable question

2002-04-06 Thread John W. Krahn
Aman Cgiperl wrote: > > Execute the following on cmd line as follows > $./cnt.pl , > You can replace the comma (,) on the command line to find any other > character's occurrence in the string > ___ > #!/usr/bin/perl > > for(;$i $str[i] = substr($ARGV[0],$i,1); >

RE: Variable question

2002-04-06 Thread aman cgiperl
ECTED] Subject: Variable question Hi everybody. I am a new user and my first question to this list is probably a very simple one. I am trying to count the number of commas in a variable. The book I am learning from doesn't cover specific information like that. Thanks for any hel

Fwd: Variable question

2002-04-05 Thread Helen Dynah
Thanks everyone for all the help.  The suggestions worked great.   Helen   Note: forwarded message attached. Music, Movies, Sports, Games! Yahoo! Canada Entertainment--- Begin Message --- Hi everybody. I am a new user and my first question to this list is probably a very simple one. I am tryi

Re: Variable question

2002-04-05 Thread Chas Owens
On Fri, 2002-04-05 at 13:46, bob ackerman wrote: > or, to continue to discussion: > @s = $string =~ /,/g; > print scalar @s,"\n"; > > i don't know how to get count directly assigned to variable. someone? > I believe it is as simple as: $count = () = $string =~ /,/g; -- Today is Setting Ora

Re: Variable question

2002-04-05 Thread bob ackerman
the /g switch of > m//. > > while($string =~ /,/g){ >$num++; > } > > -Original Message- > From: Tanton Gibbs [mailto:[EMAIL PROTECTED]] > Sent: Friday, April 05, 2002 10:06 AM > To: Helen Dynah; [EMAIL PROTECTED] > Subject: Re: Variable question > > >

RE: Variable question

2002-04-05 Thread Timothy Johnson
Just for the sake of argument, you can also do it using the /g switch of m//. while($string =~ /,/g){ $num++; } -Original Message- From: Tanton Gibbs [mailto:[EMAIL PROTECTED]] Sent: Friday, April 05, 2002 10:06 AM To: Helen Dynah; [EMAIL PROTECTED] Subject: Re: Variable question

Re: Variable question

2002-04-05 Thread Tanton Gibbs
of a character were in the string. my $string = "a,b,c"; my $num = $string =~ tr/,//; print $num; prints 2. - Original Message - From: "Helen Dynah" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Friday, April 05, 2002 12:52 PM Subject: Variable quest

Variable question

2002-04-05 Thread Helen Dynah
Hi everybody. I am a new user and my first question to this list is probably a very simple one. I am trying to count the number of commas in a variable. The book I am learning from doesn't cover specific information like that. Thanks for any help. Helen --

Re: Environment variable question

2001-05-08 Thread Matt Cauthorn
If you're using Unix (I think even a dos shell can do this sort of thing too), why couldn't you just do a system call to the shell? i.e. system(" export MY_Variable=whatever "); I haven't tried this, but it sure seems like it would work -- provided you're running and exiting the script as the sa

Re: Environment variable question

2001-05-04 Thread Me
> I am trying to get [one program to pass some > info to another] There's many ways to skin that cat! (Apologies to my four cats). I suggest creating a file which contains the directory name.

Re: Environment variable question

2001-05-04 Thread Hitesh Ray
Hi, I am atuomating our testing infrastructure using "Testify". The scenario is: Testify calls a script that builds and creates the necessary dir. structure useful to testify. During that process it is suppose to change the directory name. I am trying to get the perl script return the new directo

Re: Environment variable question

2001-05-04 Thread Paul
--- Hitesh Ray <[EMAIL PROTECTED]> wrote: > I am required to modify an Environment variable from one value to > another using perl script. I can access the env. variables in the perl > script using ENV. How can i modify so that when I exit my perl script > -- the env. variable has new value. Tha

Re: Environment variable question

2001-05-04 Thread Michael Lamertz
Hitesh Ray ([EMAIL PROTECTED]) wrote: > > > > Hi All, > > I am required to modify an Environment variable from one value to another > using perl script. I can access the env. variables in the perl > script using ENV. How can i modify so that when I exit my perl script -- the > env. variable has

Re: Environment variable question

2001-05-04 Thread Timothy Kimball
: I am required to modify an Environment variable from one value to another : using perl script. I can access the env. variables in the perl : script using ENV. How can i modify so that when I exit my perl script -- the : env. variable has new value. You can't. Perl scripts are child processes o

Environment variable question

2001-05-04 Thread Hitesh Ray
> Hi All, I am required to modify an Environment variable from one value to another using perl script. I can access the env. variables in the perl script using ENV. How can i modify so that when I exit my perl script -- the env. variable has new value. Thanks in advance. Regards, Hitesh