[25829] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 8066 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue May 10 18:05:33 2005

Date: Tue, 10 May 2005 15:05:08 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Tue, 10 May 2005     Volume: 10 Number: 8066

Today's topics:
        Basic question - having one program calling another (Chris Page)
    Re: Basic question - having one program calling another <1usa@llenroc.ude.invalid>
    Re: Basic question - having one program calling another <noreply@gunnar.cc>
        Basil [ Was: Re: Inserting & Updating from txtx to a da axel@white-eagle.co.uk
    Re: Basil <noreply@gunnar.cc>
    Re: Inserting & Updating from txtx to a database! <hackeras@gmail.com>
    Re: Media Lending Library - web based application <tadmc@augustmail.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Tue, 10 May 2005 17:01:30 -0400
From: page@studentnojunk.physics.upenn.edu (Chris Page)
Subject: Basic question - having one program calling another
Message-Id: <page-1005051701300001@192.168.12.24>


I'm trying to get one program to call another, passing it values.
Reading the documentation lets me know in multiple places that it
can be done, but I haven't found the specific syntax needed.

More precisely, (writing in pseudocode), I'd like to be able
to do the following:

PROGRAM 1
    Call program 2, forwarding the constant '4'.
    End

PROGRAM 2
    Print the value passed to it.
    End


The operating system is unix, though I suspect it doesn't matter.

Any help would be greatly appreciated.

Thanks,

-Chris Page
page@studentnojunk.physics.upenn.edu
(fix email address if you wish to reply directly)


------------------------------

Date: Tue, 10 May 2005 20:56:03 +0000 (UTC)
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Basic question - having one program calling another
Message-Id: <Xns9652AC43986DCasu1cornelledu@132.236.56.8>

page@studentnojunk.physics.upenn.edu (Chris Page) wrote in news:page-
1005051701300001@192.168.12.24:

> I'm trying to get one program to call another, passing it values.
> Reading the documentation lets me know in multiple places that it
> can be done, but I haven't found the specific syntax needed.

How come?

perldoc -f system

is a good place to start to find out how to call an external program.

In a Perl program, you can access command line arguments via @ARGV. It is 
documented in perldoc perlvar.

> More precisely, (writing in pseudocode), I'd like to be able
> to do the following:
> 
> PROGRAM 1
>     Call program 2, forwarding the constant '4'.
>     End
> 
> PROGRAM 2
>     Print the value passed to it.
>     End

Hmmmm ... I have lost count of how many times I asked the question "What 
have you done so far?" just in the last two days.

The weather here is great, my office hours are over, I am feeling good, 
etc etc, so I am just going to ask you to please read the posting 
guidelines for the group, and take a look at the example below.

Remember, to research and try first, and then ask everyone else.

#! /usr/bin/perl

# t1.pl

use strict;
use warnings;

my $v = '4';

my $r = `perl t2.pl $v`;
chomp $r;

my $out = (($v eq $r) ? 'SUCCESS: ' : 'FAILURE ');
$out .= "Passed '$v' to t2, and received '$r'.\n";

print $out;

__END__

#! /usr/bin/perl

# t2.pl 

use strict;
use warnings;

print "$ARGV[0]\n";

__END__

C:\asu1>perl t1.pl
SUCCESS: Passed '4' to t2, and received '4'.

Sinan


------------------------------

Date: Tue, 10 May 2005 23:03:34 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Basic question - having one program calling another
Message-Id: <3eclvcF2djs2U1@individual.net>

Chris Page wrote:
> I'm trying to get one program to call another, passing it values.
> Reading the documentation lets me know in multiple places that it
> can be done, but I haven't found the specific syntax needed.
> 
> More precisely, (writing in pseudocode), I'd like to be able
> to do the following:
> 
> PROGRAM 1
>     Call program 2, forwarding the constant '4'.
>     End
> 
> PROGRAM 2
>     Print the value passed to it.
>     End

Assuming you want a Perl program call another Perl program:

     perldoc -f do
     perldoc -f require

Now, it's often better to load modules instead of jumping between 
different Perl programs.

     perldoc perlmod

Check out those documents, and if you need further guidance, please post 
actual Perl code with what you got so far, and let us know exactly what 
the problem is.

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl


------------------------------

Date: Tue, 10 May 2005 21:24:52 GMT
From: axel@white-eagle.co.uk
Subject: Basil [ Was: Re: Inserting & Updating from txtx to a database! ]
Message-Id: <EE9ge.60953$Cq2.4340@fe2.news.blueyonder.co.uk>

Nikos <hackeras@gmail.com> wrote:
> Yes iam trying to improve the script as you correctly noticed.
> 
> I changed it again. Here it is now:
> 
> my (@row, $gamename, $gamedesc, $gamecount);
> my $select = $dbh->prepare( "SELECT * FROM games WHERE gamename=$gamen
> +ame" );
> my $insert = $dbh->prepare( "INSERT INTO games (gamename, gamedesc, ga
> +mecounter) VALUES (?, ?, ?)" );
> my $update = $dbh->prepare( "UPDATE games SET gamedesc=?, gamecount=?+
> +1 where gamename=?" );
> 
> open (FILE, "<../data/games/descriptions.txt") or die $!;
>     while (<FILE>) {
>         chomp;
> 
>         ($gamename, $gamedesc) = split /\t/;
>         $select->execute( $gamename );
> 
>         if ($select->rows) {
>            $update->execute( $gamedesc, $gamecount, $gamename );
>         }
>         else {
>            $insert->execute( $gamename, $gamedesc, 0 );
>         }
>     }
> close (FILE);
> 
> the descriptions.txt contains a blank line after each line of info. I 
> dont want it to be loaded and also every time games.pl is runnign it 
> gets doubled and doubles each time!

May I suggest a new phrase to the group (and to Usenet in general)...
I do not know if many of you have ever seen the TV programme 'Fawlty
Towers', but in the episode 'The Psychatrist', Basil Fawlty ends up
doing a strange hopping dance while covering his head.

I am now doing a Basil.

Axel







------------------------------

Date: Tue, 10 May 2005 23:45:10 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Basil
Message-Id: <3ecodqF2ed4sU1@individual.net>

axel@white-eagle.co.uk wrote:
> May I suggest a new phrase to the group (and to Usenet in general)...
> I do not know if many of you have ever seen the TV programme 'Fawlty
> Towers', but in the episode 'The Psychatrist', Basil Fawlty ends up
> doing a strange hopping dance while covering his head.
> 
> I am now doing a Basil.

Assuming you have web-tv, which is the URL where we can watch? :)

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl


------------------------------

Date: Tue, 10 May 2005 22:37:02 +0300
From: Nikos <hackeras@gmail.com>
Subject: Re: Inserting & Updating from txtx to a database!
Message-Id: <d5r2gr$8rt$1@nic.grnet.gr>

Yes iam trying to improve the script as you correctly noticed.

I changed it again. Here it is now:

my (@row, $gamename, $gamedesc, $gamecount);
my $select = $dbh->prepare( "SELECT * FROM games WHERE gamename=$gamen
+ame" );
my $insert = $dbh->prepare( "INSERT INTO games (gamename, gamedesc, ga
+mecounter) VALUES (?, ?, ?)" );
my $update = $dbh->prepare( "UPDATE games SET gamedesc=?, gamecount=?+
+1 where gamename=?" );

open (FILE, "<../data/games/descriptions.txt") or die $!;
     while (<FILE>) {
         chomp;

         ($gamename, $gamedesc) = split /\t/;
         $select->execute( $gamename );

         if ($select->rows) {
            $update->execute( $gamedesc, $gamecount, $gamename );
         }
         else {
            $insert->execute( $gamename, $gamedesc, 0 );
         }
     }
close (FILE);

the descriptions.txt contains a blank line after each line of info. I 
dont want it to be loaded and also every time games.pl is runnign it 
gets doubled and doubles each time!


------------------------------

Date: Tue, 10 May 2005 13:16:04 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Media Lending Library - web based application
Message-Id: <slrnd81uj4.bi5.tadmc@magna.augustmail.com>

Michael De Tomaso <mdetomaso@bak.rr.com> wrote:
> 
> "Gunnar Hjalmarsson" <noreply@gunnar.cc> wrote in message 
> news:3ea3vtF1top7U1@individual.net...
>> Michael De Tomaso wrote:

>>> Q: I'm looking for a PHP-MySQL web solution
>>
>> Why are you posting about it here?


> What if there was 
> a solution in perl that someone knew of within this group, etc. etc.


Then it would be worthless to you, as you specify above that it
must be in some other language.

Perhaps you'd like to amend the specification?


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


------------------------------

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>


Administrivia:

#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc.  For subscription or unsubscription requests, send
#the single line:
#
#	subscribe perl-users
#or:
#	unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.

#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V10 Issue 8066
***************************************


home help back first fref pref prev next nref lref last post