[19756] in Perl-Users-Digest
Perl-Users Digest, Issue: 1951 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Oct 18 00:05:31 2001
Date: Wed, 17 Oct 2001 21:05:10 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <1003377910-v10-i1951@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Wed, 17 Oct 2001 Volume: 10 Number: 1951
Today's topics:
Array / Regular Expression / Searching <gclark@wavetel.com>
Re: Array / Regular Expression / Searching (Garry Williams)
Re: Array / Regular Expression / Searching (Tad McClellan)
Re: Array / Regular Expression / Searching <gclark@wavetel.com>
Re: Change Last Modified for all files in a directory <goldbb2@earthlink.net>
Re: Checking if a file exists <CYNg@ntu.edu.sg>
Re: Help on wait and get process ids.. <goldbb2@earthlink.net>
Re: How to restore a filehandle tie correctly? <goldbb2@earthlink.net>
Re: Need help to find a regexp (Clinton A. Pierce)
Re: Need help to find a regexp <nospam@newsranger.com>
Re: Newbie Question on Writing\Printing to a File <goldbb2@earthlink.net>
Password. <scaiecat@telia.com>
Re: Password. <tony_curtis32@yahoo.com>
Re: Password. <jurgenex@hotmail.com>
Re: pcl printer codes <mragsdal@utk.edu>
Re: pcl printer codes (Garry Williams)
perl converted to exe is dyeing..please help.. <Jamuna.Krishnappa@fmr.com>
Re: perl converted to exe is dyeing..please help.. (Clinton A. Pierce)
Re: perl program converted to NT service-problems (Clinton A. Pierce)
Re: POD documentation question (Clinton A. Pierce)
Re: precedence question <joe+usenet@sunstarsys.com>
Re: precedence question (Clinton A. Pierce)
Re: precedence question <rtrahan@monmouth.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 18 Oct 2001 02:29:56 GMT
From: "Geoff Clark" <gclark@wavetel.com>
Subject: Array / Regular Expression / Searching
Message-Id: <E8rz7.525187$Lw3.32060227@news2.aus1.giganews.com>
I have a question I hope someone could assist with. I am in the process of
writing a cgi script. This script needs to search through a text file and
find a match and give back a result.
Example:
File-
p10020D6ACB204 00 10.1.66.13 10.1.64.2 1021903392
voicedhc
p10020D6BC31B4 00 10.1.66.14 10.1.64.2 1022592484
voicedhc
p10020D68CDA8D 00 10.1.66.15 10.1.64.2 1026616822
voicedhc
I need to be able to search on the first column and display the result from
the 3rd column.
My idea is this as follows:
if ($current_line =~ /^$mac (.*)/) {
$the_mac= $1;
}
$mac being the field that is searched on. I am not real comfortable with
regular Expressions. If you someone could assist with this. I would
greatly appreciate it.
Thanks,
Geoff
------------------------------
Date: Thu, 18 Oct 2001 03:38:48 GMT
From: garry@ifr.zvolve.net (Garry Williams)
Subject: Re: Array / Regular Expression / Searching
Message-Id: <slrn9ssjm8.l1i.garry@zfw.zvolve.net>
On Thu, 18 Oct 2001 02:29:56 GMT, Geoff Clark <gclark@wavetel.com> wrote:
> I have a question I hope someone could assist with. I am in the process of
> writing a cgi script. This script needs to search through a text file and
> find a match and give back a result.
>
> Example:
> File-
>
> p10020D6ACB204 00 10.1.66.13 10.1.64.2 1021903392
> voicedhc
> p10020D6BC31B4 00 10.1.66.14 10.1.64.2 1022592484
> voicedhc
> p10020D68CDA8D 00 10.1.66.15 10.1.64.2 1026616822
> voicedhc
>
> I need to be able to search on the first column and display the result from
> the 3rd column.
>
> My idea is this as follows:
>
> if ($current_line =~ /^$mac (.*)/) {
> $the_mac= $1;
> }
>
> $mac being the field that is searched on.
It would be a big help, if you gave us complete code that illustrates
your problem. The code you show has no way of "displaying the
result".
Maybe this will help:
while ($current_line = <TEXT_FILE>) {
if ( substr($current_line, 0, 14) eq $mac ) {
print +(split " ", $current_line)[2], "\n";
}
}
> I am not real comfortable with
> regular Expressions. If you someone could assist with this. I would
> greatly appreciate it.
You haven't defined a requirement for a regular expression.
--
Garry Williams
------------------------------
Date: Thu, 18 Oct 2001 03:43:08 GMT
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Array / Regular Expression / Searching
Message-Id: <slrn9ssgol.mrs.tadmc@tadmc26.august.net>
Geoff Clark <gclark@wavetel.com> wrote:
>This script needs to search through a text file and
>find a match and give back a result.
>I need to be able to search on the first column and display the result from
>the 3rd column.
>$mac being the field that is searched on. I am not real comfortable with
>regular Expressions.
That's fine, because you do not need them for this problem :-)
>If you someone could assist with this. I would
>greatly appreciate it.
------------------
#!/usr/bin/perl
use warnings;
use strict;
my $mac = 'p10020D6ACB204';
while (<DATA>) {
my($first, undef, $third) = split;
print "$third\n" if $first eq $mac;
}
__DATA__
p10020D6ACB204 00 10.1.66.13 10.1.64.2 1021903392
p10020D6BC31B4 00 10.1.66.14 10.1.64.2 1022592484
p10020D68CDA8D 00 10.1.66.15 10.1.64.2 1026616822
------------------
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Thu, 18 Oct 2001 03:54:00 GMT
From: "Geoff Clark" <gclark@wavetel.com>
Subject: Re: Array / Regular Expression / Searching
Message-Id: <rnsz7.785370$NK1.71246567@bin3.nnrp.aus1.giganews.com>
Gary,
This is what I have tried :
#!/usr/bin/perl
use warnings;
use strict;
use vars qw($current_line $mac);
my $mac = 'p10020D6ACB204';
while ($current_line = <dhcp.txt>) {
if ( substr($current_line, 0, 14) eq $mac ) {
print +(split " ", $current_line)[2], "\n";
}
}
I am receiving a blank result.
Thanks,
Geoff
"Garry Williams" <garry@ifr.zvolve.net> wrote in message
news:slrn9ssjm8.l1i.garry@zfw.zvolve.net...
> On Thu, 18 Oct 2001 02:29:56 GMT, Geoff Clark <gclark@wavetel.com> wrote:
> > I have a question I hope someone could assist with. I am in the process
of
> > writing a cgi script. This script needs to search through a text file
and
> > find a match and give back a result.
> >
> > Example:
> > File-
> >
> > p10020D6ACB204 00 10.1.66.13 10.1.64.2 1021903392
> > voicedhc
> > p10020D6BC31B4 00 10.1.66.14 10.1.64.2 1022592484
> > voicedhc
> > p10020D68CDA8D 00 10.1.66.15 10.1.64.2 1026616822
> > voicedhc
> >
> > I need to be able to search on the first column and display the result
from
> > the 3rd column.
> >
> > My idea is this as follows:
> >
> > if ($current_line =~ /^$mac (.*)/) {
> > $the_mac= $1;
> > }
> >
> > $mac being the field that is searched on.
>
> It would be a big help, if you gave us complete code that illustrates
> your problem. The code you show has no way of "displaying the
> result".
>
> Maybe this will help:
>
> while ($current_line = <TEXT_FILE>) {
> if ( substr($current_line, 0, 14) eq $mac ) {
> print +(split " ", $current_line)[2], "\n";
> }
> }
>
> > I am not real comfortable with
> > regular Expressions. If you someone could assist with this. I would
> > greatly appreciate it.
>
> You haven't defined a requirement for a regular expression.
>
> --
> Garry Williams
>
------------------------------
Date: Wed, 17 Oct 2001 22:55:12 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Change Last Modified for all files in a directory
Message-Id: <3BCE4490.98871319@earthlink.net>
What A Man ! wrote:
>
> Garry Williams wrote:
> >
> > On Sun, 14 Oct 2001 23:50:55 GMT, What A Man ! <whataman@home.com>
> > wrote:
> > > My script below does not change the last modified date.
> >
> > I don't believe you.
[snip]
> > As a matter of fact, the code above changes the times on all of the
> > files in the directory as many times as there are files in the
> > directory.
> >
>
> Sorry, it didn't change them until I restarted my browser so I didn't
> notice the date change.
It *did* change them, but you didn't press reload, so you didn't see it.
Note that since dates and such are part of the files' inodes, not part
of the directory, so changing them *does not* change the 'last modified'
time of the directory [then thing which contains a list of the files] --
the 'last modified' time of the directory only gets changed if an entry
in it is added, removed, or renamed.
So if you press reload *without* holding down shift, then netscape will
ask the web server if the page has changed, and send back "302 not
modified" as the http respons.
So press shift when reloading when you run into this kind of problem.
--
"What does stupid old man mean pidgin talk? Shampoo does not talk like a
bird."
------------------------------
Date: Thu, 18 Oct 2001 09:07:21 +0800
From: Ng Chze Yong <CYNg@ntu.edu.sg>
Subject: Re: Checking if a file exists
Message-Id: <8D5C8824989A21458FFF1C3CE990203605875DBD@mail12.main.ntu.edu.sg>
-----Original Message-----
From: Wyzelli [mailto:wyzelli@yahoo.com]
Posted At: Wednesday, October 17, 2001 12:01 PM
Posted To: misc
Conversation: Checking if a file exists
Subject: Re: Checking if a file exists
>Permissions problem.
>
>With CGI, the server runs as a very low privilege user. Check
permissions
>for the directory and file you are trying to read.
Permissions were previously set to read+execute on the dir/file for
internet guest account. Now i even tried granting full control
permissions - didn't work either.
Thanks for your help, though.
------------------------------
Date: Wed, 17 Oct 2001 23:29:54 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Help on wait and get process ids..
Message-Id: <3BCE4CB2.D18F25F2@earthlink.net>
Rashyid wrote:
>
> Hi there Martin,
>
> Thanks for the response: Am reading through it and am trying to digest
> everything in..
>
> Ok.. what the subprocedures do:
>
> A - Extract one table out from a DB
> B - Load one table into another DB
> C - Do a consistency check of the extract and load for one table..
>
> so what would be happening
>
> Extract table 1
>
> once finish extract load table 1
>
> once finish load do consistency check.
>
> after extracting from table 1 - extract from table 2
>
> therefore the extract and load after the first would be done
> simultaneously rather than one after the other, hence saving time..
> There wont be any overlap as the extraction takes LOADS of more time
> compared to the other two. it will be something like..
>
> A1----finish---->A2----finish----->A3----finish---->A4----finish.....
> | | | |
> |---->B1-->C1 |---->B2-->C2 |---->B3-->C3 |...
>
> therefore it can be seen that A2 will run in parallel with B1 and then
> C1, A3 with B2 and then C2... etc etc etc...and it goes on and on for
> around 70 tables..
Well, you still probably want to use fork and wait, but you probably
don't want to use seperate *programs* for each of these, since exec()
[and system] both incur quite a bit of time overhead which you likely
want to avoid.
my $db_read_from = DBI->connect( ....., {RaiseError=>1} );
my $db_insert_to = DBI->connect( ....., {RaiseError=>1} );
my $readsth = $db_read_from->prepare( ..... );
$readsth->execute;
while( my $row = $readsth->fetchrow_arrayref ) { # <-- command A.
defined( my $pid = fork ) or die "Couldn't fork: $!\n";
# both main process and child of main process:
if( $pid ) { # main process:
wait or die "Child dissappeared: $!\n";
$? and die "Child couldn't fork\n";
next;
}
# child of main process:
$db_read_from->{InactiveDestroy} = 1;
$db_insert_to->{InactiveDestroy} = 1;
defined($pid = fork) or die "In child, couldn't fork: $!\n";
# child of main process and grandchild of main process:
exit(0) if $pid; # child goes bye-bye, caught by wait() above.
# grandchild of main process:
# command B:
$db_insert_to->do( do { local $" = ", "; qq[
INSERT
(@$sth->{NAME}) = (@{[("?")x@$row]})
INTO table
] } );
# command C:
.... something ....
}
Obviously this code is untested and incomplete, but I'm sure with a
little bit of thought, you will come to understand it and be able to
finish it.
--
"What does stupid old man mean pidgin talk?
Shampoo does not talk like a bird."
------------------------------
Date: Wed, 17 Oct 2001 21:31:15 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: How to restore a filehandle tie correctly?
Message-Id: <3BCE30E3.2B03CF70@earthlink.net>
David Coppit wrote:
>
> Benjamin Goldberg wrote:
>
> > David Coppit wrote:
> >
> >>Greetings all,
> >>
> >>I'm trying to update CGI::Cache to play well with FCGI. The problem
> >>is that both want to tie to STDOUT.
> >
> > Use the Source, Luke. You don't need to do that, since CGI::Cache
> > already takes into account that STDOUT might already be tied. Take
> > a look inside of start().
>
> Um, check out the maintainer's name for CGI::Cache. I think I know
> what I'm talking about. :)
Ack! *blush* my mistake, sorry :)
> The problem is that what I'm doing inside CGI::Cache to take into
> account the previous tie isn't working correctly with FCGI. The code I
> posted shows the essential problem.
Hmm.
In CGI::Cache's stop() function, you retie using:
tie (*STDOUT,ref $OLD_STDOUT_TIE) if defined $OLD_STDOUT_TIE;
tie (*STDERR,ref $OLD_STDERR_TIE) if defined $OLD_STDERR_TIE;
This doesn't work for the simple reason that it creates a *new* tied
object for the stream, which of course is not what's wanted in most
cases.
In the post with which you start the thread, you try:
# Doesn't work. Causes script to exit as soon as
# FCGI::Stream::PRINT is called.
#tie ( *STDOUT, $OLD_STDOUT_TIE ) if defined $OLD_STDOUT_TIE;
This doesn't work for the obvious reason that $OLD_STDOUT_TIE isn't a
class, it's an object. Oops :) Well, obvious when you compare it the
code from start(), anyway :)
The proper fix is to do this:
tie( *STDOUT, "Tie::Restorer", $OLD_STDOUT_TIE )
if defined $OLD_STDOUT_TIE;
And create a package Tie::Restorer with the following contents:
package Tie::Restorer;
(*TIESCALAR, *TIEARRAY, *TIEHASH, *TIEHANDLE) =
( sub { $_[1] } ) x 4;
1;
__END__
This should reattach the old tieobject to the thing it was tied to.
--
"What does stupid old man mean pidgin talk? Shampoo does not talk like a
bird."
------------------------------
Date: Thu, 18 Oct 2001 01:34:14 GMT
From: clintp@geeksalad.org (Clinton A. Pierce)
Subject: Re: Need help to find a regexp
Message-Id: <qkqz7.181449$K6.86586436@news2>
[Posted and mailed]
In article <3BCDCAA3.DB1B0F93@web.de>,
Mirko Schur <mschur@web.de> writes:
> Hi,
>
> I try to find a regexp for the following task:
>
> In the following string for example
>
> "<b>Important</b> Note: {<i>}The Note{</i>}"
>
> I try to delete the html tags with a regular expression, however
> those enclosed by { and } should not be deleted.
>
> Can anybody find a regexp for that task?
Uh...why use a regexp? HTML::Parser could take care of this
fairly easily. Have the text callback set a "strip" or "not strip"
flag based on finding a { or } (hell, make sure they're balanced too
while you're at it). The strip flag would be on to begin with.
The text handler otherwise would just spit out whatever it finds.
The start handler would emit a tag only if the "strip" flag is
unset. The end handler would emit a tag only if the "strip" flag
is unset also.
--
Clinton A. Pierce Teach Yourself Perl in 24 Hours *and*
clintp@geeksalad.org Perl Developer's Dictionary
"If you rush a Miracle Man, for details, see http://geeksalad.org
you get rotten Miracles." --Miracle Max, The Princess Bride
------------------------------
Date: Thu, 18 Oct 2001 02:13:37 GMT
From: jdcfan <nospam@newsranger.com>
Subject: Re: Need help to find a regexp
Message-Id: <lVqz7.33554$ev2.40751@www.newsranger.com>
In article <3BCDCAA3.DB1B0F93@web.de>, Mirko Schur says...
>
>I try to delete the html tags with a regular expression, however
>those enclosed by { and } should not be deleted.
>
>Can anybody find a regexp for that task?
>
You can try this...
$string = "<b>Important</b> Note: {<i>}The Note{</i>}";
$string=~s/(?<!{)<[^>]*>(?!})//g; # Will remove HTML tags without {}
$string=~s/{(<[^>]*>)}/$1/g; # Remove {} from the remaining tags
Probably not very efficient, but I think it works.
Dan L.
------------------------------
Date: Wed, 17 Oct 2001 22:42:04 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Newbie Question on Writing\Printing to a File
Message-Id: <3BCE417C.77DC8D6E@earthlink.net>
Geoff Clark wrote:
>
> I am using the Net::SNMP module to get certain data from our devices.
> I have the script written where it pulls the data fine and outputs it
> to the screen, but I am trying to find out how to output this info to
> a file. I have a few books on Perl (Lama). But all I am seeing is
> how to print data from a text to a form. I want to print this info to
> a form but from the results. I'm not sure where to start, if anyone
> could help it would be greatly appreciated. The following is the
> script as sits now.
You have two problems here: One is using perl's formats [which
invlolved using write(), and format whatever = ... .], the other using
sending your data [whether via print() or via write()] to a file.
Considering that you appear to only be producing 10 sets of values, and
are putting one set per line [10 lines], and your header isn't really
all that big, there is no real point in using perl's formats. They're
really only useful for printing out reports on really huge data sets.
To output to a file, you open a filehandle to the target file [see
perlopentut], and then print to that filehandle.
#!'C:\Perl\bin\Perl.exe' -w
use strict;
use Net::SNMP;
my @params = qw/1.3.6.1.4.1.710.3.3.11.5.0
1.3.6.1.4.1.710.3.3.10.3.0
1.3.6.1.4.1.710.3.3.6.23.1.0/;
open THEFILE, ">", "snmp_output.txt"
or die "Couldn't open file 'snmp_output.txt' : $!";
print THEFILE <<HEADER;
WaveTel Network Operations - Best AU Support
0 = Disabled 1 = Enabled
HEADER
my $format = qq[%14s %24s %15s\n];
printf THEFILE $format . $format,
"IP Address", "Unit Name", "Best Au Support",
"=" x 14, "=" x 24, "=" x 15;
foreach my $host ( 1 .. 10 ) {
my ($session, $error) = Net::SNMP->session(
-hostname => "10.1.66.$host",
-community => 'public',
-timeout => '5',
-retries => '1',
);
print("Error: $error\n"), next
if !$session;
my $response = $session->get_request(@params);
print("Error: ",$session->error,"\n"), $session->close, next
if !$response;
printf THEFILE $format, @$response{@params};
$session->close;
}
__END__
NB: This code is untested.
--
"What does stupid old man mean pidgin talk?
Shampoo does not talk like a bird."
------------------------------
Date: Thu, 18 Oct 2001 01:31:20 GMT
From: "Scaiecat Spa Gigi" <scaiecat@telia.com>
Subject: Password.
Message-Id: <Ihqz7.877$Z_1.234963@newsc.telia.net>
Hi,
I wonder how I can make some pages which can be accessed to only by using a
password.
Regards
Luigi Donatello Asero
------------------------------
Date: Wed, 17 Oct 2001 20:47:19 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: Password.
Message-Id: <874roxvhw8.fsf@limey.hpcc.uh.edu>
>> On Thu, 18 Oct 2001 01:31:20 GMT,
>> "Scaiecat Spa Gigi" <scaiecat@telia.com> said:
> Hi, I wonder how I can make some pages which can be
> accessed to only by using a password.
Depends on what you mean by "page".
You're probably talking about the WWW and Basic
authentication, so I'll refer you to
comp.infosystems.www.servers.misc
where such things are discussed.
If that's not the case and you really want to do something
in perl, please expand on the details.
hth
t
--
Oh! I've said too much. Smithers, use the amnesia ray.
------------------------------
Date: Wed, 17 Oct 2001 19:09:18 -0700
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Password.
Message-Id: <3bce39cf@news.microsoft.com>
"Scaiecat Spa Gigi" <scaiecat@telia.com> wrote in message
news:Ihqz7.877$Z_1.234963@newsc.telia.net...
> I wonder how I can make some pages which can be accessed to only by using
a
> password.
Well, Perl doesn't have pages, but if you are looking for how to read a
password then
perldoc -q password
would be the right place to start.
jue
------------------------------
Date: Wed, 17 Oct 2001 22:26:11 -0400
From: Mike Ragsdale <mragsdal@utk.edu>
Subject: Re: pcl printer codes
Message-Id: <3BCE3DC3.448A9FB6@utk.edu>
Garry Williams wrote:
>
> On Wed, 17 Oct 2001 11:48:27 -0600, Mark Winter
> <mwinter@nrel.nrel.gov> wrote:
>
> > I am trying to write a perl program that embeds a HP printer code in the
> > file useing something
> > like this:
> >
> > print(OUT"ord(027) ord(038) ord(108) ord(054) ord(103) \n");
>
> That probably won't result in what you want. Maybe a closer
> approximation would be:
>
> print OUT ord(027), ord(038), ord(108), ord(054), ord(103), "\n";
>
> --
> Garry Williams
I don't think that will work either. You need to send these codes with
a PCL escape character. For instance to send a standard BOLD code, you
would send:
print OUT ("\e(s3B")
to UNBOLD, you would then send:
print OUT ("\e(s0B")
I haven't done this recently for octal ASCII codes, but if I recall
correctly, you need only escape each octal value, so your intended
output should be as this:
print OUT ("\e027\e038\e108\e054\e103\n");
-Mike
------------------------------
Date: Thu, 18 Oct 2001 03:16:19 GMT
From: garry@ifr.zvolve.net (Garry Williams)
Subject: Re: pcl printer codes
Message-Id: <slrn9ssic3.l1i.garry@zfw.zvolve.net>
On Wed, 17 Oct 2001 22:26:11 -0400, Mike Ragsdale <mragsdal@utk.edu> wrote:
> Garry Williams wrote:
>>
>> On Wed, 17 Oct 2001 11:48:27 -0600, Mark Winter
>> <mwinter@nrel.nrel.gov> wrote:
>>
>> > I am trying to write a perl program that embeds a HP printer code in the
>> > file useing something
>> > like this:
>> >
>> > print(OUT"ord(027) ord(038) ord(108) ord(054) ord(103) \n");
>>
>> That probably won't result in what you want. Maybe a closer
>> approximation would be:
>>
>> print OUT ord(027), ord(038), ord(108), ord(054), ord(103), "\n";
>
> I don't think that will work either. You need to send these codes with
> a PCL escape character. For instance to send a standard BOLD code, you
> would send:
>
> print OUT ("\e(s3B")
>
> to UNBOLD, you would then send:
>
> print OUT ("\e(s0B")
>
> I haven't done this recently for octal ASCII codes, but if I recall
> correctly, you need only escape each octal value, so your intended
> output should be as this:
>
> print OUT ("\e027\e038\e108\e054\e103\n");
I corrected my original post by using the chr() funtion instead of the
ord() function that the OP seemed to be wanting to use.
As to the actual characters that some printer will or will not
recognize, I have no knowledge. Indeed, that seems to be clearly off
topic. The OP had a Perl statement that didn't to do what he wanted,
so I commented on the Perl question.
BTW, there is no octal number `038' -- the OP apparently meant decimal
numbers in his original post even though he typed leading zeros in the
two digit decimal numbers. That was another problem with the Perl
code he posted.
--
Garry Williams
------------------------------
Date: Wed, 17 Oct 2001 14:58:28 -0400
From: Jamuna Krishnappa <Jamuna.Krishnappa@fmr.com>
Subject: perl converted to exe is dyeing..please help..
Message-Id: <3BCDD4D4.100AA3E3@fmr.com>
Hello everybody,
I have perl program which I converted to an NT service, and once it's
started, afer 1 or two days, it keeps dyieng..Any reason, Please help
me..I am very despearate.
I have used srvany.exe from ntresource kit..and used perl2exe to convert
from .pl to .exe.
Any input will be greatly appreciated...
Thanks in advance..
Jamuna
------------------------------
Date: Thu, 18 Oct 2001 01:51:45 GMT
From: clintp@geeksalad.org (Clinton A. Pierce)
Subject: Re: perl converted to exe is dyeing..please help..
Message-Id: <RAqz7.181468$K6.86608009@news2>
[Posted and mailed]
In article <3BCDD4D4.100AA3E3@fmr.com>,
Jamuna Krishnappa <Jamuna.Krishnappa@fmr.com> writes:
> Hello everybody,
You keep asking this question. Cut it out. Have patience.
------------------------------
Date: Thu, 18 Oct 2001 01:24:15 GMT
From: clintp@geeksalad.org (Clinton A. Pierce)
Subject: Re: perl program converted to NT service-problems
Message-Id: <3bqz7.181437$K6.86575449@news2>
[Posted and mailed]
In article <3BCDCCAF.BC7987B3@fmr.com>,
Jamuna Krishnappa <Jamuna.Krishnappa@fmr.com> writes:
> Hello everybody,
>
> I have perl program which I converted to an NT service, and once it's
> started, afer 1 or two days, it keeps dyieng..Any reason, Please help
> me..I am very despearate.
>
> I have used srvany.exe from ntresource kit..and used perl2exe to convert
> from .pl to .exe.
In itself, that's not enough to cause a script to die. I've got Perl
scripts running as services on production machines that have run for
weeks on end without trouble. The only reason they quit after weeks is,
well, they are NT machines and need to be rebooted occasionally.
Why'd you use perl2exe? You can run a script as a service without this
extra "conversion".
--
Clinton A. Pierce Teach Yourself Perl in 24 Hours *and*
clintp@geeksalad.org Perl Developer's Dictionary
"If you rush a Miracle Man, for details, see http://geeksalad.org
you get rotten Miracles." --Miracle Max, The Princess Bride
------------------------------
Date: Thu, 18 Oct 2001 01:28:26 GMT
From: clintp@geeksalad.org (Clinton A. Pierce)
Subject: Re: POD documentation question
Message-Id: <_eqz7.181439$K6.86579560@news2>
[Posted and mailed]
In article <3BCDC7FD.40800F09@tektronix.com>,
Warren L Dodge <warren.dodge@tektronix.com> writes:
> I want to do some pod documentation for the programs I have written. It looks
> as though it can do most of what I want to do.
>
> I have many programs which actually do multiple functions depending on how the
> program is called. I would like to write the POD documentation such that it can
> be output into multiple files of data. One for each function of the program.
>
> I don't see how I could do this as I read the manual.
>
> Am I missing something? Ideas?
If you write your own POD translator (and don't rely on pod2xxx or whatever)
you could hijack the =for directive for this use. The translator could
use differing =for blocks for the different kinds of functionality.
If you rely on the existing translators, you're probably stuck.
--
Clinton A. Pierce Teach Yourself Perl in 24 Hours *and*
clintp@geeksalad.org Perl Developer's Dictionary
"If you rush a Miracle Man, for details, see http://geeksalad.org
you get rotten Miracles." --Miracle Max, The Princess Bride
------------------------------
Date: 17 Oct 2001 21:34:04 -0400
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: precedence question
Message-Id: <m3itddbuk3.fsf@mumonkan.sunstarsys.com>
Andrew Gierth <andrew@erlenstar.demon.co.uk> writes:
> >>>>> "Richard" == Richard Trahan <rtrahan@monmouth.com> writes:
>
> Richard> In other words, I cannot find any set of rules that justify
> Richard> autoincrementing the second $a before the first.
Because there simply are none in Perl. Perl code is interpreted *and*
compiled into an op tree, which is later executed by walking the tree.
The actual sequence taken during the evaluation of a single expression
is not completely specified by the parser; that responsibility belongs
to perl (the executable).
> you are confusing "precedence" with "order of evaluation". They are not
> related.
>
> The fact that the lexer and/or parser sees the tokens in a particular
> order is not relevent - the two autoincrements are part of separate,
> unrelated subexpressions and there is therefore no required ordering
> between them.
Exactly- look at this
% perl -le '$var[$a++] = ++$a; print join ",",@var;'
,2
If you think the LHS of the assignment is carried out "first",
then it should print "2,"; but if you think the RHS is done first,
it should print ",1". Neither if these possibilities occurs because
perl is free to "optimize" a meaningless expression like
$var[$a++] = ++$a;
any way it sees fit. To reinforce this point, here's another one of
my favorite examples
% perl -wle 'print ++$a - ++$a; print $a'
0
2
HTH
--
Joe Schaefer "Life is just one damn thing after another."
--Mark Twain
------------------------------
Date: Thu, 18 Oct 2001 02:03:52 GMT
From: clintp@geeksalad.org (Clinton A. Pierce)
Subject: Re: precedence question
Message-Id: <cMqz7.181527$K6.86622593@news2>
[Posted and mailed]
In article <3BCD9B62.728E1FEB@monmouth.com>,
Richard Trahan <rtrahan@monmouth.com> writes:
> Consider the following program:
> [...]
> $var[$a++] = $var[$a++] + $value; # (Wall, 3rd ed., p. 107)
> [...]
> I cannot justify the answer based on my (apparently wrong)
> understanding of precedence.
It's not precedence, it's order-of-evaluation. Don't do this.
This is evil. Bad Larry! No biscuit!
This kind of crap drives C programmers nuts. According to
the comp.lang.c FAQ:
Section 3. Expressions
3.1: Why doesn't this code:
a[i] = i++;
work?
A: The subexpression i++ causes a side effect -- it modifies i's
value -- which leads to undefined behavior since i is also
referenced elsewhere in the same expression, and there's no way
to determine whether the reference (in a[i] on the left-hand
side) should be to the old or the new value. (Note that
although the language in K&R suggests that the behavior of this
expression is unspecified, the C Standard makes the stronger
statement that it is undefined -- see question 11.33.)
References: K&R1 Sec. 2.12; K&R2 Sec. 2.12; ISO Sec. 6.3; H&S
Sec. 7.12 pp. 227-9.
[Note that "undefined" means that it's perfectly acceptable for the
compiler to cause monkeys to come flying out of the programmer's butt
playing Beethoven's 5th symphony on the banjo with their teeth.]
Yeah, this is Perl and not C...but the same kinds of nonsense will
cause you and others headaches. Don't do it, please.
--
Clinton A. Pierce Teach Yourself Perl in 24 Hours *and*
clintp@geeksalad.org Perl Developer's Dictionary
"If you rush a Miracle Man, for details, see http://geeksalad.org
you get rotten Miracles." --Miracle Max, The Princess Bride
------------------------------
Date: Wed, 17 Oct 2001 23:27:02 -0700
From: Richard Trahan <rtrahan@monmouth.com>
Subject: Re: precedence question
Message-Id: <3BCE7636.1D205DB9@monmouth.com>
Dave Tweed wrote:
>
> No, the parser doesn't execute code at all. It generates code that
> gets executed later, in the proper sequence.
Yes, you're right; I was mixing up tokenizing with order of execution.
Nevertheless, the parser does output an opcode tree whose ordering
influences order of execution (doesn't it?).
>
> The SYNOPSIS section of "perldoc perlop" seems to be fairly explicit to
> me about precedence and associativity. "=" is right-associative, which
> means (among other things) that the right side is evaluated before the
> left side.
I disagree. Right- and left-associativness are only used as tie-
breakers when two operators of the same precedence are delivered to
the parser; right-associative causes a parser "shift", and left-
causes a "reduce". (You can read about this in the Bison manual,
which serves as the tutorial for the Perl Yapp module.)
Here's a little program that demonstrates evaluation on the left
side of the equals sign first:
use strict;
use warnings;
my $a=5;
(print("left $a\n")),$a = (print ("right $a\n")),7;
print "$a\n";
The output clearly shows that the left print statement is being
evaluated (I assume you mean 'executed', not tokenized) before
the right. Notice that $a winds up with a value of 1, which is
the return value of the right print (1 for true); this is because
the precedence of "=" is higher than that of ",", otherwise $a
would wind up as 7.
There are two other bizarre aspects of the above code. If run
as is, you get a "useless use of constant in void context"
warning, presumably the 7, which is reasonable because it's not
used for anything. But if you change the 7 to a 1, the warning
goes away. Could this be due to "constant folding"? If so, this
is surely a bug in the warning system.
Second, if you remove the "my $a=5" line, the program will warn
about concatenation of an unitialized variable, which makes sense,
but more importantly, it doesn't die for lack of a "my" or "our"
declaration for $a. In fact, "use strict" doesn't seem to work at
all in toplevel code (but works in subs). How come?
(Results may vary; I'm running ActivePerl on Windows 98.)
Another poster said that my example, which is taken from Wall, is
meaningless code because the optimizer is free to do things that
would make the result indeterminate. That's fine with me, as I would
never write such a line. I'm just groping for understanding, and
your input is appreciated.
------------------------------
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.
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 1951
***************************************