Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Hi,
I have a problem -- I have a text file like this:
This is a line. Another line is here. Here's a line. Line five is this one.
What I need to do is get the first column of each of these (columns being ended by spaces), so that my output looks like this:
This Another Line
As you can see, if the line begins with spaces or is empty, I just want to print out a blank line so I can tell that there was something there. I would do this on my own, but this is just a little part of a much bigger project of mine, and I'm still just learning Perl and I'm really bad with regular expressions. Any help would be much appreciated (and I promise to learn from your answers before I return!). Thanks!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Grabbing first column of text
by japhy (Canon) on Aug 02, 2001 at 20:15 UTC | |
by twerq (Deacon) on Aug 02, 2001 at 22:40 UTC | |
by Anonymous Monk on Aug 02, 2001 at 22:52 UTC | |
by japhy (Canon) on Aug 02, 2001 at 22:53 UTC | |
|
Re: Grabbing first column of text
by CheeseLord (Deacon) on Aug 02, 2001 at 20:13 UTC | |
|
Re: Grabbing first column of text
by tachyon (Chancellor) on Aug 02, 2001 at 20:37 UTC | |
|
Re: Grabbing first column of text
by Hofmator (Curate) on Aug 02, 2001 at 20:47 UTC |