[7095] in Perl-Users-Digest
Perl-Users Digest, Issue: 719 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Jul 11 00:07:27 1997
Date: Thu, 10 Jul 97 21:01:20 -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, 10 Jul 1997 Volume: 8 Number: 719
Today's topics:
Re: "Sourcing" common Perl ENV values <fischer@HL.Siemens.de>
/x /s ......problem (Fan Ng)
Re: /x /s ......problem (Tung-chiang Yang)
Re: 500 Server Error - Perl & Win 95 PWS (Michael Stillwell)
blank lines???? (Fan Ng)
Buffer flushing with IO <oboyle@.cs.purdue.edu>
Re: chdir not working for array <cs@zip.com.au>
Re: chdir not working for array (Tad McClellan)
Re: Checking for HTTP open connection <rootbeer@teleport.com>
concatination <gland@ccs.neu.edu>
Configure CC test fails on AIX 4.2.1 <ppadd@netorb.com>
Dear Spammer! We are NOT happy with you. dc@rabi.phys.columbia.edu
Re: Execute Perlscripts with a command string <rootbeer@teleport.com>
Re: Foreach with lists of arrays (beryte)
Re: Foreach with lists of arrays <ajohnson@gpu.srv.ualberta.ca>
Re: FTP and Perl (Clay Irving)
Re: GIF Control Blocks / Types in perl - unsigned, etc. <support@dwx.com>
h2ph utility in Perl Win32 <ting@platinum.com>
Re: Help me to find my loose change !!! (Matti Kinnunen)
Help with nested loop! (Brian Godden)
Re: Help with nested loop! (M. muPe)
HELP: Activeware's-->Sarathy's Perl: OLE doesn't work a nospam@is.good.spam.com
Re: HELP: Activeware's-->Sarathy's Perl: OLE doesn't wo nospam@is.good.spam.com
Re: How does perl work with Win32?? (etta )
Re: How does perl work with Win32?? <dada@divinf.it>
Re: how to redirect using ` ` (Tad McClellan)
Re: How to substract a uniq integer from a ASCI string (Craig Berry)
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 09 Jul 1997 13:31:13 +0200
From: Horst Fischer <fischer@HL.Siemens.de>
Subject: Re: "Sourcing" common Perl ENV values
Message-Id: <33C37681.F1F172CC@HL.Siemens.de>
Scott Chapman wrote:
>
> New to Perl and dont see much talk about this specifically..
> Any pointers would be appreciated.
>
> Whats the normal Perl way to handle a typical Korn shell
> environment setup, that is shared within a project or runtime env
> without jacketing all the Perl scripts in Shell scripts before
> starting them?
Try this:
#!/bin/sh
# Setup the environment for this shell script command...
# source in my common environment setup, functions, etc.
. set_up_common_env_and_funcs
# other shell stuff follows that uses the ENV, etc provided by the
above.
# Call perl. Note the -x
/usr/local/bin/perl -x ${0} $*
exit
#!perl -w
# other Perl stuff here.
Regards, Horst
--
======================================================================
Horst Fischer Ext. Phone: +49 89-636-28641
Siemens AG FAX: +49 89-636-?????
Semiconductor Div. Internet mailto:fischer@hl.siemens.de
HL CAD FCA X400: c=DE;a=DBP;p=SCN;o=SIEMENS;
MchM s=FISCHER;g=HORST;
R08.222 ou1=MCH2;ou2=P54
======================================================================
------------------------------
Date: Wed, 09 Jul 1997 13:39:07 GMT
From: FANNGMAIL@prodigy.net (Fan Ng)
Subject: /x /s ......problem
Message-Id: <33c6fe60.1867295@news.prodigy.net>
Hi all:
I don't know that what is the slash follow a character means.
just like /x or /s .......
But i know \s or \n or \w.......means.
Can someone tell me that where are they different. and where use the /x /s
.......
Thanks
------------------------------
Date: Thu, 10 Jul 1997 01:52:58 GMT
From: tcyang@netcom.com (Tung-chiang Yang)
Subject: Re: /x /s ......problem
Message-Id: <tcyangED2yKA.1r3@netcom.com>
Check out the Camel book. Hope this helps!
=============================
Fan Ng wrote after zapping the scum of the universe:
: Hi all:
: I don't know that what is the slash follow a character means.
: just like /x or /s .......
: But i know \s or \n or \w.......means.
: Can someone tell me that where are they different. and where use the /x /s
: .......
: Thanks
--
========= Try the low-crossposting robomoderated 'alt.culture.taiwan' ===
soc.culture.taiwan, soc.culture.china (by SCC FAQ Team) FAQ's:
http://www.iglou.com/tcyang/Taiwan_faq.shtml, China_faq.shtml
------------------------------
Date: 9 Jul 1997 09:57:39 GMT
From: mist@yoyo.cc.monash.edu.au (Michael Stillwell)
Subject: Re: 500 Server Error - Perl & Win 95 PWS
Message-Id: <slrn45s6o4j.7dm.mist@aurora.cc.monash.edu.au>
On Tue, 8 Jul 1997 17:56:42 GMT, Abigail <abigail@fnx.com> wrote:
: Michael Adams (msadams@netcom.com) wrote on 1406 September 1993 in
: <URL: news:msadamsECysKy.8E@netcom.com>:
: ++ Abigail (abigail@fnx.com) wrote:
: ++ : Michael Adams (msadams@netcom.com) wrote on 1404 September 1993 in
: ++ : <URL: news:msadamsECv9zp.FDw@netcom.com>:
: ++ : ++
: ++ : ++ It would appear that it is not loading the Perl script.
: ++
: ++ : So, it's not a Perl question. Try a more appropriate group, like
: ++ : rec.pets.penguins, sci.trainspotting, comp.infosystems.www.authoring.cgi,
: ++ : misc.test, comp.infosystems.www.servers.ms-windows or alt.tla.
: ++
: ++ I am sorry to bother you and everyone else on this Usenet with my
: ++ "inappropriate" questions, but I have reached a deadend. I figured if
: ++ anyone would know the answer it would be people on this Usenet.
:
: "This Usenet"? How many other Usenets are there? Sure, there will be
: people on Usenet knowing the answer, just as there are people on this
: planet knowing the answer. But that doesn't mean your question is
: appropriate in a Zairian bar. There might be more than a million people
: having access to Usenet. A couple of hundreds, maybe a thousand post
: in this group. Since this groups is not about servers, it's unreasonable
: to assume there are relatively many people here that can answer your
: question.
As long as people continue to answer questions that were posted to the
wrong newsgroup people will continue to post them. And if this is the
case, responsibility for the resultant clutter lies as much with the
people who post replies as the person who posed the question. But at
least these aren't as annoying as sarcastic (and content-less) replies
to inappropriate messages, especially if the author of such posts also
does make useful posts to the newsgroup. This really screws with
kill-files. Perhaps sarcastic replies should contain an X-Sarcasm:
header.
Michael
--
.. ABSOLUT .SIG. ..
.. Michael Stillwell ..
.. mist@yoyo.cc.monash.edu.au ..
.. http://yoyo.cc.monash.edu.au/~mist/ ..
------------------------------
Date: Wed, 09 Jul 1997 13:40:33 GMT
From: FANNGMAIL@prodigy.net (Fan Ng)
Subject: blank lines????
Message-Id: <33c594be.1447546@news.prodigy.net>
Hi all:
I wrote a HTML file who is excuted by perl. In My HTML has some text in a small
windows(textarea) but when it (HTML)pointed to perl, perl separate my text (in
HTML) whit the blank lines come out ( when I used the browers to view it).
My question how to cancel the blank lines.
help me, Thank you
fanngmail@prodigy.net
------------------------------
Date: 10 Jul 1997 22:14:51 GMT
From: Todd O'Boyle <oboyle@.cs.purdue.edu>
Subject: Buffer flushing with IO
Message-Id: <5q3msr$5lq@ector.cs.purdue.edu>
I have never been the best with understanding perl's buffering
techniques, so here is my question. Can someone explain to me why, when
sent an EOF, this code prints to the socket nicely; without the EOF,
nothing gets sent?
I am under the impression that the $ref->flush(); of IO::Socket
(via IO::Handle) will flush the buffer, thus sending it to the
listen()ing host. It is not happening.
Using perl5.004, and the IO modules that come with it.
Here are some excerpts:
--
package Authd;
sub connect
{
my $self = shift;
my $host = shift;
my $port = shift;
use IO::Socket;
my $self = shift;
$nh = new IO::Socket::INET (
PeerAddr => "$host:$port",
Proto => 'tcp',
Timeout => 10
);
$self->{'nh'} = $nh;
}
sub print
{
my $self = shift;
my $data = shift;
$self->{'nh'}->print($data);
$self->{'nh'}->flush;
}
sub new
{
my $class = shift;
my $hits = shift;
my $self = {
'hits' => $hits,
'hammers_done' => 0,
'nh' => '' ## Our shared network handle.
};
bless $self, $class;
return $self;
}
# ...
1;
--
#!/usr/local/bin/perl -w
use Authd;
$authdRef = new Authd 5;
$authdRef->connect('lore.cs.purdue.edu',9000);
$authdRef->print("eek!\n"); ## Does nothing on the listen()ing
## side.
# $authdRef->print(<STDIN>); ## Works after sending an EOF!
--
cheers,
-Todd
--
Todd O'Boyle - Programmer, Perl Hacker, BMX Rider, etc. -
URL: <a href="http://www.cs.purdue.edu/homes/oboyle/"> My Homepage! </a>
PGP: finger oboyle@cs.purdue.edu
EMAIL: oboyle@purdue.edu
------------------------------
Date: 11 Jul 1997 01:08:49 GMT
From: Cameron Simpson <cs@zip.com.au>
To: "Mike Webb" <mwebb@blue.weeg.uiowa.edu>
Subject: Re: chdir not working for array
Message-Id: <19970711113216-cameron-1-18586@sid.research.canon.com.au>
"Mike Webb" <mwebb@blue.weeg.uiowa.edu> writes:
| and am haveing trouble changing to the dir with the chdir command. This is
| just a test program here taht I am trying out to see if it works:
| .....
| use Cwd;
| open(dirfile,"test.txt");
Try to make your barewords all upper case (thus DIRFILE). This stops them
accidentally conflicting (silently) with subroutine names and keywords.
| @dir = <dirfile>;
Beware, this includes the newlines. Try adding:
for (@dir) { chomp; }
after that line.
| $p = @dir + 0; #count of how many directories in dir.txt
The +0 is unecessary - in a scalar context (assignment to $p) @dir returns
the count anyway.
| $current = getcwd();
|
| for ($k=0; $k<=$p-1; $k++){
| chdir(@dir[$k]);
You want to say
$dir[$k]
This is your bug.
| @files = `ls`;
| print @files;
| }
MUCH faster to say:
for $dir (@dir)
{ if (opendir(DIR,$dir))
{ @files=readdir(DIR);
closedir(DIR);
for (@files) { print "$dir/$_\n"; }
}
}
Ciao,
- Cameron Simpson, cs@zip.com.au, DoD#743
http://www.zip.com.au/~cs/
--
Pred Bundalo (pred@iitmax.acc.iit.edu) wrote:
| P.S. So who's the wiseguy in IL who grabbed up the DOOM plates before me?
That was me, you poser-ovlov-wannabe cowl-rat flunky. Sit down.
- Dave Svoboda, svoboda@ranger.rtsg.mot.com, DoD#0330
recipient by overwhelming acclaim of the coveted 1993
Fourth Annual Iron Horse Joust and Ride *Squid Award*!
------------------------------
Date: Tue, 8 Jul 1997 16:29:34 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: chdir not working for array
Message-Id: <ufbup5.c68.ln@localhost>
Mike Webb (mwebb@blue.weeg.uiowa.edu) wrote:
: I am writting a database program in perl and I have a text file with 729
: directories such as
: f:\news\animals
: f:\news\animals\wildlife
: f:\news\answers
: f:\news\antiques
: f:\news\antiques\bottles
: f:\news\antiques\marketplace
: f:\news\antiques\radio+phono
: and am haveing trouble changing to the dir with the chdir command. This is
: just a test program here taht I am trying out to see if it works:
: ......
: use Cwd;
: open(dirfile,"test.txt");
^^^^^^^
Bare word.
Use the -w switch...
Check your return values:
open(DIRFILE,"test.txt") || die "could not open 'test.txt' $!";
: @dir = <dirfile>;
Don't you want to chomp() off the newlines at the end of each filename?
: $p = @dir + 0; #count of how many directories in dir.txt
???
: $current = getcwd();
: for ($k=0; $k<=$p-1; $k++){
: chdir(@dir[$k]);
^
^
Use the -w switch...
Check your return values (see below)
: @files = `ls`;
: print @files;
: }
# UNTESTED
foreach (@dir) {
chomp;
chdir($_) || die "could not chdir() to '$_' $!";
print `ls`;
}
: ,.......
: When it finishes it just list what is on my c:\ drive and not what is in
: those dir I have above. I am using perl 5 for NT and have not had any other
: problems with changing a dir when not in an array. Any help would be
: appreciated. Also could you CC a copy to my e-mail address becasue our
: news server is slow and crashes when I try to download the post that have
: been posted.
--
Tad McClellan SGML Consulting
Tag And Document Consulting Perl programming
tadmc@flash.net
------------------------------
Date: Wed, 9 Jul 1997 08:47:13 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: "Kevin B. Rich" <kman@cfer.com>
Subject: Re: Checking for HTTP open connection
Message-Id: <Pine.GSO.3.96.970709083659.14216J-100000@kelly.teleport.com>
On Mon, 7 Jul 1997, Kevin B. Rich wrote:
> open(FILE, filename);
You're using a bareword there; using -w will warn you about that. (And do
you really have a file called 'filename'?) More importantly, you're not
checking that the open succeeded.
> while (1) {
> $scalar = ENV{REMOTE_ADDR}; # also tried ENV{'REMOTE_ADDR'}
Maybe you wanted $ENV{REMOTE_ADDR} there.
> .... do file actions here ....
> if ($scalar = 0) { # also tried ($scalar eq "")
That's an assignment you have there. You probably intended to use the
numeric equality test, but that's probably not what you wanted. That
environment variable will normally either be an IP address or undefined.
Maybe you wanted to test whether it was defined, but I'm not sure.
> die;
> }
> $scalar = ""; #to reset the variable
> }
I don't see why you would want to reset the variable; the next iteration
should assign it a value at the top of the loop.
> close(FILE);
Unless your "file actions" included a 'last' statement, you'll be in an
infinite loop, and you'll never reach that close. Did you want to use last
instead of die? That still won't do what I think you want, unless you've
done something to alter that environment variable. (It won't change by
itself.)
> The script works fine except when the user moves on, the script.cgi
> process continues to run on the server.
No doubt because of that infinite loop; there's no way in the CGI spec for
your script to be notified that the user has gotten tired of waiting for
it to finish processing. :-)
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/
------------------------------
Date: 9 Jul 1997 16:34:47 GMT
From: Greg Land <gland@ccs.neu.edu>
Subject: concatination
Message-Id: <5q0ej7$bpf$1@camelot.ccs.neu.edu>
I am aware that the "." is the concatination command in perl... but when I use it although it "looks" correct perl is not acting as I would like.
Here is a short example:
$html = 'http://' . $ARGV[0] unless $ARGV[0] =~ m!^http://!;
$parsed_html = HTML::Parse::parse_html($html);
print "Address: $html"; #this prints what you expect
for (@{ $parsed_html->extract_links() }) {
print "Address: $html"; #This is the error (nothing prints)
$url = new URI::URL $link;
$full_url = $url->abs($ARGV[0]);
print "$full_url\n";
}
This comes out of the "Web Client Programing with Perl" book on page 91.
------------------------------
Date: Wed, 09 Jul 1997 11:56:17 -0700
From: Peter Padd <ppadd@netorb.com>
Subject: Configure CC test fails on AIX 4.2.1
Message-Id: <33C3DED1.DD9C58EB@netorb.com>
Hello all,
I have Perl 5.003 and AIX 4.2.1. When I run sh Configure...it fails on
the test of the cc C compiler. I have cc on the AIX box it is IBM C Set
or AIX. Does anyone know how to fix this. Configure ends each time at
this point even though cc is there...
any suggestions please?
thanks much,
Peter
--
Peter Padd ppadd@netorb.com
Distributed Solutions, Inc. www.netorb.com
1 Sansome Street Suite 2100
San Francisco CA 94104
ph: 415-984-3122
fx: 415-951-4653
------------------------------
Date: Thu, 10 Jul 1997 17:42:50 -0400
From: dc@rabi.phys.columbia.edu
Subject: Dear Spammer! We are NOT happy with you.
Message-Id: <33C5575A.1588@rabi.phys.columbia.edu>
Please do not spam us again. I hope this request is clear enough for
you. If not, you might eventually have to suffer flames and bombs, and
your sysadmins will beat you savagely. I am not making any sort of a
personal threat, of course, I am merely warning you against provocative
behaviour.
Good Day.
>PJ wrote:
>
> $50,000.00 for only $5.00 within 2 MONTHS?????
> ==============================================
>
> You gotta be crazy! How on earth do you think you can buy 50 grand
> for lousy 5 bucks? Well, that's what I was wondering, too until I
> came across this letter.
>
> First of all, IT'S PERFECTLY LEGAL! (Call 1-800-725-2161) if you
> have any questions about the following opportunity to make
> $50,000.00 and that probably WITHIN LESS THAN TWO MONTHS!
>
> Well, here it goes:
.
.
.
> Please remember to declare your extra income. Thanks once again...
------------------------------
Date: Wed, 9 Jul 1997 08:25:43 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Cliff Shaw <cliff@shawfamily.com>
Subject: Re: Execute Perlscripts with a command string
Message-Id: <Pine.GSO.3.96.970709081858.14216F-100000@kelly.teleport.com>
On 8 Jul 1997, Cliff Shaw wrote:
> Does anyone know how I can execute another perlscript within another
> perlscript, including the variables.
Sure; you can use system() or backticks, among other ways.
> i.e. I run script.cgi, how do I call in that script to run
> "counter.cgi?counterfilename"
That's not the name of a Perl script, I'm sure. It sounds as if you want
to call a program by implementing the Common Gateway Interface, so here's
the documentation on that. Hope this helps!
http://hoohoo.ncsa.uiuc.edu/cgi/
--
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/
------------------------------
Date: Wed, 09 Jul 1997 23:31:27 GMT
From: beryte@leb.net (beryte)
Subject: Re: Foreach with lists of arrays
Message-Id: <33c41f3f.5887589@news.telecom.at>
Joshua Gemmell <joshg@ola.bc.ca> wrote:
>But if I try this with a list of arrays, things get screwy.
>
>@List = (['one','two','three'],['a','b','c'],['1','2','3']);
>foreach $Thing (@List) {
> print " This is $Thing\n";
>}
>And the output is...
> This is ARRAY(0x217e738)
> This is ARRAY(0x2180288)
> This is ARRAY(0x21802c4)
Maybe you should use "( )" instead of "[ ]" in this case.
@array1 = ("one", "two", "three");
@array2 = ("a", "b", "c");
@array3 = ("1", "2", "3");
@list_of_arrays = (@array1, @array2, @array3);
foreach $item (@list_of_arrays) {
print "This is $item\n";
}
equals to:
@list_of_arrays = (("one", "two", "three"), ("a", "b", "c"), ("1",
"2", "3"));
foreach $item (@list_of_arrays) {
print "This is $item\n";
}
equals to:
foreach (("one", "two", "three"), ("a", "b", "c"), ("1", "2", "3")) {
print "This is $_\n";
}
Does it help?
beryte
------------------------------
Date: Wed, 09 Jul 1997 20:30:20 -0500
From: Andrew Johnson <ajohnson@gpu.srv.ualberta.ca>
Subject: Re: Foreach with lists of arrays
Message-Id: <33C43B2C.44E1F7D1@gpu.srv.ualberta.ca>
Joshua Gemmell wrote:
>
> Howdy,
>
> Is it possible to iterate through a list of arrays and get the whole
> array? For example, iterating through a list of scalars goes like this:
>
[snip]
> But if I try this with a list of arrays, things get screwy.
>
> @List = (['one','two','three'],['a','b','c'],['1','2','3']);
> foreach $Thing (@List) {
> print " This is $Thing\n";
> }
>
> And the output is...
> This is ARRAY(0x217e738)
> This is ARRAY(0x2180288)
> This is ARRAY(0x21802c4)
>
dereference $Thing:
@List = (['one','two','three'],['a','b','c'],['1','2','3']);
foreach $Thing (@List) {
print " This is @{$Thing}\n";
}
you could also set up an inner loop through each element of @{$Thing}
if you wanted..
hope it helps
regards
andrew
------------------------------
Date: 9 Jul 1997 17:03:43 -0400
From: clay@panix.com (Clay Irving)
Subject: Re: FTP and Perl
Message-Id: <5q0ubf$2vu@panix.com>
In <1997Jul9.150031.5598@galileo.cc.rochester.edu> Joshua Pincus <froboz@roundtable.cif.rochester.edu> writes:
>I need to write an automated FTP program in Perl. The program needs to be able
>to communicate with the remote FTP daemon in the language spelled out in
>RFC959.
>I'll be honest and tell you that I have never written a socket-based Perl
>program before. It doesn't look hard, and I know that there is plenty of info
>in the Perl FAQ. My question is this: Hooking up with the daemon doesn't look
>bad, but I have absolutely NO idea how I can implement the data stream in FTP
>to actually GET the data from one place to the other.
>Anyone have some suggestions? Any help would be greatly appreciated.
Perl Modules are your friend.
Get Net::FTP at CPAN
<http://perl.com/CPAN/modules/by-module/Net/libnet-1.05.tar.gz>
Look at: http://www.panix.com/~clay/perl/module.cgi?Net::FTP
--
Clay Irving See the happy moron,
clay@panix.com He doesn't give a damn,
http://www.panix.com/~clay I wish I were a moron,
My God! Perhaps I am!
------------------------------
Date: Tue, 08 Jul 1997 17:03:25 -0500
From: DWX <support@dwx.com>
To: "M. muPe" <mupe@desk.nl>
Subject: Re: GIF Control Blocks / Types in perl - unsigned, etc.
Message-Id: <33C2B92C.D7568615@dwx.com>
M. muPe wrote:
> I'm at the moment also into gif mixing.
> First of all note where the Graphic Control Block is placed between
> other
> blocks. Secondly take care this block is at the right offset.
> (previous color table is correct size, and so on)
> And this is what anyhow works (just like you did only a little more
> readable) ;
>
> # Graphic Control Extension block
> $graphCtrE = chr(33) ;
> $byte2 = chr(249) ;
> $byte3 = chr(04) ;
> $graphCtrE = $graphCtrE . $byte2 . $byte3 ;
> $packet3 = pack("B8", "00000000") ;
> $delaytime = pack("S", 00) ;
> $transpar = chr(00) ;
> $end = chr(00) ;
> $graphCtrE = $graphCtrE . $packet3 . $delaytime . $transpar . $end ;
>
> Hope it helps,
>
> Mathilde muPe
Actually, you're all too right - your code does EXACTLY the same thing
mine does, introduce a delay which is too long. I changed your
$delaytime = pack("S", 00);
to
$delaytime = pack("S", 50);
and used your code. My delay still comes across as 256 * 50, or 12800
hundredths of a second.
Could this be some sort of bug? Except for the delay time fields in my
control blocks, everything is EXACTLY as it should be...
I'm running straight 5.000:
% perl -v
This is perl, version 5.000
Thanks,
Josh Kortbein
------------------------------
Date: Wed, 9 Jul 1997 17:46:44 -0500
From: "Wen Ting" <ting@platinum.com>
Subject: h2ph utility in Perl Win32
Message-Id: <5q14b7$9pr$1@news.platinum.com>
Is utility h2ph (convert a C header file to Perl header) available in Perl
Win32 environment?
Is the file generated by this utility in UNIX portable to Win32?
wen
------------------------------
Date: 09 Jul 1997 17:06:58 +0300
From: matti@universe.pc.helsinki.fi (Matti Kinnunen)
Subject: Re: Help me to find my loose change !!!
Message-Id: <lzhge49v5p.fsf@universe.pc.helsinki.fi>
Rounding to 2 decimal places
print int(($num + 0.005) *100) / 100;
--
- matti -
* matti.kinnunen@helsinki.fi
* +358-9-191 23978 / 621 44 02
* Ratakatu 11-13 B 19, 00120 Helsinki
* Finland
------------------------------
Date: 10 Jul 1997 23:52:24 GMT
From: bgodden@jamaica.next.com (Brian Godden)
Subject: Help with nested loop!
Message-Id: <5q3sjo$c9s$1@news.apple.com>
Keywords: nested loop
Hi,
Sorry if this is too simple of a question for this forum, I'm in a bit of
a crunch and have no one around at the time to get a second set of eyes on
my script.
I have two nested loops, the outside loop reads the first line of it's
file and the inside loop completes the reading of it's entire file, then
the outside loop does not continue to read the rest of it's file.
I know I'm missing something obvious here, can anyone help? Here is the
script:
Thanks in advance!
Brian Godden
#!/usr/bin/perl
#checks list of duplicate hosts against dns for subnet 4
open(DUPS,"./hostlist") || die "cannot open file for reading";
open(HOSTS,"./subnet4_hosts") || die "cannot open /etc/hosts";
open(OUT,">>./hostsfound") || die "cannot create output file";
$count = 0;
while(<DUPS>)
{
chop;
$duphost = $_;
while(<HOSTS>)
{
print "$duphost\n";
chop;
$host = $_;
if ($host =~ /'$duphost'/ && $host =~
/129\.18\.4\.[0-9]*/)
{
print OUT "$host\n";
print "$host\n";
$count++;
}
}
}
print "There are $count duplicate hosts in subnet 4\n";
------------------------------
Date: Fri, 11 Jul 1997 02:01:24 GMT
From: mupe@desk.nl (M. muPe)
Subject: Re: Help with nested loop!
Message-Id: <5q40tq$fdl$1@news2.xs4all.nl>
Keywords: nested loop
In article <5q3sjo$c9s$1@news.apple.com>, bgodden@next.com wrote:
>I have two nested loops, the outside loop reads the first line of it's
>file and the inside loop completes the reading of it's entire file, then
>the outside loop does not continue to read the rest of it's file.
>
>I know I'm missing something obvious here, can anyone help? Here is the
>script:
>
>Thanks in advance!
>Brian Godden
>
>#!/usr/bin/perl
>
>#checks list of duplicate hosts against dns for subnet 4
>
>
>open(DUPS,"./hostlist") || die "cannot open file for reading";
>open(HOSTS,"./subnet4_hosts") || die "cannot open /etc/hosts";
>
>open(OUT,">>./hostsfound") || die "cannot create output file";
>$count = 0;
>while(<DUPS>)
>{
>chop;
>$duphost = $_;
> while(<HOSTS>)
> {
> print "$duphost\n";
> chop;
> $host = $_;
> if ($host =~ /'$duphost'/ && $host =~
>/129\.18\.4\.[0-9]*/)
> {
> print OUT "$host\n";
> print "$host\n";
> $count++;
> }
> }
>}
I see 2 mistakes;
You read two files. After reading 1 line from DUPS you read
through the entire file HOSTS and then while HOSTS file index
is still at the end you continue to the same routine with line 2 of DUPS
Secondly the matching line $host = ~ /'$duphost'/ ..
[0-9]* does only match none upto to many occurences of
the same digit. And why quotes around '$duphost'?
This might solve it;
while(<HOSTS>) {
print "$duphost\n";
chop;
$host = $_;
if ($host =~ /$duphost/ && $host =~ /129\.18\.4\.\d+/ ) {
print OUT "$host\n";
print "$host\n";
$count++;
}
}
seek(HOSTS, 1 ,0) # set the file pointer back to the begin of file
Hope it helps,
Mathilde muPe
------------------------------
Date: Thu, 10 Jul 1997 04:03:08 GMT
From: nospam@is.good.spam.com
Subject: HELP: Activeware's-->Sarathy's Perl: OLE doesn't work anymore.
Message-Id: <33c459e2.11877008@news1.radix.net>
X-No-Archive: yes
I am running NT4.0 (SP3) on an Intel box and have MS Office 97 SBE
installed.
I installed Activeware's Perl for Win32 (v5.003_7). The OLE
Automation test scripts excel1.pl and excel2.pl ran fine.
I deleted the Activeware installation, removed the associated registry
entries (the ones installed by install.bat) and installed Sarathy, et
al's port of Perl 5.004 to NT. I couldn't get the following to work:
use Win32::OLE;
$application = new Win32::OLE 'Excel.Application' || die "oops\n";
That statement does not die but...
In the new constructor of \perl\lib\site\win32\ole.pm, CreateObject
fails everytime: (I verified this with print statements.)
sub new {
my( $object );
my( $c ) = shift;
my( $type ) = shift;
if ( CreateObject( $type, $object ) ) {
return $object;
} else {
return undef;
}
}
Does anyone know why this is happening or what could be wrong with my
installation? Excel otherwise runs fine and I have tested the perl
installation by running the test script of Dada's Win32::Internet.
TIA,
Bud
Please delete the caps to respond.
geoMAPSdesic@radONix.net
------------------------------
Date: Thu, 10 Jul 1997 04:18:41 GMT
From: nospam@is.good.spam.com
Subject: Re: HELP: Activeware's-->Sarathy's Perl: OLE doesn't work anymore.
Message-Id: <33c461d8.13914097@news1.radix.net>
On Thu, 10 Jul 1997 04:03:08 GMT, nospam@is.good.spam.com wrote:
> snipped
>In the new constructor of \perl\lib\site\win32\ole.pm, CreateObject
>fails everytime: (I verified this with print statements.)
>
>sub new {
> my( $object );
> my( $c ) = shift;
> my( $type ) = shift;
> if ( CreateObject( $type, $object ) ) {
> return $object;
> } else {
> return undef;
> }
>}
>snipped
In the code above, CreateObject still fails when I code
CreateObject(Excel.Application, $object)
or CreateObject('Excel.Application', $object)
or CreateObject("Excel.Application", $object)
to be sure the proper argument is passed.
TIA,
Bud
Please delete the caps to respond.
geoMAPSdesic@radONix.net
------------------------------
Date: Tue, 08 Jul 1997 23:49:33 GMT
From: etta@fyi.com (etta )
Subject: Re: How does perl work with Win32??
Message-Id: <33c2d195.3998011@netnews.worldnet.att.net>
Did you set up the .pl extension in your web server? The server has to
know how to run .pl or .cgi extensions. What web server are you using?
etta
On Wed, 09 Jul 1997 00:16:35 -0700, Spin <spin@cyberlab.nl> wrote:
>I am new for using Perl. After I installd Perl to my computer which is
>running NT4.0, I wrote a test.pl 'print "Hello, is it OK?\n";'. It
>worked ok at the command line. But when I wrote a HTML code as '<a
>href="/cgi-bin/test.pl">test</a>' and run it on Netscape, it didn't work
>correctly. Can anybody tell me what wrong here. By the in IIS I give dir
>'cgi-bin' execute right.
>
>Thanks!
>
>John
------------------------------
Date: Wed, 09 Jul 1997 17:20:24 +0200
From: Aldo Calpini <dada@divinf.it>
To: Spin <spin@cyberlab.nl>
Subject: Re: How does perl work with Win32??
Message-Id: <33C3AC38.57EE9605@divinf.it>
Spin wrote:
>
> I am new for using Perl. After I installd Perl to my computer which is
> running NT4.0, I wrote a test.pl 'print "Hello, is it OK?\n";'. It
> worked ok at the command line. But when I wrote a HTML code as '<a
> href="/cgi-bin/test.pl">test</a>' and run it on Netscape, it didn't
> work correctly. Can anybody tell me what wrong here. By the in IIS I
> give dir 'cgi-bin' execute right.
Hi John,
you may want to add this first line to your test.pl:
print "Content-type: text/html\n\n";
Bye,
Aldo Calpini
---/\-----------------------------------------------------------
--/ \--------------------------------- mailto:dada@divinf.it --
-<dada>-- POPULUS VULT DECIPI, -------- mailto:sis@divinf.it ---
--\ /------- ERGO DECIPIATUR --------- http://sis.divinf.it ---
---\/-----------------------------------------------------------
------------------------------
Date: Wed, 9 Jul 1997 15:42:30 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: how to redirect using ` `
Message-Id: <m3t0q5.6r5.ln@localhost>
aarhus (raarhus@bme.unc.edu) wrote:
: I used ` ` to execute a command which outputs to the screen. Then I
: tried redirect it to a file. e.g.
: ` $cmmd $infile >& $outfile `;
: I found that perl couldn't recognize the redirection symbol. Could
: anyone tell how I can redirect output? Thanks a lot
RTFM
from the Perl FAQ, note my underlining with ^^^^:
-----------------------------
=head2 How can I capture STDERR from an external command?
There are three basic ways of running external commands:
system $cmd; # using system()
$output = `$cmd`; # using backticks (``)
open (PIPE, "cmd |"); # using open()
With system(), both STDOUT and STDERR will go the same place as the
script's versions of these, unless the command redirects them.
Backticks and open() read B<only> the STDOUT of your command.
With any of these, you can change file descriptors before the call:
open(STDOUT, ">logfile");
system("ls");
or you can use Bourne shell file-descriptor redirection:
$output = `$cmd 2>some_file`;
open (PIPE, "cmd 2>some_file |");
You can also use file-descriptor redirection to make STDERR a
duplicate of STDOUT:
$output = `$cmd 2>&1`;
open (PIPE, "cmd 2>&1 |");
Note that you I<cannot> simply open STDERR to be a dup of STDOUT
in your Perl program and avoid calling the shell to do the redirection.
This doesn't work:
open(STDERR, ">&STDOUT");
$alloutput = `cmd args`; # stderr still escapes
This fails because the open() makes STDERR go to where STDOUT was
going at the time of the open(). The backticks then make STDOUT go to
a string, but don't change STDERR (which still goes to the old
STDOUT).
Note that you I<must> use Bourne shell (sh(1)) redirection syntax in
^^^^^^^^^^^^^^^^ ^^^^^^
^^^^^^^^^^^^^^^^ ^^^^^^
backticks, not csh(1)! Details on why Perl's system() and backtick
^^^^^^^
^^^^^^^
and pipe opens all use the Bourne shell are in
http://www.perl.com/CPAN/doc/FMTEYEWTK/versus/csh.whynot .
You may also use the IPC::Open3 module (part of the standard perl
distribution), but be warned that it has a different order of
arguments from IPC::Open2 (see L<IPC::Open3>).
-----------------------------
--
Tad McClellan SGML Consulting
Tag And Document Consulting Perl programming
tadmc@flash.net
------------------------------
Date: 10 Jul 1997 21:57:14 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: How to substract a uniq integer from a ASCI string
Message-Id: <5q3lrq$rhe$1@marina.cinenet.net>
Toutatis (toutatis@remove.this.toutatis.net) wrote:
: Could anybody advise me on how to create from a given string
: an integer that somehow is (quite) unique for that character string?
If you remove the uniqueness requirement, you're asking for a hashing
algorithm. If you insist on uniqueness, you're asking (effectively) for
a compression algorithm. Researching whichever of these is appropriate
might be a copious source of ideas for you.
: I came up with the following solution myself in perl:
:
: foreach(unpack('C*',$string)){
: $code += $_;
: }
:
: It simply returns the sum of all ASCI values.
Exactly; I've seen primitive hash tricks that used something like this,
though it's highly suboptimal for that particular application.
: but this way, toutatis results in the same code as titatous. I need
: something less easy to "crack" than this.
If what you really need is not uniqueness (non-lossy compression) but
rather a key which is unlikely to be in common with other strings in your
data set (hashing), then modulo-multiplication might work reasonably well:
$limit = 1000; # You can tweak this number up to INT_MAX.
$code = $limit - 1;
foreach(unpack('C*',$string)){
$code *= $_;
$code %= $limit;
}
This does poorly on short strings, but as your min length seems to be 97
(see below), that's not an issue.
The result is that each string is assigned a number from 0 to 999 (or
$limit-1, for whatever $limit you use in the commented line above), and
similar-looking strings will normally yield very different numbers.
You can make hashing arbitrarily clever; this is definitely a
dain-bramaged variant, but may be good enough depending on your
particular needs.
: And my returned codes vary from string-length * 97 to string-length * 122,
: where I prefer to use the *complete* integer "spectrum" to represent this
: string.
If by "complete integer spectrum" you mean the range of a normal unsigned
integer on your archtecture, say 0..(2**32 - 1), *and* you demand
uniqueness, you're in trouble...
: Although I prefer the returned code to be an integer, a fixed width string of
: say 6 characters would be fine too.
...because a (say) 100-byte string is effectively a 100-digit number in
base 256, with a truly awe-inspiring range of potential values, and
there's just no way to compress an aribtrary number of that size into a
dword integer, a six-character string, or *anything* smaller than 100
characters while maintaining uniqueness. Compression algorithms will
yield much shorter strings on average, but a few *longer* than 100
characters. Even if you limit each byte to being alphanumeric or space,
that's still 63 potential values, and the 100-character string is still a
100-digit number in base 63.
See the problem?
---------------------------------------------------------------------
| Craig Berry - cberry@cinenet.net
--*-- Home Page: http://www.cinenet.net/users/cberry/home.html
| Member of The HTML Writers Guild: http://www.hwg.org/
"Every man and every woman is a star."
------------------------------
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 719
*************************************