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 7420879
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T08:18:54+00:00 2026-05-29T08:18:54+00:00

I am writing a program that somewhat mimics the last command in UNIX, and

  • 0

I am writing a program that somewhat mimics the last command in UNIX, and I am trying to use backreferencing in my solution. My program does exactly what it is supposed to do but I get a run time error/warning. My question is why is this error/warning coming up and how can I fix an issue like this?

If you need more information I can provide.

Program Execution

./last dodoherty

OUTPUT

Here is a listing of the logins for dodoherty:

1. dodohert pts/1        pc-618-012.omhq. Wed Feb  8 09:19   still logged in
2. dodohert pts/6        ip98-168-203-118 Tue Feb  7 19:19 - 20:50  (01:31)
3. dodohert pts/3        137.48.207.178   Tue Feb  7 14:00 - 15:06  (01:05)
4. dodohert pts/1        137.48.219.250   Tue Feb  7 12:32 - 12:36  (00:04)
5. dodohert pts/21       137.48.207.237   Tue Feb  7 12:07 - 12:23  (00:16)
6. dodohert pts/11       ip98-168-203-118 Mon Feb  6 20:50 - 23:29  (02:39)
7. dodohert pts/9        ip98-168-203-118 Mon Feb  6 20:31 - 22:57  (02:26)
8. dodohert pts/5        pc-618-012.omhq. Fri Feb  3 10:24 - 10:30  (00:05)
Use of uninitialized value $1 in addition (+) at ./odoherty_last.pl line 43.
Use of uninitialized value $2 in addition (+) at ./odoherty_last.pl line 44.
Here is a summary of the time spent on the system for dodoherty:

dodoherty
8
8:6

The Code (Snippet of where the error is coming from, Also this is the only time $1 and $2 are used.)

foreach my $line2 (@user)
{
        $line2 =~ /\S*\((\d{2,2})\:(\d{2,2})\)\s*/;
        $hours = $hours + $1;
        $mins = $mins + $2;

        if( $mins >= 60 )
        {
                $hours = $hours + 1;
                $mins = $mins - 60;
        }
}
  • 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-29T08:18:55+00:00Added an answer on May 29, 2026 at 8:18 am

    I think the problem might be in the following line.


    1. dodohert pts/1 pc-618-012.omhq. Wed Feb 8 09:19 still logged in

    That is because nothing matches the pattern so $1 and $2 are undefined.

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

Sidebar

Related Questions

If you are writing a program that is executable from the command line, you
I am writing a program that does a lot of writes to a Postgres
I'm new to C but trying some system calls. I'm writing program that iterates
I am writing program that does alot of table lookups. As such, I was
I am writing a numerical program that should be somewhat fast, and is also
Im writing a program that should read input via stdin, so I have the
I'm writing a program that sends an email out at a client's specific local
I'm writing a program that uses SetWindowRgn to make transparent holes in a window
I'm writing a program that contains a generational garbage collector. There are just two
I am writing a program that will draw a solid along the curve of

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.