regex - Why am I still getting newlines? -


i have following code:

open input, "input.txt"; $line = ""; while (<input>) {         $line = $_;         $line =~  s/\s+^//;         print $line; } 

but output still includes newlines. have tried \v , \r.

/\s+^/ means "one or more whitespace characters before start of string" — never match.

if goal remove trailing whitespace characters, need $ rather ^:

    $line =~  s/\s+$//; 

(and if goal remove trailing newline, should use the built-in chomp function.)


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -