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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T22:20:16+00:00 2026-05-18T22:20:16+00:00

I am calling the following script from my main Perl program. The script takes

  • 0

I am calling the following script from my main Perl program. The script takes a process name and returns its PID.
The script is included in my main perl code by using the require key word:

require "getPid.pl";

and called using:

&pidGetter($processName);

getPid.pl is:

#!/usr/bin/perl -w

use strict;
use warnings;

use Proc::ProcessTable;

pidGetter($ARGV[0]);

sub pidGetter
{
   my $ret="PROCESS ID NOT FOUND\n";
   my $t = new Proc::ProcessTable;
   my $procName = $_[0];

   foreach my $p (@{$t->table})
   {
      if ($p->fname =~ /$procName/)
      {
         $ret = $p->pid;
      }   
   }

   return $ret;
}          

However, when the script is called, I get the following warning:

Use of uninitialized value $procName in regexp compilation at getPid.pl line 19

The rest of the script seems to function fine.
It is my understanding that $procName is initialized by $procName = &_[0];

I have put in print statements to debug, and $procName does return a value, so it is initialised. Does anyone know why I am getting these warnings?

  • 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-18T22:20:17+00:00Added an answer on May 18, 2026 at 10:20 pm

    require "getPid.pl"; evaluates the code contained in getPid.pl. So you actually call the pidGetter() function twice: in the require‘d script and in the main script. As $ARGV[0] is undef inside the require‘d script, you get the warning.

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

Sidebar

Related Questions

I am currently calling the following line of code: java.net.URL connection_url = new java.net.URL(http://<ip
I would like to execute a PHP script from a C program and store
When calling CoInitializeEx , you can specify the following values for dwCoInit : typedef
I am (successfully) calling the Windows FilterSendMessage function in c# using the following pinvoke
I've created a custom component in Flex, and I've created it from the main
What are the consequences, (if any) not calling the conn.logoff() method after the following
I have following script: #!/usr/bin/python while True: x = raw_input() print x[::-1] I am
In the script below I am calling a batch file to break mirroring between
I'm attempting to execute MSBuild from a NAnt script (which is called by CruiseControl.NET).
I'm getting a slightly weird result from calling subprocess.Popen that I suspect has a

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.