I managed to get it working.
I changed you code a little here is what I came up with.
Firstly...changed toelsif ($option eq 'f') { print "Who are you looking for?\n"; &find; }
Then I changed you find sub fromelsif ($option eq 'f') { print "Who are you looking for?\n"; chomp(my $f = <STDIN>); $f =~s/\cM//g; if (!&find($f)) { print "Name $f cannot be found in the directory.\n"; }
to look as followssub find { chomp(my $f = <STDIN>); # $f=~tr/\r\z//d; #$f =~s/\r\z//; $f =~s/\cM//g; if (exists $dbm{$f}) { my($name, $number, $email, $addr1, $addr2) = split "\0", $dbm{$f} +; print "$name\n$number\n$email\n$addr1\n$addr2\n\n\n"; } else { print "Name $f cannot be found in the directory.\n"; } }
sub find { my $rc = 0; my $f = shift; foreach my $key ( sort keys %dbm ) { my($name, $number, $email, $addr1, $addr2) = split "\0", $ +dbm{$key}; if ($name eq $f) { print "$name\n$number\n$email\n$addr1\n$addr2\n\n\n"; $rc = 1; last; } } }
Disclaimer: I know nothing about tie and less about SDBM_File but thats why I like perl.
-----In reply to Re: Flawless Script problems?
by AcidHawk
in thread Flawless Script problems?
by sulfericacid
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |