CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
If value is NULL then quit?

 



StarkRavingCalm
User

Mar 22, 2013, 10:47 AM

Post #1 of 2 (332 views)
If value is NULL then quit? Can't Post

I am creating a script that will monitor directories for specific files and email the contents.
That part is working great but how do I tell the script to quit if the array is empty?

my @files = grep ( -f ,<*.txt>);
# Write them out
foreach $file (@files) {
print "$file\n";
}

I dont want to repeatedly recieve email with:

$VAR1 = {};


(This post was edited by StarkRavingCalm on Mar 22, 2013, 10:49 AM)


Kenosis
User

Mar 22, 2013, 10:57 AM

Post #2 of 2 (328 views)
Re: [StarkRavingCalm] If value is NULL then quit? [In reply to] Can't Post


Code
my @files = grep ( -f ,<*.txt>) or exit;


And this gives the same results:


Code
my @files = <*.txt> or exit;


Don't need to grep for whether it's a file...


(This post was edited by Kenosis on Mar 22, 2013, 11:03 AM)

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives