Hi:

  Is there a better way of rewriting the following perl statement?
  (method 1)
  @arr = split /\s+/, $str, $num_elem;
   
  die("Should have $num_elem element") if ( (scalar @arr) != $some_number);

  $var1 = @arr[0];
  $var2 = @arr[1];
  ...
  ...
  $varn  [EMAIL PROTECTED]<number>];

  (method 2)

   ($var1,$var2,$var3) = split /\s+/,@arr,3;

  But using method2 2, it seems the only way to check if 3 elements are 
returned by split is have
something like this (I maybe wrong):

   if (!(defined($var3))) {
      die("less than 3 elements returned");
   }


   Any better way of combining the brevity of method 2 and the error checking 
of method 1?

   Thanks

Regards,
Ludwig


      
_________________________________________________
Philippine Linux Users' Group (PLUG) Mailing List
http://lists.linux.org.ph/mailman/listinfo/plug
Searchable Archives: http://archives.free.net.ph

Reply via email to