Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

help me with this

Status
Not open for further replies.

NEVERSLEEP

Programmer
Apr 14, 2002
667
CA
i wanted to show someone....
now im the one needing help [lol]

on perl -c "find.pl syntax OK"
on run infinite time those two error
Use of uninitialized value in numeric eq (==) at C:\Documents and Settings\Administrator\Desktop\fin
d.pl line 30, <stdin> line 2.
Use of uninitialized value in numeric eq (==) at C:\Documents and Settings\Administrator\Desktop\fin
d.pl line 70, <stdin> line 2.

the code
thanks for your help
first time im playing with @ARGV

Code:
use strict;
my $count = 0;					# line counter
my $so;						# <stdin> so ?
my $switch = 0;					# default dir switch
my $dwitch = 0;					# deeplook switch
my @drives = ('c','d','e','f');			# place as many as u like
my $manualdrive;				# manual drive
my $manualfile;					# manual file
my @dir_output;					# dir storer

&startup;					# here we goooooooo!

sub startup {
 &bad_argument(1) unless $ARGV[0];		# check if drive letter was unspecified
 &bad_argument(2) unless $ARGV[1];		# check if file name was unspecified
 &bad_argument(3) if $ARGV[2];			# check if surspecified
 $ARGV[0] =~ tr/a-zA-Z/ /cs;
 $ARGV[0] =~ s/\s//g;
 $ARGV[1] =~ tr/a-zA-Z0-9[.][_]/ /cs;
 $ARGV[1] =~ s/\s//g;
 @dir_output = `dir $ARGV[0]:\\$ARGV[1].pl /s/o/b`;
 &find_it;
}

sub find_it {
 if ($dir_output[0] == &quot;File Not Found&quot;) {	# check if not found of this drive
  &deeplook;
 } elsif ($dir_output[1]) {			# check if there is more than one result possible
  &multiple;
 } else {					# haddle single result
  &single($dir_output[0]);
 }
}

sub bad_argument {
 if ($_[0] == 1) {				# no drive specified
  print &quot;\nmanual&quot;;
  &manual
 } elsif ($_[0] == 2) {				# no filename
  print &quot;\nmanual&quot;;				
  &manual;
 } elsif ($_[0] == 3) {				# warn
  print &quot;\nToo Many parameters&quot;;
 }
}

sub manual {
 print &quot;\nDrive letter :&quot;;
 $manualdrive = <stdin>;
 chomp $manualdrive;
 $manualdrive =~ tr/a-zA-z/ /cs;
 $manualdrive =~ s/\s//g;
 print &quot;\nFile name (no extention) :&quot;;
 $manualfile = <stdin>;
 chomp $manualfile;
 $manualfile =~ tr/a-zA-z/ /cs;
 $manualfile =~ s/\s//g;
 @dir_output = `dir $manualdrive:\\$manualfile.pl /s/o/b`;
 &find_it; 
}

sub deeplook {
 while ($dwitch != scalar(@drives)) {		# loop for the lenght of @drives
  @dir_output = `dir $drives[$dwitch]:\\$ARGV[1].pl /s/o/b`;
  $dwitch++;
 } next if ($dir_output[0] == &quot;File Not Found&quot;)
 &find_it;
}

sub multiple {					# deeplook sub
 print &quot;Multiple Results Please chose file by number at left\n&quot;;
 foreach (@dir_output) {
  print &quot;\n<$count> - $_&quot;;
 }
 print &quot;\nEnter your file number :&quot;;
 $so = <stdin>;
 chomp $so;
 $so =~ tr/0-9/ /cs;				# all non 0-9 chages to spaces
 $so =~ s/\s//g;				# supress spaces
 if (($so == 0) || ($so > $count)) {		# check if valid file number
  &multiple;
 } else {					# u have chosen goto single
  &single($dir_output[$so]);
 }
}

sub single {
 system(&quot;notepad.exe $_[0]&quot;);
 &end_of_script;
}

sub end_of_script {
 print &quot;\nHit Enter to quit&quot;;
 while (! <stdin>) {sleep;}
 exit;
}

---------------------------------------
wmail.jpg


someone knowledge ends where
someone else knowledge starts
 
aaa [lol] nerver mind ...i just need sleep ---------------------------------------
wmail.jpg


someone knowledge ends where
someone else knowledge starts
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top