[7930] in Perl-Users-Digest
Perl-Users Digest, Issue: 1555 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Dec 31 03:29:59 1997
Date: Wed, 31 Dec 97 00:00:55 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Wed, 31 Dec 1997 Volume: 8 Number: 1555
Today's topics:
Can you make a literal "@" show up in a format? <janetbuehler@mindspring.com>
Can't e-mail & redirect simultaneously <ajhayes@iland.net>
Re: Can't e-mail & redirect simultaneously <janetbuehler@mindspring.com>
Re: Can't e-mail & redirect simultaneously (Michael Budash)
Re: Can't e-mail & redirect simultaneously (brian d foy)
Re: Can't e-mail & redirect simultaneously (brian d foy)
Re: Effective Perl Contest... word game. <#@qz.to>
Get Method amerar@unsu.com
Re: Get Method (Michael Budash)
Re: Get Method (brian d foy)
Hashes - Heres my try, can you help me to tidy it up ! <jerryp.usenet@connected.demon.co.uk>
Re: Hashes - Heres my try, can you help me to tidy it u <ebohlman@netcom.com>
Re: Hashes - Heres my try, can you help me to tidy it u (Justin Vallon)
Re: How do I efficiently match many patterns at once? <#@qz.to>
misterious context <cho@teleipxsun.kotel.co.kr>
Re: misterious context <ebohlman@netcom.com>
Re: Perl 5 and Win95 (Michael Ng)
Re: Perl-To-C translation ... Help, please. <*@qz.to>
Re: problem when Perl abends WIN32 (Mark A. Stanfill)
Re: problem when Perl abends WIN32 (Michael Ng)
Re: SHELL/REGEX GUNSLINGERS NEEDED!!! <#@qz.to>
Re: SHELL/REGEX GUNSLINGERS NEEDED!!! (Tad McClellan)
SQL Error??? <s027119@income.com.sg>
Re: Testing for null and spaces (Michael Budash)
Re: Wacky idea: a PERL server <joshr@idiom.com>
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 30 Dec 1997 23:48:04 -0500
From: "Janet Buehler" <janetbuehler@mindspring.com>
Subject: Can you make a literal "@" show up in a format?
Message-Id: <68cj66$nmr@camel20.mindspring.com>
I've created a Perl script that compiles some FTP statistics, and then
writes it out in a formatted table to an email message to me. I would like
to be able to specify the To:, From:, and Subject: headers in my REPORT_TOP
format, so the header information is passed to /usr/lib/sendmail -t when I
write the report:
format REPORT_TOP =
To: me@mysite.com
From: me@myserver.com
Subject: FTP Statistics
Date--------------File----------Att--Suc---UF----Bandwidth
.
format REPORT =
@<<<<<<<<<<<<<< @<<<<<<<<<< @>>> @>>> @>>> @>>>>>>>>>>
$datestring,$item,$attempts{$item},$completes{$item},$unrecoveredcount,$band
{$item}
.
However, the format doesn't like to see those "@"s in the email addresses --
it perceives them to be misused picture fields.
Is there any way I can make a literal @ appear in a format? (No,
backslashing it doesn't work.)
My only other option is to specify the recipient and sender as command-line
arguments to sendmail, which works, but is kludgy and which seems to not
have the recipient show up in the headers even when it delivers correctly.
Any ideas?
--Georg
gbuehler@elsitech.com
------------------------------
Date: Tue, 30 Dec 1997 21:20:15 -0600
From: "James & Amber Hayes" <ajhayes@iland.net>
Subject: Can't e-mail & redirect simultaneously
Message-Id: <68cdgs$rqj$1@news.corpcomm.net>
I'm having trouble getting my perl cgi program to e-mail form results and
then redirect the user to another URL. If I put the location header before
the Content-type header, my e-mail is empty. If I put the location header
after the Content-type header, the program generates an html page containing
"Location:.......". Thanks in advance for the help.
Amber
ajhayes@iland.net
------------------------------
Date: Tue, 30 Dec 1997 23:38:57 -0500
From: "Janet Buehler" <janetbuehler@mindspring.com>
Subject: Re: Can't e-mail & redirect simultaneously
Message-Id: <68cj65$nmr@camel20.mindspring.com>
The sending of email and the output of the redirection should be two totally
separate processes.
The email should be sent first (writing out to a filehandle that pipes into
sendmail) and then the redirection output should be written to standard
output. Rather than using redirection, you might want to use client-pull
instead:
<meta http-equiv="refresh"
content="0;url=http://my.redirected.site.com/message.html">
</head>
<body>
One moment, please . . .
</body>
Hope this helps,
--Georg
gbuehler@elsitech.com
James & Amber Hayes wrote in message <68cdgs$rqj$1@news.corpcomm.net>...
>I'm having trouble getting my perl cgi program to e-mail form results and
>then redirect the user to another URL. If I put the location header before
>the Content-type header, my e-mail is empty. If I put the location header
>after the Content-type header, the program generates an html page
containing
>"Location:.......". Thanks in advance for the help.
>Amber
>ajhayes@iland.net
>
>
------------------------------
Date: Tue, 30 Dec 1997 21:54:01 -0700
From: mbudash@sonic.net (Michael Budash)
Subject: Re: Can't e-mail & redirect simultaneously
Message-Id: <mbudash-3012972154020001@d68.nas16.sonic.net>
In article <68cdgs$rqj$1@news.corpcomm.net>, "James & Amber Hayes"
<ajhayes@iland.net> wrote:
>> I'm having trouble getting my perl cgi program to e-mail form results and
>> then redirect the user to another URL. If I put the location header before
>> the Content-type header, my e-mail is empty. If I put the location header
>> after the Content-type header, the program generates an html page containing
>> "Location:.......". Thanks in advance for the help.
>> Amber
>> ajhayes@iland.net
Use _either_ a Content-type: header _or_ a Location: header - not both.
That being said, you can do the email thing, then send the Location:
header back to the browser.
HTH
--
Michael Budash, Owner * Michael Budash Consulting
mbudash@sonic.net * http://www.sonic.net/~mbudash
707-255-5371 * 707-258-7800 x7736
------------------------------
Date: Wed, 31 Dec 1997 02:50:58 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: Can't e-mail & redirect simultaneously
Message-Id: <68ct45$4sc@bgtnsc02.worldnet.att.net>
Keywords: just another new york perl hacker
In article <mbudash-3012972154020001@d68.nas16.sonic.net>, mbudash@sonic.net (Michael Budash) wrote:
> Use _either_ a Content-type: header _or_ a Location: header - not both.
> That being said, you can do the email thing, then send the Location:
> header back to the browser.
unless you have a broken server [1] or are doing server side redirection
(i.e. relative URLs), you should be sending both the Location and
Content-type headers, a a short hypertext note. see the HTTP
specification [2] for more details.
[1]
smells like IIS
[2]
referenced in the CGI Meta FAQ
<URL:http://computerdog.com/CGI_MetaFAQ.html>
--
brian d foy <http://computerdog.com>
#!/usr/bin/perl
$_=q|osyrNewkecnaYhe.mlorsePptMskurj|;s;[NY.PM]; ;g;local$\=
qq$\n$;@pm=split//;while($NY=pop @pm){$pm.=$NY;$ny.=pop @pm}
$pm=join'',reverse($ny,$pm);open(NY,'>&STDOUT');print NY $pm
------------------------------
Date: Wed, 31 Dec 1997 02:54:08 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: Can't e-mail & redirect simultaneously
Message-Id: <68cta3$4sc@bgtnsc02.worldnet.att.net>
In article <68cj65$nmr@camel20.mindspring.com>, "Janet Buehler" <janetbuehler@mindspring.com> wrote:
> The sending of email and the output of the redirection should be two totally
> separate processes.
one process is quite capable of handling several tasks. there is
absolutely no reason to double the load on your server to simply
send mail.
i would suggest sending the HTTP response last though so you can
catch errors before the server complains about them.
--
brian d foy <http://computerdog.com>
#!/usr/bin/perl
$_=q|osyrNewkecnaYhe.mlorsePptMskurj|;s;[NY.PM]; ;g;local$\=
qq$\n$;@pm=split//;while($NY=pop @pm){$pm.=$NY;$ny.=pop @pm}
$pm=join'',reverse($ny,$pm);open(NY,'>&STDOUT');print NY $pm
------------------------------
Date: 31 Dec 1997 04:41:39 GMT
From: Eli the Bearded <#@qz.to>
Subject: Re: Effective Perl Contest... word game.
Message-Id: <qz$9712302256@qz.little-neck.ny.us>
Martin D Schweitzer <martin@matilda.vut.edu.au> wrote:
> Here is a problem:
>
> I have written a word game. The user must find all words using
> the letters given in a square, e.g:
>
> H A N
> D I W
> O R K
(1) All words using those letters? Eg "KIND" is allowed.
(2) All words that you can trace a line through without leaving the box or
crossing lines? Eg "HAIR":
H A
I
R
(3) All words that can be formed by dropping letters from "HANDIWORK"?
Eg. "ARK".
Each of these will have a different solution.
> The computer then generates a list of solutions. The technique I
> am currently using is as follows:
>
> (pseudocode)
> $magic = sort "HANDIWORK" ;
> foreach word (/usr/dict/words)
> { $current = sort word ;
> $current -> c.*u.*r.*r.*e.*n.*t.* ; # if you get my meaning
(The final .* is not needed.)
> print $word if $magic =~ /$current/ ;
> }
This is version (1) above, if I get your meaning. First time through
your psuedocode I thought it was (3). First time I looked at the
problem description I thought it was (2).
> Some ideas I have had are to do a grep -v on all letters
> that do not appear in the original word. I am sure that there
> are far more efficient ways, though, of finding if a word can
> be made from the given letters. I look forward to seeing
> any submissions.
I've written code to do anagramming in (obfuscated) C. For that I
would create a bit map of the letters in the original, and in each
of the dictionary words as a fast way to junk stuff. Perl doesn't
have as easy access to bitmaps, but you could use tr to similar
effect:
# preprocess word into list of unique letters used
$letters = &findletters $word;
# this line doesn't actually work
$invletters = ( "ABCDEFGHIJKLMNOPQRSTUVWXYZ" =~ tr:$letters::d )
foreach word (/usr/dict/words)
{
next if ($word =~ tr:$invletters:$invletters:);
# check here for sufficient quantites of each letter
# and you are done. using regular expressions to do this
# is probably too slow. a hash or array with the number
# of each letter available is probably best.
}
Elijah
------ /* gcc signature.c -lm */
main(i,j,k,l){for(i=-12;i<13;i++,printf("\e[H")){for(l=141596885
;l>8;l>>=4)p(97-(l>>22)+(l&15));for(j=-12;j<12;){for(k=j+12?-12:
-6;12>k;)p((l=k*k+++i*i+j*j)<144?(l=sqrt(l))[".,:;iIJYVSOM"]:32)
;j++<11?p(10):0;}}puts("Elijah: #@qz.to");}p(m){printf("%c",m);}
------------------------------
Date: Tue, 30 Dec 1997 23:11:07 -0600
From: amerar@unsu.com
Subject: Get Method
Message-Id: <883544656.1631780868@dejanews.com>
Hello,
If I want to send more than one parameter to a perl/cgi program using the
GET method, I have two questions:
1) How do I seperate the fields??
2) How do I parse them in the program?
I am used to a single parameter like this: name=Chuck
Then in the program:
($field_name, $value) = splir(/=/,$query_string)
How can I do more than one field?
Thanks,
Arthur
amerar@unsu.com
-------------------==== Posted via Deja News ====-----------------------
http://www.dejanews.com/ Search, Read, Post to Usenet
------------------------------
Date: Tue, 30 Dec 1997 22:10:05 -0700
From: mbudash@sonic.net (Michael Budash)
Subject: Re: Get Method
Message-Id: <mbudash-3012972210050001@d68.nas16.sonic.net>
In article <883544656.1631780868@dejanews.com>, amerar@unsu.com wrote:
>> If I want to send more than one parameter to a perl/cgi program using the
>> GET method, I have two questions:
>>
>> 1) How do I seperate the fields??
>>
the same way a browser sends 'em to a form's action-specified script when
the get method is specified: with &. e.g., name=Chuck&age=33&sex=sometimes
>> 2) How do I parse them in the program?
>>
>> I am used to a single parameter like this: name=Chuck
>>
>> Then in the program:
>>
>> ($field_name, $value) = split(/=/,$query_string)
>>
>> How can I do more than one field?
try:
@pairs = split(/&/, $query_string);
foreach (@pairs) {
($field_name, $value) = split(/=/);
... and so on ...
HTH
--
Michael Budash, Owner * Michael Budash Consulting
mbudash@sonic.net * http://www.sonic.net/~mbudash
707-255-5371 * 707-258-7800 x7736
------------------------------
Date: Wed, 31 Dec 1997 02:58:38 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: Get Method
Message-Id: <68ctih$4sc@bgtnsc02.worldnet.att.net>
Keywords: just another new york perl hacker
In article <mbudash-3012972210050001@d68.nas16.sonic.net>, mbudash@sonic.net (Michael Budash) wrote:
> In article <883544656.1631780868@dejanews.com>, amerar@unsu.com wrote:
> >> 2) How do I parse them in the program?
> >>
> >> I am used to a single parameter like this: name=Chuck
> >>
> >> Then in the program:
> >>
> >> ($field_name, $value) = split(/=/,$query_string)
> >>
> >> How can I do more than one field?
>
> try:
[snip same old broken code]
use the CGI module. you can feed it any query string that you like
(i.e. not just from CGI input).
--
brian d foy <http://computerdog.com>
#!/usr/bin/perl
$_=q|osyrNewkecnaYhe.mlorsePptMskurj|;s;[NY.PM]; ;g;local$\=
qq$\n$;@pm=split//;while($NY=pop @pm){$pm.=$NY;$ny.=pop @pm}
$pm=join'',reverse($ny,$pm);open(NY,'>&STDOUT');print NY $pm
------------------------------
Date: Wed, 31 Dec 1997 05:53:31 +0000
From: Jerry Pank <jerryp.usenet@connected.demon.co.uk>
Subject: Hashes - Heres my try, can you help me to tidy it up !
Message-Id: <3xUNrBAb3dq0EwNN@connected.demon.co.uk>
I am trying to do a basic search through a document counting duplicated
words and display the results in (repeat count) order.
There must be a way to sort the hash on values displaying :
keys,values in value order (in a better way than I have).
Could this be achieved using regex ?
Heres my try:
#!/bin/perl5
use strict;
my (%hash,@array,@keys,@values,$i,$value,$key);
$_ = "egg egg bacon bread egg fried chips"; # its early morning !
# split words into @array using space delimiter
@array = sort split(/ /);
# build hash of words,word_count (key,value)
foreach $_ (@array) {
$hash{$_}++
}
# perly black magic to sort hash by values
@keys = sort { $hash{$b} <=> $hash{$a} || length($b) <=> length($a) ||
$a cmp $b} keys %hash ;
# array of values in order
@values = reverse sort values(%hash);
# put the two together
foreach $key (@keys) {
print "$key $values[$i] \n";
$i++;
}
# produces
# egg 3
# bacon 1
# bread 1
# chips 1
# fried 1
# your turn !
--
__Jerry Pank_________________________jerryp.usenet@connected.demon.co.uk_
__www.netconnected.com__________________________Just_another_Perl_Hacker_
------------------------------
Date: Wed, 31 Dec 1997 06:55:48 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: Hashes - Heres my try, can you help me to tidy it up !
Message-Id: <ebohlmanEM1KL0.FLL@netcom.com>
Jerry Pank <jerryp.usenet@connected.demon.co.uk> wrote:
: I am trying to do a basic search through a document counting duplicated
: words and display the results in (repeat count) order.
: There must be a way to sort the hash on values displaying :
: keys,values in value order (in a better way than I have).
Yes, there is.
: Could this be achieved using regex ?
Since this doesn't involve any pattern matching, I don't see why.
: Heres my try:
: #!/bin/perl5
You forgot the "-w"
: use strict;
: my (%hash,@array,@keys,@values,$i,$value,$key);
: $_ = "egg egg bacon bread egg fried chips"; # its early morning !
: # split words into @array using space delimiter
: @array = sort split(/ /);
No need to sort the array.
: # build hash of words,word_count (key,value)
: foreach $_ (@array) {
: $hash{$_}++
: }
Fine, though in Real Life you might be doing this several times within a
program, so you'd want to clear out %hash first.
:
: # perly black magic to sort hash by values
: @keys = sort { $hash{$b} <=> $hash{$a} || length($b) <=> length($a) ||
: $a cmp $b} keys %hash ;
: # array of values in order
: @values = reverse sort values(%hash);
There's no need for this. @keys contains a list of keys sorted by their
values.
: # put the two together
: foreach $key (@keys) {
: print "$key $values[$i] \n";
print "$key $hash{$key} \n";
: $i++;
ditch this.
: }
------------------------------
Date: Wed, 31 Dec 1997 02:11:23 -0500
From: vallon@mindspring.com (Justin Vallon)
Subject: Re: Hashes - Heres my try, can you help me to tidy it up !
Message-Id: <19971231021123623198@user-37kb6e1.dialup.mindspring.com>
Jerry Pank <jerryp.usenet@connected.demon.co.uk> wrote:
> I am trying to do a basic search through a document counting duplicated
> words and display the results in (repeat count) order.
>
> There must be a way to sort the hash on values displaying :
> keys,values in value order (in a better way than I have).
>
> Could this be achieved using regex ?
>
> Heres my try:
>
>
> #!/bin/perl5
>
> use strict;
>
> my (%hash,@array,@keys,@values,$i,$value,$key);
>
> $_ = "egg egg bacon bread egg fried chips"; # its early morning !
>
> # split words into @array using space delimiter
> @array = sort split(/ /);
Don't bother sorting it if you're just counting them anyway.
@array = split /\s+/; # Whitespace
>
> # build hash of words,word_count (key,value)
> foreach $_ (@array) {
> $hash{$_}++
> }
>
> # perly black magic to sort hash by values
> @keys = sort { $hash{$b} <=> $hash{$a} || length($b) <=> length($a) ||
> $a cmp $b} keys %hash ;
Personally, I would sort by number, then alphabetical:
@keys = sort { $hash{$b} <=> $hash{$a} || $a cmp $b } keys %hash;
>
> # array of values in order
> @values = reverse sort values(%hash);
>
... You were doing so well... Don't bother with the @values.
> # put the two together
> foreach $key (@keys) {
> print "$key $values[$i] \n";
> $i++;
> }
# Print the keys and their counts.
for $key (@keys) {
print "$key $hash{$key}\n";
}
>
> # produces
> # egg 3
> # bacon 1
> # bread 1
> # chips 1
> # fried 1
>
> # your turn !
--
-Justin
vallon@mindspring.com
------------------------------
Date: 31 Dec 1997 03:25:38 GMT
From: Eli the Bearded <#@qz.to>
Subject: Re: How do I efficiently match many patterns at once?
Message-Id: <qz$9712302208@qz.little-neck.ny.us>
Stephan Vladimir Bugaj <bugaj@bell-labs.com> wrote:
> FAQ sez:
> "How do I efficiently match many patterns at once?
> Instead, you either need to use one of the experimental Regexp extension
> modules from CPAN (which might well be overkill for you purposes)..."
> Well, I looked on CPAN and found only
>
> Devel::RegExp
...
> Which don't seem to have extended functionality for matching
> quickly against large arrays of patterns as a replacement for
> the:
Well, the Devel:RegExp module is supposed to help by allowing you to
precompile all the regular expressions without creating a function to
hold them. I tried it out in a script of mine that involves doing some
30000 matches on a typical input from some 400 regular expressions. I
found that it slowed my script down, making about four to five times
slower.
Using the benchmark module, I found that the 30000 calls to Regexp::match
were taking three times as long as the whole script without the
precompilation (but also with the benchmark module).
Elijah
------
#!/usr/bin/perl -- -*- my ny.pm sig -*-
$_=$^ ;s;s;sss;;s^.^ju^&&s&P+&\n&&&(s(_..)(ers)||s|^|^^|)&&s(T)(q(st%eg))eg;
s<.(o).><$& new 1$$>i+s+\dst.+$a--||reverse(q(rep k))+ge;s*%.+u* so+*i;s=\++
="me"=mex&&s%ege%l$"hke%;$a||s/^\S+ /\/\//;s;\d+;yor;;s[KE]<ac$&>i;print $_;
------------------------------
Date: Wed, 31 Dec 1997 13:25:44 -0800
From: Cho SangWook <cho@teleipxsun.kotel.co.kr>
Subject: misterious context
Message-Id: <34AAB858.41C6@teleipxsun.kotel.co.kr>
Hi, all!
I'm rather new to Perl.
The scalar and list context are somewhat confusing to me.
I thought that I understood each context, but I failed to
understand the following code. It originated from page 116 from
Programming Perl book.
Suppose
%foo = (f => 1, g => 'abc', h => 3, i => '21a');
while ($k = each %foo) {
print "key = $k\n";
}
I thought that above code had to print 1, abc, 3, 21a in random
order. But I was wrong.
It printed keys instead.
"each" returns two elements list consisting of key and value pairs.
But
$x = (4, 5, 6);
print "$x\n";
prints 6 and
@x = (4, 5, 6);
$x = @x;
print "$x\n";
prints 3.
>From these I guessed that the topmost code had to print the values
of hash.
What's wrong with my understanding?
Can anybody explain to me?
Thanks in advance.
Cho, SangWook(cho@teleipxsun.kotel.co.kr)
------------------------------
Date: Wed, 31 Dec 1997 07:04:35 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: misterious context
Message-Id: <ebohlmanEM1Kzn.Fzz@netcom.com>
Cho SangWook <cho@teleipxsun.kotel.co.kr> wrote:
: The scalar and list context are somewhat confusing to me.
: I thought that I understood each context, but I failed to
: understand the following code. It originated from page 116 from
: Programming Perl book.
: Suppose
: %foo = (f => 1, g => 'abc', h => 3, i => '21a');
: while ($k = each %foo) {
: print "key = $k\n";
: }
: I thought that above code had to print 1, abc, 3, 21a in random
: order. But I was wrong.
: It printed keys instead.
: "each" returns two elements list consisting of key and value pairs.
If you try to assign a list to a scalar, only the first element in the
list gets assigned.
: But
: $x = (4, 5, 6);
: print "$x\n";
: prints 6 and
While this looks like an assignment of a list to a scalar, it isn't.
"(4,5,6)" isn't treated as a list here; it's treated as an expression
with two comma operators, the value of which is the value of the
last sub-expression.
: @x = (4, 5, 6);
: $x = @x;
: print "$x\n";
: prints 3.
"@arrayname" in scalar context gives the number of elements in the array.
------------------------------
Date: 31 Dec 1997 07:19:31 GMT
From: syng@garlic.engr.ucdavis.edu (Michael Ng)
Subject: Re: Perl 5 and Win95
Message-Id: <68crm3$4k2$2@mark.ucdavis.edu>
Tom Phoenix (rootbeer@teleport.com) wrote:
::> On Tue, 30 Dec 1997, G. Helms wrote:
::> > I'm finding lots of downloads for Perl on Win32, and I've been told
::> > Win32==Win95....
::> Yes....
Actually, I might say.. Win32 > Win95. I think the Win32 is mainly
referring to WinNT. AFAIK (I am using the "native port" ver of Perl in
Win32), not all Win32 related features works in 95.
::> > yet another doc I've found says that Perl has problems with Win95, and
::> > one has to hand-edit several files to get it to function.
::> That sounds as if it's talking about compiling it yourself, which you
::> shouldn't need to do.
If my memory is correct, Perl for Win32 in earlier day (I think it is
Activestate? ver), needs some tricks in installation part.
My native ver. of Perl 5.004 something didn't report any error during
installation (as far as I can recall)
::> > The other issue is, I'd prefer to snag the binary
version, ::> > as I don't have any development compilers on this system.
::> Getting the binary is a good idea. Use Sarathy's, which you can find on
::> CPAN. Hope this helps!
You can find the link from www.perl.com
--
Michael (syng@engr.ucdavis.edu)
------------------------------
Date: 31 Dec 1997 03:34:47 GMT
From: Eli the Bearded <*@qz.to>
Subject: Re: Perl-To-C translation ... Help, please.
Message-Id: <qz$9712302226@qz.little-neck.ny.us>
In article <6864d4$7uf@drn.zippo.com>, <chad> wrote:
Love that email address, chad.
> I read that there where a Per-To-C translators but where I read it, it gave no
> resources to help me use or find it. Does anyone know anything about this and
> could you please give me links (URLS).
CPAN is where you should look for stuff like this.
<URL:http://www.perl.com/CPAN/>
Hint: look for it as a "compiler" not a "translator".
Elijah
------
thinks of 'chad' as being card punch refuse
------------------------------
Date: Wed, 31 Dec 1997 05:14:09 GMT
From: mstan@flashSPAAM.net (Mark A. Stanfill)
Subject: Re: problem when Perl abends WIN32
Message-Id: <34afd3c4.66035596@209.30.0.7>
Please excuse me if any of this seems too basic. First of all,
if you know the name of the file you were writing, a simple:
dir /s filename.txt
executed from c:\ will show any occurrences of the file. I'm
going to assume that you've run scandisk and defrag to look for
any obvious linking problems. Finally, be aware that the
creation of a large number of directories will take up a huge
amount of space, but will not appear in the byte-count of a
directory listing (ie, if you have a folder with one 2meg file
and 3,000 subdirectories, the directory listing will only report
the 2meg file and not the several meg that the directory indexes
are occupying). Finally, something like:
dir /s /a-d /o-d | perl -e "while (<>){print if /(\d{2,},\d+,/;}"
will print all files between 10 and 99 meg.
'dir /s /a-d /o-d | perl -e "while (<>){print if
/(\d+,)*\d+,\d+,/;}" '
will cover the bases for anything larger than that.
Hope this helps.
On Tue, 30 Dec 1997 20:23:04 -0600, <NoSpam/w6089@cloudnet.com>
wrote:
>I wrote a program that was on the way toward
>using up all my disk space.
>I Killed the program, but by did not
>release the disk space.
>Before the program I had 3/4 of
>a gigabyte. afterward I had about
>5 megabytes.
>I deleted what I thought was the
>file created. it used 0 bytes.
>I even deleted everything in
>the temp directory after
>rebooting.
>I've rebooted about 4 times.
>and still all this disk space
>is still held.
>I'm thinking I'm going to have to
>reinstall the operating system
>top get it all back. I shouldn't
>have to do this.
>Can anyone out there, please,
>help me?
>Thank you
>Dennis Woolsey
>w6089@cloudnet.com
>
>
------------------------------
Date: 31 Dec 1997 07:23:20 GMT
From: syng@garlic.engr.ucdavis.edu (Michael Ng)
Subject: Re: problem when Perl abends WIN32
Message-Id: <68crt8$4k2$3@mark.ucdavis.edu>
Um.. I dunno what File system you ar eusing.. Say, if you use FAT, there
may some lost clusters which may occupies a lot of space. It is possible
because you kill the program, so that it cannot close the file, update
the disk record.
Maybe using program like scandisk will help.
Dunno what to do in NTFS.
BTW, next time, please adjust the right margin. There is a lot of space
on the right hand side ;-)
NoSpam/w6089@cloudnet.com wrote:
::> I wrote a program that was on the way toward
::> using up all my disk space.
::> I Killed the program, but by did not
::> release the disk space.
::> Before the program I had 3/4 of
::> a gigabyte. afterward I had about
::> 5 megabytes.
::> I deleted what I thought was the
::> file created. it used 0 bytes.
::> I even deleted everything in
::> the temp directory after
::> rebooting.
::> I've rebooted about 4 times.
::> and still all this disk space
::> is still held.
::> I'm thinking I'm going to have to
::> reinstall the operating system
::> top get it all back. I shouldn't
::> have to do this.
::> Can anyone out there, please,
::> help me?
::> Thank you
::> Dennis Woolsey
::> w6089@cloudnet.com
--
Michael (syng@engr.ucdavis.edu)
+--------------------------------------------------------------+
| http://www.engr.ucdavis.edu/~syng/ |
| <PGP public key: http://www.engr.ucdavis.edu/~syng/mike.pgp> |
+--------------------------------------------------------------+
------------------------------
Date: 31 Dec 1997 04:55:08 GMT
From: Eli the Bearded <#@qz.to>
Subject: Re: SHELL/REGEX GUNSLINGERS NEEDED!!!
Message-Id: <qz$9712302342@qz.little-neck.ny.us>
<Rholder@sispost1.bis.adp.com> wrote:
See Sami's post for a good perl solution, I've set followups to c.u.s.
> #!/usr/bin/ksh -x
...
> for REGEX in `(cat /usr/local/scripts/pregex)`
That's a Useless Use of Cat. Better would be:
for REGEX in $(</usr/local/scripts/pregex)
Works for sure in ksh and probably in bash and zsh.
> ps -eo pid,args | egrep -v egrep | egrep $REGEX | awk '{print $1}'
> ....and here is what is in the file /usr/local/scripts/pregex:
> '(dataserver).*(miler)+'
That's your problem. The quotes will be *inside* the variable $REGEX
instead of quoting the *contents* of $REGEX.
You wanted:
ps -eo pid,args | egrep -v egrep | egrep "$REGEX" | awk '{print $1}'
And the file to contain:
(dataserver).*(miler)+
(I'd probably use cut instead of awk, myself.)
Except that those REs are kinda weird, and maybe you really meant:
dataserver.*miler
(It is almost certainly the pattern grep will match, regaurdless of
what you inteneded. For effeciency, most/all greps do what perl'ers
call non-greedy matching.)
Elijah
------
perl -e 's Y Yreverse q N ny pm srekcah lrep kroy wen emosNYex and s Pmp ynP
P and s MsMjust sMx and print and s NYPM MPYN Nis or reverse and print q qq'
------------------------------
Date: Tue, 30 Dec 1997 22:22:07 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: SHELL/REGEX GUNSLINGERS NEEDED!!!
Message-Id: <f9hc86.434.ln@localhost>
Rholder@sispost1.bis.adp.com wrote:
: I want to store regular expressions in one file, and then use a
: shell script to read them into a shell variable within a "for" loop,
: and then feed the expression into egrep via the shell variable.
: I'm doing this under Solaris 2.5.1.
[snip script]
: .....and here is what is in the file /usr/local/scripts/pregex:
: '(dataserver).*(miler)+'
: '(dataserver).*(citys)+'
: '(dataserver).*(demo)+'
Why the plus signs in there?
Do you really mean to match 'dataserver milermiler' ?
That is much too uniform a set of regexes to need a file to store
them in.
: Here is what the lines I'm searching for look like:
: $ ps -eo pid,args | egrep dataserver
: 970 /opt/sybase/bin/dataserver -d/db/mstr/miler_mstr.0 -smiler
: 18042 egrep dataserver
: 959 /opt/sybase/bin/dataserver -d/db/mstr/demo_mstr.0 -sdemo
: 948 /opt/sybase/bin/dataserver -d/db/mstr/citys_mstr.0 -scitys
ps -eo pid,args | egrep 'dataserver.*(miler|citys|demo)' | awk '{print $1}'
: I don't want to write a long, ugly script with lots of individual egrep
: statements. Is there a way to do this, or should I try an entirely
: different approach? I'm just starting to learn Perl, and I have a
: feeling this is easier to do in Perl, but I need to get this script done,
: like, yesterday...
If you knew Perl, then you could knock that out in 2-3 minutes
(I'm a slow typist)
-----------------------
#!/usr/bin/perl -w
#open(PS, 'ps -eo pid,args |') || die "could not fork";
while (<DATA>) {
print "$1 = $2\n" if /^\s*(\d+).*dataserver.*(miler|citys|demo)/;
}
#close(PS) || die "error running 'ps'";
__DATA__
970 /opt/sybase/bin/dataserver -d/db/mstr/miler_mstr.0 -smiler
18042 egrep dataserver
959 /opt/sybase/bin/dataserver -d/db/mstr/demo_mstr.0 -sdemo
948 /opt/sybase/bin/dataserver -d/db/mstr/citys_mstr.0 -scitys
-----------------------
Uncomment those lines above and change the DATA filehandle to PS.
I don't have a 'ps -eo pid,args' to try it out with here.
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: 31 Dec 1997 04:02:14 GMT
From: "S. Sarkar" <s027119@income.com.sg>
Subject: SQL Error???
Message-Id: <01bd15a0$a7a37520$2d1809a8@sarkar.income.com.sg>
I am using the Minisoft Odbc for HP 3000 mini from within a Perl script.
The following
sql statement did not retrieve any records though there were records in the
table satisfying the condition.
select * from table where upper(name) like upper('mr lim%')
Doesn't does the odbc support sql statements with certain clauses in it?
If so, what is the replacement for the above stmnt? Please help ASAP.
------------------------------
Date: Tue, 30 Dec 1997 22:17:56 -0700
From: mbudash@sonic.net (Michael Budash)
Subject: Re: Testing for null and spaces
Message-Id: <mbudash-3012972217570001@d68.nas16.sonic.net>
In article <asquiresEM1497.F80@netcom.com>, asquires@netcom.com (Andy
Squires) wrote:
>> I'm trying to test whether or not a variable is blank or null and can't
figure out why the following doesn't work.
>>
>> str1=" ";
>> if(str1=~ /^\s*$/) {
>> print "The field does not contain data\n";
>> } else {
>> print "The field does contain data\n";
>> }
>>
I tested this script, and as I suspected, it won't even compile! Here's
the errors:
---------
Can't modify constant item in scalar assignment at test.pl line 5, near
"" ";"
Execution of test.pl aborted due to compilation errors.
---------
so...
str1=" ";
should read:
$str1=" "; # note the "$", necessary to denote a scalar variable
and
if(str1=~ /^\s*$/) {
should read:
if($str1=~ /^\s*$/) {
testing with those changes yields:
The field does not contain data
HTH
--
Michael Budash, Owner * Michael Budash Consulting
mbudash@sonic.net * http://www.sonic.net/~mbudash
707-255-5371 * 707-258-7800 x7736
------------------------------
Date: 31 Dec 1997 03:37:47 GMT
From: josh rotenberg <joshr@idiom.com>
Subject: Re: Wacky idea: a PERL server
Message-Id: <68cemb$821$1@news.idiom.com>
this is pretty much unrelated cuz its not a server, but the latest beta
versions of vim, the ViIMproved editor let you compile a perl interpreter in
and you can write macros and whatnot in perl ... kinda nifty.
just fyi in case anyone wants to play with it.
josh
brian moore <bem@news.cmc.net> wrote:
> In article <67l27e$pve$1@mahler.udel.edu>,
> biell @ udel . edu (Bill Totten) writes:
> > In article <wx090tlw0bz.fsf@sws5.ctd.ornl.gov>,
> > Dave Sill <dsill@sws5.ctd.ornl.gov> wrote:
> >>Perl is nifty, but it's just too expensive to start up a new perl
> >>process to handle a quick job like munging/matching mail/news headers
> >>on a busy SMTP/NNTP server. Has anyone ever thought about the
> >>possibility of running perl in a client/server mode, where
> >>/usr/bin/perl is just a client that passes the script to a long-lived
> >>server daemon and waits for the results? One obvious complication is
> >>handling different users. The server could run as root, I suppose, but
> > <...>
> >
> > This is not really necessary, however. In any reasonable OS, perl will
> > stay in shared memory if you have enough of it. So, if perl never leaves
> > shared memory, you have the bulk of the program ready for use by anyone.
> > The first time you start it, it will still need to be loaded.
> Actually, it's unnecessary for another reason: INN, for example can be
> easily built with perl hooks. This allows a long running perl function
> to scan message headers (and with a patch to INN, the body) looking for
> articles to reject. I drop well over 100k spams a day with this at a
> cost of <10ms per message (with the current volumes of spam, this is
> a huge win, since it's a lot of messages I don't write to disk :)).
> Embedding a perl interpreter in other things (say, Apache) has also
> been done with great effect: compile the stuff once, the perl functions
> can be rerun quickly and simply.
> Don't even have to run 'perl' itself, then: just libperl.
> The best thing about perl5 is its ability to be embedded in other programs
> and the huge collections of modules from CPAN. Um, the two best things...
> --
> Brian Moore Kill A Spammer For Jesus
> Sysadmin, C/Perl Hacker
--
josh rotenberg
email: josh@adj.com josh@parasite.com
web: www.adj.com www.parasite.com
phone: 415 487 4520 x 151 don't call me.
Segmentation fault (core dumped)
------------------------------
Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 8 Mar 97)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.
The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V8 Issue 1555
**************************************