data not pushing to list

2003-08-14 Thread Trina Espinoza
Is there any reason why this doesn't print the @missing?
Ive also tried unless ($myhash{$elem} == 1) { push(@missing, $frame) }
Any insight into what I'm doing wrong would be greatly appreciated.

Thanks!

-T


CODE:

@missing = ;
@framelist= (1, 2, 3, 6, 10);
$startFrame= 001;
$endFrame = 0010;

@fullList = (int $startFrame .. int $endFrame);
print FULL RANGE @fullList\n;
foreach $item(@fullList) {
 $myhash{$item} = 1;
}

foreach $elem(@framelist) {
 print $elem\n;
 if ($myhash{$elem} == 1) {
  print $elem found!\n;
 }else{
  push(@missing, $elem);
 } 
}

print Missing Frames @missing; ##Doesn't print this!
--
OUTPUT :

FULL RANGE 1 2 3 4 5 6 7 8 9 10
1
1 found!
2
2 found!
3
3 found!
6
6 found!
10
10 found!
Missing Frames

Re: data not pushing to list

2003-08-14 Thread Li Ngok Lam
 Is there any reason why this doesn't print the @missing?
 Ive also tried unless ($myhash{$elem} == 1) { push(@missing, $frame) }
 Any insight into what I'm doing wrong would be greatly appreciated.

 @missing = ;

Wrong assignment, should be:
my @missing = ();
my %myhash = ();

 @framelist= (1, 2, 3, 6, 10);
 $startFrame= 001;
 $endFrame = 0010;
 
 @fullList = (int $startFrame .. int $endFrame);
 print FULL RANGE @fullList\n;
 foreach $item(@fullList) {
  $myhash{$item} = 1;
 }
 
 foreach $elem(@framelist) {

do you want $elem(@fullList) or @framelist ??

  print $elem\n;
  if ($myhash{$elem} == 1) {
   print $elem found!\n;
  }else{
   push(@missing, $elem);
  } 
 }
 
 print Missing Frames @missing; ##Doesn't print this!
 
As your output tells, everything are found !! So, of cause no missing..
Also, you assign all the values for any keys in %myhash are 1.
So you won't get any missing result even you assing @framelist = (1..10)

HTH

 --
 OUTPUT :
 
 FULL RANGE 1 2 3 4 5 6 7 8 9 10
 1
 1 found!
 2
 2 found!
 3
 3 found!
 6
 6 found!
 10
 10 found!
 Missing Frames



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: data not pushing to list

2003-08-14 Thread Jeff 'japhy' Pinyan
On Aug 7, Trina Espinoza said:

Is there any reason why this doesn't print the @missing?
Ive also tried unless ($myhash{$elem} == 1) { push(@missing, $frame) }
Any insight into what I'm doing wrong would be greatly appreciated.

I'd like to know what you're trying to do... I think you're using the
wrong array somewhere.

@missing = ;

That should be

  @missing = ();

No need to store an empty string in the array.

@framelist= (1, 2, 3, 6, 10);
$startFrame= 001;
$endFrame = 0010;

@fullList = (int $startFrame .. int $endFrame);
print FULL RANGE @fullList\n;

So this is: 1 2 3 4 5 6 7 8 9 10.

foreach $item(@fullList) {
 $myhash{$item} = 1;
}

See, here I think you meant to use @framelist, not @fullList.  Because by
using @fullList, you've set all the numbers 1 through 10 as keys in the
hash.  Perhaps you wanted to use @framelist here...

foreach $elem(@framelist) {

... and @fullList here?

 print $elem\n;
 if ($myhash{$elem} == 1) {
  print $elem found!\n;
 }else{
  push(@missing, $elem);
 }
}

What would you have expected to be in @missing?

-- 
Jeff japhy Pinyan  [EMAIL PROTECTED]  http://www.pobox.com/~japhy/
RPI Acacia brother #734   http://www.perlmonks.org/   http://www.cpan.org/
stu what does y/// stand for?  tenderpuss why, yansliterate of course.
[  I'm looking for programming work.  If you like my work, let me know.  ]


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]