[10677] in Perl-Users-Digest
Perl-Users Digest, Issue: 4269 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Nov 21 11:13:46 1998
Date: Sat, 21 Nov 98 08:00:22 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Sat, 21 Nov 1998 Volume: 8 Number: 4269
Today's topics:
2nd Req: Open TTY failure Q's <bobm@cunix.com>
Re: 2nd Req: Open TTY failure Q's (Bbirthisel)
CGI tools - Shopping Basket juliegee@iname.com
Re: CGI tools - Shopping Basket (Jonathan Bobin)
Re: chmod <emills@harris.com>
Re: chmod <emills@harris.com>
Re: compare list elements within if statement (Peter J. Kernan)
Re: Help with curses <trikiw@hotmail.com>
Re: How to get data from an rs232 com port (Bbirthisel)
Re: Looking for a script to "roll dice" <r28629@email.sps.mot.com>
Matt's SSI image help <bbilling@sno.net>
mode_perl and cgi confusion <mkshanx@uxmail.ust.hk>
PAGE WITH ERROR IF BLANKS <jmcmilla@gettysburg.edu>
Passing HASH as a parameter <emills@harris.com>
Re: Passing HASH as a parameter <mkahn@vbe.com>
Re: perl/win95 (Greg Chapman)
Processing files applying exclusion criteria <ilya@foothill.net>
Re: Processing files applying exclusion criteria (David Stanaway)
Re: Processing files applying exclusion criteria <r28629@email.sps.mot.com>
Re: Processing files applying exclusion criteria (M.J.T. Guy)
Re: puzzler (David Alan Black)
Puzzling compiling issues - 5.005_02, Solaris 2.5.1 (Chin Fang)
Re: Question from a mega-geek <Tony.Curtis+usenet@vcpc.univie.ac.at>
Recommend Perl books? <om7@cyberdude.com>
Re: Recommend Perl books? <jmcmilla@gettysburg.edu>
Re: system() executes at unexpected time in SunOS4, Per <mkahn@vbe.com>
system() executes at unexpected time in SunOS4, Perl5, (Michael Goodlett)
Re: system() executes at unexpected time in SunOS4, Per <r28629@email.sps.mot.com>
tkPerl error (John Gannon)
Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sat, 21 Nov 1998 08:50:55 -0500
From: Bob Mariotti <bobm@cunix.com>
Subject: 2nd Req: Open TTY failure Q's
Message-Id: <3656C53E.962C2D76@cunix.com>
We have been struggling for a week or two with protecting and
serializing multi-tasking access to a tty port unsuccessfully.
In order to perform a flock on the tty port we have the following line:
open(TTY, "+<$cx_main::CUPORT") or die "Open TTY failure: $!";
Using the perl debugger and by inserting `print ...` statements we have
been able to trace the logic and variable contents. The
$cx_main::CUPORT package variable contains /dev/tty2 and with we run the
script from the command line, it works. If run from the web, it fails
with the message "A file or directory in the path name does not exist".
The first thing we did after verifying the content of the variable was
to check the permissions. The directory where the cgi resides is
rwxrwxrwx the /dev/tty2 is crw-rw-rw and just about everything else
checks out. Several long days struggling with this rather simple
problem has become "major frustrating".
Can someone shed some light on this problem? Thanks in advance.
ps: and please e-mail in addition to posting. Thanks.
+-----------------------+---------------------------+
+ Bob Mariotti + Financial DataCorp (FDC) +
------------------------------
Date: 21 Nov 1998 15:17:33 GMT
From: bbirthisel@aol.com (Bbirthisel)
Subject: Re: 2nd Req: Open TTY failure Q's
Message-Id: <19981121101733.05949.00000854@ng-fd2.aol.com>
Hi Bob:
>script from the command line, it works. If run from the web, it fails
>with the message "A file or directory in the path name does not exist".
>The first thing we did after verifying the content of the variable was
>to check the permissions. The directory where the cgi resides is
>rwxrwxrwx the /dev/tty2 is crw-rw-rw and just about everything else
>checks out. Several long days struggling with this rather simple
>problem has become "major frustrating".
>
>Can someone shed some light on this problem? Thanks in advance.
For security reasons, it is common for web servers to change the
root path and run in a "virtual filesystem" that is a subset of the full
filesystem. Part of the reason is to prevent "accidently or otherwise"
corrupting /etc, /dev, you_get_the_idea. You may have to link the
location you need into the accessible space. A quick cgi script that
displays what IT thinks is the absolute path will clarify this - or you
can check the server configuration files.
>ps: and please e-mail in addition to posting. Thanks.
-bill
Making computers work in Manufacturing for over 25 years (inquiries welcome)
------------------------------
Date: Sat, 21 Nov 1998 11:35:07 GMT
From: juliegee@iname.com
Subject: CGI tools - Shopping Basket
Message-Id: <7368hb$igk$1@nnrp1.dejanews.com>
Hi all,
I am writing some HTML pages for a company and they need some CGI.
They have around 9,000 products and I think they need something like
a "Shopping basket" on their web site.
Is there a CGI program available or a Tool to help me write the CGI
for a "Shopping basket" type web site.
What I mean by shopping basket is the user should be able to browse through
the products and add each one to the shopping basket as he/she likes.
Then at the end, the "check out", the CGI will give them a list of all things
put in the basket and the total cost.
If there are any programs avaliable to help me with this, please let me know.
All replies are greatly appreciated.
Julie Gee.
juliegee@iname.com
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: 21 Nov 1998 15:50:12 GMT
From: jonathan@core.dumped.org (Jonathan Bobin)
Subject: Re: CGI tools - Shopping Basket
Message-Id: <slrn75dosl.a2.jonathan@core.dumped.org>
In article <7368hb$igk$1@nnrp1.dejanews.com>, juliegee@iname.com wrote:
>Hi all,
>
>I am writing some HTML pages for a company and they need some CGI.
>They have around 9,000 products and I think they need something like
>a "Shopping basket" on their web site.
>
>Is there a CGI program available or a Tool to help me write the CGI
>for a "Shopping basket" type web site.
Your best bet would be to go with a company that does it already, like
http://stores.yahoo.com, which is pretty cheap afaik.
I'm sure that there are free CGI programs out there... try a website like
http://www.freecode.com/
Good luck..
--
Jonathan Bobin http://members.xoom.com/moocat jonathan@core.dumped.org
Got Mole problems? Call Avogadro, 6.022 * 10^23.
------------------------------
Date: Fri, 20 Nov 1998 16:41:20 -0500
From: "PERL ROCKS!" <emills@harris.com>
Subject: Re: chmod
Message-Id: <3655E200.340C75A9@harris.com>
Sorry to bother everyone - but I just had a question on my own response (does that make this a recursive
post)?
Why doesn't
$cnt = chmod 0777, 'file1', 'file2';
have to have "("'s around the list, as in:
$cnt = chmod 0777, ('file1', 'file2');
My llama book says that lists are surrounded by parens..
-Spider
-----------------------------------------------------------------------------------------------------------
"PERL ROCKS!" wrote:
> I'm not sure your question is clear, but in unix you could use
>
> csh> chmod 777 myfile
>
>
------------------------------
Date: Fri, 20 Nov 1998 16:37:37 -0500
From: "PERL ROCKS!" <emills@harris.com>
Subject: Re: chmod
Message-Id: <3655E121.8301215F@harris.com>
I'm not sure your question is clear, but in unix you could use
csh> chmod 777 myfile
although that has nothing whatsoever to do with PERL. From within PERL
you could use
system("chmod 777 myfile") && die "it didnt get changed\n";
and of course you can use the primitive perl function too (from Camel
Bible it is written):
$cnt = chmod 0777, 'file1', 'file2';
or $cnt = chmod 0777, @myfilelist;
where $cnt is the number of files changed.
I think this is what you were asking perhaps, but its indeterminant. If
not, maybe someone other newbie learned something from me just a mere
mortal in this veritable sea of Perl Gods!
-Spider
"If it can't be done in PERL it can't be done."
----------------------------------------------------------------------------------------------------------
"Bjvrn Oldsen" wrote:
> Hi
>
> How can I apply chmod to read,write and execute on unix with
> perl(cgi)-code
>
> Bjoern
------------------------------
Date: 21 Nov 1998 08:01:52 GMT
From: pete@localhost.localdomain (Peter J. Kernan)
Subject: Re: compare list elements within if statement
Message-Id: <735s1g$s1r$1@pale-rider.INS.CWRU.Edu>
In article <734p43$d0n$1@nnrp1.dejanews.com>,
pjgeer@my-dejanews.com writes:
> I want to compare elements between two lists searching for a match. But I
> want to do it in a single line of code thats < 80 characters long. I want
so you can use punch cards?
--
Perl is the Embed and Rule Language
open SIG, "<$ENV{HOME}/.sig" or die "sigless! $!";
$sig = do {local $/; <SIG>}; close SIG && print<<"$sig SIG";
Pete Kernan CWRU Physics and Statistics Depts
http://theory2.phys.cwru.edu/~pete
$sig SIG
------------------------------
Date: Sat, 21 Nov 1998 15:59:28 GMT
From: Ricardo Dague <trikiw@hotmail.com>
Subject: Re: Help with curses
Message-Id: <3656E32D.25EC1B46@hotmail.com>
James S. White wrote:
>
> Does anyone know where I can find good documentation on the perl Curses module?
> TIA!
On my Linux system, 'man Curses', which tells me to look up
the C curses documentation, 'man ncurses'.
HTH :)
-- Ricardo
------------------------------
Date: 21 Nov 1998 15:29:57 GMT
From: bbirthisel@aol.com (Bbirthisel)
Subject: Re: How to get data from an rs232 com port
Message-Id: <19981121102957.05949.00000861@ng-fd2.aol.com>
Hi Mike:
>How do I get data coming into the com port (rs232) on a PC running
> Win95?
The Win32::SerialPort module.
CPAN under authors/id/B/BB/BBIRTH
or http://members.aol.com/bbirthisel/alpha.html
>What about if it's running linux or some other unix? Is this an easy
>thing to do? Is there a perl module written to do this already?
I don't know of a corresponding module for *nux. There has not
appeared to be a large demand. The lack of a suitable "stty" on Win32
is what prompted the module creation.
-bill
Making computers work in Manufacturing for over 25 years (inquiries welcome)
------------------------------
Date: Sat, 21 Nov 1998 08:49:20 -0500
From: Tk Soh <r28629@email.sps.mot.com>
Subject: Re: Looking for a script to "roll dice"
Message-Id: <3656C4DA.8721FE68@email.sps.mot.com>
brian d foy wrote:
>
> In article <36561B48.A0CD4894@qis.net>, Donboy <donboy@qis.net> posted:
>
> > I'm currently webmastering a site for role playing games and I need a
> > cgi program that will roll dice online.
> >
> > The script must be able to generate random numbers, roll dice of any
> > number of sides (i.e. 10 sided dice, 4 sided dice as well as the regular
> > 6 sided dice) and it must be able to receive input via an HTML form.
>
> int(rand($number_of_sides) + 1);
>
Cool, can you get Perl to cook for me too? FYI, the Cookbook does tell me how
to do this ;)
Cheers,
TK
------------------------------
Date: Fri, 20 Nov 1998 23:09:05 -0800
From: "J.Billingsley" <bbilling@sno.net>
Subject: Matt's SSI image help
Message-Id: <36566711.CCC@sno.net>
I have exhausted every effort to make Matt Wright's random SSI image
script to work to no avail! I can call the images directly from the
script but i cannot call them from my .shtml page - i get a broken
link/image
the code once the .shtml page loads is still calling the script
ie. instead of it writing in the image to the page it still looks like
this: <IMG SRC="http://www.myserver.com/cgi-bin/ssi.pl">
has anyone tackled similar .shtml call problems?
Jason Billingsley
------------------------------
Date: Sat, 21 Nov 1998 15:32:22 +0800
From: Ron <mkshanx@uxmail.ust.hk>
Subject: mode_perl and cgi confusion
Message-Id: <Pine.GSO.3.95L.981121153014.19537F-100000@uststf1>
HI,
I am a bit confused by the distinction/relation between mod_perl and
cgi...i read apache.org's FAQ about this, but that tells me nothing much
about it~
If I am using mod_perl, can I still use CGI.pm on it? (Because my book
teaches me CGI programming and mod_perl seems to be entirely
different..will I now need a new book? :))
Thanks,
Ron
------------------------------
Date: Sat, 21 Nov 1998 10:42:37 -0500
From: Graham McMillan <jmcmilla@gettysburg.edu>
Subject: PAGE WITH ERROR IF BLANKS
Message-Id: <3656DF6D.952574FE@gettysburg.edu>
Does anyone now how to print an error page from a html submit? I'm
going to have an html page where the users type in the info and then the
cgi will process it and I want it to check and make sure that all forms
are filled in. Does anyone now how to do this?
If so post a reply.
Graham McMillan
------------------------------
Date: Fri, 20 Nov 1998 14:00:02 -0500
From: "PERL ROCKS!" <emills@harris.com>
Subject: Passing HASH as a parameter
Message-Id: <3655BC32.F97B0A1A@harris.com>
Gooday! I wonder can you point me to an example of someone who is
passing an arbitrary-length hash, and subsequently using the hash as an
input parameter to a sub? I'm trying to do it by reference, using the
Camel book illustrations, but I'm not having much sucesss yet. I don't
necessarily want to make changes to the sub- a local copy should do
fine.
Thank-You in advance for your assistance.
-Spider
"If it can't be done in PERL it can't be done.", Spider, 1998
------------------------------
Date: Sat, 21 Nov 1998 08:08:00 -0600
From: Mark Kahn <mkahn@vbe.com>
Subject: Re: Passing HASH as a parameter
Message-Id: <3656C940.E73CCDF@vbe.com>
Did you try looking in the perlref documentation?
Example:
#!/usr/bin/perl -w
my($myhash,$key);
$myhash = {1,'this',2,'is',3,'a',4,'test'}; # Build anonymous hash
somefunc($myhash); # Call a function and pass the reference
exit(0);
sub somefunc {
my($arg,$key);
$arg = shift; # Grab the reference passed in
foreach $key (sort keys %$arg) { # Print out all the key/value pairs
print "$key = $$arg{$key}\n";
}
}
--
Mark Kahn
mkahn@vbe.com
------------------------------
Date: 21 Nov 1998 15:51:54 GMT
From: glc@well.com (Greg Chapman)
Subject: Re: perl/win95
Message-Id: <3656e008.30914687@netnews.worldnet.att.net>
In straight Windows 95, you can associate .pl files with perl so that perl is
invoked when you double-click on a .pl file in the Windows Explorer; however,
the only way to get this to work from the command line is to use:
start <filename>
which will start the executable associated with the filename, whatever it might
be. If you have replaced command.com with 4DOS, you can use 4DOS's executable
extensions feature to associate .pl files with perl. Then if you have a file
named xyz.pl in the current directory or somewhere in the path, all you have to
do is type xyz to invoke perl with the file.
On 20 Nov 1998 00:16:11 GMT, Mark Carnes <mendrak@worldnet.att.net> wrote:
>
>
>mila@stars.gsfc.nasa.gov wrote:
>
>> Forrest,
>> You can type perl hello.pl on the DOS command line. Either go to
>> the perl dir and type it from there. Or, if you have .pl associated with
>> perl.exe, it should work from any dir.
>>
>
>I've installed perl and I can certainly type perl xyz.pl and it will work
>but I can't just type xyz.pl. What do I have to do to associate it?
>
------------------------------
Date: 21 Nov 1998 12:04:39 GMT
From: Ilya <ilya@foothill.net>
Subject: Processing files applying exclusion criteria
Message-Id: <736a8o$a4k$1@ns2.foothill.net>
If I have a file composed of records with several fields and an exclusion
file composed of one field, I want to eliminate all files that have a
certain field match any field in the exclusion file. For instance,
given input file
aaa bbb ccc ddd eee ingres fff gggg
aaa bbb ccc ddd eee oracle fff gggg
aaa bbb ccc ddd eee solid fff gggg
and the exclusion file
oracle
I want just the lines that do not contain "oracle", in other words:
aaa bbb ccc ddd eee ingres fff gggg
aaa bbb ccc ddd eee solid fff gggg
I understand I can do something like
foreach $i (@exclude_list)
{
push @new list, $current_line if $current_line =~ $i;
}
But I do not want to process the entire exclusion file if it gets really
big, thousands of lines. How can I speed up the process if both the input
file and the exclusion file are sorted, both by the key fields.
------------------------------
Date: 21 Nov 1998 12:13:18 GMT
From: dstanawa@grudge. (David Stanaway)
Subject: Re: Processing files applying exclusion criteria
Message-Id: <736aou$bbr$1@metro.ucc.usyd.edu.au>
In article <736a8o$a4k$1@ns2.foothill.net>, Ilya wrote:
>
>If I have a file composed of records with several fields and an exclusion
>file composed of one field, I want to eliminate all files that have a
>certain field match any field in the exclusion file. For instance,
>given input file
Try the xpg4 grep. It takes a file with patterns to match as an arg. and
there is a switch for lines that don't match to be shown.
/usr/xpg4/bin/grep -v -f $excludefile < $datafile
THis may not work though.
David Stanaway.
------------------------------
Date: Sat, 21 Nov 1998 08:44:57 -0500
From: Tk Soh <r28629@email.sps.mot.com>
To: Ilya <ilya@foothill.net>
Subject: Re: Processing files applying exclusion criteria
Message-Id: <3656C3D4.C80BDA85@email.sps.mot.com>
[posted to c.l.p.m and copy emailed]
Ilya wrote:
>
> If I have a file composed of records with several fields and an exclusion
> file composed of one field, I want to eliminate all files that have a
> certain field match any field in the exclusion file. For instance,
> given input file
>
> aaa bbb ccc ddd eee ingres fff gggg
> aaa bbb ccc ddd eee oracle fff gggg
> aaa bbb ccc ddd eee solid fff gggg
>
> and the exclusion file
>
> oracle
>
> I want just the lines that do not contain "oracle", in other words:
>
> aaa bbb ccc ddd eee ingres fff gggg
> aaa bbb ccc ddd eee solid fff gggg
>
> I understand I can do something like
>
> foreach $i (@exclude_list)
> {
> push @new list, $current_line if $current_line =~ $i;
^^^^^
Sure ?? perhaps you meant $current_line =~ /$i/;
> }
>
> But I do not want to process the entire exclusion file if it gets really
> big, thousands of lines. How can I speed up the process if both the input
> file and the exclusion file are sorted, both by the key fields.
Remember a friend of us named 'hash' ? Here a quick sample:
-----------
@to_exclude = ( <you built this from you exclude file> );
@exs{ @to_exclude } = ();
while (<DATA>) {
($key) = (split)[5];
print unless exists $exs{$key};
}
----------
See? you don't even need to sort anything. Ain't Perl nice? :)
HTH.
-TK
------------------------------
Date: 21 Nov 1998 15:23:18 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: Processing files applying exclusion criteria
Message-Id: <736lt6$hqb$1@pegasus.csx.cam.ac.uk>
In article <736a8o$a4k$1@ns2.foothill.net>, Ilya <ilya@foothill.net> wrote:
>
>But I do not want to process the entire exclusion file if it gets really
>big, thousands of lines. How can I speed up the process if both the input
>file and the exclusion file are sorted, both by the key fields.
If both files are sorted, you can read them in parallel. Something like
open EXCL, .... or die ....;
open FILE, .... or die ....;
my $excl = '';
while (<FILE>) {
my $field = ... code to extract field from $_ ... ;
chomp($exclusion = <EXCL> || 'zzzzzz') while $field gt $exclusion;
print if $field lt $exclusion;
};
This assumes that any valid exclusion is greater than '', and is less than
'zzzzzz'. If such "sentinel" values aren't available, you'll need to
write extra code for the initial / final states.
Mike Guy
------------------------------
Date: 21 Nov 1998 04:02:15 -0500
From: dblack@pilot.njin.net (David Alan Black)
Subject: Re: puzzler
Message-Id: <735vin$l10$1@pilot.njin.net>
Hello -
Todd Smith <tbsmith@viper.net> writes:
>David Alan Black wrote:
>> my @new = grep { $_ } map { map { shift @$_ } @lol }
>> (0..(sort map { scalar @$_ } @lol)[-1]-1);
>>
>> print "@new\n"; # fred george homer barney judy lisa elroy bart
>don't like temp variables? (like @new?) then do this:
> print grep { $_ } map { map { shift @$_ } @lol }
> (0..(sort map { scalar @$_ } @lol)[-1]-1);
I actually wanted to store the results in this case, though I suppose
one could do:
print "@{[grep { $_ } map { map { shift @$_ } @lol }
(0..(sort map { scalar @$_ } @lol)[-1]-1)]}";
and get the same output :-)
(Or one could use Uri's solution....)
David Black
dblack@pilot.njin.net
------------------------------
Date: 21 Nov 1998 04:51:48 -0800
From: fangchin@leland.Stanford.EDU (Chin Fang)
Subject: Puzzling compiling issues - 5.005_02, Solaris 2.5.1
Message-Id: <736d14$h7@saga20.Stanford.EDU>
After many trials, I am really puzzled. Since Perl 4 to the previous
verison, I have never had such problems so far.
Machine: Sun SS5 170 Mhz 128 RAM. OS: 2.5.1 with latest recommended patch
Compiler: egcs 1.1b and Sun Sun WorkShop Compiler C 4.2.
sh Configure -Dusethread
No matter what, I always got the following. The INSTALL file
suggests that it could be caused by GNU ld and as. In my case,
it's impossible, I have never built these two. The same problems
occure even when I use Sun's compiler!
Making IPC::SysV (dynamic)
.... some removed
LD_RUN_PATH="" gcc -B/usr/ccs/bin/ -o ../../../lib/auto/IPC/SysV/SysV.so -G -L/usr/local/lib SysV.o
gcc: file path prefix `/usr/ccs/bin/' never used
chmod 755 ../../../lib/auto/IPC/SysV/SysV.so
cp SysV.bs ../../../lib/auto/IPC/SysV/SysV.bs
chmod 644 ../../../lib/auto/IPC/SysV/SysV.bs
Manifying blib/man3/IPC::SysV.3
ld.so.1: perl: fatal: relocation error: file perl: symbol Perl_perl_destruct_level: referenced symbol not found
Killed
Manifying blib/man3/IPC::Msg.3
ld.so.1: perl: fatal: relocation error: file perl: symbol Perl_perl_destruct_level: referenced symbol not found
Killed
Manifying blib/man3/IPC::Semaphore.3
ld.so.1: perl: fatal: relocation error: file perl: symbol Perl_perl_destruct_level: referenced symbol not found
Killed
....
Making Errno (nonxs)
.....[some removed]
Manifying blib/man3/Errno.3
ld.so.1: perl: fatal: relocation error: file perl: symbol Perl_perl_destruct_level: referenced symbol not found
Killed
Identical problems regardless whether egcs 1.1b or Sun Workshop C is used.
I tried two SS5s, different patch levels, but same results.
The interesting thing is that all tests are successful, on both SS5s.
I have tried to build 5.005_02 on a Sun UltraSPARC running Solaris 2.6 5/98
and egcs 1.1b. There were no such error messages. I must admit that
so far I haven't figured out why there are such differences.
No. I don't have the luxary to upgrade all our machines at present. So,
must build Perl for both OS releases.
Would appreciate any hints. Is the build really trustable? Why
the relocation error in building the Errno and IPC::SysV?
Thanks, and please email.
Chin Fang
fangchin@leland.stanford.edu
------------------------------
Date: 21 Nov 1998 11:10:22 +0100
From: Tony Curtis <Tony.Curtis+usenet@vcpc.univie.ac.at>
Subject: Re: Question from a mega-geek
Message-Id: <83emqxwe41.fsf@vcpc.univie.ac.at>
Re: Question from a mega-geek, sara
<nospam.perl_rocks@hotmail.com> said:
sara> anyone know where I can buy "perl-phenelia"? I'd love
"paraperlnalia" surely? :-)
(off-topic but at least it's not about CGI)
--
Tony Curtis, Systems Manager, VCPC, | Tel +43 1 310 93 96 - 12; Fax - 13
Liechtensteinstrasse 22, A-1090 Wien, | <URI:http://www.vcpc.univie.ac.at/>
"You see? You see? Your stupid minds! | private email:
Stupid! Stupid!" ~ Eros, Plan9 fOS.| <URI:mailto:tony_curtis32@hotmail.com>
------------------------------
Date: Sat, 21 Nov 1998 15:01:50 -0000
From: "OM" <om7@cyberdude.com>
Subject: Recommend Perl books?
Message-Id: <736l08$lp2$1@eros.clara.net>
Can anyone please recommend a good Perl book. I'm new to Perl and have
never used it before. But I do have programming experience.
Thanks.
------------------------------
Date: Sat, 21 Nov 1998 10:39:33 -0500
From: Graham McMillan <jmcmilla@gettysburg.edu>
Subject: Re: Recommend Perl books?
Message-Id: <3656DEB5.A402A15B@gettysburg.edu>
I would suggest you buy Learning Perl (2nd Edition) and Programming Perl.
They
are great perl books and are very informational. When you get perl down
buy the
Perl5 desktop reference by Johan Vromas.
OM wrote:
> Can anyone please recommend a good Perl book. I'm new to Perl and have
> never used it before. But I do have programming experience.
>
> Thanks.
------------------------------
Date: Sat, 21 Nov 1998 07:32:33 -0600
From: Mark Kahn <mkahn@vbe.com>
Subject: Re: system() executes at unexpected time in SunOS4, Perl5, seems to fork early
Message-Id: <3656C0F1.FFCCCB22@vbe.com>
Michael Goodlett wrote:
[stuff deleted ...]
> However, when attempting to use this call, the system() call is
> being run before the first line of the perl code. It is like
> something in the OS looks through the perl code and decides that
> it doesn't need to run the system() inline with the rest of the
> code and just executes it immediately.
>
> My test prints show that the system() call executes first and
> then the start of the perl script executes ... and of course, the
> perl script and the system() call both fail because the
> system() call doesn't run in-line with the rest of the perl code.
>
My guess is that you are being fooled by STDOUT buffering somehow. Not
sure, but that's what it sounds like.
>
> I have changed this call to backtics and that works to actually
> run the simulation. But, there is another thing I'm trying to
> accomplish.
>
The backtic method is that is recommended in the perldocs (See perldoc -f
system) if you want to use the output returned from the call:
print `command`;
will work fine.
> If I force backtic:
>
> $variablename = `$simstring`;
>
> this backtic call works but the output information that I wish to view
> while the simulation is running is collected into the $variablename and
> I have no way of getting at it. I want to see the information going
> to "stdout" of the simulation run WHILE the simulation run is processing.
See above.
>
> (1) I believe that the system() call is behaving abnormally.
> Is there a way to force it to run inline with the rest of the script?
Works fine for me using perl 5.005_02 and Linux.
HTH,
Mark
--
Mark Kahn
mkahn@vbe.com
------------------------------
Date: Sat, 21 Nov 1998 03:55:08 -0600
From: goodlett@cyberramp.net (Michael Goodlett)
Subject: system() executes at unexpected time in SunOS4, Perl5, seems to fork early
Message-Id: <MPG.10c049f565e94168989683@newshost.cyberramp.net>
Hello,
I've searched the archives and I've been reading the reference
manual from O'Reilly to try and figure out a solution to this
particular system() call problem that I am seeing.
I have written a script in perl to setup parameters that are
then used when calling a simulation run.
The script is able to handle multiple parameter
changes in order to make multiple simulation runs without manual
intervention.
This is Perl5 on SunOS4.
The script is set to executable mode in the UNIX environment.
Example of what I'm doing:
//////////////////////////////////////////////////
#!/bin/perl
#
###### note test print statement
print "This is the first line of the perl script\n";
Start loop here
... some perl code here ...
system("$simstring"); ### $simstring is the command
### line call to run the simulator
### The command line that system()
### sees is correct
... some more perl code here ...
end loop here
////////////////////////////////////////////////////
Per the documentation, the system call is supposed to execute and
the perl script is supposed to wait for the child to exit before
continueing execution of the script. This allows pre-processing
to setup $simstring and also post process cleanup of the
files generated by the simulation run.
However, when attempting to use this call, the system() call is
being run before the first line of the perl code. It is like
something in the OS looks through the perl code and decides that
it doesn't need to run the system() inline with the rest of the
code and just executes it immediately.
My test prints show that the system() call executes first and
then the start of the perl script executes ... and of course, the
perl script and the system() call both fail because the
system() call doesn't run in-line with the rest of the perl code.
I tried:
$variablename = system("$simstring");
But this doesn't solve the problem either.
I have changed this call to backtics and that works to actually
run the simulation. But, there is another thing I'm trying to
accomplish.
WHAT I'M TRYING TO GET AS A RESULT:
I need the perl script to setup the parameters (Ie, setup $simstring)
and then when system("$simstring") is called, any output from the
simulation run actually shows up on the display.
If the simulation is run from outside the perl script, the simulation
actually posts the simulation time so you can see how far into the
simulation you have run. Ie, monitor that the simulation is running or
stalled.
If I force backtic:
$variablename = `$simstring`;
this backtic call works but the output information that I wish to view
while the simulation is running is collected into the $variablename and
I have no way of getting at it. I want to see the information going
to "stdout" of the simulation run WHILE the simulation run is processing.
(1) I believe that the system() call is behaving abnormally.
Is there a way to force it to run inline with the rest of the script?
(2) Have I misunderstood the way the system() call works in perl?
(3) Is there another way to receive the "stdout" information being
returned while the simulation is running AND make the perl code
wait until the simulation process is done before continuing?
I'm now at a loss of what to try to get the type of output I need
and I'm hoping somebody here recognizes what might be happening.
Thanks and Regards,
Mike
goodlett@cyberramp.net
////////////////////////
------------------------------
Date: Sat, 21 Nov 1998 08:09:27 -0500
From: Tk Soh <r28629@email.sps.mot.com>
To: Michael Goodlett <goodlett@cyberramp.net>
Subject: Re: system() executes at unexpected time in SunOS4, Perl5, seems to fork early
Message-Id: <3656BB84.75266B6@email.sps.mot.com>
[posted to c.l.p.m and copy emailed]
Michael Goodlett wrote:
>
> Hello,
>
> I've searched the archives and I've been reading the reference
> manual from O'Reilly to try and figure out a solution to this
> particular system() call problem that I am seeing.
>
> I have written a script in perl to setup parameters that are
> then used when calling a simulation run.
> The script is able to handle multiple parameter
> changes in order to make multiple simulation runs without manual
> intervention.
>
> This is Perl5 on SunOS4.
>
> The script is set to executable mode in the UNIX environment.
>
> Example of what I'm doing:
> //////////////////////////////////////////////////
> #!/bin/perl
> #
>
> ###### note test print statement
> print "This is the first line of the perl script\n";
>
> Start loop here
> ... some perl code here ...
>
> system("$simstring"); ### $simstring is the command
> ### line call to run the simulator
> ### The command line that system()
> ### sees is correct
>
> ... some more perl code here ...
> end loop here
> ////////////////////////////////////////////////////
>
> Per the documentation, the system call is supposed to execute and
> the perl script is supposed to wait for the child to exit before
> continueing execution of the script. This allows pre-processing
> to setup $simstring and also post process cleanup of the
> files generated by the simulation run.
>
> However, when attempting to use this call, the system() call is
> being run before the first line of the perl code. It is like
> something in the OS looks through the perl code and decides that
> it doesn't need to run the system() inline with the rest of the
> code and just executes it immediately.
>
> My test prints show that the system() call executes first and
> then the start of the perl script executes ... and of course, the
First put this on top of you program and try iot again:
$|++;
Then, run your program in debugger and trace it. You shouldn't rely on stdout
for this.
> perl script and the system() call both fail because the
> system() call doesn't run in-line with the rest of the perl code.
>
> I tried:
>
> $variablename = system("$simstring");
>
> But this doesn't solve the problem either.
>
did you check $variablename to make sure system() ran okay?
perldoc -f system
[...]
>
> If I force backtic:
>
> $variablename = `$simstring`;
>
> this backtic call works but the output information that I wish to view
> while the simulation is running is collected into the $variablename and
> I have no way of getting at it. I want to see the information going
> to "stdout" of the simulation run WHILE the simulation run is processing.
why not? you can always look at $variablename, can't you?
[...]
-TK
------------------------------
Date: 21 Nov 1998 07:21:13 GMT
From: johng@tiac.net (John Gannon)
Subject: tkPerl error
Message-Id: <735pl9$1l8@news-central.tiac.net>
Hello,
I am using tkPerl to develop a graphical system monitoring package. The
GUI is basically a Canvas with a menu at the top. One of the menu items
is giving me trouble. When I select it, it creates a window (by calling
the subroutine below). After I change the interface, the window is destroyed.
The next time I select the menu item and change the interface (both times
by clicking OK or cancel) I get the folllowing error:
Tk::Error: Tk::Listbox=HASH(0x83aace0) is not a Tk object at ./bmon-ui.pl line 111.
\&main::__ANON__
Tk callback for .button
Tk::Button::butUp at /usr/lib/perl5/site_perl/Tk/Button.pm line 111
(command bound to event)
Does anyone know what could be causing this? The subroutine is below.
Thanks in advance,
John
sub change_interface {
my $intwin = MainWindow->new();
my @ints = ();
my @newint = ();
my $intnum;
$intwin->title("Change Interface");
$intwin->Label('-text' => 'Click on an interface to monitor it.'
)->pack('-side' => 'left', '-padx' => 10);
@ints = &snmpwalk($hostname, $SNMP_util::OIDS{ifDescr});
my $intlist = $intwin->Listbox(-width => 20, -height => $#ints + 1)->pack();
foreach (@ints) {
$intlist->insert('end', "$_");
}
# $intlist->bind('<Double-1>', \&change_interface_var);
my $ok_button = $intwin->Button(-text => 'OK',
-command => sub
{
&change_interface_var;
$intwin->destroy();
}
);
$ok_button->pack();
my $cancel_button = $intwin->Button(-text => 'Cancel',
-command => sub { $intwin->destroy(); }
);
$cancel_button->pack();
#### this subroutine is nested to deal with scoping issues
# change_interface_var actually changes the global interface variable to whatever the user
# double clicked on
sub change_interface_var {
my $newint = $intlist->get('active');
my @ta = ();
@ta = split(/:/, $newint);
$pollinterface = $ta[0];
print STDERR "poll int is now = $pollinterface\n";
&clear_graph;
}
}
--
John Gannon
johng@tiac.net
"The greatest dangers to liberty lurk in the insidious encroachment by men of
zeal, well-meaning but without understanding."
-- Justice Louis D. Brandeis (1928)
------------------------------
Date: 12 Jul 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Special: Digest Administrivia (Last modified: 12 Mar 98)
Message-Id: <null>
Administrivia:
Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.
If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu.
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.
To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.
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.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.
The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.
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 V8 Issue 4269
**************************************