Hi All,
The following code gives the pid of the process holding the lock as 0
when run
with perl 5.6.1 on Redhat linux 7.2. It works fine with perl 5.6.0 on
the same
machine. The code that locks the file works fine (tested by getting the
lock
information with C code and using 5.6.0 perl). Has any
Hi all, this is a difficult one to explain!!
i have a perl script that is inserting entries into an oracle database
table. so far so good!!
the difficulty i have is that the table has a sequence against a unique id
column (number) that can increment itself using seq.nextval.
when i test the scri
Hello people from the mighty list,
I have a problem with substitutions...
In the piece of code, here below,
"display $var1, $var"' should be "display val1, val2";
I don't see why, but the if condition doesn't seems to work...
and if I remove the if condition, the replacement doesn't occur...
Does
From: [EMAIL PROTECTED]
> Hi all, this is a difficult one to explain!!
>
> i have a perl script that is inserting entries into an oracle database
> table. so far so good!! the difficulty i have is that the table has a
> sequence against a unique id column (number) that can increment itself
> usi
Below is sample code that does not work as I intend, the intention being
to list all the sub-directories in a given directory.
#!/usr/local/ActivePerl-5.6/bin/perl5.6.1 -w
use strict;
my $mw;
my $menubar;
my $algebra;
my @file_array;
my $dir_to_process = "/home/rfell/mathprogram";
opendir DH, $
Whitespace, whitespace, whitespace. Right, got that over with now let's look
at your code (formatted so it's readable)
#!/usr/local/ActivePerl-5.6/bin/perl5.6.1 -w
use strict;
my $mw;
my $menubar;
my $algebra;
my @file_array;
my $dir_to_process = "/home/rfell/mathprogram";
opendir DH, $dir_to_
Wim,
You're not declaring $var1 or $var2 anywhere. Instead you're assigning 'val1' and
'val2' to elements in the hash %VarValue.
So something like...
$VarValue{$var1} = 'val1';
print "I like $VarValue{$var1}!";
will print out...
I like val1
To define $var1, do something like:
$var1 = 'cheese'
Sorry. That should have been prepend.
-Original Message-
From: John Edwards [mailto:[EMAIL PROTECTED]]
Sent: 11 April 2002 12:47
To: 'richard noel fell'; [EMAIL PROTECTED]
Subject: RE: problem with directory listing
Whitespace, whitespace, whitespace. Right, got that over with now let'
Tristan,
I'm writing a script to send command from a textfile to cisco devices...
I the textfile, I like to have variables, something like
conf t
int $interface
.
when my script reads the line, it should replace $interface by the value
asked from the value the user enters...
$var{$interfa
"Aman Raheja" <[EMAIL PROTECTED]> writes:
> Hi everyone
> I have a situation here. I have to do it this way, becuase that's how the
> framework is.
> When I submit a form, it is processed by abc.cgi.
> Now this abc.cgi has to be a frame. The main page is xyz.cgi, with a header,
> a left frame an
> Hi all
> I am trying to send a mail with the following code and the last print
> statement doesn't print, ie, the mail is not sent.
> This code is called on submitting a form on the web
>
> open(MAIL, "/usr/sbin/sendmail -oi -t") || die "Can't open mail";
> print MAIL < To:
John -
Thank you for your explanation. A stupid mistake on my part.
Dick Fell
John Edwards wrote:
>
> Sorry. That should have been prepend.
>
> -Original Message-
> From: John Edwards [mailto:[EMAIL PROTECTED]]
> Sent: 11 April 2002 12:47
> To: 'richard noel fell'; [EMAIL PRO
Wim,
I can't believe how long it's taken me to figure out what you're on about, and what
the problem (probably) is. My brain's far too slow to be at work today :)
If cmd came from standard input or something, your script would work. But you're using
a string to simulate that input, and because
Wim,
Sorry, I forgot to mention escaping/single quoting the hash keys too...
As you defined it, your hash is empty as you are trying to set 'val1', 'val2' to
VarValue{undef} ($Var1 hasn't been defined).
Try
VarValue{'$Var1'}
or
VarValue{"\$Var1"}
Now the string '$Val1' is a the key, not undef.
I've been experiencing a weird behavior lately with one of my messaging
scripts. I keep on seeing msg recipients getting BCC'd a copy of the msg, in
addition to their listing in the To: field. I have no idea why, but it seems
to have something to do with the "hard" ->recipient method call - but wh
Hi,
I want to opena datafile and erase it's all it's contents. Can anyone help?
Thanks,
Allison
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
perldoc -f unlink
-Original Message-
From: Allison Ogle [mailto:[EMAIL PROTECTED]]
Sent: Thursday, April 11, 2002 10:26 AM
To: [EMAIL PROTECTED]
Subject: Deleting the contents of a file
Hi,
I want to opena datafile and erase it's all it's contents. Can anyone help?
Thanks,
Allison
Hi all,
I am trying to write a perl script that uses different HTML templates
depending on the data drawn from a DataBase.
It seems the only solution is to use the PERL module HTML::Template; but my
web host doesn't support this and wont install it.
Is there anyway I can install it myself ?
I think...
open(DATA, ">$file") or die "cannot open: $!";
would do the trick.
> -Original Message-
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, April 11, 2002 10:25 AM
> To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
> Subject: RE: Deleting the contents of a file
>
From: Builder http://builder.com.com
Presents your
PERL E-NEWSLETTER for April 11, 2002
COMMENT OUT CODE WITH POD
Commenting out large blocks of code can be more laborious in Perl than
in C and C++ because Perl doesn't have a multiline comment operator like
'/* .. */'. A decent editor with mac
cat /dev/null >datafile
> -Original Message-
> From: Nikola Janceski [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, April 11, 2002 10:33 AM
> To: '[EMAIL PROTECTED]'; [EMAIL PROTECTED]; [EMAIL PROTECTED]
> Subject: RE: Deleting the contents of a file
>
>
> I think...
>
> open(DATA, ">$f
Hi, I am very new to PERL but if all you want to do is open an existing file
and delete all of it's contents you could open the file for writing and then
close it.
open(F, ">filename");
close (F);
There maybe a more acceptable way to do this - but this should open the file
- remove its conten
Hi Dudes
Two questions for ya.
What clients can I use to you connect to comp.lang.perl.modules?
I've tired a browser and telnet. had a look in my e-mail client options. No
joy.
The second question is...
Why wont *any* of the versions of GD.pm install on my RedHat Linux box
(kernal 7.2)?
I'm
On Apr 11, Allison Ogle said:
>I want to opena datafile and erase it's all it's contents. Can anyone help?
No need to open the file.
truncate($path_to_file, 0);
--
Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/
RPI Acacia brother #734 http://www.perlmonks.or
Hi,
I have a hash that will have some keys contain single values and other keys
that will have multiple values:
%hash = (
key1 => 'test-1',
key2 => ['test-2-0', 'test-2-1'],
key3 => 'test-3'
);
I want to loop t
Use the ref function..
foreach $key(keys %hash) {
if(ref($hash{$key})){
print "$key = array( ";
foreach my $item (@{$hash{$key}}){
print "$item ";
)
print ")\n";
> How about the JIT engine then.
JIT runs on bytecode, producing bytecode.
> When does parrot use it?
Before executing bytecode.
> how well does it scale? ( has anyone done some benchmarking )
Don't ask me :P If you haven't already, then you'd
be best looking at the background information at
[ Send to wrong mailinglist - meant for perl6-internals]
> > How about the JIT engine then.
>
> JIT runs on bytecode, producing bytecode.
>
> > When does parrot use it?
>
> Before executing bytecode.
>
> > how well does it scale? ( has anyone done some benchmarking )
>
> Don't ask me :P If
Hi,
I've got a comma separate list, like:
apples, oranges, pears
I'd like to make it reads:
apples, oranges, or pears
My guess was to use s/// to turn the last ',' into ', or'
Any ideas?
Thanks
Tristan
___
sent via the murky.net webmai
When I put the -w switch on I get this error:
Use of uninitialized value in concatenation (.) at
/var/www/cgi-bin/ticket.cgi line 71:
on this line:
print "$trd Driver ID:$columns[19] -- $drvname";
Can anyone point out my mistake?
It still runs but fills up my error_log
and I do have the variabl
http://stason.org/TULARC/webmaster/myfaq.html#7 has a guide to this. I'm
using HTML::Template (installed into my own directory) and I like it, but
TMTOWTDI. I understand Mason is pretty cool, but I've never done it.
And of course, there's PHP...
--Jerry
http://www.jerrymccusker.com/
At 02
One of the vars in the print are empty or equal to "".
to ignore this for just that line use this unless all the vars are supposed
to have something in them.
{
no warnings 'uninitialized';
print "$trd Driver ID:$columns[19] -- $drvname";
}
> -Original Message-
> From: Scott Taylor [mail
[What mail client are you using? It refuses to include a Date: header]
On , [EMAIL PROTECTED] said:
>apples, oranges, pears
>
>I'd like to make it reads:
>
>apples, oranges, or pears
No need to use a regex, especially since a regex will have to go through
the whole string.
# if there is a c
here is your substitution.. (haven't tested it but should work).
s/,([^,]*)$/, or$1/;
> -Original Message-
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
> Sent: None
> To: [EMAIL PROTECTED]
> Subject: Matching last comma (not last character)
>
>
> Hi,
>
> I've got a comma sepa
> -Original Message-
> From: richard noel fell [mailto:[EMAIL PROTECTED]]
> Subject: problem with directory listing
>
> Below is sample code that does not work as I intend, the
> intention being
> to list all the sub-directories in a given directory.
>
> #!/usr/local/ActivePerl-5.6/bin/
Hello, beginners.
Sorry to trouble you.
Is anybody use any free Regexp tester?
Like in the OptiPerl - but it's non-free... :(
Thank you in advance.
Babichev L. Dmitry
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
On Wednesday, April 10, 2002, at 09:20 , Jenda Krynicky wrote:
No flame war intended...
[..]
> Anyway ... to sum this all up I'd say:
>
> 1) If you are not sure you know whadaheck package means ...
>don't use it in your code.
> 2) If you introduce another package in a script
Thanks, it works great.
I used the regex in the end, the list will only ever be a few elements long (and the
script doesn't need to be efficient). Can't say I understand it completely though (I
was with you up until the first comma) :)
Apologies for my mail client. It's a web-based dohickey th
On Wednesday, April 10, 2002, at 06:58 , Jorge Goncalvez wrote:
> Hi, I tried to get the IP address in a Win98 machine I made a perl module
> and I
> put it in /site/lib with .pm extension.
> it is Registry98.pm
>
> But I have this error:
> Can't call method Open of a undefined value at Registr
unlink will delete the file. The filename will no longer exist in a
directory listing also.
open FILE ">file.txt";
# You can then print to file.txt if you wish.
# If you do not write to the file, its size will be ZERO
system ("echo >file.txt")
# works also but size of the file is 1 byte
-Or
If on windows environment, you can try Komodo ( ActiveState IDE ) which has a
Regex tester.
Wags ;)
-Original Message-
From: Babichev Dmitry [mailto:[EMAIL PROTECTED]]
Sent: Thursday, April 11, 2002 08:28
To: [EMAIL PROTECTED]
Subject: Regexp tester
Hello, beginners.
Sorry to
Scott,
You've declared it...
my $drvname;
...but not initialised it(given it a value). So at the moment it has the special value
'undef' (which is treated as 0 in a numeric context, or '' in a scalar one). Try and
do much with an undef and you'll get a warning, basically reminding you to do
so
Whoa! thanks for the clarification. I need to take out some of my no
warnings now. ;)
> -Original Message-
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
> Sent: None
> To: [EMAIL PROTECTED]
> Subject: Re: Use of uninitialized value in concatenation (.)
>
>
> Scott,
>
> You've de
At 09:01 AM 11/04/2002, [EMAIL PROTECTED] wrote:
>Scott,
>
>You've declared it...
>my $drvname;
>...but not initialised it(given it a value). So at the moment it has the
>special value 'undef' (which is treated as 0 in a numeric context, or ''
>in a scalar one). Try and do much with an undef and
Hello, Wagner-David.
You wrote 11 àïðåëÿ 2002 ã., 19:00:01:
fanx
WDvc> If on windows environment, you can try Komodo ( ActiveState IDE ) which
has a Regex tester.
WDvc> Wags ;)
WDvc> -Original Message-
WDvc> From: Babichev Dmitry [mailto:[EMAIL PROTECTED]]
WDvc> Sent: Thursda
Hi
>Is anybody use any free Regexp tester?
>Like in the OptiPerl - but it's non-free... :(
Don't know how complicated OptiPerl is but if you just want to see what
your regex is matching:
~~~
#!/usr/bin/perl
while (<>) {
chomp;
if (/YOUR_PATTERN_GOES_HERE/) {
> I have a problem with substitutions...
> In the piece of code, here below,
> "display $var1, $var"' should be "display val1, val2";
> I don't see why, but the if condition doesn't seems to
> work... and if I remove the if condition, the replacement
> doesn't occur... Does any of you know why?
On Thursday, April 11, 2002, at 08:17 , Scott Taylor wrote:
[..]
> on this line:
> print "$trd Driver ID:$columns[19] -- $drvname";
>
> Can anyone point out my mistake?
> It still runs but fills up my error_log
> and I do have the variables initialized before the loop:
> my $trd = "";
> my $drvna
On , [EMAIL PROTECTED] said:
>I used the regex in the end, the list will only ever be a few elements
>long (and the script doesn't need to be efficient). Can't say I
>understand it completely though (I was with you up until the first
>comma) :)
Ok, here's an explanation:
>> s/,(?=[^,]*$)/, or/
Given text such as :
-
-> "SPRID12345678"
"SPRID23456789"
-
I want to match the SPRID strings. I was trying to get them to be
in $1 $2 etc, as there's almost always 1, sometimes more, sometimes none,
but almost never more than 3-4. How would I match them. To t
yeah... Japhy almost always beats me in the sensible algorithms.. his rindex
idea is the most efficient way, then his regex with the positive look ahead
assertion, then my crappy poorly thoughtout regex. ;)
> -Original Message-
> From: Jeff 'japhy' Pinyan [mailto:[EMAIL PROTECTED]]
> Sent
On Apr 11, Kingsbury, Michael said:
>
>
> -> "SPRID12345678"
>"SPRID23456789"
>
>
>I want to match the SPRID strings.
@data = $string =~ /SPRID\d+/g;
Or, if you only want the numbers:
@data = $string =~ /SPRID(\d+)/g;
This is assume $string is the ENTIRE data. Otherwis
An update on previous post...
It seems that I typed some errors :-(
This is a small rewrite of my script...
#!/usr/bin/perl
use warnings;
my $var = "test";
my $rvar = "\$interface";
my $cmd = "int \$interface\n";
print "$var\n";
print "$cmd\n";
$cmd =~ s/$rvar/$var/g;
print "$cmd\n";
If y
Hello,
How would you put the matches into a comma separated list?
-Original Message-
From: Jeff 'japhy' Pinyan [mailto:[EMAIL PROTECTED]]
Sent: Thursday, April 11, 2002 12:48 PM
To: Kingsbury, Michael
Cc: '[EMAIL PROTECTED]'
Subject: Re: RegEx matching multiple items.
On Apr 11, Kings
On Thursday, April 11, 2002, at 10:57 AM, wim wrote:
> my $var = "test";
> my $rvar = "\$interface";
>
try:
my $rvar = '\$interface';
so it doesn't look like a variable to be interpolated when you get to the
substitution.
> my $cmd = "int \$interface\n";
>
> print "$var\n";
> print "$cmd\
> An update on previous post...
> It seems that I typed some errors :-(
>
> This is a small rewrite of my script...
> #!/usr/bin/perl
>
> use warnings;
>
> my $var = "test";
> my $rvar = "\$interface";
> my $cmd = "int \$interface\n";
>
> print "$var\n";
> print "$cmd\n";
>
> $cmd =~ s/$rva
On Thursday, April 11, 2002, at 11:46 AM, Amerson, Kevin wrote:
> Hello,
>
> How would you put the matches into a comma separated list?
>
if you want to print it out:
print "@data";
if you want to create a single string:
$data = join ',',@data;
or did you have something else in mind?
>
> --
Could someone explain the while and do w/ couple of examples? I have
yet to use them, only using the foreach loop and if else stmts.
--
---
- Teresa Raymond -
- Mariposa Net -
- http://www.mariposanet.com -
---
Nope that was it, I just knew that we didn't have to loop through the array
to build the string :)
Thanks!
-Original Message-
From: bob ackerman [mailto:[EMAIL PROTECTED]]
Sent: Thursday, April 11, 2002 1:57 PM
To: [EMAIL PROTECTED]
Subject: Re: RegEx matching multiple items.
On Thurs
while ($file = shift @build_line or $dir = shift @makedir){ # will do
@build_line first then @makedir
} # can't do that with foreach
do{ # do this loop at least once regardless of the conditional at the
end
print "This time ", $n++," attempts.\n";
} until ($n >= 1);
On Thursday, April 11, 2002, at 12:02 , Teresa Raymond wrote:
> Could someone explain the while and do w/ couple of examples? I have yet
> to use them, only using the foreach loop and if else stmts.
the obvious ones are
while() {
# bunch of stuff one wants to do with
Some useful perl control structures:
do { statements; } while someexpression;
do { statements; } until someexpression;
while (someexpression) { statements; } --or-- statement while
someexpression;
until (someexpression) { statements; } --or-- statement until
someexpression;
unless (someexpressio
Dave Chappell wrote:
>
> Hi,
Hello,
> I have a hash that will have some keys contain single values and other keys
> that will have multiple values:
>
> %hash = (
> key1 => 'test-1',
> key2 => ['test-2-0', 'test-2-1'],
> key3 => 'test-3'
> );
The simple answer is to put all values
Teresa Raymond wrote:
>
> Could someone explain the while and do w/ couple of examples? I have
> yet to use them, only using the foreach loop and if else stmts.
Have you read the perlsyn document?
John
--
use Perl;
program
fulfillment
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additi
I have a script that waits for user input, and prints info based on the
info. The print info part sometimes takes a long time.
I want to capture the INT signal (^C) but depending on if I am waiting for
input or printing something I want (^C) to act differently.
This program loops endlessly, waiti
Please take into account that I'm new at this...
Rather than using CGI.pm, I'm using the following library sub-routine
which was passed to me by a friend (I think from one of the O'Reilly
books). What I'm wondering is if Perl 5 has any built in functionality
to prevent buffer overruns or excessiv
Just for those who haven't figured out why the first example is so useful,
consider what perl is doing in the following two snippets:
1
==
open(INFILE,"myfile.txt");
@file = ;
foreach(@file){
do something to $_...
}
2
==
open(INFILE,"myfile.txt");
while(){
do something to $_...
}
$someVar = max(@listofvalues);
Is there a function in perl like this?
- B
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
On Apr 5, Shaun Fryer said:
>Rather than using CGI.pm, I'm using the following library sub-routine
>which was passed to me by a friend (I think from one of the O'Reilly
>books). What I'm wondering is if Perl 5 has any built in functionality
I highly doubt it was found in an O'Reilly book -- if i
On Apr 11, Bryan R Harris said:
>$someVar = max(@listofvalues);
>
>Is there a function in perl like this?
You could use the List::Util module (from CPAN). Or, you could write your
own:
sub max {
my $max = shift;
for (@_) { $max = $_ if $_ > $max }
return $max;
}
--
Jeff "japh
From: Shaun Fryer <[EMAIL PROTECTED]>
> Please take into account that I'm new at this...
>
> Rather than using CGI.pm, I'm using the following library sub-routine
> which was passed to me by a friend (I think from one of the O'Reilly
> books).
Especialy since you are new at this you should use
> I have a script that waits for user input, and prints info based on the
> info. The print info part sometimes takes a long time.
>
> I want to capture the INT signal (^C) but depending on if I am waiting for
> input or printing something I want (^C) to act differently.
> This program loops endl
On Thursday, April 11, 2002, at 01:17 PM, Timothy Johnson wrote:
>
> Just for those who haven't figured out why the first example is so useful,
> consider what perl is doing in the following two snippets:
>
> 1
> ==
> open(INFILE,"myfile.txt");
> @file = ;
> foreach(@file){
>do somethin
Good catch. That's what I meant, alright.
-Original Message-
From: bob ackerman [mailto:[EMAIL PROTECTED]]
Sent: Thursday, April 11, 2002 2:34 PM
To: Timothy Johnson
Cc: [EMAIL PROTECTED]
Subject: Re: while and do
On Thursday, April 11, 2002, at 01:17 PM, Timothy Johnson wrote:
On Thursday, April 11, 2002, at 01:42 PM, Jeff 'japhy' Pinyan wrote:
> On Apr 11, Bryan R Harris said:
>
>> $someVar = max(@listofvalues);
>>
>> Is there a function in perl like this?
>
> You could use the List::Util module (from CPAN). Or, you could write your
> own:
>
> sub max {
> my
ACK! void use of map!
change it! change it!
$max=0;
foreach (@listofvalues) {$max=$_ if($_>$max)}
> -Original Message-
> From: bob ackerman [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, April 11, 2002 5:52 PM
> To: [EMAIL PROTECTED]
> Subject: Re: max/min
>
>
>
> i like:
> $max=0;
> ma
even better...
__
On Thursday, April 11, 2002, at 01:17 PM, Timothy Johnson wrote:
>
> Just for those who haven't figured out why the first example is so
useful,
> consider what perl is doing in the following two snippets:
>
> 1
> ==
> open(INFILE,"myfile.txt");
> @file =
On Thursday, April 11, 2002, at 02:56 PM, Nikola Janceski wrote:
> ACK! void use of map!
>
> change it! change it!
> $max=0;
>
fussy correction for case where all values are negative:
$max=$listofvalues[0];
(assumes list isn't empty).
> foreach (@listofvalues) {$max=$_ if($_>$max)}
>
>> ---
After I sent this I had a flash of enlightenment:
$max = (sort {$a <=> $b} @_)[-1];
May be slower, though, I don't know.
- B
On Apr 11, Bryan R Harris said:
>$someVar = max(@listofvalues);
>
>Is there a function in perl like this?
You could use the List::Util module (from CPAN). Or, yo
> ACK! void use of map!
>
> change it! change it!
> $max=0;
> foreach (@listofvalues) {$max=$_ if($_>$max)}
Huh? Is that "void" or "avoid"? What's wrong with map?
- B
__
> -Original Message-
> From: bob ackerman [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, April 11,
> After I sent this I had a flash of enlightenment:
>
>$max = (sort {$a <=> $b} @_)[-1];
>
> May be slower, though, I don't know.
How many times have I seen this? I mean, I've seen
this construct many times, and the question deserves
a place in the Perl FAQ.
Please refer back to:
http://
- Original Message -
From: "James Campbell" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, April 11, 2002 5:31 PM
Subject: RE:regex tester
> Hi
>
> >Is anybody use any free Regexp tester?
> >Like in the OptiPerl - but it's non-free... :(
>
> Don't know how complicated O
On Apr 11, Ahmed Moustafa said:
>> # foo.txt.bak => bak
>> ($extension) = $name =~ /.*\.([^.]*)/;
>> # or
>> # ($extension) = $name =~ /\.([^.]*)$/;
>
>It doesn't work if there is no extension in $name.
Yes, and like I said in the post, if there is NO extension AT ALL (meaning
no . at al
> # foo.txt.bak => bak
> ($extension) = $name =~ /.*\.([^.]*)/;
> # or
> # ($extension) = $name =~ /\.([^.]*)$/;
It doesn't work if there is no extension in $name.
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
How can I get the current index of an array while processing the array
in a loop? I know I can do it with a counter type function, but I was
curious if there was a better way of doing this.
For example:
my @array = (1 .. 100);
my $counter = 0;
for (@array) {
print "index -> $counter elem
On Apr 11, James Taylor said:
>How can I get the current index of an array while processing the array
>in a loop? I know I can do it with a counter type function, but I was
>curious if there was a better way of doing this.
That won't be automatic until Perl 6. Your method is fine.
>my @array
86 matches
Mail list logo