[21898] in Perl-Users-Digest
Perl-Users Digest, Issue: 4102 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Nov 12 06:06:25 2002
Date: Tue, 12 Nov 2002 03:05:13 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Tue, 12 Nov 2002 Volume: 10 Number: 4102
Today's topics:
Re: Changing color in a GIF image? <bigiain@mightymedia.com.au>
emiling files with perl (ddineen.cs@clearstream.com)
Re: fetch all the bouncing e-mailaddresses (Leif Wessman)
Re: fetch all the bouncing e-mailaddresses (Leif Wessman)
Re: Global file search function? <koos_pol@NO.nl.JUNK.compuware.MAIL.com>
Re: Global file search function? <tk@WINDOZEdigiserv.net>
help with Win32::OLE MS Word <tednospam94107@yahoo.com>
Re: illegal use of comment ? <garry@ifr.zvolve.net>
Re: looping through named arrays (p cooper)
LWP-download help (Chris Liu)
newbie question (raoul_s2222@yahoo.com)
Newbie script needs help <al@onetel.net.uk>
Re: Newbie with Perl <nospam@nospam.com>
one value in the array <rwh2100@hotmail.com>
Re: one value in the array <Graham.T.Wood@oracle.com>
Re: one value in the array <nobull@mail.com>
Re: Perl CGI Java help <jwillmore@cyberia.com>
perl daemon in windows memory hog ? <flying_dragon@china.com>
Re: perl daemon in windows memory hog ? <bowman@montana.com>
Re: perl daemon in windows memory hog ? <nospam@nospam.com>
Perl: string vs. numeric <member@mainframeforum.com>
Re: saving a cgi file <islaw@w98.sr>
SNMP::Multi: Dereferer syntax to create hash? (Jens Abromeit)
Splitting on a line break that isn't <rubberducky703@hotmail.com>
Re: Splitting on a line break that isn't <tassilo.parseval@post.rwth-aachen.de>
Re: Splitting on a line break that isn't <rubberducky703@hotmail.com>
Re: Splitting on a line break that isn't <tk@WINDOZEdigiserv.net>
Re: What is this: "sub myFunc ($$) {" <bigiain@mightymedia.com.au>
Re: Windows and nonblocking IO edgue@web.de
Re: Windows and nonblocking IO edgue@web.de
Re: xml news@roaima.freeserve.co.uk
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 12 Nov 2002 16:43:28 +1100
From: Iain Chalmers <bigiain@mightymedia.com.au>
Subject: Re: Changing color in a GIF image?
Message-Id: <bigiain-9C6C49.16432812112002@nasal.pacific.net.au>
In article <xfsvznsgm0z1.fsf@blue.engin.umich.edu>,
Arnar Mar Hrafnkelsson <addi@umich.edu> wrote:
> caryz@hotmail.com (C Z) writes:
>
> > All, I am trying to change one color in a gif image to another (say
> > change all red spots to blue spots) (output preferrably in GD format
> > so I can do more stuff). Searched CPAN and internet, not very lucky. I
> > am wondering if any one of you could give me some directions?
> > Thanks,
> >
> > CZ
>
> Imager.pm can do general color conversions:
>
> http://www.eecs.umich.edu/~addi/perl/Imager/
>
> It's very likely that Image::Magick has ways to do this also. Less likely
> but still possible that GD.pm can do this.
The last version of GD that supported gifs doesn't appear to be able to
do it, but there are some bits of Image::ParseGIF that do it, tho they
don't appear to be documented, so you need to poke round the source to
see how they work...
(Oh, and thanks Tony for pointing it out ;-)
big
------------------------------
Date: 12 Nov 2002 02:39:03 -0800
From: ddineen.cs@clearstream.com (ddineen.cs@clearstream.com)
Subject: emiling files with perl
Message-Id: <da25c255.0211120239.787763cc@posting.google.com>
Hi,
I am trying to write a perl program which creates a randomly named
file, closes it and then emails it using the unix mail program. When I
run the program I get no errors but the mail is not sent. However if I
run it again and this time generate a new file, but email the one
generated in the previous run, the email is sent fine. It seems to me
that it is unable to email the file gererated during that run of the
program, it is as if the file handle has not been released by perl yet
(even though close has been called). It is as if the file actually has
not been created when I go to send the email.
I have provided two code snippets, the first shows a program trying to
email the file generated in that run (this fails), the second
generates a new file but emails the one generated in the previous run.
What do I need to do to the program so that I can generate a file,
close it and then email it on?
Any help is greatly appreciated,
Dave.
*************************************************************************
First code snippet
*************************************************************************
#refnum is 8 bits of randomly generated data. This is used as the
reference no #for request
$refnum = random_filename_generator();
open(TSDREQUEST,">../TSDRequests/CodeSigning/$refnum.req") || die
"Couldn't open.\n";
print TSDREQUEST "RequestType: Code Signing\n";
#loads of other print TSDREQUEST statements......
#I then close the file
close(TSDREQUESTS);
$the_cmd='mail ddineen.cs\@clearstream.com <
../TSDRequests/CodeSigning/'.$refnum;
$the_cmd .=".req";
print("$the_cmd");
system($the_cmd);
*************************************************************************
Second code snippet. For this run say, the file generated in the last
run
was vDE7aned.req. This email is sent.
*************************************************************************
#refnum is 8 bits of randomly generated data. This is used as the
reference no #for request
$refnum = random_filename_generator();
open(TSDREQUEST,">../TSDRequests/CodeSigning/$refnum.req") || die
"Couldn't open.\n";
print TSDREQUEST "RequestType: Code Signing\n";
#loads of other print TSDREQUEST statements......
#I then close the file
close(TSDREQUESTS);
$refnum="vDE7aned";
$the_cmd='mail ddineen.cs\@clearstream.com <
../TSDRequests/CodeSigning/'.$refnum;
$the_cmd .=".req";
print("$the_cmd");
system($the_cmd);
------------------------------
Date: 11 Nov 2002 23:51:43 -0800
From: leifwessman@hotmail.com (Leif Wessman)
Subject: Re: fetch all the bouncing e-mailaddresses
Message-Id: <64beeaad.0211112351.193bb310@posting.google.com>
Thank you for your answer. My main question is still unanswered: How
do I do it so that I can fetch the address only
Leif
Andras Malatinszky <nobody@dev.null> wrote in message news:<3DCFCCAD.60703@dev.null>...
> Leif Wessman wrote:
>
> >[...] I want to go thru all the bounce-mails and fetch all occurrences
> > of e-mailadresses like this:
> >
> > open IN, "<$ARGV[0]" or die "open: $!";
> > while ($line = <IN>) {
> > if ($line =~ /^[a-zA-Z0-9\-\._]+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/)
> > {
> > print $1;
> > }
> > }
> > close IN;
> >
> > But the problem is that $1 does not contain anything at any point. How
> > should I write to fetch out the addresses??
>
>
> $1 will contain whatever the sub-regex within the first pair of
> parantheses matches. Your first pair of parentheses contains
>
> \[?
>
> meaning that you are asking your computer to print a left square bracket
> if it happens to occur after the @ character in the e-mails. Sure
> enough, when I tested your script against
>
> elvis@[presley.com
>
> it dutifully printed
> [
>
> Your list probably doesn't contain any addresses with [ as the first
> character of the domain name; that's why you don't get any output.
------------------------------
Date: 11 Nov 2002 23:53:41 -0800
From: leifwessman@hotmail.com (Leif Wessman)
Subject: Re: fetch all the bouncing e-mailaddresses
Message-Id: <64beeaad.0211112353.456a2cf2@posting.google.com>
> Modern list management s/w encodes the recipient into return path so
> that bounces are easily identifyable.
>
Where can I read more about how to identify a bounce and the original emailaddress?
> For any mailing list big enough to warrant any form of automation I
> strongly recommend using standard list management software rather than
> rolling your own.
I will consider this for the future.
Thank you for your help.
Leif
------------------------------
Date: Tue, 12 Nov 2002 08:14:48 +0100
From: Koos Pol <koos_pol@NO.nl.JUNK.compuware.MAIL.com>
Subject: Re: Global file search function?
Message-Id: <newscache$o4cg5h$ce3$1@news.emea.compuware.com>
Miguel wrote (Monday 11 November 2002 22:16):
> Hello Everyone,
>
> I'm wondering how will be possible to search for a specific
> file format (example .zip) within the "entire" system, *every folder*.
> I understand is possible to do it within perl's "current working
> directory" but I'm really talking about doing a complete check trough
> every folder within the system.
> Any help will be appreciated. Thank You.
>
> -Miguel Daniel <m_dv@hotmail.com>
There is ofcourse the GNU "locate" command. Perhaps already installed on
your system...
--
KP
------------------------------
Date: Tue, 12 Nov 2002 11:00:20 GMT
From: tk <tk@WINDOZEdigiserv.net>
Subject: Re: Global file search function?
Message-Id: <7rn1tuccr61jqureajfvs3fvcg62glu3l4@4ax.com>
In a fit of excitement on Tue, 12 Nov 2002 08:14:48 +0100, Koos Pol
<koos_pol@NO.nl.JUNK.compuware.MAIL.com> managed to scribble:
| Miguel wrote (Monday 11 November 2002 22:16):
|
| > Hello Everyone,
| >
| > I'm wondering how will be possible to search for a specific
| > file format (example .zip) within the "entire" system, *every folder*.
| > I understand is possible to do it within perl's "current working
| > directory" but I'm really talking about doing a complete check trough
| > every folder within the system.
| > Any help will be appreciated. Thank You.
| >
| > -Miguel Daniel <m_dv@hotmail.com>
|
| There is ofcourse the GNU "locate" command. Perhaps already installed on
| your system...
WHy on earth would you want to use a system call when you can do it
quite as easily in Perl that's portable?
tk
--
+--------------------------+
| digiServ Network |
| Web solutions | Remove WINDOZE to reply.
| http://www.digiserv.net/ |
+--------------------------+
------------------------------
Date: Tue, 12 Nov 2002 00:25:53 -0800
From: "ted" <tednospam94107@yahoo.com>
Subject: help with Win32::OLE MS Word
Message-Id: <aqqdmq$k4c$1@slb2.atl.mindspring.net>
Hello,
I'm trying to extract text from MS Word docs that have tables and bulleted
lists.
How would I detect tables and bulleted lists (and nested lists) in the Word
doc? They are scattered throughout the doc.
Any help appreciated. Thanks.
-Ted
------------------------------
Date: Tue, 12 Nov 2002 07:41:48 -0000
From: Garry Williams <garry@ifr.zvolve.net>
Subject: Re: illegal use of comment ?
Message-Id: <slrnat1c5s.ri9.garry@zfw.zvolve.net>
On Mon, 11 Nov 2002 21:50:57 GMT, pkent <pkent77tea@yahoo.com.tea> wrote:
[snip]
> ObPerl:
> And why yes I did have to deal with a load of data files proving that
> people can get an email address 'wrong' in a variety of ways including:
> adding newlines, or carriage returns
> appending a final dot to the domain
> typing the whole thing in upper case
> etc. Hmm.
Those last two are _not_ incorrect.
The final dot _is_ the root domain and (sendmail at least) doesn't
make a distinction between upper and lower case for the part to the
left of the @. (This leads to a problem on Unix systems that have
user names in mixed case. The mail cannot get delivered.) Domain
names, of course are not case-sensitive, by definition.
--
Garry Williams
------------------------------
Date: 12 Nov 2002 02:00:50 -0800
From: pdc124@yahoo.co.uk (p cooper)
Subject: Re: looping through named arrays
Message-Id: <e742a0ce.0211120200.32a02e79@posting.google.com>
thanks guys - getting sorted.
not sure yet that im conceptually up to a list of lists (?something
like a 2 dimensional array) but what ive got is a vast improvement.
it was never this hard in BBC Basic ( so that shows my age!)
------------------------------
Date: 12 Nov 2002 00:20:56 -0800
From: fcqmax@pchome.com.tw (Chris Liu)
Subject: LWP-download help
Message-Id: <806277c.0211120020.8bfb3b3@posting.google.com>
Somehow lwp-download doesn't recognize the variables in the URL string
when I use the GET method. Any advice? Thanks.
a perl newbie
------------------------------
Date: Mon, 11 Nov 2002 23:25:29 GMT
From: u712646484@spawnkill.ip-mobilphone.net (raoul_s2222@yahoo.com)
Subject: newbie question
Message-Id: <l.1037057129.1451416015@[63.127.215.130]>
hi,
I am very new to perl but need this code for a purpose.
1) how do i modify this code so that it skips the header size
of 4,8,16,... bytes.
2) how to convert to decimal as well (as a choice)?.
Raoul
# perl bin2hex.pl banner.gif 0 >source.txt <<usage
# bin2hex.pl by Chami.com
# http://www.chami.com/tips/
#
# number of characters per line
$chars_per_line = 15;
# -------------------------------------
# language id
#
# 0 = Perl (default)
# 1 = C / C++
# 2 = Pascal / Delphi
#
$lang = $ARGV[1];
$rem_begin = "begin binary data:";
$rem_end = "end binary data.";
# initialize for Perl strings
# by default
$_var = "# $rem_begin\n".
"\$bin_data = # %d\n";
$_begin = "\"";
$_end = "\";\n";
$_break = "\".\n\"";
$_format = "\\x%02X";
$_separator = "";
$_comment = "# $rem_end ".
"size = %d bytes";
# C / C++
if(1 == $lang)
{
$_var = "/* $rem_begin */\n".
"char bin_data[] = ".
"/* %d */\n";
$_begin = "{";
$_end = "};\n";
$_break = "\n";
$_format = "0x%02X";
$_separator = ",";
$_comment = "/* $rem_end ".
"size = %d bytes */";
}
elsif(2 == $lang)
{
$_var = "{ $rem_begin }\n".
"const bin_data : ".
"array [1..%d] of ".
"byte = \n";
$_begin = "(";
$_end = ");\n";
$_break = "\n";
$_format = "\$%02X";
$_separator = ",";
$_comment = "{ $rem_end ".
"size = %d bytes }";
}
if(open(F, "<".$ARGV[0]))
{
binmode(F);
$s = '';
$i = 0;
$count = 0;
$first = 1;
$s .= $_begin;
while(!eof(F))
{
if($i >= $chars_per_line)
{
$s .= $_break;
$i = 0;
}
if(!$first)
{
$s .= $_separator;
}
$s .= sprintf(
$_format, ord(getc(F)));
++$i;
++$count;
$first = 0;
}
$s .= $_end;
$s .= sprintf $_comment, $count;
$s .= "\n\n";
$s = "\n".sprintf($_var, $count).$s;
print $s;
close( F );
}
else
{
print
"bin2hex.pl by Chami.com\n".
"\n".
"usage:\n".
" perl bin2hex.pl <binary file>".
" <language id>\n".
"\n".
" <binary file> : path to the ".
"binary file\n".
" <language id> : 0 = Perl, ".
"1 = C/C++/Java, ".
"2 = Pascal/Delphi\n".
"\n";
}
--
Sent by raoul_s2222 from yahoo part of com
This is a spam protected message. Please answer with reference header.
Posted via http://www.usenet-replayer.com/cgi/content/new
------------------------------
Date: 12 Nov 2002 00:10:28 GMT
From: al <al@onetel.net.uk>
Subject: Newbie script needs help
Message-Id: <slrnat0hpj.3ru.al@localhost.localdomain>
Keywords: search, database, perl
I'm new to Perl and could use some help with a script I am trying to
write. The program should pull in a comma-delimited text file called
"qa.db". It should prompt the user for the string and which field to
be searched. It should then search for a string by field -- i.e., not
just anywhere on the line, but by specific parts of the line as
delimited by the commas. The results will then be printed to screen
and/or to a file.
I have been able to pull in qa.db but cannot get the search routine to
fly. Any ideas?
search.pl:
#!/usr/bin/perl
# A program to read in a database
# and search it by field
# for a string issued by the user
#
$file = 'qa.db' ; # Name the file
open(INFO, "<$file" ) ; # Open the file
@lines = <INFO> ; # Read it into an array
close(INFO) ; # Close the file
print "Search string: " ;
read STDIN, $search, 3, 0; #Prompt user for search string
print "\n Results for $search : ";
foreach $line (@lines) #My search routine
{
if ($line =~ /^ $search/cis )
{
print " $line \n" ;
}
}
__END__
------------------------------
Date: Tue, 12 Nov 2002 00:16:05 -0800
From: "Tan Nguyen" <nospam@nospam.com>
Subject: Re: Newbie with Perl
Message-Id: <3dd0b82e_2@nopics.sjc>
"Michael J Wilusz" <mjwilusz@acsu.buffalo.edu> wrote in message
news:aqpsff$5ff$1@prometheus.acsu.buffalo.edu...
> and not lookin to hurt eachother.
Hold it right there....Read a bit more and you'll be amazed.
> And here's a hint I was given:
> Hint: the first line of your script should be:
> #! /util/bin/perl -w
The next line should be
use strict;
A few more lines might look like this:
open(FH, $ARGV[0]) or die "cannot open $ARGV[0]: $!\n";
while (<FH>) {
# parse the input line, print out the extracted field etc.
}
close FH;
------------------------------
Date: Tue, 12 Nov 2002 18:57:08 +1100
From: "Rodney Hunter" <rwh2100@hotmail.com>
Subject: one value in the array
Message-Id: <Zy2A9.27055$Sr6.781253@ozemail.com.au>
the code below works for just one value in the array @veg_type - for two
values (vegetation_type04, vegetation_type01) in the array gives the Apache
error message. How come? .
Newbie Thanks
Rodney Hunter
* Note - the print code is used just for debugging with values 7011 for
$thisjobno and 312011 for $easting
* Perl code -
# print HTML header
printHead('EA Journal');
my $sth = $dbh->prepare(q{insert into ea_veg (job_no, veg_type,
veg_status) values (:job, :type, 1)}) ;
foreach (@veg_type) {
print <<ENDOFTEXT;
$thisjobno $easting @veg_type
ENDOFTEXT
$sth->bind_param(":job",$thisjobno);
$sth->bind_param(":type",@veg_type);
$sth->execute() || die "insert failed";
}
* Apache error message -
7011 312011 vegetation_type04 vegetation_type01
OK
The server encountered an internal error or misconfiguration and was unable
to complete your request.
More information about this error may be available in the server error log.
* Apache WS error log -
[Tue Nov 12 18:24:48 2002] [error] DBI::st=HASH(0x4c492b4)->bind_param(...):
attribute parameter 'vegetation_type01' is not a hash ref at
c:/apache/htdocs/eaj/eajob2.pl line 157.
------------------------------
Date: Tue, 12 Nov 2002 10:04:46 +0000
From: Graham Wood <Graham.T.Wood@oracle.com>
Subject: Re: one value in the array
Message-Id: <3DD0D23E.21A9430E@oracle.com>
Rodney Hunter wrote:
> printHead('EA Journal');
> my $sth = $dbh->prepare(q{insert into ea_veg (job_no, veg_type,
> veg_status) values (:job, :type, 1)}) ;
You appear to be using scalar values here...
>
> foreach (@veg_type) {
> print <<ENDOFTEXT;
> $thisjobno $easting @veg_type
> ENDOFTEXT
> $sth->bind_param(":job",$thisjobno);
> $sth->bind_param(":type",@veg_type);
and attempting to bind an array to the scalar :type variable here.
You are already looping over the elements of @veg_type so I think you need to
replace @veg_type with $_ in 2 places:
foreach (@veg_type) {
print <<ENDOFTEXT;
$thisjobno $easting $_
ENDOFTEXT
$sth->bind_param(":job",$thisjobno);
$sth->bind_param(":type",$_);
$sth->execute() || die "insert failed";
}
Hope this helps
Graham Wood
------------------------------
Date: 12 Nov 2002 08:57:36 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: one value in the array
Message-Id: <u9n0of14si.fsf@wcl-l.bham.ac.uk>
"Rodney Hunter" <rwh2100@hotmail.com> writes:
> foreach (@veg_type) {
[...]
> $sth->bind_param(":type",@veg_type);
^^^^^^^^^
Surely you mean $_
> $sth->execute() || die "insert failed";
> }
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Tue, 12 Nov 2002 05:49:14 GMT
From: James Willmore <jwillmore@cyberia.com>
Subject: Re: Perl CGI Java help
Message-Id: <20021112004546.7e92b9ff.jwillmore@cyberia.com>
> Hi! I am basically working on a mock up of a e-commerce site. I have
> an XML file that stores posters information. I have users come in to
> my site and they select a category (such as Sports) and I need to
> display all the posters that are in the Sports category. There is
> also a JAVA Server running, that when run initially loads XML and
> stores poster information in memory data structure. Now when users
> click say sports from main page, I run this perl script, that in
> turn calls a function in Server.java that fetches all sports posters
> from memory, create an HTML page, and send it back to perl script
> which in turn displays this result HTML to user on the browser. What
> I don't understand is how to have PERL script call the Java
> function? I am using PERL, CGI and Java Server btw.
If I understand what you're trying to do correctly, you want a Perl
script to make a call to a Java application? If that's the case, you
have a couple of options.
First, you could incorporate Java code into your Perl script using the
Inline::Java module.
Are you using an XML aware server (ie Tomcat or JRun)? You could use
one of the various XML modules and ditch the Java code completely.
If you're not thrilled at the idea of ditching the Java code, why not
use JSP?
In general, this question is both incomplete (no real Perl specifics)
and not applicable to this newsgroup (this is comp.perl.lang.misc -
perhaps you wanted a newsgroup specific to WWW
authoring/administration).
HTH
Jim
------------------------------
Date: Tue, 12 Nov 2002 05:25:40 GMT
From: "James Q.L" <flying_dragon@china.com>
Subject: perl daemon in windows memory hog ?
Message-Id: <oh0A9.64304$MGm1.14471@news02.bloor.is.net.cable.rogers.com>
Hi,
I don't have much experience with Perl in M$..
now i need to write a script that monitor the IIS server state and restart
it when necessary.
i am going to use Win32::Daemon and leave it on all the time. but i am
afraid that perl
will eat much more memory and hog the server..
if you have experience working on this. i would love to hear.
thanks,
James.Q.L
------------------------------
Date: Mon, 11 Nov 2002 23:28:34 -0700
From: bowman <bowman@montana.com>
Subject: Re: perl daemon in windows memory hog ?
Message-Id: <aqq70p$c8pc9$1@ID-159066.news.dfncis.de>
James Q.L wrote:
>
> now i need to write a script that monitor the IIS server state and restart
> it when necessary.
> i am going to use Win32::Daemon and leave it on all the time. but i am
> afraid that perl
> will eat much more memory and hog the server..
>
> if you have experience working on this. i would love to hear.
I've never monitored the IIS server, but it is easy to query the SCManager
periodically to get a services's state, and restart it if it isn't
running.You just need to sleep so the script isn't running a tight loop.
You may need to tweak the script's shutdown priority. You want to be sure
the script terminates before the services that support the net calls, or
when the script attempts to query the SCManager you'll get an ugly little
dialog on a shutdown or restart.
------------------------------
Date: Tue, 12 Nov 2002 00:32:18 -0800
From: "Tan Nguyen" <nospam@nospam.com>
Subject: Re: perl daemon in windows memory hog ?
Message-Id: <3dd0bbfb$1_4@nopics.sjc>
"bowman" <bowman@montana.com> wrote in message
news:aqq70p$c8pc9$1@ID-159066.news.dfncis.de...
> James Q.L wrote:
> >
> > now i need to write a script that monitor the IIS server state and
restart
> > it when necessary.
> > i am going to use Win32::Daemon and leave it on all the time. but i am
> > afraid that perl
> > will eat much more memory and hog the server..
Are you going to monitor several IIS servers or just one on a local box?
> >
> > if you have experience working on this. i would love to hear.
> >
I wrote a little monitor in C++ using Win32 API and SCManager to be able to
monitor the servers both locally and remotely.
> I've never monitored the IIS server, but it is easy to query the SCManager
> periodically to get a services's state, and restart it if it isn't
> running.You just need to sleep so the script isn't running a tight loop.
The problem with SCManager is that for some reason IIS doesn't respond while
it's still alive, thus SCManager still sees it as a functioning service. The
only true test is sending HEAD requests to IIS to see if it responds. If
not, you can use RPC calls to shut down the remote server or stop IIS
service on the local box and restart it. I'm not sure if Win32 Perl module
will handle these nicely. It's not too hard to write this stuff in C++ using
Win32 API. If memory serves me right, my stuff took less than 200 lines of
code including emailing when detecting problematic server etc.
> You may need to tweak the script's shutdown priority. You want to be sure
> the script terminates before the services that support the net calls, or
> when the script attempts to query the SCManager you'll get an ugly little
> dialog on a shutdown or restart.
>
>
------------------------------
Date: 12 Nov 2002 05:23:31 -0500
From: yisraelharris <member@mainframeforum.com>
Subject: Perl: string vs. numeric
Message-Id: <3dd0d6a3$1_2@news.onlynews.com>
When I pass an array which contains ('hi', 3) to a function, and
then the function takes each element a builds a string, I get
".....hi 3......".
What I really want is to get ".....'hi' 3....."
For now, I'm passing it ("'hi'", 3) and that works. (That's single
quotes inside double quotes, if it's difficult to discern.)
If there's a better solution, where the function knows that the first
element had quotations and the second doesn't, and proceeds accordingly,
I'd be very grateful if someone could tell me.
If you please: I'd appreciate no advice, comments, questions, etc.
Please direct solutions to this question only. Thank you :)
--
www.MainFrameForum.com - USENET Gateway
------------------------------
Date: Tue, 12 Nov 2002 06:19:53 GMT
From: "Islaw" <islaw@w98.sr>
Subject: Re: saving a cgi file
Message-Id: <d41A9.549$yL2.55045367@newssvr21.news.prodigy.com>
tk wrote:
> -----BEGIN xxx SIGNED MESSAGE-----
> Hash: SHA1
>
> In a fit of excitement on 11 Nov 2002 12:36:32 -0800,
> intlone@hotmail.com (Westy) managed to scribble:
>
>> Rather new to perl! Writing programs in notepad, but having trouble
>> saving them as cgi files, keep saving as text files. Appreciate any
>> suggestions.
>
> UltraEdit32 is a worthwhile look.
>
> Multiple open docs at the same time, more than one view of the file ya
> working on (great to read data from the top of the file if you're
> working near the bottom for example), coloured syntax highlighting (if
> you're into that) etc etc.
>
> Google will shed some more info on it if interested.
>
> There's also PFE (Programmers File Editor) but from what I understand
> from a post the other day, this is now no longer supported.
>
> Can also go crazy and download the DOS/Win port of VIM ;)
Better yet, the win32 GUI version.
ftp://ftp.vim.org/pub/vim/pc/gvim61.exe
--
Islaw
------------------------------
Date: 12 Nov 2002 04:59:00 GMT
From: j.abromeit@jpberlin.de (Jens Abromeit)
Subject: SNMP::Multi: Dereferer syntax to create hash?
Message-Id: <8$kxv59nqwB@enerclim.jpberlin.de>
Hello together,
I want to modify the example script of the module SNMP::Multi.
Aim:
-----
Putt each SNMP object-identifier (called by method
SNMP::Varbind->name() and according responses, (called by method SNMP-
Varbind->val() ) into a hash element of %result_hash.
My trial doesn't work, because the $_ is not filled with a value
(here the dereferd $varlist is missing):
--------------------------------------------------------------------
1 my %result_hash = ();
2 for my $varlist ($result->varlists()) {
3 $result_hash{$_->name()} = $_->val();
Errormessage:
"Can't call method "name" on an undefined value at line [3]..."
--------------------------------------------------------------------
How do I have to derefer the created referer $varlist in my trial so
that it works? Or is this a bad idea at all?
In the original example the $_ is filled by @$varlist: Each elment
of the reference $varlist is taken to $_ once, so that the SNMP::Varbind's
in SNMP::Varlist could be reached:
--------------------------------------------------------------------
1 for my $varlist ($result->varlists()) {
2 print map { "\t" . $_->name() . "\n" } @$varlist;
Otput of this script are SNMP object identifiers as expected:
fbLink1.2
fbLInk1.2
--------------------------------------------------------------------
additional info:
----------------------
$varlist is a reference to the array of SNMP::Varlist, created
by the method ->varlists() from SNMP::Multi
SNMP::VarList
represents an array of MIB objects to get or set,
implemented as a blessed reference to an array of
SNMP::Varbinds, (e.g., [<varbind1>, <varbind2>, ...])
SNMP::Varbind
represents a single MIB object to get or set, imple-
mented as a blessed reference to a 4 element array;
[<obj>, <iid>, <val>, <type>].
Thank you for assistance in advance! And many thanks to the guys who
discussed the script with me already!
Best regards
Jens Abromeit
------------------------------
Date: Tue, 12 Nov 2002 10:10:51 -0000
From: "Rubber Duck" <rubberducky703@hotmail.com>
Subject: Splitting on a line break that isn't
Message-Id: <aqqk1c$ce9ec$1@ID-116287.news.dfncis.de>
I have a CSV file which separates records on a 'square box' character. (its
the best way i can describe it). I'm trying to parse the file on \n but
it's not working. All i get is one BIG line (500k) which is really about
3000 separate records.
Any ideas on how i can successfully parse each record?
------------------------------
Date: 12 Nov 2002 10:14:01 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@post.rwth-aachen.de>
Subject: Re: Splitting on a line break that isn't
Message-Id: <aqqk99$5aj$1@nets3.rz.RWTH-Aachen.DE>
Also sprach Rubber Duck:
> I have a CSV file which separates records on a 'square box' character. (its
> the best way i can describe it). I'm trying to parse the file on \n but
> it's not working. All i get is one BIG line (500k) which is really about
> 3000 separate records.
It's not likely to work if you parse on \n but the separator is in fact
a 'square box' (whatever that is; the ascii code would be helpful)
character. So why not parse on this squarebox instead?
local $/ = 'squarebox character';
while (<FILE>) {
...
}
Tassilo
--
$_=q!",}])(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus;})(rekcah{lrePbus;})(lreP{rehtonabus;})(rehtona{tsuJbus!;
$_=reverse;s/sub/(reverse"bus").chr(32)/xge;tr~\n~~d;eval;
------------------------------
Date: Tue, 12 Nov 2002 10:25:57 -0000
From: "Rubber Duck" <rubberducky703@hotmail.com>
Subject: Re: Splitting on a line break that isn't
Message-Id: <aqqktl$c95e2$1@ID-116287.news.dfncis.de>
I'd love to parse on the "square box" but i don't know and can't find the
ascii code for it. It looks similare to # 219 on http://www.asciitable.com/
except its hollow???
"Tassilo v. Parseval" <tassilo.parseval@post.rwth-aachen.de> wrote in
message news:aqqk99$5aj$1@nets3.rz.RWTH-Aachen.DE...
> Also sprach Rubber Duck:
> > I have a CSV file which separates records on a 'square box' character.
(its
> > the best way i can describe it). I'm trying to parse the file on \n but
> > it's not working. All i get is one BIG line (500k) which is really
about
> > 3000 separate records.
>
> It's not likely to work if you parse on \n but the separator is in fact
> a 'square box' (whatever that is; the ascii code would be helpful)
> character. So why not parse on this squarebox instead?
>
> local $/ = 'squarebox character';
> while (<FILE>) {
> ...
> }
>
> Tassilo
> --
> $_=q!",}])(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
> pam{rekcahbus;})(rekcah{lrePbus;})(lreP{rehtonabus;})(rehtona{tsuJbus!;
> $_=reverse;s/sub/(reverse"bus").chr(32)/xge;tr~\n~~d;eval;
------------------------------
Date: Tue, 12 Nov 2002 11:03:32 GMT
From: tk <tk@WINDOZEdigiserv.net>
Subject: Re: Splitting on a line break that isn't
Message-Id: <svn1tu4ho6m3bd0fsq3d9uul1dbu31fkkn@4ax.com>
In a fit of excitement on Tue, 12 Nov 2002 10:25:57 -0000, "Rubber Duck"
<rubberducky703@hotmail.com> managed to scribble:
| I'd love to parse on the "square box" but i don't know and can't find the
| ascii code for it. It looks similare to # 219 on http://www.asciitable.com/
| except its hollow???
Would I be correct in assuming you're developing this on a windoze box?
IF so, I've got a feeling I had a similar problem writing a program a
lil while back. Instead of using "\n", have you tried "\r"? It solved my
problem =)
HTH.
Regards,
tk
--
+--------------------------+
| digiServ Network |
| Web solutions | Remove WINDOZE to reply.
| http://www.digiserv.net/ |
+--------------------------+
------------------------------
Date: Tue, 12 Nov 2002 16:32:46 +1100
From: Iain Chalmers <bigiain@mightymedia.com.au>
Subject: Re: What is this: "sub myFunc ($$) {"
Message-Id: <bigiain-57AE2E.16324612112002@nasal.pacific.net.au>
In article <3dcbb73a$1_5@news.onlynews.com>,
yisraelharris <member@mainframeforum.com> wrote:
> 3 helpful people have responded -- thanks to you all.
>
> However, I still don't know the answer.
>
> I had actually already read the perlsub documentation under prototypes,
> but I didn't understand it, because it uses a lot of terms with which I
> am unfamiliar. In general, I find the Perl documentation very difficult
> to understand, compared to documentation I have seen on other languages.
>
> Here's how the section on prototyping begins:
>
> Perl supports a very limited kind of compile-time argument checking
> using function prototyping. If you declare
>
> sub mypush (\@@)
>
> then mypush() takes arguments exactly like push() does. The function
> declaration must be visible at compile time. The prototype affects only
> interpretation of new-style calls to the function, where new-style is
> defined as not using the & character.
>
> I don't understand any of this.
>
> Later on, it said this:
>
> Declared as: sub mylink ($$) Called as: mylink $old, $new
>
> I have no idea on earth what this means.
>
> Is there someone out there who can explain it in very simple terms?
>
> So, back to the original question: in
>
> sub myFunc ($$) { ..... }
>
> What does the ($$) do?
the ($$) tells the compiler to expect 2 scalars as arguements to the
function. consider:
sub myFunc ($$) {
my $x=shift;
my $y=shift;
print "I got '$x' and '$y'\n";
}
then:
myFunc 1,2;
prints: I got '1' and '2'
myFunc 1;
gives the error: Not enough arguments for main::myFunc near "1;"
because we only gave it one scalar as an arguement
myFunc 1,2,3;
gives the error: Too many arguments for main::myFunc near "3;"
because we tried to give it 3 scarlars
and
&myFunc(1);
prints: I got '1' and ''
because we used the "old style" function call (with the &) which
bypasses the prototype checking...
The exapmle you've quoted from the perlsub doco shows a sub that takes
an list ref and a list as arguements, and will complain if you try to
give it something else
cheers,
big
------------------------------
Date: Tue, 12 Nov 2002 11:15:59 +0100
From: edgue@web.de
Subject: Re: Windows and nonblocking IO
Message-Id: <3DD0D4DF.60302@web.de>
Hi,
> It's never been true -- as long as you didn't try and use pipes for that
> communication. For example, you could create a socket for the purpose.
I tried that (with the piece of code that you posted here some
month ago.
The "unblocking" seems to work (with Perl 561) - but no output
is produces. With Perl 5.8 it tells me "Couldn't set nonblocking:"
right away.
use IO::Socket;
use IO::Select;
use strict;
use warnings;
BEGIN {
if( $^O eq 'MSWin32' ) {
*EWOULDBLOCK = sub () { 10035 };
*EINPROGRESS = sub () { 10036 };
*IO::Socket::blocking = sub {
my ($self, $blocking) = @_;
my $nonblocking = $blocking ? "0" : "1";
ioctl($self, 0x8004667e, $nonblocking);
};
} else {
require Errno;
import Errno qw(EWOULDBLOCK EINPROGRESS);
}
}
my $localhost = inet_aton("localhost");
my $select = IO::Select->new;
my %ports;
for my $port ( 7070..7072 ) {
my $sock = IO::Socket::INET->new(Proto=>'tcp') or die "socket: $@\n";
# by redefining the 'blocking' method up above,
# this part of the code becomes simple.
defined($sock->blocking(0)) or die "Couldn't set nonblocking: $^E\n";
# You have to put this part *inside* the loop, silly,
# as it depends on the port
my $addr = sockaddr_in($port, $localhost);
$sock->connect($addr) or
$! == EWOULDBLOCK or $! == EINPROGRESS or
die sprintf "connect: %d, %s\n", $!, $^E;
$select->add($sock);
$ports{$sock} = $port;
do_timeouts()
if $select->count() >= 32;
}
my @ports_reached;
sub do_timeouts {
my @reachable = $select->can_write(1)
or print_results(), return;
for my $sock (@reachable) {
my $port = delete $ports{$sock};
if( $! = $sock->sockopt(SO_ERROR) ) {
print "Error reaching $port: $^E";
} else {
push @ports_reached, $port;
}
} $select->remove(@reachable);
}
do_timeouts() while $select->count;
sub print_results {
$select = IO::Select->new();
print "port $_ is reachable\n"
for sort {$a <=> $b} splice @ports_reached;
}
print_results();
__END__
------------------------------
Date: Tue, 12 Nov 2002 11:17:51 +0100
From: edgue@web.de
Subject: Re: Windows and nonblocking IO
Message-Id: <3DD0D54F.40607@web.de>
Hi Rocco,
> IPC::Run is supposed to support it. You may want to look at how it's
> done there.
Nice module; but unfortunately it doesnt like OS/2.
Thx for the other postings; but I guess I will go for a very simple
solution: parent/child have to use flock() to synchronize; communication
is done with a plain text file. Makes debugging easier anyway.
regards,
eg
------------------------------
Date: Tue, 12 Nov 2002 10:57:32 +0000
From: news@roaima.freeserve.co.uk
Subject: Re: xml
Message-Id: <sqmqqa.sdq.ln@moldev.cmagroup.co.uk>
Elvis <esamson@web.de> wrote:
> hi I'm looking for some hints how to convert a xml file (without dtd)
> into a textfile
Two hints are XML::Simple and Text::CSV, both available on CPAN
Chris
--
@s=split(//,"Je,\nhn ersloak rcet thuarP");$k=$l=@s;for(;$k;$k--){$i=($i+1)%$l
until$s[$i];$c=$s[$i];print$c;undef$s[$i];$i=($i+(ord$c))%$l}
------------------------------
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 4102
***************************************