Home     |     .Net Programming    |     cSharp Home    |     Sql Server Home    |     Javascript / Client Side Development     |     Ajax Programming

Ruby on Rails Development     |     Perl Programming     |     C Programming Language     |     C++ Programming     |     IT Jobs

Python Programming Language     |     Laptop Suggestions?    |     TCL Scripting     |     Fortran Programming     |     Scheme Programming Language


 
 
Cervo Technologies
The Right Source to Outsource

MS Dynamics CRM 3.0

Perl Programming Language

Re-entrant code ???


I'm new to Windows perl and am recreating a menuing system that we
have on Unix, perl calling perl using the do command.  The menus
present options to users with some options going to other menus.  When
I execute one of the options, not another menu, I use "return" to
return to the calling menu/program.  When I do, all numeric inputs
from the user are ignored.  The only valid input is an "e" which exits
the menu.  Any idea what's happening?  Below is the code that returns
the program to the calling program.

if ($length == 0) {
print "Job $job currently has no output to display\n";
        sleep 3;
        return; }

On Jun 5, 8:58 am, tyjb <tyj@yahoo.com> wrote:

> I'm new to Windows perl and am recreating a menuing system that we
> have on Unix, perl calling perl using the do command.  The menus
> present options to users with some options going to other menus.  When
> I execute one of the options, not another menu, I use "return" to
> return to the calling menu/program.  When I do, all numeric inputs
> from the user are ignored.  The only valid input is an "e" which exits
> the menu.  Any idea what's happening?  Below is the code that returns
> the program to the calling program.

> if ($length == 0) {
> print "Job $job currently has no output to display\n";
>         sleep 3;
>         return; }

Please post a short BUT COMPLETE program that demonstrates what the
heck you're talking about.

This and other good advice can be found in the Posting Guidelines for
this group, posted here twice weekly.

Paul Lalli

On Jun 5, 10:07 am, Paul Lalli <mri@gmail.com> wrote:

Here's how the parent calls the child:

chomp($input = <STDIN>);                                                                  if ($input eq "1") {
           $load_cmd = "perl -w \\\\tlrntfs1\\IT_Common\\PMT\\jobs\\ojob.pl";
           system("$load_cmd");

Here's the child returning to the parent:

while (true) {
         system(($^O eq 'MSWin32') ? 'cls' : 'clear');                                          print
"********************************************************\n";
        print "**************** DISPLAY ACTIVITY **********************\n";
        print "*********( Auto Cycles Every 5 seconds )****************\n";
        print "********************************************************\n";
        print " \n";
        ($sec, $min, $hour, $dayOfMonth, $month, $yearOffset, $dayOfWeek,
$dayOfYear, undef) = localtime();
        $mins  = sprintf "%02u", $min;
        $hours = sprintf "%02u", $hour;
        $secs  = sprintf "%02u", $sec;
        $string = "Current Date & Time: $weekDays[$dayOfWeek] $months[$month]
$dayOfMonth, $year   $hours:$mins:$secs Central\n";
        print "$string\n";
        print " \n";
        @array = glob("*");
        foreach $filex (@array)                                                                 {
        open(INFO, $filex);                                                                     @lines = <INFO>;
close(INFO);                                                                            print @lines;                                                                   }
        print " \n";
        print " \n";
        print "************>>>>> to quit, do a Control / C\n";
        $SIG{INT} = sub{&create_break};
        if ($a_ok == $nah) {
                $input = "";
                return; }
        sleep 5
        }

         sub create_break {
          $a_ok = $nah; }

On Jun 5, 2:15 pm, tyjb <tyj@yahoo.com> wrote:

Which part of "complete" confused you?

Nothing in anything you posted shows how the child is supposedly
passing input back to the parent.  Nothing in anything you posted
shows the supposed do{} command that's calling a child.  Nothing in
anything you posted is reading data from the user.

Pare your problem down to the SHORTEST COMPLETE script that still
exhibits the problem.  And then post that.

It's also fairly apparent from the code you posted that you're using
neither strict nor warnings.  Start using both.  They find 95% of the
errors you're likely to make.

Paul Lalli

Return is for returning a value.  the } tells perl you are at the end.

--
Posted via a free Usenet account from http://www.teranews.com

tyjb wrote:
>       system("perl ojob.pl");

The system() call returns a single value: 0 for success and nonzero if
the other program returned some sort of error.

When ojob.pl invoked via system(), it can _NOT_ affect any variables in the
parent program.  That's not how values are passed from one script to another.

Looks to me that you haven't learned the difference between

        $string_value = `perl ojob.pl`;
        @array_values = `perl ojob.pl`;
        $error_code = system 'perl ojob.pl';
and
        @data = do "ojob.pl";

Look into "do" and how to use modules.

                -Joe

Joe Smith wrote:
> tyjb wrote:
>>    system("perl ojob.pl");

> The system() call returns a single value: 0 for success and nonzero if
> the other program returned some sort of error.

You are greatly mistaken. I suggest you re-read the third paragraph of the
documentation of system().

> When ojob.pl invoked via system(), it can _NOT_ affect any variables
> in the parent program.  That's not how values are passed from one
> script to another.

This of course is quite true.

jue

Jrgen Exner wrote:
> Joe Smith wrote:
>> tyjb wrote:
>>>    system("perl ojob.pl");
>> The system() call returns a single value: 0 for success and nonzero if
>> the other program returned some sort of error.

> You are greatly mistaken. I suggest you re-read the third paragraph of the
> documentation of system().

The point I was making is that it returns a single value.

You're right; I should not have implied that a nonzero exit code
or signal indicates an error.

Add to del.icio.us | Digg this | Stumble it | Powered by Megasolutions Inc