[17264] in Perl-Users-Digest
Perl-Users Digest, Issue: 4686 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Oct 21 21:05:25 2000
Date: Sat, 21 Oct 2000 18:05:08 -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: <972176708-v9-i4686@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Sat, 21 Oct 2000 Volume: 9 Number: 4686
Today's topics:
Re: Boolean query to Perl regexp match conversion <lincmad001@telecom-digest.zzn.com>
Re: Boolean query to Perl regexp match conversion (Gwyn Judd)
Re: converting a binary file to ascii (Peter McMorran)
Re: Deleting lines in a text file??? (Gwyn Judd)
Re: Dynamic Regex building? <krahnj@acm.org>
Re: here and filehandle <harrisr@bignet.net>
Re: here and filehandle (Tad McClellan)
Re: here and filehandle (Gwyn Judd)
Re: here and filehandle (Tad McClellan)
Re: here and filehandle <uri@sysarch.com>
Re: here and filehandle <ryantate@OCF.Berkeley.EDU>
Re: here and filehandle <harrisr@bignet.net>
Re: POST into an other cgi script <ryantate@OCF.Berkeley.EDU>
Re: should be easy, but not working - help ! (Gwyn Judd)
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sat, 21 Oct 2000 17:28:34 -0700
From: Linc Madison <lincmad001@telecom-digest.zzn.com>
Subject: Re: Boolean query to Perl regexp match conversion
Message-Id: <211020001728347441%lincmad001@telecom-digest.zzn.com>
In article <39f1a027@cs.colorado.edu>, Tom Christiansen
<tchrist@perl.com> wrote:
> No one has to date suggested the simplest solution of all. It's
> sort of an Occam's Razor approach, one often favored by Larry, so
> we'll call it Larry's Razor. Just use Perl as the input. In short,
> just require that
>
> (foo OR bar) AND blah* AND kernel
>
> be typed in with slashes as quote delimiters, yielding
>
> (/foo/ or /bar/) and /blah*/ and /kernel/
>
> which you are then free to compile as is. Benefits of this approach
> are many and strong, so you should not automatically disregard it.
Except that /blah*/ does not have the same meaning as blah* in the
original query. You would have to change it to /blah.*/ Also, as I read
he original query, it would actually change to something like
(/\bfoo\b/ or /\bbar\b/) and /\bblah/ and /\bkernel\b/
(In English, the word "foo" or the word "bar," plus any word beginning
with "blah" and the word "kernel.")
You're much less likely to get non-Perl-programmers to write that sort
of search query in Perl syntax.
------------------------------
Date: Sun, 22 Oct 2000 01:02:59 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: Boolean query to Perl regexp match conversion
Message-Id: <slrn8v4f5v.n56.tjla@thislove.dyndns.org>
I was shocked! How could Linc Madison <lincmad001@telecom-digest.zzn.com>
say such a terrible thing:
>In article <39f1a027@cs.colorado.edu>, Tom Christiansen
><tchrist@perl.com> wrote:
>
>> No one has to date suggested the simplest solution of all. It's
>> sort of an Occam's Razor approach, one often favored by Larry, so
>> we'll call it Larry's Razor. Just use Perl as the input. In short,
>> just require that
>>
>> (foo OR bar) AND blah* AND kernel
>>
>> be typed in with slashes as quote delimiters, yielding
>>
>> (/foo/ or /bar/) and /blah*/ and /kernel/
>>
>> which you are then free to compile as is. Benefits of this approach
>> are many and strong, so you should not automatically disregard it.
>
>Except that /blah*/ does not have the same meaning as blah* in the
>original query. You would have to change it to /blah.*/ Also, as I read
>he original query, it would actually change to something like
But /blah*/ matches the same strings as /blah.*/ which matches the same
strings as /blah/. Therefore they have the same meaning. Depending on
what the 'blah*' in the original query was intended to match.
>(/\bfoo\b/ or /\bbar\b/) and /\bblah/ and /\bkernel\b/
>
>(In English, the word "foo" or the word "bar," plus any word beginning
>with "blah" and the word "kernel.")
>
>You're much less likely to get non-Perl-programmers to write that sort
>of search query in Perl syntax.
True.
--
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
You will visit the Dung Pits of Glive soon.
------------------------------
Date: Sat, 21 Oct 2000 17:57:11 -0400
From: mcmorran@visi.net (Peter McMorran)
Subject: Re: converting a binary file to ascii
Message-Id: <39f21315$2$zpzbeena$mr2ice@news.visi.net>
In <39EF845D.CBCCFC3A@pauls.seanet.com>, on 10/19/00
at 04:31 PM, Paul Spitalny <pauls_spam_no@pauls.seanet.com>
said:
>Larry Rosler wrote:
>>
>>
>> Apparently your input file has 8-byte alignment screwed up. If this is
>> due to a "\12" in the binary data, it can only be because the file was
>> *written* as a text file, so what was written was really "\15\12".
>>
>> To verify this conjectore, test again without the (correct) 'binmode
>> NEW;' statement. Then any "\15\12" sequence in the input file will be
>> converted (back?) to "\12" and the program should work.
>>
>>
>> You might find unpacking the file with 'H*' format a useful way of
>> seeing what is really there.
>>
>> --
>> (Just Another Larry) Rosler
>>
>Hi Larry,
>Right you are! Here is what I get... I print the output line #
>(just for convenience), then do an unpack using "H*" and the
>unpack using "d" . See how line # 14 with the (hex) 0d and 0a is
>where things start to go astray.
>1 00f7fcf4cf03c73e 2.74358891508189e-006
>2 5327c018bd7d2dbf -0.000224999745455807
>3 0000000000000000 0
>4 0000006febacfbbd -4.02731055969274e-010
>5 0000000000000000 0
>6 a334d21ff8c3483f 0.000755783228343927
>7 00307602fbda48bf -0.000758526385582936
>8 00003e13abdcfdbd -4.34549080089396e-010
>9 0000000000000000 0
>10 0000000000000000 0
>11 00485baafeff0140 2.24999745455807
>12 0000000000000240 2.25
>13 00a42d55ffff0140 2.24999872727903
>14 cffab7ae3e1e0d0a 2.95908505230826e-260
>15 4000485baafeff01 4.77753130050077e-299
>I coded it like this:
>open(BIN,'<purebin.dat');
>open(OUT,'>decoded.dat');
>binmode(BIN);
>$count = 0;
>seek(DAT, $point, 0);
>while (read(BIN,$in,8))
> {
> $count ++;
> $foo = unpack("H*",$in);
> $bar = unpack("d",$in);
> print OUT "$count $foo $bar\n";
> }
>close(BIN);
>close(OUT);
>Any thoughts on how to cure myself of this CR, lF dis-ease??
>By the way, the file I am struggling with is written by a cad
>tool (a SPICE simulator). The format is entirely due to the guys
>at the simulator factory!!
>Thanks for all your help to-date, thanks a whole lot!
>Paul
Hello Paul,
Did you by any chance ftp this file from a *nix system to a
Windows system? If so, did you make sure to use binary instead of
ascii mode when transferring the file? ascii mode ftp would make
this helpful modification to the file. The cleanest solution
would be to repeat the ftp transfer in binary mode.
If the file was really written as binary data on a Windows system
with this CR/LF nonsense enabled, you should really send a short
message to the guys at the factory to let them know they have
propagated a huge bug.
Cheers,
Peter
--
-----------------------------------------------------------
mcmorran@visi.net (Peter McMorran)
-----------------------------------------------------------
------------------------------
Date: Sat, 21 Oct 2000 23:38:22 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: Deleting lines in a text file???
Message-Id: <slrn8v4a7a.lev.tjla@thislove.dyndns.org>
I was shocked! How could Tony Dalbrekt <tony.dalbrekt@swipnet.se>
say such a terrible thing:
>How do I delete selected lines in a text file?
This is in the FAQ:
perldoc -q 'delete a line in a file'
--
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
"Through the force, things you will see. Other places. The future . . . the
past. Old pants long gone." --Yoda
"The Empire Strikes Back (tm)", "Pants" Style
------------------------------
Date: Sat, 21 Oct 2000 16:37:57 -0700
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: Dynamic Regex building?
Message-Id: <39F228D5.8F59CBF7@acm.org>
Michael Hoffman wrote:
>
> Hi,
> I'm a longtime programmer, but brand-new to Perl, so any pointers
> to relevant info would be appreciated. I've scoured the docs and this
> newsgroup, but couldn;t find an answer.
>
> PROBLEM SYNOPSIS: I need to build a Replace regex based on given criteria.
>
> PROBLEM DETAIL: I am updating a database table dump ("|" delimited) based on
> the differences between the current table schema and a new table layout. New
> fields will be added, but never deleted.
>
> SPECIFICS: I read and compare both schema and build a Search and a Replace
> Regex based on their differences. Then I read in the data file and replace
> the data with the new format.
>
> I've included my entire code in case anyone wants to show me faster ways to
> carry out the procedures. Everything seems to work until the final steps.
From what you have shown us it looks like you are doing too much work
but it is hard to tell without looking at some samples from the data
files. An example of doing too much is assigning a null string to the
first element of an array and then later removing it.
> my @newst="";
> shift @newst; # needed b/c blank character is first record
You do this with three different arrays.
Is the data in $sch_file and $tabfile not related to the data in
$unl_file, and if it is there might be a better (for certain values of
better) way to do it.
Remember, TMTOWTDI. :-)
John
------------------------------
Date: Sat, 21 Oct 2000 18:59:18 -0400
From: "Randy Harris" <harrisr@bignet.net>
Subject: Re: here and filehandle
Message-Id: <sv47t2bm7s9oad@corp.supernews.com>
Ryan Travis Tate <ryantate@OCF.Berkeley.EDU> wrote in message
news:8st0oh$9dq$2@agate.berkeley.edu...
> |> print SMB_CONF <<EOF;
>
> goddamnit everyone -- QUOTE MARKS!!
>
> print SMB CONF <<"EOF";
>
> like that. i pulled out my camel book and everything ...
The camel sayeth:
A line-oriented form of quoting is based on the shell's here-document
syntax.[15] Following a << you specify a string to terminate the quoted
material, and all lines following the current line down to the
terminating string are quoted. The terminating string may be either an
identifier (a word), or some quoted text. If quoted, the type of quote
you use determines the treatment of the text, just as in regular
quoting. An unquoted identifier works like double quotes.
Randy Harris
------------------------------
Date: Sat, 21 Oct 2000 18:20:13 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: here and filehandle
Message-Id: <slrn8v45kt.7oq.tadmc@magna.metronet.com>
On 21 Oct 2000 14:33:31 -0500, Andrew J. Perrin
<aperrin@demog.berkeley.edu> wrote:
>"Arthur Dalessandro" <adalessandro@odione.com> writes:
>
>> I am trying to print to a filehandle using the HERE document type, it is not
>> working, any ideas on how to accomplish this task?
>> open (SMB_CONF,">>$SMB_CONF_FILE");
>> print SMB_CONF <<EOF;
>
>Lose the ; here
>
>> ....
>> .....
>> EOF
>
>and add it here.
That won't fix it either...
>open (SMB_CONF, ">>$SMB_CONF_FILE") or die $!;
^^^^^^^^^
... but that might.
--
Tad McClellan SGML consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sat, 21 Oct 2000 23:20:19 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: here and filehandle
Message-Id: <slrn8v495e.lev.tjla@thislove.dyndns.org>
I was shocked! How could Andrew J. Perrin <aperrin@demog.berkeley.edu>
say such a terrible thing:
>"Arthur Dalessandro" <adalessandro@odione.com> writes:
>
>> I am trying to print to a filehandle using the HERE document type, it is not
>> working, any ideas on how to accomplish this task?
>> open (SMB_CONF,">>$SMB_CONF_FILE");
>> print SMB_CONF <<EOF;
>
>Lose the ; here
>
>> ....
>> .....
>> EOF
>
>and add it here.
>
>open (SMB_CONF, ">>$SMB_CONF_FILE") or die $!;
>print SMB_CONF <<EOF
>....
>.....
>EOF;
Did you even try that?
--
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
No matter how many hot dogs you consume at home, they always taste better
at the ball park.
-Oscar Mayer's Creed
------------------------------
Date: Sat, 21 Oct 2000 18:32:09 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: here and filehandle
Message-Id: <slrn8v46b9.7ps.tadmc@magna.metronet.com>
On 21 Oct 2000 21:10:41 GMT, Ryan Travis Tate <ryantate@OCF.Berkeley.EDU> wrote:
> |> print SMB_CONF <<EOF;
>
>goddamnit everyone -- QUOTE MARKS!!
>
>print SMB CONF <<"EOF";
>
>like that. i pulled out my camel book and everything ...
Did I miss the part where we were to give random guesses
(all of them incorrect) about where the problem is?
Choice of delimiter string is not the problem.
Using double quotes instead of defaulting to double quotes
is not the problem.
Placement of the semicolon is not the problem.
I think the random guesses are because the OP never told
us what is wrong.
That is unclever, as then people start guessing, which is likely
to make the confusion increase, rather than decrease.
"not working" can mean anything.
You deserve bad answers in response to a bad question,
so ask good questions (like tell us what you observed
when you tried it).
And always, yes *always*, check the return value from open().
--
Tad McClellan SGML consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sat, 21 Oct 2000 23:41:50 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: here and filehandle
Message-Id: <x7d7gtpxs2.fsf@home.sysarch.com>
>>>>> "RTT" == Ryan Travis Tate <ryantate@OCF.Berkeley.EDU> writes:
RTT> |> print SMB_CONF <<EOF;
RTT> goddamnit everyone -- QUOTE MARKS!!
RTT> print SMB CONF <<"EOF";
RTT> like that. i pulled out my camel book and everything ...
as others have said, that does nothing as the default behavior of here
docs is double quotish. and i solved his problem by pointing him to the
undefined values in the TEXT of his here doc. his syntax was fine but his
data was faulty.
next time read the other responses before you so wildly jump in.
uri
--
Uri Guttman --------- uri@sysarch.com ---------- http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page ----------- http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net ---------- http://www.northernlight.com
------------------------------
Date: 21 Oct 2000 23:52:11 GMT
From: Ryan Travis Tate <ryantate@OCF.Berkeley.EDU>
Subject: Re: here and filehandle
Message-Id: <8sta7b$ac2$2@agate.berkeley.edu>
my apologies!
i'll re-lurk now ...
cheers
r
------------------------------
Date: Sat, 21 Oct 2000 20:19:04 -0400
From: "Randy Harris" <harrisr@bignet.net>
Subject: Re: here and filehandle
Message-Id: <sv4cik8up2ggae@corp.supernews.com>
Tad McClellan <tadmc@metronet.com> wrote in message
news:slrn8v46b9.7ps.tadmc@magna.metronet.com...
> On 21 Oct 2000 21:10:41 GMT, Ryan Travis Tate
<ryantate@OCF.Berkeley.EDU> wrote:
[snip]
>
> I think the random guesses are because the OP never told
> us what is wrong.
>
Actually, he did, just not in his first post. In a follow up, he
provided sample code and error messages. Based on that info, Uri
appears to have identified the problem.
Randy Harris
> That is unclever, as then people start guessing, which is likely
> to make the confusion increase, rather than decrease.
>
> "not working" can mean anything.
>
> You deserve bad answers in response to a bad question,
> so ask good questions (like tell us what you observed
> when you tried it).
>
>
> And always, yes *always*, check the return value from open().
>
>
> --
> Tad McClellan SGML consulting
> tadmc@metronet.com Perl programming
> Fort Worth, Texas
------------------------------
Date: 21 Oct 2000 23:46:23 GMT
From: Ryan Travis Tate <ryantate@OCF.Berkeley.EDU>
Subject: Re: POST into an other cgi script
Message-Id: <8st9sf$ac2$1@agate.berkeley.edu>
In article <972034158.535136@proxy.bos.nl> you wrote:
| Anyway.. want i want to do is let users post some data into myscript.cgi (my
| script)
| Then i want my script to do something with the data..... and then post that
| data to a script wich isn't mine...
| Understand? And i know how to do it using a get. But i want to submit it
| trough a POST.
here is one raw code example of this, if you care to wade through it:
http://www.ocf.berkeley.edu/~ryantate/src-cgi/tickers_passthru.pl.txt
the actual re-posting occurs around the '$ua = new LWP::UserAgent;' part.
best of luck. in addition to 'perldoc lwpcook' (already suggested), you
might also try 'perldoc LWP::UserAgent'.
and try not to let the crusty PH's 'round here get to you. the lack of sun
and pasty skin and lack of f2f human contact can take quite a toll on the
human psyche :--) but they're sometimes helpful, and always nice
underneath it all!
cheers
ryan
------------------------------
Date: Sat, 21 Oct 2000 23:16:11 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: should be easy, but not working - help !
Message-Id: <slrn8v48tn.lev.tjla@thislove.dyndns.org>
I was shocked! How could none <none@nospam.com>
say such a terrible thing:
>Thanks for the help, but that didn't work either.
>Any other ideas ?
Well, "Didn't work" is a very vague statement. What didn't work? What
error messages did you get? What were the results? I think you need to
post some sufficient code so as to make a self contained script that
exhibits the behaviour.
--
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
1 1 was a race-horse, 2 2 was 1 2. When 1 1 1 1 race, 2 2 1 1 2.
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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.
| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
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 V9 Issue 4686
**************************************