dreman has asked for the wisdom of the Perl Monks concerning the following question:
sub check_server_exist { my($svr) = "\Uempdb"; ### altered word #### my(@sql_in) = "d:\\tmp\\sql.txt"; ##### Open file, if server name exists, will close if true ### @check_name = (); open(sql_ini, "< @sql_in") or die "can't open the file: @sql_in $! \n" +; ## Open existing file while (<sql_ini>) { ## { print "$_"; } ; ## Readi +ng every line in the file chomp; # no newline s/#.*//; # no comments s/^\s+//; # no leading white s/\s+$//; # no trailing white #push(@check_name, $_); } print "This is the server name: $svr\n"; if ($_ =~ m/${svr}/ || $_ =~ m/${svr}_BACKUP/ || $_ =~ m/${svr}_REP/ | +| $_ =~ m/${svr}_RSM/ || $_ =~ m/${svr}_XP/) { print "Server name exists\n\n"; &leave } } };
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Comparing variables
by dragonchild (Archbishop) on Aug 24, 2001 at 00:02 UTC |