Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6141159
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T18:12:42+00:00 2026-05-23T18:12:42+00:00

I am trying to complete a college assignment in Perl, and we’ve been told

  • 0

I am trying to complete a college assignment in Perl, and we’ve been told by our professor to use:

use strict;
use warnings;

With use strict; my code works perfectly. with use warnings;, however, my code spews all this stuff to SDOUT and I don’t know why (or how to shut it up). My relevant code is:

while($diff =~ /^(\d+)((,){1}(\d+))?([adc])(\d+)((,){1}(\d+))?/mgi) {
    # This line is used for debugging the $diff regular expression scalars.
    # print "\n1: $1\t2: $2\t 3: $3\t4: $4\t5: $5\t6: $6\t7: $7\t8: $8\t9: $9\n";

    $difflinestotal += ($4 - $1) unless $4 == "";
    $difflinestotal += ($9 - $6) unless $9 == "";
    $difflinestotal += 1 if (($4 == "") && ($9 == ""));
}

With warnings, it spits this out in the middle of my output:

Argument "" isn't numeric in numeric eq (==) at ./partc.pl line 145.
Use of uninitialized value $4 in numeric eq (==) at ./partc.pl line 145.
Argument "" isn't numeric in numeric eq (==) at ./partc.pl line 146.
Argument "" isn't numeric in numeric eq (==) at ./partc.pl line 147.
Use of uninitialized value $4 in numeric eq (==) at ./partc.pl line 147.
Argument "" isn't numeric in numeric eq (==) at ./partc.pl line 147.
Use of uninitialized value $9 in numeric eq (==) at ./partc.pl line 146.
Use of uninitialized value $4 in numeric eq (==) at ./partc.pl line 145.
Use of uninitialized value $9 in numeric eq (==) at ./partc.pl line 146.
Use of uninitialized value $4 in numeric eq (==) at ./partc.pl line 147.
Use of uninitialized value $9 in numeric eq (==) at ./partc.pl line 147.
Use of uninitialized value $4 in numeric eq (==) at ./partc.pl line 145.
Use of uninitialized value $4 in numeric eq (==) at ./partc.pl line 147.

…and it’s messing up my formatting (I am generating a table in the console). I tried ‘declaring’ the scalars, but then (of course) those were in error. How can I get my Perl script to shut up with these warnings (especially since the works anyway)?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T18:12:42+00:00Added an answer on May 23, 2026 at 6:12 pm

    That goes to STDERR, not STDOUT.

    Capture variables aren’t always set; if they aren’t, they will be undefined. For example, your regex has ((,){1}(\d+))? (where the (\d+) is the 4th capture). The ? makes the whole group optional. If it is not used in matching the string, $3 and $4 will be left undefined.

    Where you are testing unless $4 == "" you should be testing if defined $4.

    A couple other notes: {1} does nothing; it says that the preceding part of the regular expression should match exactly once – which it would do without the {1} too. It can be easier to keep track of which capture variables you are using if you use non-capturing groups ((?: ... )) for the groupings you don’t need captured.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been trying to complete the following assignment for my college. So far,
I am trying to complete a college assignment, and the marking criteria specifies 5%
I'm trying to complete this assignment, I've got the code set up, however, there's
I mam trying to complete a college assignment in C++ and am having trouble
I'm trying to complete my assignment and this is the last thing to do
Hi I am am trying to complete an assignment, where it is ok to
I am trying to complete my assignment.which says In a Distance class create an
We were trying to rebase our stream. After click on complete we got issue
I am trying to complete a tutorial about easymock to use it for the
I'm trying to complete an example from php.net (code below) which allows you to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.