[9579] in Perl-Users-Digest
Perl-Users Digest, Issue: 3173 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jul 16 04:07:13 1998
Date: Thu, 16 Jul 98 01:00:59 -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, 16 Jul 1998 Volume: 8 Number: 3173
Today's topics:
Re: "uniq -c"-like script (Craig Berry)
Re: anyone working on CDO or CDONTS module? (Martien Verbruggen)
Re: anyone working on CDO or CDONTS module? (Jan Dubois)
Re: AWK Interpreter (Martien Verbruggen)
Re: Better way of saying this. (Andrew M. Langmead)
Re: Better way of saying this. (Abigail)
Re: client/server help (Mark Maurer)
Closing pipes results in "uninitialized value" (Miguel Cruz)
Re: Closing pipes results in "uninitialized value" (Miguel Cruz)
Re: Closing pipes results in "uninitialized value" (Larry Rosler)
Re: Closing pipes results in "uninitialized value" (Miguel Cruz)
RE: Config PWS; Edit Registry? <lefever@interport.net>
Re: copying softlinks (David A. Black)
Re: CRYPT on win32 <ismkoehlerism@nmism-us.campus.mci.net>
databases on a Unix platform <jeoff.remove@geocities.com>
Re: m//g strange behaviour ? <desar@club-internet.fr>
Re: mail bomber source code for perl. (Craig Berry)
Re: mail bomber source code for perl. (Ronald J Kimball)
Newbie question <jjune@ibm.net>
Re: Newbie question <pgunn01@ibm.net>
Re: Newbie question (Martien Verbruggen)
Re: Newbie question (Larry Rosler)
Re: Newbie: standard input/ouput (Craig Berry)
OFFTOPIC: Re: HELP: Internet Database Design questions. (C. Abney)
Re: OLE under Win32 (Jan Dubois)
Re: pattern matching with an = (Ronald J Kimball)
persistent objects (looper)
Re: Please Help Me! (Matt's Script BB Problem) Sniper308@qconline.com
Re: Recipient Validation <metcher@spider.herston.uq.edu.au>
Re: RegExps: Check if string consists of EXACTLY 3 digi (Abigail)
Re: Restricting refering domains access to script? (Martien Verbruggen)
Re: Restricting refering domains access to script? (Abigail)
Re: SMB and Timestamps (Leslie Mikesell)
Re: Using Perl with DCOM (Jan Dubois)
Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 16 Jul 1998 05:32:49 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: "uniq -c"-like script
Message-Id: <6ok3a1$7j6$4@marina.cinenet.net>
Sweth Chandramouli (sweth-usenet@astaroth.nit.gwu.edu) wrote:
: i have a bunch of files that are, in effect, the output of a series of
: "uniq -c" commands run on other files: the first two (tab-separated)
: columns are data, and the third column is a numerical count of the number
: of times that that particular data pair appeared in the other file. i
: need to take these files and come up with an overall count of how many
: times each data pair appeared in all of the initial files.
: for example, for a file like this:
:
: aaa bbb 3
: aaa bbb 11
: bbb aaa 3
: bbb ddd 5
: bbb ccc 2
: bbb ccc 5
: ddd aaa 5
: ddd bbb 2
: ddd bbb 18
:
: i need to be able to generate this:
:
: aaa bbb 14
: bbb aaa 3
: bbb ddd 5
: bbb ccc 7
: ddd aaa 5
: ddd bbb 20
This should do the trick (modified to work on your files, rather than
DATA, and \t rather than \s+ column separators if needed):
#!/usr/bin/perl -w
# uniqc - script in response to clpm request
# Craig Berry (19980715)
use strict;
my %totals = ();
while (<DATA>) {
my ($key, $val) = m/(\w+\s+\w+)\s+(\d+)/;
$totals{$key} += $val;
}
foreach my $key (sort keys %totals) {
print "$key\t$totals{$key}\n";
}
__DATA__
aaa bbb 3
aaa bbb 11
bbb aaa 3
bbb ddd 5
bbb ccc 2
bbb ccc 5
ddd aaa 5
ddd bbb 2
ddd bbb 18
---------------------------------------------------------------------
| 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: 16 Jul 1998 05:16:07 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: anyone working on CDO or CDONTS module?
Message-Id: <6ok2an$7hq$1@nswpull.telstra.net>
In article <t067gzx94t.fsf@hcirisc.cs.binghamton.edu>,
Tim Gray <tim@hcirisc.cs.binghamton.edu> writes:
> I don't think my question was off-topic or an FAQ or anything else
> deserving a rude response so I would appreciate it if you would not
> jump down my throut for no apparent reason.
Gosh, you're sensitive. You didn't mention in your original post that
you had checked CPAN and ActiveState's site, so I pointed out that
they might have information. I didn't say you were being off topic.
I wasn't being rude. I didn't call names. I didn't tell you to go
away. Nothing like that.
I just wondered why you considered one MS specific thing more or less
propietory than another. You have explained that. Fine.
Do yourself a favour. Don't read everything as an attack.
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | "In a world without fences,
Commercial Dynamics Pty. Ltd. | who needs Gates?"
NSW, Australia |
------------------------------
Date: Thu, 16 Jul 1998 09:24:29 +0200
From: jan.dubois@ibm.net (Jan Dubois)
Subject: Re: anyone working on CDO or CDONTS module?
Message-Id: <35b0a734.3799803@news2.ibm.net>
[mailed & posted]
Tim Gray <tim@hcirisc.cs.binghamton.edu> wrote:
>mgjv@comdyn.com.au (Martien Verbruggen) writes:
>
>> In article <t0ww9gjely.fsf@hcirisc.cs.binghamton.edu>,
>> Tim Gray <tim@hcirisc.cs.binghamton.edu> writes:
>> > At work we use MS Exchange and I would really like to get some more
>> > functionality out of it. But the way most people do that is with
>> > Outlook forms and other unfriedly or highly proprietary and costly
>> > solutions. So I was wondering if anyone is working on a module to use
>>
>> How is Outlook any more proprietory and costly than Exchange?
>
>Re-read the post. I am talking about getting information out of
>exchange. I am not making a comparison of exchange and outlook.
>Outlook forms are more proprietary than CDO because they are
>completely non-portable. CDO is an API which could be accessed
>through many programming languages. Some costly solution could be
>from the companies who have partnered with Microsoft to provide
>exchange solutions as opposed to a perl solution.
I would assume that CDO provides an OLE Automation interface, in which
case you could use Win32::OLE to access the API. I once tried to look
for any information about CDO but couldn't find anything on Microsofts
pages.
[snip]
>I don't think my question was off-topic or an FAQ or anything else
>deserving a rude response so I would appreciate it if you would not
>jump down my throut for no apparent reason.
If you think Martiens response was rude then you need to get out more
often! :-) He was just asking some "obvious" questions which only appear
rude to you because you *did* consider them beforehand.
-Jan
------------------------------
Date: 16 Jul 1998 06:48:55 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: AWK Interpreter
Message-Id: <6ok7on$bj7$2@nswpull.telstra.net>
In article <6ojnp0$vt$1@news.wolsi.com>,
"David Reynolds" <irisbeau@wolsi.com> writes:
> I am learning Perl and have have programmed a great deal in AWK. I was
> looking for a perl program that converted AWK code to Perl. I would like to
> see the differences between the two.
There's one that comes with perl, called a2p
# man a2p
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | For heaven's sake, don't TRY to be
Commercial Dynamics Pty. Ltd. | cynical. It's perfectly easy to be
NSW, Australia | cynical.
------------------------------
Date: Thu, 16 Jul 1998 05:16:26 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: Better way of saying this.
Message-Id: <Ew69BE.Fur@world.std.com>
"David Thompson" <domainsource@usa.net> writes:
>$teststring = "something"
>$allowed = "";
>@allowed = qw (mary joe bob);
>foreach $keystring (@allowed)
> {
> if ($teststring =~ /$keystring/i) {$allowed = "yup";}
> }
>unless ($allowed eq "yup") {die "Sorry, not found";}
>----------
>Now, is there an easier way to do that without a foreach? Thanks much!
Take a look at the FAQ entry "How do I efficiently match many patterns
at once"
<URL:http://www.perl.com//CPAN/doc/manual/html/pod/perlfaq6/How
_do_I_eficiently_match_many_.html>
--
Andrew Langmead
------------------------------
Date: 16 Jul 1998 05:39:28 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Better way of saying this.
Message-Id: <6ok3mg$d76$1@client3.news.psi.net>
David Thompson (domainsource@usa.net) wrote on MDCCLXXX September
MCMXCIII in <URL: news:6ojqkt$6nk$1@winter.news.erols.com>:
++ I have a feeling that I'm carrying C++ to far into Perl here and I'm
++ missing a good way of doing things.
++ I have a list of keywords and a string. I need to see if any of the
++ keywords are in the string.
Even C++ programmers can read the faq!
Abigail
--
perl -wle 'print "Prime" if (0 x shift) !~ m 0^\0?$|^(\0\0+?)\1+$0'
------------------------------
Date: 16 Jul 1998 06:01:02 GMT
From: mwmaurer@pace1.cts.mtu.edu (Mark Maurer)
Subject: Re: client/server help
Message-Id: <slrn6qr5u7.arh.mwmaurer@pace1.cts.mtu.edu>
In article <6oiphe$1m5$1@ultranews.duc.auburn.edu>, Joseph M Carlton wrote:
>I'm working with the client and server examples on pages 349-354 of
>Programming Perl. I can't get them to run without errors. I know that I
>need to change stuff, but it is not real clear what I need to change to
>get it to work on my system. For example, I get an error on the line
>$rendezvous = shift || '/tmp/catsock'; because /tmp/catsock does not exist.
>What is this file? What should be in it? I'm also getting the following
>errors on my server:
>Global symbol "paddr" requires explicit package name at server2.perl line 27.
>Global symbol "waitedpid" requires explicit package name at server2.perl
>line 43.
>Variable "$waitedpid" is not imported at server2.perl line 45.
>Global symbol "waitedpid" requires explicit package name at server2.perl
>line 45.
First off, there are many examples in those pages, so telling us exactly
which one may help a little more.
Second, the /tmp directory on unix machines is usually just that, a place for
temporary files. So /tmp/catsock probably doesn't exist on most machines.
But in any case, it looks like you are using the unix-domain socket example.
In the book, you can place any file in place of /tmp/catsock. Someone
correct me if I am wrong, but the file will just have to exist and be empty
to be used for unix-domain sockets.
Try running the command "touch /tmp/catsock", and see what happens. Touching
up your unix knowledge may help, as well as searching the net for information
on sockets, but internet domain and unix domain style...
As for your other errors, get ahold of a copy of "programming perl", or check
the perl website, to see what the errors mean and how to correct them. But I
suggest checking over your code to make sure it is exactly like the code in
the book first.
--
Mark Maurer markm@dct.com mwmaurer@mtu.edu
Programmer, Digital Magic Interactive http://www.dminteractive.com
Senior, Michigan Technological University Houghton, MI
-- Views do not represent those of my employer or school
------------------------------
Date: 16 Jul 1998 06:39:53 GMT
From: mnc@diana.law.yale.edu (Miguel Cruz)
Subject: Closing pipes results in "uninitialized value"
Message-Id: <6ok77p$4ff$1@news.ycc.yale.edu>
I asked about this a few days ago but ended up working around the problem.
Now I see it's a sufficiently big problem that I can't get anything else
done. Anyone who has any insights will have earned their way into my heart.
Whenever I close a descriptor that was a pipe opened for reading, I get the
following three error messages:
Use of uninitialized value at blah blah, <PIPE> chunk blah
Use of uninitialized value at blah blah, <PIPE> chunk blah
Unable to create sub named "" at blah blah, <PIPE> chunk blah
Previously this was happening on the final read, now it's moved inexplicably
to the close.
This only happens if the descriptor was opened as part of a method; if it's
just in a plain old Perl program, everything works fine.
Any ideas? Thanks.
miguel
------------------------------
Date: 16 Jul 1998 07:01:49 GMT
From: mnc@diana.law.yale.edu (Miguel Cruz)
Subject: Re: Closing pipes results in "uninitialized value"
Message-Id: <6ok8gt$5ti$1@news.ycc.yale.edu>
Miguel Cruz <mnc@diana.law.yale.edu> wrote:
> Whenever I close a descriptor that was a pipe opened for reading, I get the
> following three error messages:
>
> Use of uninitialized value at blah blah, <PIPE> chunk blah
> Use of uninitialized value at blah blah, <PIPE> chunk blah
> Unable to create sub named "" at blah blah, <PIPE> chunk blah
The plot thickens. I indeed get those error messages when running an older
version of Perl:
This is perl, version 5.003 with EMBED
But after I decided it just had to be a bug in perl rather than with my
gorgeous and flawless code, and upgraded to this version:
This is perl, version 5.004_04 built for i386-linux
my program just segfaulted instead. It also dumps core on a Sun with this
perl:
This is perl, version 5.004_01
The inconsistency between the two versions leads me to believe that there is
indeed some sort of problem with perl. (I find hubris to be a very useful
diagnostic tool). If it will be faster, I would be willing to migrate my
development to another language - I have heard high praise for python and
tcl, though I don't know the first thing about either. All I want is
rudimentary OO support, decent text manipulation, and good interaction with
the OS. Any recommendations?
For the curious, here's the new problem code:
sub processExists {
local $pr = pop (@_);
$found = 0;
open(PIPE, "ps -ax 2>&1 |");
while (<PIPE>) {
if ($_ =~ /\s*\S+\s+\S+\s+\S+\s+\S+\s+(\S*$pr\S*)/) {
$found = 1;
last;
}
}
close PIPE; ## it dies on this line in perl 5.003
$found;
}
miguel
------------------------------
Date: Thu, 16 Jul 1998 00:28:44 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Closing pipes results in "uninitialized value"
Message-Id: <MPG.10174b8771c8ffeb98974b@nntp.hpl.hp.com>
[This followup was posted to comp.lang.perl.misc and a copy was sent to
the cited author.]
In article <6ok8gt$5ti$1@news.ycc.yale.edu> on 16 Jul 1998 07:01:49 GMT,
Miguel Cruz <mnc@diana.law.yale.edu> says...
...
> sub processExists {
> local $pr = pop (@_);
> $found = 0;
> open(PIPE, "ps -ax 2>&1 |");
> while (<PIPE>) {
> if ($_ =~ /\s*\S+\s+\S+\s+\S+\s+\S+\s+(\S*$pr\S*)/) {
> $found = 1;
> last;
> }
> }
> close PIPE; ## it dies on this line in perl 5.003
> $found;
> }
You check the success of neither the open nor the close. What happens if
you do?
open ... or die "Couldn't ... $!."
close ... or die "Couldn't ... $!."
You should also use 'my $pr' and 'my $found' though those aren't the
problem. $pr picks up the last argument. What if there are none?
--
Larry Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 16 Jul 1998 07:54:09 GMT
From: mnc@diana.law.yale.edu (Miguel Cruz)
Subject: Re: Closing pipes results in "uninitialized value"
Message-Id: <6okbj1$91k$1@news.ycc.yale.edu>
Larry Rosler <lr@hpl.hp.com> wrote:
> You check the success of neither the open nor the close. What happens if
> you do?
Same thing; the open succeeds and the pipe reads all go fine. Then it
segfaults in the process of doing the close() and never gets to the die.
miguel
------------------------------
Date: Thu, 16 Jul 1998 01:16:54 -0400
From: Larry LeFever <lefever@interport.net>
Subject: RE: Config PWS; Edit Registry?
Message-Id: <35AD8CC6.1B9AD7B0@interport.net>
I understand that I need to edit the Registry (Windows 95) in order to
get Personal Web Server to process a Perl script (via localhost,
incidentally).
I've seen a couple of examples of how to do it, but I'm squeamish about
editing the Registry (I've never done it before).
So, first of all, does editing the Registry actually solve the problem
in question?
And, if so, then can someone give me very precise instructions on how
best to do it?
------------------------------
Date: Wed, 15 Jul 1998 17:20:44 EDT
From: dblack@saturn.superlink.net (David A. Black)
Subject: Re: copying softlinks
Message-Id: <6oj6fc$kli$1@earth.superlink.net>
Hello -
Kin Cho <kin@omni.c-cube.com> writes:
>Does someone has some quick Perl code to copy softlinks?
>That is:
>ln -s a b # point b at a
>perl cpln.pl b c d # I want c and d to point at a as well
perldoc -f symlink
David Black
dblack@saturn.superlink.net
------------------------------
Date: Wed, 15 Jul 1998 23:01:12 -0600
From: "Rick K" <ismkoehlerism@nmism-us.campus.mci.net>
Subject: Re: CRYPT on win32
Message-Id: <6ok1eq$3go$1@news.campus.mci.net>
Brian Moffatt wrote in message ...
>Why do I get a "paranoia" message when trying to use the crypt function
[snip snap snip]
AFAIK, the last ActiveState variant of perl I used contained an
implementation
of crypt, but when I migrated to the pre-compiled binary kindly foisted by
G.S., I, too, learned all about excessive paranoia.
Don't know if the ActiveState still has it, pretty sure the
"all-other-things-
considered Gurusamy Sarathy - nice-being" doesn't have it, and probably
never will.
Choices seem to be stick with ActiveState if it means that much to you;
compile your own; or
use one of the various modules available that encrypt things ...
(can you say CPAN ?).
Hope this helps.
Oh, I forgot, flame flame flame flame flame, read the documentation,
blah^3, yadda^3. =8^)
------------------------------
Date: Wed, 15 Jul 1998 22:59:53 -0700
From: "Jeoff Micalizzi" <jeoff.remove@geocities.com>
Subject: databases on a Unix platform
Message-Id: <6ok4tl$53a$1@speedx1.speed.net>
Does anyone how to access a database on a web server using PERL cgi scripts.
I would like to keep a database on my (ISP's) web server wich is running
some flavor of Unix. What database formats are available. Can I put a
Microsoft Access file or an Excel file or a dbase file on the server and
access it with PERL? Or is my only option to use text files?
Any help is extremely appreciated,
Thanks,
Jeoff Micalizzi
jeoff@geocities.com
------------------------------
Date: Thu, 16 Jul 1998 09:02:58 +0200
From: Francois Desarmenien <desar@club-internet.fr>
To: Rick Delaney <rick.delaney@shaw.wave.ca>
Subject: Re: m//g strange behaviour ?
Message-Id: <35ADA5A2.ED120B0@club-internet.fr>
Thank you Rick for your answer,
unfortunatly, you answered (very well) the part I knew,
m//g in a list context with \G anchor (with the magic of m//gc)
I use and abuse it for writing lexers.
My real question is *why* is it executed in a list context ?
The list context (to my understanding) should only apply
to the returned value(s) of the sub, not to arbitrary statements
inside of the sub. In fact it is *really* confusing: you write
your sub which works fine, really clean for reuse, testing for
wantarray before returning, then three weeks later you reuse it
or modify one of its call so the scalar context call becomes a
list context call. Then you loose four hours to debug and isolate
the problem.
I really wander if its a feature...
Regards
Francois
----------------------------------------------
Hiroshima 45 - Tchernobyl 86 - Windows 95
----------------------------------------------
> > Could someone tell me why this script:
> >
> > --------------------------------------
> > sub foo {
> > $_[0] =~ /\G(.)/g;
> > $1
> > }
> > print scalar foo('abcdef'), foo('abcef');
> > --------------------------------------
> >
> > output "af" instead of "aa" that I would have expected ?
> > Why the list context of second call to foo should modify
> > the $_[0] =~ /\G(.)/g behaviour ?
> >
------------------------------
Date: 16 Jul 1998 04:57:05 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: mail bomber source code for perl.
Message-Id: <6ok171$7j6$2@marina.cinenet.net>
Abigail (abigail@fnx.com) wrote:
: The computer is the game.
...And some days, the game is Whack-A-Mole...
---------------------------------------------------------------------
| 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: Thu, 16 Jul 1998 01:28:01 -0400
From: rjk@coos.dartmouth.edu (Ronald J Kimball)
Subject: Re: mail bomber source code for perl.
Message-Id: <1dc8jkx.e8662f1wwc5imN@bay1-425.quincy.ziplink.net>
Matthew Flinchbaugh <matthew@nofear.hjsoft.com> wrote:
> hey does any one have the perl source code for a mail bomber?
> for Linux
> ?
I'm writing one right now, but I'm not sure it's working correctly.
Mind if I test it on your email address?
--
_ / ' _ / - aka - rjk@coos.dartmouth.edu
( /)//)//)(//)/( Ronald J Kimball chipmunk@m-net.arbornet.org
/ http://www.ziplink.net/~rjk/
"It's funny 'cause it's true ... and vice versa."
------------------------------
Date: Thu, 16 Jul 1998 00:35:15 -0500
From: <jjune@ibm.net>
Subject: Newbie question
Message-Id: <35ad927f.0@news1.ibm.net>
Hello,
I've been trying to figure out this little bit of syntax, but without any
success.. so if anyone has any hints... I would really appreciate it.
I have a file that has lines of letters like
AJDOEMGJDISAOIENA
AIJEJIROEIWJEITOEK
DIWOINEQLEIXXNSE
I want to be able to read in the file and put the letters in an array...
with one character in each slot... any ideas?
Thanks for your help in advance!!
JJ
------------------------------
Date: Thu, 16 Jul 1998 02:38:35 -0400
From: Pat Gunn <pgunn01@ibm.net>
Subject: Re: Newbie question
Message-Id: <35AD9FEB.DAF@ibm.net>
jjune@ibm.net wrote:
>
> Hello,
>
> I've been trying to figure out this little bit of syntax, but without any
> success.. so if anyone has any hints... I would really appreciate it.
>
> I have a file that has lines of letters like
>
> AJDOEMGJDISAOIENA
> AIJEJIROEIWJEITOEK
> DIWOINEQLEIXXNSE
>
> I want to be able to read in the file and put the letters in an array...
> with one character in each slot... any ideas?
If it were me, I'd implement the following pseudocode.
open the file
while not at the end of file
{
$foo = getc(filehandle)
unless $foo = '\n' put foo into the array
}
--
---------------------------------------------------
Pat Gunn, moderator:comp.sys.newton.announce
comoderator:comp.os.os2.moderated
"You can always judge a man by the quality of his enemies." -- Dr Who
http://junior.apk.net/~qc
------------------------------------------------
------------------------------
Date: 16 Jul 1998 06:47:59 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Newbie question
Message-Id: <6ok7mv$bj7$1@nswpull.telstra.net>
In article <35ad927f.0@news1.ibm.net>,
<jjune@ibm.net> writes:
> I have a file that has lines of letters like
>
> AJDOEMGJDISAOIENA
> AIJEJIROEIWJEITOEK
> DIWOINEQLEIXXNSE
>
> I want to be able to read in the file and put the letters in an array...
> with one character in each slot... any ideas?
Why?
Anyway:
#!/usr/local/bin/perl -w
use strict;
while (<DATA>)
{
# Get rid of the newline
chomp;
# split the string in separate characters, and store in @a
my @a = split //;
# print @a joined together with ':'
print join(':', @a), "\n";
}
__DATA__
AJDOEMGJDISAOIENA
AIJEJIROEIWJEITOEK
DIWOINEQLEIXXNSE
This of course uses the builting DATA file handle. To read from a real
file, all you need to do is open and close it.
open(FF, $filename) || die "Cannot open $filename: $!";
while (<FF>)
{
# do the above
}
close (FF);
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | In a world without fences, who needs
Commercial Dynamics Pty. Ltd. | Gates?
NSW, Australia |
------------------------------
Date: Thu, 16 Jul 1998 00:09:16 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Newbie question
Message-Id: <MPG.101746de52b8dc24989749@nntp.hpl.hp.com>
[This followup was posted to comp.lang.perl.misc and a copy was sent to
the cited author.]
In article <35ad927f.0@news1.ibm.net> on Thu, 16 Jul 1998 00:35:15 -0500,
jjune@ibm.net <jjune@ibm.net> says...
> Hello,
>
> I've been trying to figure out this little bit of syntax, but without any
> success.. so if anyone has any hints... I would really appreciate it.
>
> I have a file that has lines of letters like
>
> AJDOEMGJDISAOIENA
> AIJEJIROEIWJEITOEK
> DIWOINEQLEIXXNSE
>
> I want to be able to read in the file and put the letters in an array...
> with one character in each slot... any ideas?
It can be done as essentially a one-liner:
#!/usr/local/bin/perl -w
use strict;
my $file = '/foo/bar/baz';
open IN, $file or die "Couldn't read $file. $!";
my @array;
chomp, push @array, split // while <IN>; # This is the one line!
print "@array\n";
--
Larry Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 16 Jul 1998 05:10:36 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Newbie: standard input/ouput
Message-Id: <6ok20c$7j6$3@marina.cinenet.net>
tdean (tdean@gte.net) wrote:
: I have gotten to the point with perl where I can create and run perl scripts
: and see the output in the dos box using print statements. How do I now
: redirect that output to a text file? A small example would be helpful. Any
: info will be appreciated. TIA
Well, you can do it without modifying your scripts by using shell
redirection characters. For example, if you normally run your script
named foo.pl like this:
> perl foo.pl
Then doing it like this will send output to file out.txt:
> perl foo.pl >out.txt
Or, if you want to name and manipulate your output file from inside the
script, see the documentation on the Perl function open(), and on the
optional filehandle argument to print().
Best of luck!
---------------------------------------------------------------------
| 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: 16 Jul 1998 01:30:59 GMT
From: cabneySP4M@SP4M.SP4Mcyberpass.net (C. Abney)
Subject: OFFTOPIC: Re: HELP: Internet Database Design questions...
Message-Id: <6ojl4j$iku$1@news.infonex.net>
In article <6ogl04$69d$1@bvbsd2.kc.bv.com>,
"dogmat" <macdonaldrj@bv.com> writes:
> - wrote in message <35aa9523.19867848@nntp.idsonline.com>...
>>Just because you've had a pc on your desk for a couple years does not
>>make you technically literate. Using word, or netscape is not a
>>computer skill, it's being a computer user. Being a computer user
>>does not qualify you to make suggestions about network environments.
> Such insight. You probably hang out with your other lonely guy colleagues
> making fun of all those silly users.
> Grow up. And if you have any brains, keep an eye on NT. It may not be better
> than Unix, but it wasn't any better than the Mac either.
If you *really* want to know why you shouldn't want to do anything using
NT, or IIS, or any of MS offalings, just point your browser at:
http://www.any.site.stupid.enough.to.serve.asps/default.asp::$DATA
and you will understand that what you don't see is often what you get
when you buy from MS. Using a computer on the web is /not/ the act of a
pedestrian. Frightening. Kind of makes one want to stick with perl if
only to stay away from VBscript ( among its other weaknesses. I don't
really know if this works for _any_ scripted page on IIS or not, I am
only trying to bring the discussion a little closer to on topic. :)
-C
--
All your qualifications for kookiness seem to be aimed at eliminating
yourself simply because you advocate a mainstream product. That is sort
of just being a kook who is a conformist. A bit of a contradiction in
terms, but a valid description. -Bob O C. Abney
------------------------------
Date: Thu, 16 Jul 1998 09:24:38 +0200
From: jan.dubois@ibm.net (Jan Dubois)
Subject: Re: OLE under Win32
Message-Id: <35b1a8b2.4181532@news2.ibm.net>
[mailed & posted]
john@dlugosz.com (John M. Dlugosz) wrote:
>Has anybody figured out some proper instructions for using OLE in
>ActiveWare's "official" Win32 Perl? Here's what I've figured out thus
>far: function calls return undef unless there is an "out" parameter,
>and the OLE result is obtained always with the OLEGetError function.
>
>Sometimes the hash syntax for properties works for read/write,
>sometimes it does't work and you have to use the function-call syntax
>instead. How do you write to an "indexed" property?
>
>Alternativly, is there another Perl port out there that has Win32
>support including OLE Automation?
Standard Perl with libwin32 does support Win32::OLE, which is a superset
of the ActiveState OLE module. There is a binary distribution of it on
CPAN in the authors/GSAR directory.
The new "ActivePerl" builds from ActiveState also contain an uptodate
Win32::OLE module with extended documentation (relative to OLE.pm from
their 3xx builds). Please be advise though, that the ActivePerl builds
are currently based on beta code for Perl 5.005. Some things don't work
just yet with it (like Tk).
-Jan
------------------------------
Date: Thu, 16 Jul 1998 01:28:03 -0400
From: rjk@coos.dartmouth.edu (Ronald J Kimball)
Subject: Re: pattern matching with an =
Message-Id: <1dc8jq8.2r7ypzhvbxs0N@bay1-425.quincy.ziplink.net>
Rick Delaney <rick.delaney@shaw.wave.ca> wrote:
> BTW, it's pretty hard to blow up the world by testing perl code.
It is possible to blow up the world by *not* testing perl code, however.
The Perl Journal
Vol 2, Issue 1
Spring 1997
;-)
--
_ / ' _ / - aka - rjk@coos.dartmouth.edu
( /)//)//)(//)/( Ronald J Kimball chipmunk@m-net.arbornet.org
/ http://www.ziplink.net/~rjk/
"It's funny 'cause it's true ... and vice versa."
------------------------------
Date: Wed, 15 Jul 1998 22:50:55 -0700
From: looper@sparadigm.com (looper)
Subject: persistent objects
Message-Id: <looper-ya023480001507982250550001@news.keyway.net>
Is there a simple way I can store a reference to something in a file that
the other perl processess can open and actually use (just given something
like ARRAY(0xacc50))?
I have a nested data structure that maintains an array of objects
(FileHandle's, Socket's etc.) which is created by one perl invocation. I
need all other perl invocations to be able to get at it.
I tried Eroot.pm with not much success, ObjectStore.pm seems a touch over
the top for me, and I haven't bothered with Storable.pm because of the Sys
V dependant stuff which I can't have.
So how do you take a string "ARRAY(0xacc50)" and remap it to a real reference?
Any assistance would greatly be appreciated.
Thanks much,
-Josh Blackwell <josh@netoutfit.com>
------------------------------
Date: Thu, 16 Jul 1998 07:48:11 GMT
From: Sniper308@qconline.com
Subject: Re: Please Help Me! (Matt's Script BB Problem)
Message-Id: <6okb7r$lhh$1@nnrp1.dejanews.com>
In article <linberg-1507981256350001@projdirc.literacy.upenn.edu>,
linberg@literacy.upenn.edu (Steve Linberg) wrote:
> I'll be glad to. My contract rate is $125/hr. Contact information below.
>
> If you want free help, you should provide a lot more information about
> specifically what's wrong. "It doesn't work" isn't much to go on. And
> please remember that you should be polite and nice when asking for free
> help.
>
> Finally, I can tell you right now that you are looking at a server
> configuration problem or an HTML filename reference problem, not a Perl
> problem, unless you have modified the scripts. Matt's scripts are far
> from perfect and roundly criticized here, but they do function. So the
> chances are that aren't in the right place -- again, unless you have
> modified the scripts.
Nice? I don't know how to PLEAD ON MY KNEES any nicer than to yell for help
to someone who I think has the knowledge to help me.
Free? I thought this was a newsgroup, not a contracting service system.
Yes, I expected "free" help. If you people are "advertising," make it more
obvious in your newsgroups title. What the Hell is this newsgroup for, if
not for sharing assistance and knowledge with others? So far, I've only
gotten two responses (yours and one other), both wanting to charge me money,
when I'm not making a dime from what I'm doing the bulletin board for.
I don't generally ask for help unless I've busted my gut trying to work
things out on my own. You and your snobby "I'll charge you $$$" friends can
kiss my ass. I'm sorry it was such a BOTHER for you to "CONSIDER" helping.
Problem description? That's why I gave the URL, Einstein, so you could check
it on your own. I didn't think telling you "ERROR: No Name" would have
revealed any more to you, or anyone else, than a quick visit to the problem
page.
$125 an hour?
I'm sure sorry I even came here for help.
Tell me, if you guys even go to church, do you put money IN the collection
plate, or take it out?!!!
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum
------------------------------
Date: Thu, 16 Jul 1998 16:59:32 +1000
From: Jaime Metcher <metcher@spider.herston.uq.edu.au>
Subject: Re: Recipient Validation
Message-Id: <35ADA4D4.A2B5B969@spider.herston.uq.edu.au>
brian d foy wrote:
>
> In article <35AD0EC4.E167A892@mediapromotion.ch>, "H.P. Buerki"
>
> use MX records all you want, but you're not going to be using VRFY on
> any system that i admin.
>
<snip>
Or why not use VRFY on my MicroVAX? It will confirm any address you
care to mention. It's the SMTP expression of "Smile and nod".
Everybody wins.
--
Jaime Metcher
------------------------------
Date: 16 Jul 1998 05:52:01 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: RegExps: Check if string consists of EXACTLY 3 digits ??
Message-Id: <6ok4e1$d76$2@client3.news.psi.net>
brian d foy (comdog@computerdog.com) wrote on MDCCLXXX September MCMXCIII
in <URL: news:comdog-ya02408000R1607980001150001@news.panix.com>:
++
++ after thinking about this, i wonder if this is a bug. the $ assertion
++ is documented to match at the "end of the string" or "before the
++ newline". it seems that the actual behaviour is "before any
++ new line if there is one" since the "end of string" certainly
++ doesn't make sense here.
++
++ the /s modifier allows the . to match newlines and documents
++ no exception for the end of the string assertion. if it can
++ really match any character, as documented, why can't you
++ match the very last character with it.
Well, Perl can, but you're instructing Perl to avoid that if possible.
Compare:
perl -wle '$a = "zaped\n"; $a =~ s/[a-z]*?(.)$/$1/s; print length($a)'
and
perl -wle '$a = "zaped\n"; $a =~ s/[a-z]*(.)$/$1/s; print length($a)'
Abigail
--
perl -wle '(1 x $_) !~ /^(11+)\1+$/ && print while ++ $_'
------------------------------
Date: 16 Jul 1998 05:19:33 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Restricting refering domains access to script?
Message-Id: <6ok2h5$7hq$2@nswpull.telstra.net>
In article <6ojnd4$7hb$1@winter.news.erols.com>,
"David Thompson" <domainsource@usa.net> writes:
> That's what I was looking for ($ENV{HTTP_REFERRER}). It's a rather
> useful script and the logs are showing some accesses outside my domain
>:)...
<OFFTOPIC>
Be aware that HTTP_REFERRER doesn't mean much. It just is the string
that the HTTP server got from the client. Most 'standard' clients will
set it to something meaningful. Some mightn't. It depends on the
programmer.
</OFFTOPIC>
To discuss these sorts of things, you could visit a group that talks
about CGI.
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | "In a world without fences,
Commercial Dynamics Pty. Ltd. | who needs Gates?"
NSW, Australia |
------------------------------
Date: 16 Jul 1998 05:55:25 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Restricting refering domains access to script?
Message-Id: <6ok4kd$d76$3@client3.news.psi.net>
brian d foy (comdog@computerdog.com) wrote on MDCCLXXX September MCMXCIII
in <URL: news:comdog-ya02408000R1607980002520001@news.panix.com>:
++ In article <6ojf30$s6$1@camel15.mindspring.com>, "Doug Younger" <cgi-bin@mindspring.com> posted:
++
++ >Hello,
++ >$ENV{REMOTE_HOST} is the machine where the end user is sitting at... (or
++ >$ENV{REMOTE_ADDR} for IP address.
++ > If you want where the script was called from (from a web page not on the
++ >same server), which I doubt is the case, but just in case, use:
++ >$ENV{HTTP_REFERER} will need to split out the server portion as it contains
++ >the entire URL.
++
++ of course, none of those are reliable due to proxies and broken
++ browsers.
Broken? Broken? First of all, a browser isn't sending the IP number
(or name) - that can be interfered from the TCP/IP connection.
As for REFERER, the RFC does not make it a requirement, and
in certain cases, browser should not even send a REFERER header.
Ob Puzzle: Name 3 cases where there is no sensible REFERER to send
for a browser.
Abigail
--
perl5.004 -wMMath::BigInt -e'$^V=new Math::BigInt+qq;$^F$^W783$[$%9889$^F47$|88768$^W596577669$%$^W5$^F3364$[$^W$^F$|838747$[8889739$%$|$^F673$%$^W98$^F76777$=56;;$^U=substr($]=>$|=>5)*(q.25..($^W=@^V))=>do{print+chr$^V%$^U;$^V/=$^U}while$^V!=$^W'
------------------------------
Date: 16 Jul 1998 01:25:57 -0500
From: les@MCS.COM (Leslie Mikesell)
Subject: Re: SMB and Timestamps
Message-Id: <6ok6dl$jij$1@Jupiter.Mcs.Net>
In article <6ois1h$e28$1@nntp.msstate.edu>,
Brent Johnson <brentj@ext.msstate.edu> wrote:
>>> I am trying to write a Perl script which scans through a common
>>> public directory and moves any files older than a certain date
>>> to another directory. Problem is, when someone saves a file to
>>> a mounted SMB filesystem, it keeps the original file date.
>>>
>>> Is there a way to 'touch' files when they are copied? Or some
>>> other way? I've looked at the creation times (same as it is
>>> on their PC's), modified times (no help there) and the 'atime' ..
>>> which I have no idea what that is.. but it isnt correct.
>>>
>I want the time the files were actually created on the system - and
>ctime, mtime nor atime seem to show me that information.
Ctime is the last modification time for the inode. It will be the
time of the copy into the file system or later so it should work
for your purpose. It is updated on file renames or changes to
ownership or permissions. Atime is the last time the file was
read, but if you use a filesystem based backup (like tar) it will
be updated during those reads too. Mtime, as you probably already
know, is the time of the last update to the contents of the file.
Les Mikesell
les@mcs.com
------------------------------
Date: Thu, 16 Jul 1998 09:24:23 +0200
From: jan.dubois@ibm.net (Jan Dubois)
Subject: Re: Using Perl with DCOM
Message-Id: <35aea68e.3633745@news2.ibm.net>
[mailed & posted]
Ketan Patel <kbp1527@ihgp.lucent.com> wrote:
>I am trying to use Perl on Win32 platform to communicate with a COM object. One
>of the methods of the COM object passes parameter by reference and it returns
>result in this parameter. How do I handle this in Perl? I know how hard and
>relative references work in Perl. However, I am unable to get the result passed
>by the COM method as one of the parameters. Has anyone else faced this problem?
>If so, can someone point me to a book or an article which discusses this. I know
>that there is Perl Resource Kit for Win32 is coming out soon. But, I can't wait
>for it.
You can do it with standard Perl and Win32::OLE from libwin32-0.12.
Please check the example in the Win32::OLE::Variant module:
my $x = Variant(VT_I4|VT_BYREF, 0);
my $y = Variant(VT_I4|VT_BYREF, 0);
$Corel->GetSize($x, $y);
print "Size is $x by $y\n";
This is also possible with the current ActivePerl releases (which are
betas of Perl 5.005 to come), which also include the latest Win32::OLE
module.
-Jan
------------------------------
Date: 12 Jul 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Special: Digest Administrivia (Last modified: 12 Mar 98)
Message-Id: <null>
Administrivia:
Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.
If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu.
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.
The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V8 Issue 3173
**************************************