in reply to Why doesn't the whole line print?

See Death to Dot Star!. There is no reason for the '.*' in your regex. All you need is:
print $string if $string =~ /\bso\b/;
As for your problem, all I can say is, how are you setting '@current_sentence', and is it what you expect when you assign it to '$string'? Print both out to see if they are what you think they are.

Replies are listed 'Best First'.
Re: Re: Why doesn't the whole line print?
by hillard (Acolyte) on Aug 18, 2001 at 04:09 UTC
    Sorry for the '.*' I put it in hoping that the whole line would be matched and not truncated. As far as the @current_sentence, I am just pushing words onto the array as I strip them from a data base. In the example I gave 'so' is the first word in the sentence, so I also added a '<s>' to the word I pushed, here is the code:
    push @current_sentence, "<s> $current_word ";
    Then I push additional words onto the array as I find them with this:
    push @current_sentence, "$current_word ";
    Finally the last word of a sentence gets pushed like so:
    push @current_sentence, "$current_word <\/s>\n";
    Another interesting comment, I just tried printing the string outside the if statement and the whole thing printed! But earlier I tried to get around this by having the if statement set a flag and then printing from another if statement that checked the flag... and it still printed truncated. So I still can't print conditionally.

    Thanks for all the help so far.

    An update: I have looked at the behavior on some other examples and it seem as though the print statement is printing the array element that was originally pushed onto the array, even though I put the array into a single string. What I mean be this is that if the word starts a sentence, the <s> tag is ahead of it, if it is in the middle there are no other tags, and if it was at the end a </s> tag follows it. Baffeling to me!