Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much

Verifying data change

by Anonymous Monk
on Aug 15, 2002 at 12:48 UTC ( #190382=perlquestion: print w/replies, xml ) Need Help??
Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Currently I am fetching executable files from a web site. I only fetch when part of the executable name is changed. This has worked for the past year but now they changed the whole name. So I wanted to add to my script a part to notify me if they changed the whole name of the executable so I dont try and fetch some name that doesnt exist.

here is my current part of my script with the new name change:
my ($var) = $content =~ /(.{3}\-a99\-9)/; $var = $1;
Now here is what I propose to add to my script so I am notified about a complete new filename:
if (not defined $var) { print "The whole name was changed so no match found. You need to +change your reg expression.\n"; exit 0; #Since no match then exit the script. }
I want advise on if this is the correct way to handle this?? Also "exit 0" means good exit? Or do I use "exit 1"??

Replies are listed 'Best First'.
Re: Verifying data change
by adrianh (Chancellor) on Aug 15, 2002 at 21:22 UTC

    Yes, "0" is the exit code for success. I'm not sure what else you're asking... can you expand on the problem you''re having (if any?)

      I think he's asking how he can detect the "whole filename changed", although he almost provided the answer: use a pattern describing what you're expecting to see and match the filename against that. If the filename doens't match, it changed beyond your expectations ("the whole filename changed").

      Two nits: you don't need the capturing (to do this, at least) and you'd want to anchor the pattern to the beginning and end of the filename.

      — Arien

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://190382]
Approved by Courage
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (11)
As of 2018-06-22 18:02 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (124 votes). Check out past polls.