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

Re: [PBML] use strict err ....

Expand Messages
  • Charles K. Clarkson
    From: Barazani ... try adding: use diagnostics; It sometimes adds helpful advice to error messages and warnings. ... It isn t necesary to quote file handles.
    Message 1 of 1 , Feb 27 10:16 AM
    • 0 Attachment
      From: Barazani
      : I am getting this error - " Use of uninitialized value at
      : ./chkbck.pl line 17, <FSTAB> chunk 3" while runing
      : the foolowing script ,
      : any idea's why ?
      : (of course if i remove the use strict it works great ...)
      : #!/usr/local/bin/perl -w
      : use strict;

      try adding:
      use diagnostics;

      It sometimes adds helpful advice to error messages
      and warnings.

      : my $hostname=`hostname`;
      : open("FSTAB","/etc/vfstab") || die "cannot open vfstab";
      : open("DUMPS","/etc/dumpdates") || die "cannot open dumpdates";

      It isn't necesary to quote file handles. Use FSTAB instead of
      "FSTAB"

      : my ($dev,$rdev,$mpoint,$type,$fsck,$boot,$opt);

      initialize these variable with something like:
      my ($dev,$rdev,$mpoint,$type,$fsck,$boot,$opt)
      = '' x 7;
      This will eliminate the warnings, but look below:

      : while(<FSTAB>){

      While you could test the lines before the next statement
      with something like:
      next if /^$/ || /^#/; skip line if blank or comment
      There's a safer test below:

      : ($dev,$rdev,$mpoint,$type,$fsck,$boot,$opt)=split(/ /,$_);

      Is the first line of FSTAB a blank or incomplete line or
      just doesn't look like the other lines?

      Note: you could test after split with:
      if ( $rdev && $rdev =~ /dsk/ && $mpoint !~ /^\/$/ )

      : if( "$rdev" =~ /dsk/ && "$mpoint" !~ /^\/$/){

      This is line 17. $rdev is not defined. $mpoint can be
      undefined and not raise an error. Split might have
      encountered a line in FSTAB that produced only 0
      (or 1) values.

      It's a bad idea to quote variables unnecesarily. Read
      FAQ 4 in the perl docmentation. Look for:
      What's wrong with always quoting "$vars''?

      HTH,
      Charles K. Clarkson


      : print "$mpoint \n";
      : }
      : }
      : close(DUMPS);
      : close(FSTAB);
    Your message has been successfully submitted and would be delivered to recipients shortly.