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

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -