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

android - net_scheduler holding wakelock -

sql - MySQL : Getting Entries from a many-to-many table -

java - Retrieving data from database using jsp (Hibernate + Spring + Maven) -