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

Looks OK to me.. have you tried printing the string before you do the match. Or perhaps the values of @current_sentence.. I don't se any immediate error in your code. Try something like:

print "current_sentence element: $_\n" for (@current_sentence); $string = "@current_sentence"; print "String Before: $string\n"; if( $string =~ /.*\bso\b.*/ ) { print "String After: $string\n"; }

-Blake

Replies are listed 'Best First'.
Re: Re: Why doesn't the whole line print?
by hillard (Acolyte) on Aug 18, 2001 at 03:46 UTC
    Yep, I did that and the whole line prints. That's why I'm stumped, it seems as if the regex is clipping the string...
      You'll have to post a bit more code then, because my demo program doesn't suffer from the same problem:

      #!/usr/bin/perl my @current_sentence = qw(so we can do it again yeah yeah); print "current_sentence element: $_\n" for (@current_sentence); $string = "@current_sentence"; print "String Before: $string\n"; if( $string =~ /.*\bso\b.*/ ) { print "String After: $string\n"; }
      OUTPUT

      current_sentence element: so current_sentence element: we current_sentence element: can current_sentence element: do current_sentence element: it current_sentence element: again current_sentence element: yeah current_sentence element: yeah String Before: so we can do it again yeah yeah String After: so we can do it again yeah yeah

      Although I don't really like the $scalar = "@array" construct, I see nothing wrong with it. I would probably use: $scalar = join(' ',@array) instead for clarity.

      -Blake