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

user interface - Python attempting to create a simple gui, getting "AttributeError: 'MainMenu' object has no attribute 'intro_screen'" -

jquery - Common JavaScript snippet to share files on Google Drive, Dropbox, Box.net or SkyDrive -

Android Gson.fromJson error -