6

I have some code from http://www.hyllander.org/node/23 that uses $* ("dollar asterisk" or "dollar star"), but my version of perl reports:

$* is no longer supported at migrate.pl line 284.

Do you know what were the side-effects of doing

$*=1

Did that somehow affect functions like split or tokenizers or regular expressions?

ysth
  • 96,171
  • 6
  • 121
  • 214
Shalom Craimer
  • 20,659
  • 8
  • 70
  • 106
  • 1
    All of Perl's variables are documented in perlvar. – brian d foy Nov 23 '09 at 11:54
  • 4
    Unless you are using perl 5.10. It documents all of Perl's variables, but not the discontinued ones. – innaM Nov 23 '09 at 15:09
  • You can find any given version of documentation at e.g. http://search.cpan.org/dist/perl-5.8.5 – ysth Nov 24 '09 at 04:21
  • 1
    @ysth: Which... means you need to know in which version the variable was discontinued in... for a variable you know nothing about... (I guess this sounds like Helen Keller's tutor complaint about trying use a dictionary to find a word's spelling :-) – Shalom Craimer Nov 24 '09 at 08:24
  • 1
    @scraimer: a little research isn't going to kill you. You might even learn something. There's a reason some people have the answers and some people have the questions. Which side do you want to be on? – brian d foy Nov 28 '09 at 08:04
  • 4
    I feel the point of SO is to bring those two groups together. The main reason I asked the question was so that the next person who searches in Google for "perl dollar star", or "perl dollar asterisk", will get to this page, and see the answer! Isn't that wonderful? – Shalom Craimer Nov 28 '09 at 23:32

1 Answers1

17

Here's part of the output of perldoc perlvar:

$* Set to a non-zero integer value to do multi-line matching within a string, 0 (or undefined) to tell Perl that it can assume that strings contain a single line, for the purpose of optimizing pattern matches. Pattern matches on strings containing multiple newlines can produce confusing results when $* is 0 or undefined. Default is undefined. (Mnemonic: * matches multiple things.) This variable influences the interpretation of only "^" and "$". A literal newline can be searched for even when "$* == 0".

Use of $* is deprecated in modern Perl, supplanted by the "/s" and "/m" modifiers on pattern matching.

Assigning a non-numerical value to $* triggers a warning (and makes $* act if "$* == 0"), while assigning a numerical value to $* makes that an implicit "int" is applied on the value.

innaM
  • 47,505
  • 4
  • 67
  • 87