[19185] in Perl-Users-Digest
Perl-Users Digest, Issue: 1380 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jul 25 21:06:38 2001
Date: Wed, 25 Jul 2001 18:05:13 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <996109513-v10-i1380@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Wed, 25 Jul 2001 Volume: 10 Number: 1380
Today's topics:
Re: Another flock question (Richard J. Rauenzahn)
Re: bitwise operations <lhswartw@ichips.intel.com>
Re: changing a field value in a particular line (Balaji)
DBD:ODBC, Openlink->MSSQL, and LongReadLen (Sebastian)
Re: don't laugh (case usage for variables) (Abigail)
FAQ: How do I find yesterday's date? <faq@denver.pm.org>
Finding a word in a sorted list. (Mario Rizzuti)
Re: Finding a word in a sorted list. (Craig Berry)
Re: Finding a word in a sorted list. <godzilla@stomp.stomp.tokyo>
match regexp pattern in a special context? <no@mail.addr>
Matching 6 Numbers To Each Other (Barry Allwood)
Re: Matching 6 Numbers To Each Other <tony_curtis32@yahoo.com>
Re: Matching 6 Numbers To Each Other <mbudash@sonic.net>
Re: Matching 6 Numbers To Each Other <krahnj@acm.org>
Re: Matching 6 Numbers To Each Other (Craig Berry)
MSI Perl package installation from ActivePerl for win98 (Razvan Mihailescu)
Re: MSI Perl package installation from ActivePerl for w <cardflourishes@f2s.com>
parsing SGML file (Shang-Lin Chen)
Re: Problem creating file <bkiggins@home.com>
Reading from .htpasswd in script <cardflourishes@f2s.com>
scroll text on text-modal console? <no@mail.addr>
Re: Self-Searchable Perl documention - Extremely Useful (John Holdsworth)
Re: Self-Searchable Perl documention - Extremely Useful <jeff@vpservices.com>
Re: Substitute _last_ occurrece in string? <godzilla@stomp.stomp.tokyo>
Re: Substitute _last_ occurrece in string? <godzilla@stomp.stomp.tokyo>
Re: Substitute _last_ occurrece in string? <weiss@kung.foo.at>
Thanks! Re: newbie semantic (non-code) question -"what <"goodrow"@opencity. com>
Re: What am I doing wrong with this command line ? <james@zephyr.org.uk>
Re: Who can help me about the confused (..) operator? <no@mail.addr>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 26 Jul 2001 00:02:59 GMT
From: nospam@hairball.cup.hp.com (Richard J. Rauenzahn)
Subject: Re: Another flock question
Message-Id: <996105779.145627@hpvablab.cup.hp.com>
[CC'ed and posted]
tadmc@augustmail.com writes:
>Eric Audet <eaudet@solution123.com> wrote:
>
>>My problem is I want the LOCKFILE deleted (I have a quota on numbers
>>of files) ... So what should I do?
>
>
>unlink() it before you close() it.
>
Doesn't this also introduce a race condition? Pseudocode...
process1 process2 process3
-------- -------- --------
open
flock
do stuff open
unlink flock open (creates new file!)
close <blocked> flock (succeeds!)
do stuff do stuff
unlink unlink
close close
To synchronize correctly, I'd think you'd have to...
start:
open file (O_CREAT/O_EXCL)
if creation failed
open file
if success
lock it
remove (should usually fail with file not found)
close
endif
go back to start
else
lock it
do stuff
unlink
close
end
This kind of puts you into a two stage lock scenario, but the flock
attempt lets you detect and remove stale lock files.
Rich
--
Rich Rauenzahn ----------+xrrauenza@cup.hp.comx+ Hewlett-Packard Company
Technical Consultant | I speak for me, | 19055 Pruneridge Ave.
Development Alliances Lab| *not* HP | MS 46TU2
ESPD / E-Serv. Partner Division +--------------+---- Cupertino, CA 95014
------------------------------
Date: Wed, 25 Jul 2001 15:59:46 -0700
From: "Swanthog" <lhswartw@ichips.intel.com>
Subject: Re: bitwise operations
Message-Id: <9jnj12$2p8@news.or.intel.com>
Many thanks for all your suggestions!
Larry S.
------------------------------
Date: 25 Jul 2001 15:40:05 -0700
From: srinivasanbala@netscape.net (Balaji)
Subject: Re: changing a field value in a particular line
Message-Id: <86e0f1f4.0107251440.6b606b06@posting.google.com>
from Balaji
followed The example in faq5 and worked well in the context of
textfile .same anyway, leave it folks.I am trying to make it work when
I POST via form.
I might comeback again .Thanks
Andras Malatinszky <andras@mortgagestats.com> wrote in message news:<3B5E1265.196A665A@mortgagestats.com>...
> Balaji wrote:
>
> > Hi Gurus
> >
> > I am new to this..but it creates lot of interest.
> >
> > I am ok with scripts like forms creating/printing to a
> > datafile/creating results page by printing correct fields etc..getting
> > a timestamp/modification time etc..
> >
> > But I am stuck here totally.
> >
> > my data file is abc.dat
> > it has following values for e.g.
> >
> > california,sfo,goldengate,80,60,localtime
> > arizona,grandcanyon,northrim,70,40,locatime
> >
> > This values are submitted using a form.
> >
> > now the same form is used to change
> > "california,sfo,goldengate,80,60,localtime" to
> > "california,sfo,IMAX,80,60,localtime"
> >
> > but i can either append the abc.dat or overwriting the whole file
> > which certainly i don't want to do.I am not been to overwrite that
> > particular line.
> >
> > I read couple of postings and perlfaq5 etc..but for me right now it is
> > tough..
> >
> > can somebody show me the simple way?
> >
> > Thanks a lot for your help.
>
> This is a FAQ and the answer is in perlfaq5, available at
> http://www.perldoc.com/perl5.6/pod/perlfaq5.html
>
> Look for the section titled "How do I change one line in a file/delete a
> line in a file/insert a line in the middle of a file/append to the
> beginning of a file? "
------------------------------
Date: 25 Jul 2001 16:13:42 -0700
From: dethtoll@yahoo.com (Sebastian)
Subject: DBD:ODBC, Openlink->MSSQL, and LongReadLen
Message-Id: <ea245403.0107251513.18000f91@posting.google.com>
Hello,
I'm using perl DBI, DBD::ODBC, and OpenLink drivers to connect to a
Win2k MS SQL Server. DBI's LongReadLen method seems to have no effect,
I still get <255 characters when retrieving data from long memo
fields. Has anyone run into this?
Thanks in advance.
------------------------------
Date: 25 Jul 2001 22:18:32 GMT
From: abigail@foad.org (Abigail)
Subject: Re: don't laugh (case usage for variables)
Message-Id: <slrn9luhf3.d4m.abigail@alexandra.xs4all.nl>
--Rick (no_trick@my-deja.com) wrote on MMDCCCLXXXIV September MCMXCIII in
<URL:news:3Xj77.50788$C81.4281160@bgtnsc04-news.ops.worldnet.att.net>:
}}
}} Yes.. It looks that way at first and you are certainly the one to
}} decide whether to use upper case for your own labels. The advantage to
}} using lower-case for your own variables is that you don't have to worry
}} about conflicting with future reserved words. In addition to that,
}} conforming to common practice makes it easier to collaborate with
}} others.
Interesting that you say this.
First of all, variables won't conflict easily with reserved words
because scalars, arrays and hashes have funny symbols in front of them,
and reserved words don't.
However, your reasoning of not conflicting with future reserved words
is usually used as an argument to use all caps file (and directory)
handles - which don't have funny symbols. This is because it's supposed
to be true that new reserved words in Perl will be all lower case.
Right.
Perl 5.005 gave us INIT and Perl 5.6.x gave us CHECK and made UNTIE
special in certain cases.
Of course, we also got 'our' and 'qr'.
It seems that only TiTleCaSe prevents you from potential conflicts.
Abigail
--
BEGIN {$^H {q} = sub {$_ [1] =~ y/S-ZA-IK-O/q-tc-fe-m/d; $_ [1]}; $^H = 0x28100}
print "Just another PYTHON hacker\n";
------------------------------
Date: Thu, 26 Jul 2001 00:16:58 GMT
From: PerlFAQ Server <faq@denver.pm.org>
Subject: FAQ: How do I find yesterday's date?
Message-Id: <_jJ77.61$os9.171000320@news.frii.net>
This message is one of several periodic postings to comp.lang.perl.misc
intended to make it easier for perl programmers to find answers to
common questions. The core of this message represents an excerpt
from the documentation provided with every Standard Distribution of
Perl.
+
How do I find yesterday's date?
The "time()" function returns the current time in seconds since the
epoch. Take twenty-four hours off that:
$yesterday = time() - ( 24 * 60 * 60 );
Then you can pass this to "localtime()" and get the individual year,
month, day, hour, minute, seconds values.
Note very carefully that the code above assumes that your days are
twenty-four hours each. For most people, there are two days a year when
they aren't: the switch to and from summer time throws this off. A
solution to this issue is offered by Russ Allbery.
sub yesterday {
my $now = defined $_[0] ? $_[0] : time;
my $then = $now - 60 * 60 * 24;
my $ndst = (localtime $now)[8] > 0;
my $tdst = (localtime $then)[8] > 0;
$then - ($tdst - $ndst) * 60 * 60;
}
# Should give you "this time yesterday" in seconds since epoch relative to
# the first argument or the current time if no argument is given and
# suitable for passing to localtime or whatever else you need to do with
# it. $ndst is whether we're currently in daylight savings time; $tdst is
# whether the point 24 hours ago was in daylight savings time. If $tdst
# and $ndst are the same, a boundary wasn't crossed, and the correction
# will subtract 0. If $tdst is 1 and $ndst is 0, subtract an hour more
# from yesterday's time since we gained an extra hour while going off
# daylight savings time. If $tdst is 0 and $ndst is 1, subtract a
# negative hour (add an hour) to yesterday's time since we lost an hour.
#
# All of this is because during those days when one switches off or onto
# DST, a "day" isn't 24 hours long; it's either 23 or 25.
#
# The explicit settings of $ndst and $tdst are necessary because localtime
# only says it returns the system tm struct, and the system tm struct at
# least on Solaris doesn't guarantee any particular positive value (like,
# say, 1) for isdst, just a positive value. And that value can
# potentially be negative, if DST information isn't available (this sub
# just treats those cases like no DST).
#
# Note that between 2am and 3am on the day after the time zone switches
# off daylight savings time, the exact hour of "yesterday" corresponding
# to the current hour is not clearly defined. Note also that if used
# between 2am and 3am the day after the change to daylight savings time,
# the result will be between 3am and 4am of the previous day; it's
# arguable whether this is correct.
#
# This sub does not attempt to deal with leap seconds (most things don't).
#
# Copyright relinquished 1999 by Russ Allbery <rra@stanford.edu>
# This code is in the public domain
-
Documents such as this have been called "Answers to Frequently
Asked Questions" or FAQ for short. They represent an important
part of the Usenet tradition. They serve to reduce the volume of
redundant traffic on a news group by providing quality answers to
questions that keep coming up.
If you are some how irritated by seeing these postings you are free
to ignore them or add the sender to your killfile. If you find
errors or other problems with these postings please send corrections
or comments to the posting email address or to the maintainers as
directed in the perlfaq manual page.
Answers to questions about LOTS of stuff, mostly not related to
Perl, can be found by pointing your news client to
news:news.answers
or to the many thousands of other useful Usenet news groups.
Note that the FAQ text posted by this server may have been modified
from that distributed in the stable Perl release. It may have been
edited to reflect the additions, changes and corrections provided
by respondents, reviewers, and critics to previous postings of
these FAQ. Complete text of these FAQ are available on request.
The perlfaq manual page contains the following copyright notice.
AUTHOR AND COPYRIGHT
Copyright (c) 1997-1999 Tom Christiansen and Nathan
Torkington. All rights reserved.
This posting is provided in the hope that it will be useful but
does not represent a commitment or contract of any kind on the part
of the contributers, authors or their agents.
04.15
--
This space intentionally left blank
------------------------------
Date: 25 Jul 2001 16:08:19 -0700
From: mariorizzuti@yahoo.com (Mario Rizzuti)
Subject: Finding a word in a sorted list.
Message-Id: <42f3ee2.0107251508.35e589ea@posting.google.com>
I have a fixed-length-records file where:
* each record is 18 bytes made by an username (12 bytes) and a number
(6 bytes).
* the records are sorted alphabetically.
I am wondering what is the fastest possible way to find the associated
numbers of a given list of usernames?
Thanks for any suggestion.
This is what I have so far:
--------
my @user = qw/mario john bill/;
my @sorted_user = sort @user; # sorting allows us to use the last
found word as
# a "$min" for the next one.
my %Line;
my @stats = stat "user.ind";
my $min = 0;
my $max = $stats[7] / 18; # how many records
open INDEX, "user.ind" or die "Can't open 'user.ind': $!";
USER: foreach my $to_find ( @sorted_user ) {
my $last_guess;
while (1) {
my $guess = int ( ($min + $max)/ 2 ); # we are sure that it's
between
# $min and $max, let's try
in the
# middle.
seek (INDEX, 18 * $guess, 0); # this should be more efficient
(?) if we
# used the last read position as
offset.
my $bytes = read INDEX, my $record, 18;
croak "Username $to_find couldn't be found." if $bytes != 18 ||
$guess == $last_guess;
my ($username, $pointer) = unpack "A12 A6", $record;
if ($username eq $to_find ) {
$Line{$username} = $pointer;
$min = $guess; # since the user list is sorted, the next word
will be
# after the one we have just found.
next USER;
} elsif ($username lt $to_find ) {
$min = $guess; # our word is not before the one we have just
read.
} else {
$max = $guess;
}
$last_guess = $guess;
}
}
close INDEX or die "Can't close 'user.ind': $!";
@user = map {$Line{$_}} @user; # return this
--------
Mario Rizzuti
------------------------------
Date: Thu, 26 Jul 2001 00:02:30 -0000
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Finding a word in a sorted list.
Message-Id: <tlungmmaunfh93@corp.supernews.com>
Mario Rizzuti (mariorizzuti@yahoo.com) wrote:
: I have a fixed-length-records file where:
:
: * each record is 18 bytes made by an username (12 bytes) and a number
: (6 bytes).
: * the records are sorted alphabetically.
:
: I am wondering what is the fastest possible way to find the associated
: numbers of a given list of usernames?
If the file is not too huge to load into a hash, I'd proceed like this,
assuming the input file open on USERS:
while (read USERS, $rec, 18) {
my $user = substr $rec, 0, 12;
my $num = substr $rec, 12, 6;
$users{$user} = $num;
}
# ... and then when you need numbers associated with some users ...
my @bunchOfUsers = qw/billxxxxyyyy sallyqqqnnnn fredfredfred/;
my @numbers = @users{@bunchOfUsers};
--
| Craig Berry - http://www.cinenet.net/~cberry/
--*-- "Brute force done fast enough looks slick."
| - William Purves
------------------------------
Date: Wed, 25 Jul 2001 17:41:46 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Finding a word in a sorted list.
Message-Id: <3B5F674A.AAA843BE@stomp.stomp.tokyo>
Mario Rizzuti wrote:
(snipped)
> I have a fixed-length-records file where:
Use of fixed-length records is highly inefficient.
Your data base is much larger than it should be,
if you are padding to a certain length. Your
articles reads you are doing this.
> * each record is 18 bytes made by an username (12 bytes)
> and a number (6 bytes).
Very poor parameters. Do you want to work with number
of bytes or number of characters? There is no "clear"
indication if your database is single line flat or one
record per line. Inclusion of a end-of-line newline
character would change both your "byte" length and your
character length for each record, yes?
A logical database uses a non-fixed length record format.
With your having two data fields, they should be simply
sorted by a delimiter, other than a meta-character. This
makes for a fast and efficient line-by-line split () to
pull information.
> * the records are sorted alphabetically.
Irrelevant.
> This is what I have so far:
You have created a monster. With a well planned single
record per line data base, using a delimiter, your
monstrous code would be reduced to,
while (<FILEHANDLE>)
{
($username, $number) = split (/¦/, $_);
... processing
This could be made even more efficient with use
of index () and substr () as follows:
$username = substr ($_, 0, index ($_, "¦"));
$number = substr ($_, 0, rindex ($_, "¦") + 1);
Even more efficient if you discard those two
variables and simply create an if conditional
which compares "what you want" to a substr ()
return from your file line input.
My suggestion, which you have solicited, is to create
a well planned and well organized data base, then use
simple and efficient code. Another suggestion is to
give some thought to your actual byte length if your
data base is multi-line. You appear to have completely
overlooked your true record byte length.
Godzilla! Queen Of Byte.
------------------------------
Date: Thu, 26 Jul 2001 09:03:22 +0800
From: MMX166+2.1G HD <no@mail.addr>
Subject: match regexp pattern in a special context?
Message-Id: <1mtqltcipb4gldmhu4cpjkuiro970dtl48@4ax.com>
hmm... there is, e.g., a html doc,I want to parse tags in it and match
the attribute="value" pairs which are inside the <tag ... >.
for example:
><img src="images/logo.gif" width="120" height="120" > don't choose me.I am a wrong name="alex"
how to match the src="images/logo.gif", width="120" and height="120"
but avoid the name="alex". thus neither /(\w+)=\"(.*?)\"/ nor
/(?:<\w+\s+)(\w+)=\"(.*?)\"(?:\s*[^>]*\/?>)/ is correct.
videlicet, match all the html attributes (name="value" pair which is
between "<" and ">").
any hint?
my badly solution is to separate whole document into tags, then
extract the attributes, at last, match name="value".
------------------------------
Date: 25 Jul 2001 22:37:41 GMT
From: barryallwood@aol.com (Barry Allwood)
Subject: Matching 6 Numbers To Each Other
Message-Id: <20010725183741.01105.00001118@ng-fg1.aol.com>
Hi,
I wanted to know if there was any way to take 2 IP numbers say
233.812.98.65
233.812.55.86
and match the first 6 numbers in it so if the person used a different IP on the
same server he would not be allowed to go on because the first 6 match
Thanks
Barry Allwood
------------------------------
Date: 25 Jul 2001 18:01:52 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: Matching 6 Numbers To Each Other
Message-Id: <87bsm8pq8v.fsf@limey.hpcc.uh.edu>
>> On 25 Jul 2001 22:37:41 GMT,
>> barryallwood@aol.com (Barry Allwood) said:
> Hi, I wanted to know if there was any way to take 2 IP
> numbers say
> 233.812.98.65 233.812.55.86
812??? I don't think so.
> and match the first 6 numbers in it so if the person
> used a different IP on the same server he would not be
> allowed to go on because the first 6 match
Sounds more like a firewalling task than an application
specific problem. I think you need to provide more
information about what you're trying to do, your use of
terms is somewhat ambiguous.
hth
t
--
Beep beep! Out of my way, I'm a motorist!
------------------------------
Date: Wed, 25 Jul 2001 23:18:30 GMT
From: Michael Budash <mbudash@sonic.net>
Subject: Re: Matching 6 Numbers To Each Other
Message-Id: <mbudash-88C771.16183025072001@news.sonic.net>
In article <20010725183741.01105.00001118@ng-fg1.aol.com>,
barryallwood@aol.com (Barry Allwood) wrote:
> Hi,
>
> I wanted to know if there was any way to take 2 IP numbers say
>
> 233.812.98.65
> 233.812.55.86
>
> and match the first 6 numbers in it so if the person used a different IP
> on the same server he would not be allowed to go on because the first 6
> match
>
what have you tried thus far? remember that the numbers in an ip address
can be 1 to 3 digits.
here's a coupla thoughts:
$ip =~ /^\d{1,3}\.\d{1,3}/;
$first2 = $&;
OR
$first2 = join (".", (split(/\./, $ip))[0,1]);
hth-
--
Michael Budash ~~~~~~~~~~ mbudash@sonic.net
------------------------------
Date: Wed, 25 Jul 2001 23:26:54 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: Matching 6 Numbers To Each Other
Message-Id: <3B5F55F5.2F7FDA6D@acm.org>
Barry Allwood wrote:
>
> I wanted to know if there was any way to take 2 IP numbers say
>
> 233.812.98.65
> 233.812.55.86
>
> and match the first 6 numbers in it so if the person used a different IP on the
> same server he would not be allowed to go on because the first 6 match
An IP address doesn't have 6 numbers, it has four numbers separated by
periods.
my $IP1 = '233.812.98.65';
my $IP2 = '233.812.55.86';
if ( "$IP1 $IP2" =~ /^(\d+\.\d+).* (\d+\.\d+)/ and $1 eq $2 ) {
print "$IP1/16 and $IP2/16 are the same\n";
}
else {
print "$IP1/16 and $IP2/16 are different\n";
}
John
--
use Perl;
program
fulfillment
------------------------------
Date: Wed, 25 Jul 2001 23:54:31 -0000
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Matching 6 Numbers To Each Other
Message-Id: <tlun1ng9s54j79@corp.supernews.com>
Barry Allwood (barryallwood@aol.com) wrote:
: I wanted to know if there was any way to take 2 IP numbers say
:
: 233.812.98.65
: 233.812.55.86
:
: and match the first 6 numbers in it so if the person used a different IP on the
: same server he would not be allowed to go on because the first 6 match
You could do that by brute force using e.g.
if (substr($x, 0, 7) eq substr($y, 0, 7)) {
which would compare the first seven characters for stringwise equality,
encompassing the first two numbers and the dot between them.
A more general and robust approach would be to split the dotted-quad
address into components, and do numeric compares on the first two
components.
--
| Craig Berry - http://www.cinenet.net/~cberry/
--*-- "Brute force done fast enough looks slick."
| - William Purves
------------------------------
Date: 25 Jul 2001 15:28:24 -0700
From: razvan.mihailescu@gartner.com (Razvan Mihailescu)
Subject: MSI Perl package installation from ActivePerl for win98
Message-Id: <451d8b00.0107251428.51d08d78@posting.google.com>
Hello,
1. I got MSI for win98 from this link to install Perl on my machine:
http://aspn.activestate.com/ASPN/Downloads/ActivePerl/
2. I ran the .msi file I got from ActivePerl
3. I typed "perl -v" to test, and it told me I didn't have
"win32gnu.dll"
4. I searched for "win32gnu.dll" on the web, found it, and copied it
on my
c:\windows\system and c:\windows\system32
5. I then went to the DOS prompt again, typed "perl -v" to see if it
would work, and I got this:
this is perl version 4.0
perl for NT $$Revision 4.0.1.8
patch level: 36
Is this good or bad? It says "perl for NT" not perl for win98
6. I then typed perl -MCGI -e "print $CGI::VERSION" and I got this:
unrecognized switch: -MCGI
What does this tell you? I'm lost.
------------------------------
Date: Thu, 26 Jul 2001 00:34:08 +0200
From: "Card Flourishes" <cardflourishes@f2s.com>
Subject: Re: MSI Perl package installation from ActivePerl for win98
Message-Id: <9jnhf0$hpn$1@wanadoo.fr>
Have you got a webserver?
Cf
Razvan Mihailescu <razvan.mihailescu@gartner.com> wrote in message
news:451d8b00.0107251428.51d08d78@posting.google.com...
> Hello,
>
> 1. I got MSI for win98 from this link to install Perl on my machine:
> http://aspn.activestate.com/ASPN/Downloads/ActivePerl/
>
> 2. I ran the .msi file I got from ActivePerl
>
> 3. I typed "perl -v" to test, and it told me I didn't have
> "win32gnu.dll"
>
> 4. I searched for "win32gnu.dll" on the web, found it, and copied it
> on my
> c:\windows\system and c:\windows\system32
>
> 5. I then went to the DOS prompt again, typed "perl -v" to see if it
> would work, and I got this:
>
> this is perl version 4.0
> perl for NT $$Revision 4.0.1.8
> patch level: 36
>
> Is this good or bad? It says "perl for NT" not perl for win98
>
> 6. I then typed perl -MCGI -e "print $CGI::VERSION" and I got this:
>
> unrecognized switch: -MCGI
>
> What does this tell you? I'm lost.
------------------------------
Date: 25 Jul 2001 16:16:51 -0700
From: schen@caltech.edu (Shang-Lin Chen)
Subject: parsing SGML file
Message-Id: <ced2ab2d.0107251516.5eb3b59@posting.google.com>
I'm writing a Perl script that will parse an SGML file into a flat
text file. I read the contents of the SGML file into a string that
will be written out to the flat file. In the original SGML file, there
are two lines,
<command>list</command>
<args>interface=inter</args>,
that I want to combine into one line. I tried a regular expression on
the string storing the contents of the file,
$myfile =~ s/(<\W*command\W*>)\n/$1/gi;
but it didn't work. How can I remove the end-of-line character?
------------------------------
Date: Wed, 25 Jul 2001 22:41:02 GMT
From: Brian Kiggins <bkiggins@home.com>
Subject: Re: Problem creating file
Message-Id: <3B5F4B16.B9C4A0C5@home.com>
Check your permissions.
Gilad Suberri wrote:
> I have a script that creates a text file. It works fine when I run it off
> the server directly, but when I call it from a web page, it does not create
> the file for some reason. If the file is already there, it will open it, but
> it will not create a new one. Any ideas? Thanks in advance
>
> Gilad
--
Brian Kiggins
"Now go away or I shall taunt you a second time"
------------------------------
Date: Thu, 26 Jul 2001 00:27:07 +0200
From: "Card Flourishes" <cardflourishes@f2s.com>
Subject: Reading from .htpasswd in script
Message-Id: <9jnh1u$9ho$1@wanadoo.fr>
Is this possible? How so...
Sorry for the newbie question,
Amadeus
------------------------------
Date: Thu, 26 Jul 2001 09:03:17 +0800
From: MMX166+2.1G HD <no@mail.addr>
Subject: scroll text on text-modal console?
Message-Id: <6p9qltg9d3iu5cscse1lp625albjpe76cp@4ax.com>
hi all:
just going to write a enhancing "more" tool that can scroll plain text
forward and backward on the console (say dos command window), and.
without TK module. what shall I do?
------------------------------
Date: 25 Jul 2001 15:26:22 -0700
From: coldwave@bigfoot.com (John Holdsworth)
Subject: Re: Self-Searchable Perl documention - Extremely Useful!
Message-Id: <2a46b11e.0107251426.6f2f506e@posting.google.com>
Re: http://www.openpsp.org/source/util/perltoc.pl
This is a little more 21st century Jeff.
Search for a pattern and it will show you
the lines where it occurs along with a link
to take you directly to the place where the
pattern matched. A variant could be included
with any set of html docs to make them self-
searchable.
Try it, you'lll like it! Besides, having
a Web page act as a Web server is kind-of
intriguing. This is the only use I could
think of for it though.
Cheers,
john
http://www.openpsp.org
Jeff Zucker <jeff@vpservices.com> wrote in message news:<3B5EEE7B.F7E6D934@vpservices.com>...
> John Holdsworth wrote:
> >
> > If you have ActiveState's "Active Perl" installed on a PC along
> > with Perl Documentation you can make it searchable without having
> > to run a Web server or be connected to the internet by
>
> a) using the built-in "find" function of windoze: start menu / find /
> files or folders / containing text ...
>
> or
>
> b) at the command line with standard switches to the perldoc command or
> with grep
------------------------------
Date: Wed, 25 Jul 2001 16:19:49 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: Self-Searchable Perl documention - Extremely Useful!
Message-Id: <3B5F5415.BFCB4D59@vpservices.com>
John Holdsworth wrote:
>
> Re: http://www.openpsp.org/source/util/perltoc.pl
Ah, ok, I thought you were hawking someone else's product, I didn't
realize this was something you'd written yourself, it sounds cool. The
part that turns me off is the "inside Internet Explorer" bit since I
have a distinct aversion to things that require a specific browser
(especailly that specific browser :-)). But your server-inside-a-page
concept sounds pretty neat. I'll check it out.
--
Jeff
------------------------------
Date: Wed, 25 Jul 2001 15:53:41 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Substitute _last_ occurrece in string?
Message-Id: <3B5F4DF5.CA0DB54@stomp.stomp.tokyo>
Stefan Weiss wrote:
> Godzilla! wrote:
> > Michael Budash wrote:
(snipped)
> [ Michael: This is the first thing that came to my mind when I read
> the question. I'm actually quite fond of Sexegers [1], but then I
> figured the lookahead assertion would be cleaner in this case. ]
> BTW, the "solution" you posted elsewhere in this thread will _not_
> work in this case. I find it amusing that you think it inefficient to
> "invoke a memory wasteful regex engine" (which would solve the problem
> in no more than 24 characters), then go ahead and propose an 8-liner
> that reads like BASIC, does not even work correctly, and would only
> waste the OP's time and patience. Efficient?
Would you like salt and pepper with your crow or,
would you simply prefer cheese with your whine?
Godzilla!
--
#!perl
print "Content-type: text/plain\n\n";
use Benchmark;
print "Run One:\n\n";
&Time;
print "\n\nRun Two:\n\n";
&Time;
print "\n\nRun Three:\n\n";
&Time;
sub Time
{
timethese (1000000,
{
'name1' =>
'$string = "Godzilla Rocks! Godzilla Rocks! Godzilla Rocks!
Godzilla Rocks! Godzilla Rocks! Godzilla Rocks! Godzilla Rocks!";
if (rindex ($string, "Godzilla Rocks!") > index ($string, "Godzilla Rocks!"))
{ substr ($string, rindex ($string, "Godzilla Rocks!"), length ("Godzilla Rocks!"), ""); }',
'name2' =>
'$string = "Godzilla Rocks! Godzilla Rocks! Godzilla Rocks!
Godzilla Rocks! Godzilla Rocks! Godzilla Rocks! Godzilla Rocks!";
$string =~ s/Godzilla Rocks!(?!.*Godzilla Rocks!)//s;',
} );
}
exit;
PRINTED RESULTS:
________________
Run One:
Benchmark: timing 1000000 iterations of name1, name2...
name1: 4 wallclock secs ( 3.90 usr + 0.00 sys = 3.90 CPU) @ 256410.26/s
name2: 14 wallclock secs (14.01 usr + 0.00 sys = 14.01 CPU) @ 71377.59/s
Run Two:
Benchmark: timing 1000000 iterations of name1, name2...
name1: 4 wallclock secs ( 4.01 usr + 0.00 sys = 4.01 CPU) @ 249376.56/s
name2: 14 wallclock secs (13.96 usr + 0.00 sys = 13.96 CPU) @ 71633.24/s
Run Three:
Benchmark: timing 1000000 iterations of name1, name2...
name1: 4 wallclock secs ( 3.90 usr + 0.00 sys = 3.90 CPU) @ 256410.26/s
name2: 14 wallclock secs (14.06 usr + 0.00 sys = 14.06 CPU) @ 71123.76/s
------------------------------
Date: Wed, 25 Jul 2001 16:15:23 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Substitute _last_ occurrece in string?
Message-Id: <3B5F530B.3FFA0214@stomp.stomp.tokyo>
Stefan Weiss wrote:
> Godzilla! wrote:
> > Michael Budash wrote:
(snipped)
> BTW, the "solution" you posted elsewhere in this thread will _not_
> work in this case. I find it amusing that you think it inefficient to
> "invoke a memory wasteful regex engine" (which would solve the problem
> in no more than 24 characters), then go ahead and propose an 8-liner
> that reads like BASIC, does not even work correctly, and would only
> waste the OP's time and patience. Efficient?
Here is a second serving of crow for you to eat.
My presumption is you have not noticed your impotent
Sexeger does not print correctly.
Clearly, my code is quite potent. I contribute this
to both a lack of a penis and lack of a penis mounted
atop my shoulders.
Godzilla! Queen Of Penisless.
--
#!perl
print "Content-type: text/plain\n\n";
use Benchmark;
print "Run One:\n\n";
&Time;
print "\n\nRun Two:\n\n";
&Time;
print "\n\nRun Three:\n\n";
&Time;
sub Time
{
timethese (1000000,
{
'name1' =>
'$string = "Godzilla Rocks! Godzilla Rocks! Godzilla Rocks!
Godzilla Rocks! Godzilla Rocks! Godzilla Rocks! Godzilla Rocks!";
substr ($string, rindex ($string, "Godzilla Rocks!"), length ("Godzilla Rocks!"), "");',
'name2' =>
'$string = "Godzilla Rocks! Godzilla Rocks! Godzilla Rocks!
Godzilla Rocks! Godzilla Rocks! Godzilla Rocks! Godzilla Rocks!";
$rev = reverse($string);
$rev =~ s/Godzilla Rocks!//s;
$string = reverse($rev);',
} );
}
exit;
PRINTED RESULTS:
________________
Run One:
Benchmark: timing 1000000 iterations of name1, name2...
name1: 2 wallclock secs ( 2.20 usr + 0.00 sys = 2.20 CPU) @ 454545.45/s
name2: 6 wallclock secs ( 5.82 usr + 0.00 sys = 5.82 CPU) @ 171821.31/s
Run Two:
Benchmark: timing 1000000 iterations of name1, name2...
name1: 2 wallclock secs ( 2.30 usr + 0.00 sys = 2.30 CPU) @ 434782.61/s
name2: 6 wallclock secs ( 5.67 usr + 0.00 sys = 5.67 CPU) @ 176366.84/s
Run Three:
Benchmark: timing 1000000 iterations of name1, name2...
name1: 2 wallclock secs ( 2.20 usr + 0.00 sys = 2.20 CPU) @ 454545.45/s
name2: 7 wallclock secs ( 5.98 usr + 0.00 sys = 5.98 CPU) @ 167224.08/s
------------------------------
Date: Thu, 26 Jul 2001 02:20:11 +0200
From: "Stefan Weiss" <weiss@kung.foo.at>
Subject: Re: Substitute _last_ occurrece in string?
Message-Id: <3b5f6187@e-post.inode.at>
"Godzilla!" <godzilla@stomp.stomp.tokyo> wrote:
> Here is a second serving of crow for you to eat.
>
> My presumption is you have not noticed your impotent
> Sexeger does not print correctly.
>
> Clearly, my code is quite potent. I contribute this
> to both a lack of a penis and lack of a penis mounted
> atop my shoulders.
[phoney benchmarks skipped]
I knew I should not have responded to any of your postings. Usually your
posts just get filtered by my mail client, but this time you posted in a
thread I had marked 'watched'. Guess I'll have to fix the priorities of
my filters...
I will not comment on your benchmarks, please see my previous posting for
the reason why. And rest assured I will not comment on any of your
postings again - some people just take a bit longer to learn a lesson...
And now I'd better stop and set a f'up2p before you accuse me of being
10 persons at once, and that I originally posted the question just to
answer it myself.
Be happy with your code.
cheers,
stefan
PS: just for fun, try http://groups.google.com/groups?as_epq=mule%20manure
------------------------------
Date: Wed, 25 Jul 2001 18:34:24 -0400
From: Jason Goodrow <"goodrow"@opencity. com>
Subject: Thanks! Re: newbie semantic (non-code) question -"what the pros call it" [OT]
Message-Id: <9jnh9b$quf$1@news.panix.com>
>
>
> > Now I have to decide for client server reasons how dense I want to make
> > the incoming data - say 100 items each a 1k array.
> > Do I send these at once in one big string or one at a time.
>
> That's the part you are probably asking about, and sorry, though I've
> done that and dealt with that issue many, many times, I don't have the
> slightest idea what it would be called, though it certainly relates to
> an issue I would label "granularity".
>
>
What I was looking for! Thanks.
goodrow@panix.com
------------------------------
Date: Thu, 26 Jul 2001 01:12:39 +0100
From: James Coupe <james@zephyr.org.uk>
Subject: Re: What am I doing wrong with this command line ?
Message-Id: <Y4i2TTP3B2X7EwtR@gratiano.zephyr.org.uk>
In message <vbG77.111898$E4.3052502@amsnews02.chello.com>, Ken Laird
<kenlaird@yahoo.com> writes
>So I'm trying something like this
>
>perl -e 'for (`ls -la`) {next if /file2/;print}'
>
>but it doesn't work.
Irrespective of whether this would do what you want anyway, you might
want to put a semi-colon in after your print statement.
--
James Coupe PGP Key: 0x5D623D5D
"Surely somewhere out there there's a woman who's EBD690ECD7A1F
been sodomized by her father and is capable of B457CA213D7E6
composing a few coherent sentences on the subject." 68C3695D623D5D
------------------------------
Date: Thu, 26 Jul 2001 09:03:13 +0800
From: MMX166+2.1G HD <no@mail.addr>
Subject: Re: Who can help me about the confused (..) operator?
Message-Id: <vr9qlto6vfhn9hqpo0qcpt9g1mgcb9affj@4ax.com>
On 23 Jul 2001 03:27:06 GMT, in comp.lang.perl.misc
ebohlman@omsdev.com (Eric Bohlman) wrote:
>[please post you comments *after* the stuff you're commenting on. I had
>to rearrange things so my reply would make sense in context]
is it OK now?sorry I had not heard of the rule of this order, I used
to let my Agent decide who is first :)
------------------------------
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 1380
***************************************