in reply to Chomp Command
If you're trying to figure out a command, write a tiny script. Run it in the debugger: perl -d myscript.pl; You can also run the debugger without any script, to experiment with a command. I use perl -demo because it's memorable, though the 'mo' don't mean anything useful.
chomp() will remove a trailing newline, but not other characters. If passed an array, it will process each element of the array. So if you care, you can use it to determine whether there used to be a newline in the variable. I don't remember ever seeing anyone care, but the potential is there.
DB<1> $a = "a \n" DB<2> x $a 0 'a ' DB<3> print chomp $a 1 DB<4> x $a 0 'a ' DB<5> print chomp $a 0 DB<6> x $a 0 'a ' DB<7> @a = ( "abc\n", "def\n", "ghi\n" ) DB<8> x \@a 0 ARRAY(0x8406258) 0 'abc ' 1 'def ' 2 'ghi ' DB<9> print chomp @a 3 DB<10> x \@a 0 ARRAY(0x8406258) 0 'abc' 1 'def' 2 'ghi'
As Occam said: Entia non sunt multiplicanda praeter necessitatem.
|
|---|