Here is something that look a bit cleaner. There are lots of comments. no warnings, /usr/bin/clear won't port. Hardcoded file paths are bad. Not checking the result of file opens is bad. Redundant code is bad ie most of your if/else do 'cls'+exit. You don't really need Term::Readline or Shell. Use File::Copy if you must.

#!/usr/bin/perl use strict; use warnings; my $DATFILE = "c:/store.txt"; my @teams = qw( Arsenal Bolton Villa Chelsea Middlesbro +ugh ` Newcastle Birmingham Blackburn Palace Fulham Liverpool ManchesterCity Norwich Portsmouth Spurs WBA ManchesterUnited Southampton Charlton Everton ); clearscreen(); # if we don't have a datfile we HAVE to INIT it!!! init_file(\@teams) unless -e $DATFILE; # now we can read the datfile becuase it exists, 100% guaranteed open F, $DATFILE or die "Can't read $DATFILE, Perl says $!\n"; chomp ( my @values = <F> ); close F; print " --------------------------- 1. Update Teams 2. Check previous Results 3. Backup Storage File 4. Quit --------------------------- Option: "; chomp( my $reply = <STDIN> ); clearscreen(); if ($reply == "0") { init_file(\@teams); } elsif ($reply == "1") { team_update(\@values, \@teams); } elsif ($reply == "2") { team_find(\@values); } elsif ($reply == "3") { storage_backup(); } else { print "Exiting\n"; } exit 0; #----------------------------------------------------------------- # subs #----------------------------------------------------------------- sub clearscreen { $^O =~ m/Win32/ ? system('cls') : system('clear') } sub init_file { my ($teams) = @_; open F, ">$DATFILE" or die "Can't write $DATFILE, Perl say $!\n"; print F "$_\n" for @$teams; close F; } # yada

cheers

tachyon


In reply to Re: code for review? by tachyon
in thread code for review? by amadain

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.