I've posted my script on Tek-Tips the other day asking for help but the person who ran the script on their linux system said it ran without hesitation. Yesterday someone on PerlMonks ran and tested the identical code that's below and they say it works on their Windows XP system.

I am running Windows XP with ActiveState Perl 5.8.0 and the script will not work and will not post back any warnings or errors and no one has been able to help figure this out. Can everyone try running this script and let me know if it runs for you (the only part that doesn't work is the Find (f) feature )? Does anyone have any idea on how I could get this working on my system so I can begin finalizing the script?

Thanks so much.

#!/usr/bin/perl -W use strict; use warnings; use POSIX; use Fcntl; use CGI; use SDBM_File; my %dbm; my $test = "test.dbm"; my $name; tie (%dbm, 'SDBM_File', $test, O_CREAT|O_RDWR, 0644) || die "Died tying database\nReason: $!"; # Printing option menu print "Aaron's Phonebook System\n\n\n"; print "f - find an entry\n"; print "a - add an entry\n"; print "m - modify an entry\n"; print "d - delete an entry\n"; print "r - read all entries\n"; print "e - erase all entries\n"; chomp(my $option = <STDIN>); $option =~s/\r//; print "Option: $option\n"; #Add An Entry if ($option eq 'a') { print "add an entry test!\n"; print "Name:"; chomp(my $name = <STDIN>); print "Phone number:"; chomp(my $number = <STDIN>); print "Email Address:"; chomp(my $email = <STDIN>); print "Address Line 1:"; chomp(my $address1 = <STDIN>); print "Address Line 2:"; chomp(my $address2 = <STDIN>); print "$name added to the list!\n"; # combine all data into one nicely snug package...I hope $dbm{$name}=join "\0",$name,$number,$email,$address1,$address2; $dbm{$name} =~s/\cM//g; } elsif ($option eq 'r') { foreach my $key ( sort keys %dbm ) { my($name, $number, $email, $addr1, $addr2) = split "\0", $dbm{$key +}; print "$name\n$number\n$email\n$addr1\n$addr2\n\n\n"; } } elsif ($option eq 'f') { print "Who are you looking for?\n"; &find; } # Delete An Entry elsif ($option eq 'd') { print "What name would you like removed?\n"; &del; } elsif ($option eq 'e') { print "To delete all entries press y, to cancel press n\n"; &erase; } else { print "Wrong button!\n"; } sub del { chomp(my $d = <STDIN>); if ($dbm{$d}) { delete $dbm{$d}; print "$d deleted successfully\n"; } else { print "$d not found\n"; } } sub 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 erase { chomp(my $e = <STDIN>); $e =~s/\r//; if ($e eq 'y') { %dbm = (); print "All entries have been deleted.\n"; } elsif ($e eq 'n') { print "Deleting process cancelled.\n"; } else { print "Key was invalid, deletion process failed\n"; } } untie %dbm;


"Age is nothing more than an inaccurate number bestowed upon us at birth as just another means for others to judge and classify us"

sulfericacid

update (broquaint): added <readmore> tag


In reply to Flawless Script problems? by sulfericacid

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.