Okay. Ill play. You really shouldn't need all those externs, they're completely unnecessary. Also their is more than one type of loop, you should have to rely on setting that $x variable. Here is a quick hack I wrote up:
#!/usr/bin/perl use strict; do { cls(); print "Address Book\n"; $_ = <>; if (/l/) { entry_list(); } elsif (/a/) { entry_add(); } elsif (/r/) { entry_rem(); } elsif (/s/) { entry_sea(); } else { print "Invalid Entry\n" if not /[lars(q|quit)]/; } } until(/q|quit/); exit; sub entry_list { cls(); open ADBK, "<adbk.db" || die "Datebase file does not exist\n"; while(<ADBK>) { print join(" ", split /:/); } close ADBK; print "Press any key to contine...\n"; $_ = <>; } sub entry_rem { my $tmp = (); my $num = 0; print "Enter the infomation:\n"; foreach("First Name: ", "Last Name: ", "Email: ") { print; chomp(my $line = <>); $tmp .= "$line:"; } cls(); open ADBK, "<adbk.db" || die "Could not open database to read\n"; my @file = <ADBK>; close ADBK; open ADBK, ">adbk.db" || die "Could not open database to open\n"; foreach ( @file) { next if /$tmp/; $num++; print ADBK $_; } close ABDK; print "No entries found\n" if $num == 0; print "Press any key to contine...\n"; $_ = <>; } sub entry_sea { my $tmp = (); my $num = 0; print "Enter the infomation:\n"; foreach("First Name: ", "Last Name: ", "Email: ") { print; chomp(my $line = <>); $tmp .= "$line:"; } cls(); open ADBK, "<adbk.db" || die "Could not open database to read\n"; while(<ADBK>) { if(/$tmp/) { print "Entry ", ++$num, ":\n", join("\n", split /:/) +; } } close ABDK; print "No entries found\n" if $num == 0; print "Press any key to contine...\n"; $_ = <>; } sub entry_add { my $tmp = (); foreach("First Name: ", "Last Name: ", "Email: ") { print; chomp(my $input = <>); $tmp .= $input.":"; } open ADBK, ">>adbk.db" || die "Could not open database to append\n"; print ADBK $tmp, "\n"; close ABDK; } sub cls { print "\033[2J"; print "\033[0;0f"; }

In reply to Re: Learning Exercise by debiandude
in thread Learning Exercise by Foncé

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.