in reply to Grabbing first column of text

You simply want to use ($first) = $line =~ /(\S*)/;

_____________________________________________________
Jeff japhy Pinyan: Perl, regex, and perl hacker.
s++=END;++y(;-P)}y js++=;shajsj<++y(p-q)}?print:??;

Replies are listed 'Best First'.
Re: Re: Grabbing first column of text
by twerq (Deacon) on Aug 02, 2001 at 22:40 UTC
    You simply want to use ($first) = $line =~ /(\S*)/;

    I believe that the original poster also wanted to capture a series of blank spaces, if that was what occupied the first element of a line.

    \S matches non-whitespace characters only. . .

    . . . the split solutions seem much more well-suited.

    --twerq

      No, if you'll read the entire post, you'll notice that I said "... if the line begins with spaces or is empty, I just want to print out a blank line..." Anyway, the first two examples here do just what I'm looking for. Thanks, guys!

      No, the original post says:
      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.
      He either wants the column of text, or nothing. That is what I give him.

      _____________________________________________________
      Jeff japhy Pinyan: Perl, regex, and perl hacker.
      s++=END;++y(;-P)}y js++=;shajsj<++y(p-q)}?print:??;