So, I am new to Perl... bought a book and I think I am off the right start with chomp or chop, except I am trying to remove a blank space from the front of a line.
I am simply trying to open the contents of a text file into an array and print them, except every line AFTER the first line prints with a blank space in front of it?! Is there some way of stripping the blank space away from every line in the array?
Contents of the text file:
one. two. three. four.
the code in my script:
my $messagebody = "message.txt"; open(messagebody, $messagebody) || Error ('open', 'file'); flock (messagebody, 2) || Error ('lock', 'file'); my @messagebody = <messagebody>; print @messagebody; sub Error { print "The server can't $_[0] the $_[1]: $! \n"; exit; }
The file prints like this:
one. two. three. four.
Is there a way to reverse what chop? (if that makes any sense...)
In reply to Getting rid of first space? by jimmybeaches
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |