Loading ...
Sorry, an error occurred while loading the content.
 

foreach help ?

Expand Messages
  • Barazani
    Hi , I am having trouble with this script (see script below ....) . bascilly i want to get some vars from one file (DUMPS) and check if they exist on the
    Message 1 of 1 , Mar 1, 2001
      Hi ,
      I am having trouble with this script (see script below ....) .
      bascilly i want to get some vars from one file (DUMPS)
      and check if they exist on the other file (VFSTAB)
      the problem is inside the foreach loop .
      it will only process the while loop once .
      so if i have in dumpdates ->

      hda1 0
      hda2 0
      hda3 0


      and in vfstab ->

      hda1 rhda1
      hda2 rhda2
      hda3 rhda3
      hda4 rhda4

      it will output ->
      hda1
      hda1
      *********
      rhda1
      hda1
      *********
      rhda2
      hda1
      *********
      rhda3
      hda1
      *********
      rhda4
      hda2
      hda3

      instead of doing the same with hda2 and jda3 ?
      why is that ?
      any idea's ?
      thanks
      barazani




      #!/usr/local/bin/perl
      use strict;
      my @date=();
      #############################
      #open the files needed
      #############################
      open("FSTAB","/etc/vfstab") || die "cannot open vfstab";
      open("DUMPS","/etc/dumpdates") || die "cannot open dumpdates";
      #############################
      while(<DUMPS>){
      if(/\b0\b/){
      my @rawdev=split(/\s+/,$_);
      push(@date,$rawdev[0]);
      }
      }
      my $slice=" ";
      foreach $slice (@date) {
      while(<FSTAB>){
      print "$slice \n";
      print "*********\n";
      my @dev=split(/\s+/,$_);
      print "$dev[1]\n";
      }
      }
      #############################
      close(DUMPS);
      close(FSTAB);
      #############################


      _________________________________________________________
      Do You Yahoo!?
      Get your free @... address at http://mail.yahoo.com
    Your message has been successfully submitted and would be delivered to recipients shortly.