I need to read a file on Unix server that has only one line with a character on it. My script needs to read in the character. If the character is 1, the script stops and exit. Otherwise, the script runs. Befoere the scripts ends, write the "0" to replace "1". I wrote some code like below. but it does not work and get error of "Reference to nonexistent group in regex; marked by <-- HERE in m/^\1 <-- HERE /". Can someone help? Thanks.
Code:
#!/usr//bin/perl -w use Net::SFTP::Foreign; open(F, 'testRead_line.txt'); while () { print "line = $_ \n"; if ($_ =~ m/^\1/) { print "The script has already been running. Exit. \n"; exit (0); } else { print "start running the script. \n"; } }
Comment