I wanted $dir to get its value from extracting text from the New Dir entry. For each new Dir there will be a x:\....\ string of text to denote a folder path, which for each line where there is New Dir match it assigns the value found to $dir, then for each corresponding line the print join prints the $dir value. Well that was the idea in theory. If I remove the $dir from the print join statement, it works.
Ok so $line fixed. but still having probs with $dir. Does the $dir =~ not declare it as an assignment?
| [reply] |
No, assignment operator is =, =~ is a pattern match operator. See perlop.
| [reply] |
| [reply] |
Pointer re choroba's answer: perlre, perlretut, etc. As you've written the regex, it's effectively a noop because you haven't assigned a value to $dir.
Beyond that, it may be that your intent and the regex's behavior don't agree. The \n is the wrong way to tackle the end of a line -- if, in fact, you need to anchor to an EOL... but you haven't offered any information to suggest it's needed at all.
So, perhaps you want something like this (after assigning a value to $dir):
$dir =~ m/([a-z:]+).*?/; $dir = $1; print $dir;
The parens capture to $1 the content matching a-z & colon more than one time... for ex, "C:"
| [reply] [d/l] [select] |