Problems? Is your data what you think it is? | |
PerlMonks |
Re: Getting rid of first space?by thpfft (Chaplain) |
on Mar 16, 2003 at 04:21 UTC ( [id://243418]=note: print w/replies, xml ) | Need Help?? |
It sounds like something in your script is setting $, to a space, for some reason. Perhaps you're trying to print something out nicely somewhere else? Well, don't :) Anyway, it's the print statement that's inserting the spaces, i think. The reason they show up the way they do is because each item in your array still has a newline on the end, and the space is added after that. you have two immediate options: you can take more control over the formatting of the list with something like this:
or you could save yourself lots of trouble, sort out the thing with $, and get rid of the newline character at the first opportunity:
The explanation of why chomping that whole statement happens to chomp the items in the array is worth coming back to later. Meanwhile, to answer the question you actually asked, there are (at least) dozens of ways of removing the first character of each item in a list. This is the first that comes to mind:
which will remove all leading spaces and tabs, and might do unkind things to, for example, messages containing python code...
In Section
Seekers of Perl Wisdom
|
|