On Sunday 08 June 2003 21:41, Jerry Preston wrote:
What you want isn't very clear (in the way of output) but let me take a shot
here...
#!/usr/bin/perl -w
use strict;
my @IDS = qw(5 10 15 20 25 30 35 40);
my $cnt = 0;
for my $id ( @IDS )
{
print 'id: '. $id;
$id++;
$cnt = $id . '_cnt';
print ' cnt: '. $cnt ."\n";
}
I think what you were asking is if Perl would be smart enough to increment
your counter with "_cnt" appended on the end of it. The answer is, Perl will
increment it but it won't do what you think it will. If this isn't what you
were asking then I truly have no clue what your goal is. See if what I
clipped up there will do what you want.
- Jim
| Hi!
|
| I am not sure if this can be done or not, but I want to create a counter on
| the fly so to speak.
|
| foreach $id ( @IDS ) {
| $cnt = "$id"."_cnt";
| $cnt++;
| }
|
| All I get is "item_cnt". Is there a way to do this?
|
| Thanks,
|
| Jerry
--
- Jim
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]