design patterns - How to add \n and delete space from perl regular expression -
i tried add \n output source:
sub fileresult{ open $file; @listoffiles; while (<$file>) { if (m/^\s+ (\w+)/x) { push @listoffiles, $1; } } close $file; open $fh, '>', ".\input.txt" or die "cannot open input.txt: $!"; print $fh join "\n", "@listoffiles"; } close $fh;
output like:
a b c
i want like:
a b c
without space @ begining of word , end of word.
perhaps don't want substitute nothing , match it, m/^\s+ (\w+)/x
instead of s/^\s+ (\w+)/x/
also can't see place print them, insert newlines between items, like:
print join "\n", @listoffiles;
or
do { local $" = "\n"; print "@listoffiles" };
Comments
Post a Comment