in reply to Re^3: Bugfixing Old Code
in thread Bugfixing Old Code

I thought that required brackets as in my @temp_and_starts = ($_=~/(\S+)/g); but it does not.

Replies are listed 'Best First'.
Re^5: Bugfixing Old Code
by choroba (Cardinal) on Jul 23, 2021 at 09:44 UTC
    Also note that $_=~ can be shortened to . Moreover, you don't need a capture if you capture the whole pattern.
    my @temp_and_starts = /\S+/g;
    map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]
      You are correct - the capturing parens are not necessary,
      In that case, the originally posted code is correct:
      # Split on multiple spaces using regex captured matches my @temp_and_starts = $_ =~ /[^\s +]+/g; my @last_AT_fracs = <$in> =~ /[^\s +]+/g; my @twenty_SFs = (<$in> . <$in> . <$in> . <$in>) =~ /[^\s +]+/g;
      and my test below shows that it works:
      $ perl -E '$_="This and that and other";@x= $_=~ /[^\s]+/g;; say for +@x' This and that and other

                      "The difficult we do today; the impossible takes a little longer."