Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

$* is no longer supported

by nootkan (Initiate)
on Oct 30, 2013 at 16:40 UTC ( #1060392=perlquestion: print w/replies, xml ) Need Help??
nootkan has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks, I need your help. I have no perl programming experience and have been using a banner exchange script for a long time now successfully until I migrated over to a new server with a newer version of perl (5.8.8 to 5.10.1). I am wondering if someone could help me to update the script to current standards. When trying to login to admin I see these errors in my logs:

$* is no longer supported at line 4296. Premature end of script headers:

I have researched on google and see that I have to make changes using /s or /m but as I stated I have no programming experience. Can anyone help me? Here is the code:

if ($mailprog eq "SMTP") { unless ($WEB_SERVER) { $WEB_SERVER = $ENV{'SERVER_NAME'}; } if (!$WEB_SERVER) { &Error_Mail; } unless ($SMTP_SERVER) { $SMTP_SERVER = "smtp.$WEB_SERVER"; $SMTP_SERVER =~ s/^smtp\.[^.]+\.([^.]+\.)/smtp.$1/; } # local($AF_INET) = ($] > 5 ? AF_INET : 2); # local($SOCK_STREAM) = ($] > 5 ? SOCK_STREAM : 1); local($AF_INET) = 2; local($SOCK_STREAM) = 1; $, = ', '; $" = ', '; local($local_address) = (gethostbyname($WEB_SERVER))[4]; local($local_socket_address) = pack('S n a4 x8', $AF_INET, 0, +$local_address); local($server_address) = (gethostbyname($SMTP_SERVER))[4]; local($server_socket_address) = pack('S n a4 x8', $AF_INET, '2 +5', $server_address); local($protocol) = (getprotobyname('tcp'))[2]; if (!socket(SMTP, $AF_INET, $SOCK_STREAM, $protocol)) { &Error +_Mail; } bind(SMTP, $local_socket_address); if (!(connect(SMTP, $server_socket_address))) { &Error_Mail; } local($old_selected) = select(SMTP); $| = 1; select($old_selected); $* = 1; select(undef, undef, undef, .75); sysread(SMTP, $_, 1024); print SMTP "HELO $WEB_SERVER\r\n"; sysread(SMTP, $_, 1024); while (/(^|(\r?\n))[^0-9]*((\d\d\d).*)$/g) { $status = $4; $message = $3; }

Replies are listed 'Best First'.
Re: $* is no longer supported
by toolic (Bishop) on Oct 30, 2013 at 16:57 UTC
    On perl 5.10 (and later), your script should work the same with the $* as without the $*. The deprecation message is letting you know that it has no effect. So, if you want to get rid of the warning message, you can just comment out the $* line:
    # $* = 1;

    Note that it is a warning, not an error. Is your script working as desired on 5.10?

    You could check to see if your script still works on 5.8 without $*.

    The problem with the $* variable is that it is global. Once set, it will apply to all regular expressions in code executed after it is set. If there are any regexes outside of your posted code, they could be affected, too.

    See also $* and perdiag

Re: $* is no longer supported
by hippo (Abbot) on Oct 30, 2013 at 16:58 UTC

    I would try removing (or commenting out if you prefer) the $* = 1 line and add the /m modifier to the match inside the last while. That's only a guess but it would make sense for the . not to match the newline here, I think.

    while (/(^|(\r?\n))[^0-9]*((\d\d\d).*)$/mg) {

    Back your script up before making any changes, of course.

    How long have you had that script? It is in quite an old style.

      Thanks guys, I was afraid of that. This isn't my script it was open source (webadverts) that has long since been abandoned. It worked fine on perl 5.8.8 on my old server so I guess I'll have to roll back to that version. If I didn't have hundreds of clients using the exchange I would just look for another one and start over.

Re: $* is no longer supported
by LanX (Bishop) on Oct 30, 2013 at 16:52 UTC
    I'm not going to analyze your code, but according to the older discussions I googled $* has to be replaced by /m and /s modifiers in your code.

    So adding /ms at every regex executed after setting '$*' should do, otherwise drop one of them (yeah the documentation isn't much clearer).

    Cheers Rolf

    ( addicted to the Perl Programming Language)

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1060392]
Front-paged by Arunbear
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (4)
As of 2018-05-20 21:49 GMT
Find Nodes?
    Voting Booth?