[7456] in Perl-Users-Digest
Perl-Users Digest, Issue: 1081 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Sep 25 21:07:23 1997
Date: Thu, 25 Sep 97 18:00:28 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Thu, 25 Sep 1997 Volume: 8 Number: 1081
Today's topics:
Re: "exp1 ? exp2 : exp" same as " if (exp1) { exp2; } e <rootbeer@teleport.com>
Re: alarm(n) works but not consistently ..... <rootbeer@teleport.com>
Re: array assignment problem. <rootbeer@teleport.com>
Re: Calling a Perl Script... <fishrman@shell.wco.com>
CGI script question <wesmills@poboxes.com>
Re: Dummy variable - can you avoid it <rootbeer@teleport.com>
Re: EOF problem? <rootbeer@teleport.com>
Help w/open3, pipes, threads(kinda long) (Shane Knapp)
Help.Where do Perl users look for a job? (TRC Staffing - West LA)
re: how to write HTML form data to a text file??? <rootbeer@teleport.com>
HTTP Query in perl (Nicolas Ross)
Re: incrementing array names <rootbeer@teleport.com>
Re: Julian Date Routine <rootbeer@teleport.com>
Re: Perl <-> RPC <-> C <jake@organic.com>
Re: Perl crashing RS600 box <bob_melson@phx.mcd.mot.com>
Re: Perl Generator? <rootbeer@teleport.com>
Re: perl install on win32 <rootbeer@teleport.com>
Re: Perl5.004 and Solaris 2.6 (Jason Gloudon)
Piping problem on NT HELP <sconklin@livemedia.com>
processing variable input variables <amhardin@erols.com>
Re: read only and flock (Charles DeRykus)
Read/Write access to a file <bosch@goweb.lu>
Re: Read/Write access to a file <rootbeer@teleport.com>
socket to http <drosquil@campus.chs.itesm.mx>
Re: substituting special chars <rootbeer@teleport.com>
Re: Tab Delimiter character -- Unix to Mac <rootbeer@teleport.com>
Re: Terminal Output <rootbeer@teleport.com>
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 25 Sep 1997 16:37:21 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: "Rui S. Pedro" <rpedro@pga.pt>
Subject: Re: "exp1 ? exp2 : exp" same as " if (exp1) { exp2; } else { exp3; }"?
Message-Id: <Pine.GSO.3.96.970925163136.6988I-100000@usertest.teleport.com>
On Thu, 25 Sep 1997, Rui S. Pedro wrote:
> 1 ? $true+=100 : $false+=100; print "$true\n";
> output:
> 200
?: has higher precedence than += does (see the perlop(1) manpage). Thus,
that first line is the same as this:
(1 ? ($true+=100) : $false) += 100; print "$true\n";
Which becomes:
($true+=100) += 100; print "$true\n";
Which is effectively:
$true += 200; print "$true\n";
> I'm using version 5.002
It won't make any difference in this example, but you should really
install 5.004. Have fun with Perl!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
Ask me about Perl trainings!
------------------------------
Date: Thu, 25 Sep 1997 16:42:18 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Atiqullah Hashmi <hashmi@cnj.digex.net>
Subject: Re: alarm(n) works but not consistently .....
Message-Id: <Pine.GSO.3.96.970925164008.6988K-100000@usertest.teleport.com>
On 25 Sep 1997, Atiqullah Hashmi wrote:
> I am using alarm(n) and catching the SIGALRM which works but not
> properly always.
Signals are not (yet) reliable in Perl. (Soon, from the looks of things,
but not yet.)
> Sometimes alarm goes off in 10 secs. but sometime it takes much longer
> like minutes on reading the pipe
A better way to do what I think you're doing is to use the four-argument
form of select() so that you can read input only when the pipe has sent
something. In that way, your program can avoid signals altogether. Hope
this helps!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
Ask me about Perl trainings!
------------------------------
Date: Thu, 25 Sep 1997 16:52:24 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Doug <doug@3dlabs.com.remove>
Subject: Re: array assignment problem.
Message-Id: <Pine.GSO.3.96.970925164324.6988L-100000@usertest.teleport.com>
On 24 Sep 1997, Doug wrote:
> I am trying to recurse directories and list all files in them, and
> their sub directories. To do this I'm getting the basedir from the user
> via $FORM{'area'}. The user can also specify 'all', upon which I would
> like to search a predefined list of directories. This is the relevant
> code I have:
>
> @areas = ('database','news','personal'); # Initial setting early in the
> program
>
> $FORM{'area'} =~ /all/i ? @DIRS = @areas : push (@DIRS, $FORM{'area'});
Oh, you don't really want to use that regular expression, do you? If the
user asks for (for example) /home/sally, do you want to force them into
the default list? :-)
How about this code instead? It's a little different than what you wrote,
but I think it's easier to understand and maintain, and it may actually do
what you want. :-)
if ($FORM{area} =~ /^\s*all\s*$/i) {
@DIRS = @areas; # default list
} else {
@DIRS = ($FORM{area}); # requested list
}
> I don't get any syntax errors.
A lack of syntax errors doesn't mean a lack of errors! :-)
> Each time it fails the web browser tries to download the perl script.
That sounds like a problem with the server, or how it's configured. Check
your server's docs and FAQs, and then maybe a server newsgroup, which can
give you a better and more complete answer to this problem than we can
here. Good luck!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
Ask me about Perl trainings!
------------------------------
Date: 23 Sep 1997 22:10:41 GMT
From: "Michael A. Watson" <fishrman@shell.wco.com>
Subject: Re: Calling a Perl Script...
Message-Id: <609ep1$luh$1@news.wco.com>
Guy Doucet <gdoucet@ait.acl.ca> wrote:
> (1) I want to know how to call a Perl script from an HTML/JavaScript
> document, other than the <form method="post"... or "get"... What I'm
> getting at is I'd like to know if a JavaScript can call the Perl script
> directly.
I worked around this problem by using document.browserinfo.submit();
you still need the <form method="post"... but no user input is needed.
Beware that if your script has no output you may get an error in the
browser. I got around that by putting the script and form into a
hidden frame, so the error message displays in the frame but
no one sees it and the code goes on executing.
Mike
fishrman@wco.com
Bay Area Regional Fishermen
http://www.wco.com/~fishrman
Dedicated to Saltwater Fishing and
Saltwater Fishing Boats of the
Monterey Bay Area, Halfmoon Bay Area,
San Francisco Bay Area, and the
Surrounding Ocean.
------------------------------
Date: Thu, 25 Sep 1997 17:17:59 -0500
From: Wes Mills <wesmills@poboxes.com>
Subject: CGI script question
Message-Id: <342AE316.5B5638D5@poboxes.com>
I've written a program for my web site called makealias.cgi that is
supposed to take the fields 'alias' and 'email' from a submitted HTML
form and echo them, with a space between, into a text file, currently
called test.txt, and it should return an HTML page that says alias ...
has been created and will forward to ... etc. However, the strings
that hold this data are always returned as empty. Why does it do this?
I have copied the library, forms-lib.pl from a book ("60 minute guide to
CGI programming with Perl 5"), and makealias.cgi is just slightly
modified from a program out of that book, so I fail to see why it
wouldn't work.
I'm not including forms-lib.pl for brevity sake, but here is
makealias.cgi:
#!/usr/bin/perl
#
# create aliases for wyvern.org forwarding
# require programs
require "libraries/forms-lib.pl";
%input = &GetFormInput();
# define some vars
$testfile = "/home/wyvern/test/test.txt";
$aliasname = $input{'alias'};
$emailaddr = $input{'email'};
print "Content-type: text/html\n\n";
print "<html><head><title>success</title></head><body bgcolor=#000000
text=#ffffff>";
print "alias $aliasname has been created. it will forward to
$emailaddr.<br>\n";
print "if this is incorrect, click <a href=modify.html>here</a>.\n";
print "</body></html>\n";
open(FILE, ">$testfile") || die "error: cannot open $testfile\n";
print FILE "$aliasname $emailaddr\n";
close(FILE);
What am I doing wrong? Thanks for the information and help.
Wes Mills - wesmills@poboxes.com
------------------------------
Date: Thu, 25 Sep 1997 16:30:16 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Helmut Jarausch <jarausch@numa1.igpm.rwth-aachen.de>
Subject: Re: Dummy variable - can you avoid it
Message-Id: <Pine.GSO.3.96.970925162440.6988H-100000@usertest.teleport.com>
On 25 Sep 1997, Helmut Jarausch wrote:
> I often have the situation where I want to feed a string to a 'sub'
> after modification.
>
> How can one get rid of $DUMMY and the do {} block in the following
> very ugly code
>
> sub foo;
>
> $s= "....."; # please don't modify me !
>
> foo( do {(my $DUMMY = $s) =~ s/abc/aBc/g;$DUMMY} );
If you want a modified copy of $s to be passed to &foo (without changing
$s) I believe that you'll be needing a temporary variable somehow
somewhere. Here's my (less ugly?) way of doing that.
{ # local scope
my $temp = $s; # temp copy
$temp =~ s/abc/aBc/g; # modified
foo($temp); # passed to &foo
}
Hope this helps!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
Ask me about Perl trainings!
------------------------------
Date: Thu, 25 Sep 1997 15:59:38 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Fleet Teachout <fleet@cbl.umces.edu>
Subject: Re: EOF problem?
Message-Id: <Pine.GSO.3.96.970925154801.6988B-100000@usertest.teleport.com>
On 24 Sep 1997, Fleet Teachout wrote:
> I think I have an ?embedded? EOF in my perl script, and haven't a clue
> how to get rid of it. The server is running Linux and the Perl compiler
> is 5.003.
Well, EOF isn't a character on Unix-type systems, and Linux is one of
those. So I don't think that an embedded EOF is possible. But let's look
at the symptoms... :-)
> w3:~> perl -w newlogs.pl
> Missing right bracket at newlogs.pl line 66, at end of line
> syntax error at newlogs.pl line 66, at EOF
> Execution of newlogs.pl aborted due to compilation errors.
> w3:~>
>
> Line 66 consists entirely of a right curly brace '}' that defines the
> end of a sub - and is the last line in the script.l
Well, that error message is telling you that there's a bracket missing
somewhere. Even though it's reporting the location as being line 66,
that's just where Perl was when it noticed the bracket was missing; it
could be missing from any of the previous lines. If your text editor won't
help you to find paired brackets, there are several good ones which will.
> FWIW, I imported the script into Linux from a Windows 3.1 buffer. Not
> sure that would be a problem, but thought I'd mention it.
Could be the problem, but it's not likely. The rule is that, when
transfering text (which a script is) from a DOS/Windows-type machine to
Unix (or vice versa), you should use a text/ASCII transfer mode so that
the line endings will be adjusted at the same time. Does that make any
difference?
Hope this helps!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
Ask me about Perl trainings!
------------------------------
Date: 26 Sep 1997 00:21:59 GMT
From: skknapp@nas.nasa.gov (Shane Knapp)
Subject: Help w/open3, pipes, threads(kinda long)
Message-Id: <60ev77$k4j$1@cnn.nas.nasa.gov>
hey all
ok, im having a sort of a problem getting the following code to work.
i am trying to use multiple filehandles designated by a hash (2-d array) to
STDERR, STDOUT and STDIN as used by open3.
basically, the script is run from a central machine and rsh's to various hosts
on the network (store in a list), pinging another host on the list. i am
using threads and open3 (so that i can scan STDERR for *each* ping, as to
catch specific, host-related errors... login incorrect, timed out, etc).
the reason that i am throwing this off onto separate processes is that, well,
it could take an extroidinarily long ammount of time to do this in
series.... doing this in parallel seems much more efficient.
quick rundown of what the program actually does:
HOST -rsh-> machine_a -ping-> machine_b
HOST -rsh-> machine_a -ping-> machine_c
HOST -rsh-> machine_b -ping-> machine_a
the children will then take the output from the ping, and throw that back down
a big-ass pipe to the parent, where, once all of the kids have died, process
it.
when i run it i get the following:
open3: wtr should not be null at ./perlping.2 line 463
now, i know that since i am not writing to the filehandle(s) used by open3,
but in a short example script (uses open3 do an 'ls' of a directory... just so
i could see if it worked) i didnt write to the filehandle, and it didn't
complain.
well, here is some pseudocode for ya to look at:
use Pseudocode;
use FileHandle;
use IPC::Open3;
pipe(READ_F, WRITE_F); # open pipes to and from the children
select(READ_F); $| = 1; #cleanse the buffers!
select(WRITE_F); $| = 1;
foreach $first (@hosts){
foreach $second (@hosts){
# create new filehandles for reading, writing and errors
$FH_W{$first}{$second} = new FileHandle; # write
$FH_R{$first}{$second} = new FileHandle; # read
$FH_E{$first}{$second} = new FileHandle; # stderr
$FH_W{$first}{$second}->autoflush();
$FH_R{$first}{$second}->autoflush();
$FH_E{$first}{$second}->autoflush();
$PING = "/bin/rsh $first /usr/bin/ping -c4 $second";
if ($pid = fork){ ; # in parent }
else {
# child
open3($FH_W{$first}{$second}, $FH_R{$first}{$second},
$FH_E{$first}{$second}, $PING);
@OUT = <$FH_R{$first}{$second}>;
@ERR = <$FH_E{$first}{$second}>;
# ...pretend there is code here...
#
# check the output, yaddah yaddah yaddah, put it in
# $result
#
print WRITE_F "$first|$second|$result\n";
# dont feel like writing out all of the 'close'
# statements.... read_f, write_f, fh_[w|e|r]....
# kill this kid
exit;
}
}
}
what happens is this:
not only do i get that 'open3: wtr should not be null at ./perlping.2 line
463' statement (463 is the open3 line), but it doesn't show anything to the
screen (or write to a file) after the open3 statement. this makes it rather
hard to debug, imho.... though i know why it's not showing anything (open3 is
taking over stderr, out and in).
ive tried alot, read the perldocs, man pages, FAQ, dejanews, etc. i have
gotten some pointers, but nothing that works.
also, the program works like this IF i take out the open3 call (i was using a
regular open() and doing a while() on the filehandle).
any ideas?
thanks much in advance.
later-
shane
--
**************************************************************
* Shane Knapp * "I am riding a bike through a realm *
* NAS Lan Team * called consciousness and I have *
* Sterling Software * squeaky brakes." *
* skknapp@nas.nasa.gov * *
**************************************************************
------------------------------
Date: Thu, 25 Sep 1997 21:56:40 GMT
From: trcwestla@worldnet.att.net (TRC Staffing - West LA)
Subject: Help.Where do Perl users look for a job?
Message-Id: <60eo8u$dnm@bgtnsc03.worldnet.att.net>
I apologize if I misdirected my posting, but I do need some help. I'm
looking for someone like you, who has sophisticated skills (Perl,
Visual Basic, HTML), but I'm not sure how to find you. How do you look
for a job? Do you post your resume and wait for people to call or do
you actively seek employment through the newspapers, computer
magazines, user group newsletters, web sites, jobs.offered newsgroups,
web classifieds, or friends? If you could reply with any information
about where to best target my search I'd really appreciate it. Thank
you.
Nancy Metro
trcwestla@worldnet.att.net
------------------------------
Date: Thu, 25 Sep 1997 17:03:03 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: "Ed.Q.Bridges" <eqbridges@cbs.com>
Subject: re: how to write HTML form data to a text file???
Message-Id: <Pine.GSO.3.96.970925170026.6988Q-100000@usertest.teleport.com>
On Thu, 25 Sep 1997, Ed.Q.Bridges wrote:
> &UnLock( DATAFILE );
> close DATAFILE;
Don't release a lock before closing the file unless you're an expert.
> foreach(<@Names>)
Oh, that's not doing what it looks like.
Please fix up your code before you post it again. Thanks!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
Ask me about Perl trainings!
------------------------------
Date: Thu, 25 Sep 1997 20:07:19 -0400
From: Nicolas.Ross@videotron.ca (Nicolas Ross)
Subject: HTTP Query in perl
Message-Id: <MPG.e94c6c61a741a4f989681@news.videotron.ca>
Hi !
I am rather a novice in perl programming, but I know a little.
What I wanna do is make a HTTP request.
Exactly, my script will take information passed to it, un scamble it and
make a request to a CGI script on a web page.
e.g. http://www.server.com/cgi-bin/script?var1=data1&om!nvar2=data2
How could I do that ??
Thanks in advance.
P.S. Please reply via e-mail...
/-----------------------------------------------------------------\
| Nicolas Ross | "The Enterprise saucer section looks like |
|rossnick@videotron.ca| a DONUT !" ____________ ____/--\____ |
| Genie Electrique | MMM... \______ ___) ( _ ____) |
| Universite Laval | donuts... __\ \____/ / `--' |
| Quebec, Canada | ) `|=(- |
| | Adm. H. Simpson \------------' |
| http://pages.infinit.net/rossnick/ |
\-----------------------------------------------------------------/
------------------------------
Date: Thu, 25 Sep 1997 16:09:36 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Ben Reser <ben@reser.org>
Subject: Re: incrementing array names
Message-Id: <Pine.GSO.3.96.970925160136.6988C-100000@usertest.teleport.com>
On Thu, 25 Sep 1997, Ben Reser wrote:
> for ($i = 0; $i <= 1000; $i++) {
> @{output$i} = split(/\s/,@input[$i]);
> }
That's wrong in at least three ways. (Why the hard-coded 1000? You're
doing a method call by mistake. You're making a slice of one element.
You're splitting on /\s/, but you're more likely to actually want /\s+/.)
Besides, I think you should have done this with references.
for (@input) {
push @output, [ split ];
}
Hope this helps!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
Ask me about Perl trainings!
------------------------------
Date: Thu, 25 Sep 1997 16:10:24 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Ben Fogarty <bfogarty@np0337.ford.com>
Subject: Re: Julian Date Routine
Message-Id: <Pine.GSO.3.96.970925161010.6988D-100000@usertest.teleport.com>
On 25 Sep 1997, Ben Fogarty wrote:
> Any of you GURUs out there have a Julian date routine in perl?
If there's a module which does what you want, it should be listed in
the module list on CPAN. If you don't find one to your liking, you're
welcome and encouraged to submit one! :-) Hope this helps!
http://www.perl.org/CPAN/
http://www.perl.com/CPAN/
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
Ask me about Perl trainings!
------------------------------
Date: 25 Sep 1997 15:07:12 -0700
From: Jake Donham <jake@organic.com>
Subject: Re: Perl <-> RPC <-> C
Message-Id: <wu9wwk52gkv.fsf@organic.com>
Somebody wrote:
>> >I have designed a RPC service under C for both client and
>> >server sides. I'm looking into the possiblity of using perl
>> >on the client side. Is it possible for perl to communicate to
>> >a server written in C via RPC? What sort of things would be
>> >involved?
Sure. See
<http://www.perl.com/CPAN/id/JAKE/perlrpcgen-0.71a.tar.gz>
Perlrpcgen generates Perl extensions from RPC .x files. It's only
running on Solaris right now but would be easy to port.
Network protocols like RPC are nice because they don't care about the
language you're writing in; it's easy to mix languages across protocol
boundaries.
--
Jake Donham
I am the serenest!
http://www.organic.com/
------------------------------
Date: Thu, 25 Sep 1997 15:06:46 -0700
From: Bob Melson <bob_melson@phx.mcd.mot.com>
Subject: Re: Perl crashing RS600 box
Message-Id: <342AE076.41C6@phx.mcd.mot.com>
Mike Heins wrote:
>
> Michael McCrann (mccrann_michael@jpmorgan.com) wrote:
> : A perl script I was running on my RS6000 AIX3.2 server caused the server
> : to crash. Can anyone tell me how I can report this bug and find out if it
> : can be fixed.
> :
>
> If a perl script can cause your OS and server to crash, it is a
> definite bug in your OS and only possibly a bug in Perl.
>
> Of course, in the case of AIX, if you are root and are
> modifying some of their control structures (I forget what they
> call them, but it is like NT's registry) then all bets are off,
> and it is likely a bug in your code.
>
> --
> Regards,
> Mike Heins
>
> This post reflects the
> opinion of my employer.
--
Contrary to popular belief, AIX ain't so bad. Without seeing the
original poster's script, I'd be more inclined to believe that the bug
is in the script and not in the o/s. WRT the ODM database (the NT
registry-like control structures you allude to), yeah, screwin' with
them can have definite adverse effects.
I'd suggest to the original poster that he post his code here, following
the FAQ guidelines (the smallest possible script that illustrates the
problem, etc.). As a first step, this would serve to implicate/clear
perl as a culprit. So far as the o/s goes, next time the system
crashes, he can use the crash utility to examine the system dump created
at meltdown. Examining the process stack *might* give some useful
clues, especially if perl is *not* implicated.
Hope this helps.
----------------------------------------------------------------------------
Bob Melson The right to be heard does not include
Motorola Computer Group the right to be taken seriously
2900 S. Diablo Way, Tempe, AZ Hubert Humphrey
----------------------------------------------------------------------------
------------------------------
Date: Thu, 25 Sep 1997 16:22:19 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Peter Prymmer <pvhp@forte.com>
Subject: Re: Perl Generator?
Message-Id: <Pine.GSO.3.96.970925162140.6988G-100000@usertest.teleport.com>
On Thu, 25 Sep 1997, Peter Prymmer wrote:
> Have you had much chance to play with SpecPerl?
No, and I can't find it on the Web (although I may not have searched hard
enough). What is it, and what is it good for?
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
Ask me about Perl trainings!
------------------------------
Date: Thu, 25 Sep 1997 16:17:29 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Kevin Goess <74561.610@CompuServe.COM>
Subject: Re: perl install on win32
Message-Id: <Pine.GSO.3.96.970925161204.6988E-100000@usertest.teleport.com>
On Wed, 24 Sep 1997, Kevin Goess wrote:
> $x = `echo bobo`;
> print "error: $!<br>\n" if $!;
$! is only set if there's an error from a system call, which wouldn't be
the case here, so any message this prints will be essentially useless.
Instead, $? is the status of the last run command, which will be zero for
success and non-zero for failure.
print "Backtick command returned status $?<br>\n" if $?;
> print "x is $x";
> Machine 2:
> error: Broken pipe
> x is <==never sets $x, why not?
Good question. If you get a status number, that may or may not tell you.
:-( But a command in backticks is starting one or more external programs,
so maybe you can find out what program that is and whether it's properly
being called on your errant system. Good luck!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
Ask me about Perl trainings!
------------------------------
Date: 26 Sep 1997 00:03:24 GMT
From: jgloudon@bbn.remove.com (Jason Gloudon)
Subject: Re: Perl5.004 and Solaris 2.6
Message-Id: <60eu4c$n7q$1@daily.bbnplanet.com>
Edward S. Marshall (emarshal@xnet.com) wrote:
: On Tue, 23 Sep 1997 13:03:50 -0600, Steve Wolfe <NerveGas@nospam.inconnect.com> wrote:
: >> >I'm trying to get Perl5.004 to compile on a sparc machine running
: >> >Solaris 2.6. I'm using the GCC 2.7.2.3 compiler on that machine
: >> >(I don't want to install the SunSoft C compiler on that machine).
: >
: > If at all possible, I would install Sun's compiler, especially if it
: >is Solaris for Sparc. Sun's compiler can optimize your binary much,
: >much more than GCC will. If it were a simple cgi program that would get
: >little use, it wouldn't matter... but as often as Perl can get used, the
: >optimization can really pay off in performance.
: Actually, now I'm interested. Has anyone done any real analysis of this
: idea (that GCC produces slower or more memory-hungry code than Sun's
: compiler), possibly using Perl as a testbed platform?
Sun's current compiler does produce faster code than gcc on their newer
processor architectures (ultra etc). No one disputes this. Memory usage,
on the other hand, excluding the actual size of the code generated, and
variations due to memory alignment generally doesn't depend on the compiler.
Jason Gloudon
------------------------------
Date: Thu, 25 Sep 1997 15:01:45 -0700
From: Sid Conklin <sconklin@livemedia.com>
Subject: Piping problem on NT HELP
Message-Id: <342ADF48.1B6892A4@livemedia.com>
My Perl script dies on the following:
open(resultScript, "|"."./"."$scriptName");
This works on my UNIX server. I'm concerned that the "|" command doesn't
work on NT. What should I use instead.
Thanks,
Sid
please send response to: sconklin@livemedia.com
#-- set in case the "GET" method is used
$sendString = $nameValFileName;
if($xact_CARDBALANCE ne "")
{
$sendString = $sendString."&"."$nameValCardVal";
}
$ENV{'QUERY_STRING'} = $nameValFileName;
# $ENV{'QUERY_STRING'} = $sendString;
open(resultScript, "|"."./"."$scriptName");
print resultScript $nameValFileName; # use if GET doesn't get.
#print resultScript $sendString; # use if GET doesn't get.
------------------------------
Date: Thu, 25 Sep 1997 06:55:58 -0400
From: "Annie P. Harding" <amhardin@erols.com>
Subject: processing variable input variables
Message-Id: <342A433E.589E@erols.com>
I am writing a perl script to process an HTML form which lists an
unknown amount of data. Each line of data has a checkbox next to it
so the user can choose to select the data to get further details on it.
Since i dont know how many checkboxes will be written out
<INPUT...NAME= is a variable (see below) ... (THIS IS GOING TO BE A PERL
QUESTION, JUST BEAR WITH ME!!!)
<form ACTION=\"/cgi-bin/addetail.pl\" METHOD=\"GET\">
foreach $jobads (@JOBADS) {
#create the variable name for the checkbox
$checked = join('', "checked",$counter);
<input TYPE=checkbox NAME=$checked VALUE=$jobads[0]> JOB INFO
}
#end form
Ok heres the perl question...on processing this form i need to
use the value of $checked to search on a file. But since the NAME
is already a variable name, how do i reference it?
#in a for loop - until $i < number of boxes checked
$checked = join('', "checked",$i);
@JOBLISTFOUND = grep (/$in{'$checked'}/, @JOBLIST);
$in{'$checked'} should be picking up the value of "checked1", "checked2"
etc....is there an easier way to process a variable number of
checkboxes?? any help would be appreciated...
Annie
------------------------------
Date: Thu, 25 Sep 1997 22:51:20 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: read only and flock
Message-Id: <EH365L.4MD@bcstec.ca.boeing.com>
In article <342994c6.5128072@news.wwa.com>, Faust Gertz <faust@wwa.com> wrote:
>There was an article a while back in which I think Charles DeRykus
><ced@bcstec.ca.boeing.com> said that he believed opening a file read
>only will set a shareable attribute and an exclusive lock from a flock
>command will be ignored.
>
>Thus, $file in the following code would not be locked.
>
>open (FILE, "<$file") || die "$0 can't open $file: $!";
>flock (FILE, 2) || warn "$0 can't flock: $!";
>close (FILE) || die "$0 can't close $file: $!";
>
>But if the first line is changed to
>
>open (FILE, "+<$file") || die "$0 can't open $file: $!";
>
>flock would set an exclusive lock. Would anyone care to confirm or
>deny this?
Yes, the +< invokes read/write access and so the lock is
exclusive, i.e, no other process is allowed write access.
A process can always get an "exclusive write" lock if
opening a file read only even if a exclusive lock's already
been granted.
The shareable attribute explanation was purely a guess about
what happens.
HTH,
--
Charles DeRykus
------------------------------
Date: Fri, 26 Sep 1997 00:06:52 +0200
From: Bosch Patrick <bosch@goweb.lu>
Subject: Read/Write access to a file
Message-Id: <342AE075.56A2C38C@goweb.lu>
Hello everybody!
I have a silly
problem with one of
my scripts. In the
specified script I
have to read
different files,
modify the data and
reprint it to the
same file. Different
users can have at
the same time access
to the file and
modify it.
So I have made a
script like the
following, which
uses a subroutine
located in another
script:
for ($counter = 0;
$counter < $limit;
$counter++) {
$filename =
@list[$counter];
&Read;
... Process the data
...
&Print;
}
The file with the
subroutines looks
like:
sub Read
{
open(FILE, "+<" .
$filename);
flock(FILE, 2);
while (<FILE>) {
... Read from $_ ...
}
}
sub Print
{
seek(FILE, 0, 0);
for ($counter_1 =
0; $counter_1 <
$limit_1;
$counter_1++) {
... Print output ...
}
close(FILE);
}
When I use this
procedure for any
file, but one at a
time, than
everything works
fine. But when I use
this subroutines for
more than one file
in a loop such of
the one above, the
program adds lines
to my file while
printing. I have
looked a look to the
data which is
correctly read and
modified. Examining
the file while
printing shows me
that file is
modified during
printing. For trial
I have done the same
thing by closing the
file and the end of
the subroutine and
reopen it for write
access at the
beginning of the
second subroutine.
Thanks a lot for
your attention
Patrick
--
Patrick Bosch
+++++++++++++++++++++++++++++++
GoWeb sarl
Internet Project
Management
+++++++++++++++++++++++++++++++
Tel.: +352/33 28 01
E-mail:
bosch@goweb.lu
14, rue General
Patton
L - 7270 Walferdange
Luxembourg
------------------------------
Date: Thu, 25 Sep 1997 17:28:33 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Bosch Patrick <bosch@goweb.lu>
Subject: Re: Read/Write access to a file
Message-Id: <Pine.GSO.3.96.970925172457.6988U-100000@usertest.teleport.com>
On Fri, 26 Sep 1997, Bosch Patrick wrote:
> I have a silly
> problem with one of
> my scripts. In the
> specified script I
> have to read
> different files,
> modify the data and
> reprint it to the
> same file. Different
> users can have at
> the same time access
> to the file and
> modify it.
Using a Commodore 64? :-) It's nice to keep the lines down to fewer than
72 characters, but I think you've gone a little too far. :-)
> $filename =
> @list[$counter];
Perl's -w option will warn you about using a slice of one element.
> open(FILE, "+<" .
> $filename);
Even when your script is "just an example" (and perhaps especially in that
case!) you should _always_ check of the return value after opening a
file.
> When I use this
> procedure for any
> file, but one at a
> time, than
> everything works
> fine. But when I use
> this subroutines for
> more than one file
> in a loop such of
> the one above, the
> program adds lines
> to my file while
> printing.
Locking the file won't prevent your script from adding to it. Is that the
problem? Hope this helps!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
Ask me about Perl trainings!
------------------------------
Date: Thu, 25 Sep 1997 16:11:43 -0500
From: Dirk Rosquillas <drosquil@campus.chs.itesm.mx>
Subject: socket to http
Message-Id: <342AD34C.2781@campus.chs.itesm.mx>
How do i create a socket to connect to an http server..
I know the transfer methods, I mean "GET /index.html HTTP/1.0"
and all the header stuff but I dont know how to get connected
Im actually trying to get a file without a browser.. and in the unix
kernel
--
Dirk Rosquillas
WebMaster
Campus Chiapas
www.chs.itesm.mx webmaster@campus.chs.itesm.mx
drosquil@campus.chs.itesm.mx
------------------------------
Date: Thu, 25 Sep 1997 16:20:54 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Per Fredrik Kvarme <perkva@itk.ntnu.no>
Subject: Re: substituting special chars
Message-Id: <Pine.GSO.3.96.970925161901.6988F-100000@usertest.teleport.com>
On Thu, 25 Sep 1997, Per Fredrik Kvarme wrote:
> I want to translate paths and file names from a PC NFS system, for
> use on UNIX. Part of that means I have to substitute all the MS-DOS "\"
> chars with the UNIX "/".
Backslash is always special in the text of your Perl script. If you mean a
real backslash, then, always use two.
$somestring =~ tr#\\#/#; # Turn backslashes into forward slashes.
Hope this helps!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
Ask me about Perl trainings!
------------------------------
Date: Thu, 25 Sep 1997 16:57:03 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Darren Hayes <darrenh@efn.org>
Subject: Re: Tab Delimiter character -- Unix to Mac
Message-Id: <Pine.GSO.3.96.970925165531.6988O-100000@usertest.teleport.com>
On Thu, 25 Sep 1997, Darren Hayes wrote:
> However \t as the Unix Tab character is not converting correctly to the
> tab character for the Mac.
print "\t";
Works for me in every Perl I've ever seen. Maybe you're sending the tab
character through some gateway or other program which is stripping it
somehow. Good luck!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
Ask me about Perl trainings!
------------------------------
Date: Thu, 25 Sep 1997 16:39:19 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Ben Kennedy <bkennedy@haverford.edu>
Subject: Re: Terminal Output
Message-Id: <Pine.GSO.3.96.970925163840.6988J-100000@usertest.teleport.com>
On Thu, 25 Sep 1997, Ben Kennedy wrote:
> Is there a way I can have my output to the terminal go to the second or
> third to last line on the screen, keeping the last line availiable for
> input?
Sounds as if you want Curses. Check the module list on CPAN. Good luck!
http://www.perl.com/CPAN/
http://www.perl.org/CPAN/
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
Ask me about Perl trainings!
------------------------------
Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 8 Mar 97)
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.
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 1081
**************************************