Hi basically my script works fine.
I wanted to add some comments in my config file but it is reading in the comment lines to.
So basically i want to not read in the config lines in the script.
This is the piece of the script that is reading in the lines in the array.
Now it works fine without the if statement. So reason it is not working.
Expand|Select|Wrap|Line Numbers
- open(HAN, "sort_config.txt") || die " Unable to run date command $!";
- while (<HAN>) {
- $configline = <HAN>;
- # This if statement is to remove lines from the array that start with #
- chomp($configline);
- if ("$configline" =~ /^\#/) {
- print "not in array $configline \n";
- }
- else {
- push @array1, [ split ];
- print "going in array $configline \n";
- }
- close HAN;
- }
Config files lines are:
# CONFIG FILE ####### Delimiter is 1 space ***** DO NOT REMOVE LINE ****
# SOURCE PATH DESTINATION PATH LOG PATH AND FILE ***** DO NOT REMOVE LINE ****
# EXAMPLE: /home/source /home/archive /home/newlog.txt ***** DO NOT REMOVE LINE ****
/home/source3 /home/archive /home/newlog3.txt
/home/source4 /home/archive2 /home/newlog4.txt
So basically i want the array to have only lines with no #