However no matter what is inputted it moves on with out giving notice stating the town name has not been found.

SSCCE, perltidy, and the code "works"...

use warnings; use strict; addind(); sub addind { open( MYINPUTFILE, "townsdata.txt" ) or die $!; $| = 1; my @lines = <MYINPUTFILE>; print "INDUSTRY TOWN\n"; my $indtwn = <STDIN>; $indtwn = <STDIN> until defined $indtwn; chomp $indtwn; print "cls();\n"; my $found = 0; foreach my $townverify (@lines) { my @field = split( ':', $townverify ); if ( $field[0] =~ m/^#/ ) { next; } if ( $field[1] =~ /(?<![\w-])$indtwn(?![\w-])/i ) { print "cls();\n"; $found = 1; } else { print "cls();\n"; print "TOWN RECORD NOT FOUND\n"; print "sleep 3;\n"; print "cls();\n"; addind(); } my $output = "inddata.txt"; open( DAT, "+<$output" ) || die("Cannot Open File"); my $indline; $indline = <DAT> until eof DAT; my ($indid) = $indline =~ m/\A(\d+):/; print DAT ( ++$indid ); print DAT (":"); print DAT ($indtwn); print DAT ("\n"); close(DAT); print "INDUSTRY SUCCESSFULLY ADDED!!\n"; print "sleep 3;\n"; print "cls();\n"; print "industry();\n"; } }
$ perl 11139256.pl
INDUSTRY TOWN
Foo
cls();
cls();
TOWN RECORD NOT FOUND
sleep 3;
cls();
INDUSTRY TOWN
PGH
cls();
cls();
INDUSTRY SUCCESSFULLY ADDED!!
sleep 3;
cls();
industry();
cls();
TOWN RECORD NOT FOUND
sleep 3;
cls();
INDUSTRY TOWN
^C

In reply to Re: Verify Town Name by Anonymous Monk
in thread Verify Town Name by PilotinControl

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.