One obvious problem -- put the mkdir inside the if statement:
if ($line =~ /mydir/) {
$directory = ...
mkdir $directory, 0775;
}
You only want to call mkdir if the line matches.
Also, passing "\n" to mkdir doesn't make any sense here. The second argument to mkdir is a permission mode mask. See the comments on perldoc -f mkdir for more discussion on how this parameter works.
Finally, you should get accustom to using the three parameter version of open:
open(FILE, '<', $ARGV[0]);
This is much safer.
|