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

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 to

Re: perl default variable question

2007-09-18 Thread Ryan Moszynski
in it as $_[0], the second parameter as $_[1] and so on. And you can refer to $_# as the index number of the last parameter: -Original Message- From: Ryan Moszynski [mailto:[EMAIL PROTECTED] Sent: 18 September 2007 15:12 To: beginners@perl.org Subject: perl default variable

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

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

$_ 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-09-09 Thread Timothy Johnson
: 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 scope. I prefer to not use aliases

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 ---BeginMessage--- Tim -- Thanks for your rejoinder. Mostly, I do use 'aliased' variables within nested loops. However,

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

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

RE: Object oriented variable question

2002-06-24 Thread Scot Robnett
AM To: [EMAIL PROTECTED] Subject: Object oriented variable question When using cgi.pm object oriented method, how do I assign a static value to a variable and then output it? The test script that I listed below prints all of the html tags with Hello!Did it work? (without the quotes

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-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 --

RE: Variable question

2002-04-17 Thread Timothy Johnson
: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, Helen

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 I've seen this myth

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 bad verbage or bad

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-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 comma in

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 explain? -dave

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 what's happening here...

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 _read_ it. I know that

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 empty list thingy is

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(). Well, there

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 hack forces the far

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 that doesn't change

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, but

RE: Variable question

2002-04-06 Thread aman cgiperl
PROTECTED] 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 help

Re: Variable question

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

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: Variable question

2002-04-05 Thread Tanton Gibbs
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 question Hi everybody. I am a new user and my first 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 bob ackerman
($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 The tr operator will translate one character to another. For example: my

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? snip / I believe it is as simple as: $count = () = $string =~ /,/g; -- Today is Setting

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---BeginMessage--- Hi everybody. I am a new user and my first question to this list is probably a very simple one. I am trying to

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. That's a

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.