It may help to copy and paste your teacher's actual instructions. Items 1 & 2 aren't altogether clear, especially instructions of the form exit when the file is an empty file, and print the last line of the file - an empty file doesn't have a last line. Have you "reinterpreted" the actual instructions for us?

You don't show us the code you've tried that uses File::Find.

Did your teacher specify that you need to search "everywhere" for the file (that's a pretty big ask depending on how you choose to interpret "everywhere"). If not, just assume the current directory and ignore File::Find.

There are many quirks in your code. Here's a cleaned up version of your code followed by some comments on the changes.

#! /usr/bin/perl # Assignment 9, check and read files and directories use strict; use warnings; use Module1; assnintro(); while (1) { print "Enter one file or directory name: "; my @params = split /\s+/, <>; if (@params != 1) { print color 'red'; print "One directory or file entry expected.\n"; print color 'reset'; next; } my $input = $params[0]; if (!-e $input) { print color 'red'; print "The file or directory '$input' doesn't exist.\n"; print color 'reset'; } elsif (-d $input) { last if !doDir($input); } else { last if !doFile($input); } } sub doDir { my ($input) = @_; print "'$input' is a directory.\n"; my @subDirs = glob $input; return if !@subDirs; #... return 1; } sub doFile { my ($input) = @_; print "'$input' is a file.\n"; #... return 1; }

Of note:

Perl is the programming world's equivalent of English

In reply to Re: verifying user input with Find::File by GrandFather
in thread verifying user input with Find::File by MrStutterZ

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.