in reply to Re: Edit a New file in place after reading it in
in thread Edit a New file in place after reading it in
I am having a bit of doubt about deciphering the regex; so, here's my best shot. Please correct me when I am wrong
$line =~ /^([^:]+):(\s+)/ && exists $subs{$1}
So, regex on $line is as follows (according to me ;-) )
"^" regex string must be at the start of the line.
The string is grouped by using the "( )", if the entire string in the "()" matches then it will substitute with a new value in the hash.
I am not sure why the class "[ ]" are opened or mean in this regex...???
Whatever is in the class bracket, it is looking for a match of"^:" character. I am not sure about the carrot "^" does here before the ":" ?? then the class bracket closes.
The "+" plus signs indicates that there may be more strings that match the ":" character ...maybe? I am guessing here. then we close the group.
Then the character ":" appears again after the parenthesis has closed. I'm not sure what this ":" does here.
then (s+) there may be one or more spaces after the first regex match.Then checks if that regex it just performed exists, if it does, then the new hash value replaces old to new value.
I could not run your code because it kept giving me an error
Error
reading file No such file or directory
Any ideas why this "reading file does not exist" when it was integrated in the code
|
|---|