danj35 has asked for the wisdom of the Perl Monks concerning the following question:
Hopefully a nice and easy problem for the monks to solve here:
I have a variable ($string) that contains some script. The script in $string is more than one line long and the content can vary. At the start and the end of the variable are newline characters and I need to remove these. At the moment I've successfully been able to remove the newline character from the end of the string using chomp as so:
Does anyone know how to remove the newline character from the start of $string? My first thought is to use regular expressions, although I wouldn't know how to write this, especially when there are likely to be other newline characters between the start and the end.chomp $string;
Many thanks :)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Remove newline character from start of string
by moritz (Cardinal) on May 10, 2010 at 12:28 UTC | |
by Roy Johnson (Monsignor) on May 10, 2010 at 15:29 UTC | |
|
Re: Remove newline character from start of string
by Old_Gray_Bear (Bishop) on May 10, 2010 at 12:42 UTC | |
by danj35 (Sexton) on May 10, 2010 at 13:19 UTC | |
by afoken (Chancellor) on May 11, 2010 at 05:21 UTC | |
|
Re: Remove newline character from start of string
by Ratazong (Monsignor) on May 10, 2010 at 12:20 UTC | |
|
Re: Remove newline character from start of string
by Marshall (Canon) on May 10, 2010 at 13:05 UTC |