[12764] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 174 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Jul 17 05:07:13 1999

Date: Sat, 17 Jul 1999 02:05:11 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Sat, 17 Jul 1999     Volume: 9 Number: 174

Today's topics:
    Re: cgi compiler <swiftkid@bigfoot.com>
    Re: dbase 4 (Eric Bohlman)
    Re: Future of Perl (Abigail)
    Re: Hex dump (Bart Lateur)
    Re: how do i know the PERL version o my Web Server ? <LanChatalot@cableone.net>
    Re: how do i know the PERL version o my Web Server ? (Abigail)
    Re: how do i know the PERL version o my Web Server ? (Dave Cross)
    Re: How to block a file (Abigail)
    Re: how to get command line filename argument back? <monty@primenet.com>
        Module to figure out pop3 server names? billy_collins@my-deja.com
    Re: Module to figure out pop3 server names? (Abigail)
    Re: Need help with cookie cgi <swiftkid@bigfoot.com>
    Re: Newbie.  Quick question about installing packages <swiftkid@bigfoot.com>
    Re: NPH mode ? (Abigail)
    Re: Old database is erased when I add new information (Neko)
    Re: Parsing a Decisive survey w/ REGEX...need help (Bart Lateur)
    Re: Parsing a Decisive survey w/ REGEX...need help <dbe@wgn.net>
        Perl on HP-UX <leaper2000@hotmail.com>
    Re: Perlshop Question (Abigail)
        Prime Factorization <fromero@csudh.edu>
    Re: Prime Factorization (Abigail)
    Re: Prime Factorization (Abigail)
        Problem with forking smnayeem7346@my-deja.com
    Re: searching man pages, perldoc's, FAQ's, README's, HO <uri@sysarch.com>
    Re: tie SDBM_File on Win95 <dbe@wgn.net>
    Re: Tiny error in perlfaq5 (Bart Lateur)
    Re: URL Verification <swiftkid@bigfoot.com>
    Re: Where to start with perl programming ? <fromero@csudh.edu>
        Digest Administrivia (Last modified: 1 Jul 99) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Sat, 17 Jul 1999 12:04:13 +0500
From: "Faisal Nasim" <swiftkid@bigfoot.com>
Subject: Re: cgi compiler
Message-Id: <7mqd7c$9jb3@news.cyber.net.pk>

: Dear,
:         Where can I find a CGI complier(work under windows)?
:     As I want to change my program into byte code!
:                                                     Thank you very much!
:        Ck
:

Check out PRK, I think it has pl2exe converter. And also:

www.demobuilder.com





------------------------------

Date: 17 Jul 1999 06:31:21 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: dbase 4
Message-Id: <7mp7vp$qfa@dfw-ixnews7.ix.netcom.com>

TravisC (travis.cox@itron.com) wrote:
: I am looking for a module to convert text files to dbase (.dbf) format
: so far I haven't found anything. Any help would be greatly appreciated.

DBD::XBase would probably help.



------------------------------

Date: 17 Jul 1999 03:36:29 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: Future of Perl
Message-Id: <slrn7p0g3c.c9j.abigail@alexandra.delanet.com>

Jeffrey (Jeffrey@ix.netcom.com) wrote on MMCXLVI September MCMXCIII in
<URL:news:3797cd5a.172442315@news.giganews.com>:
"" On 15 Jul 1999 23:24:02 -0500, abigail@delanet.com (Abigail) wrote:
"" 
"" >Don't judge programming languages on their usefullness, judge them on
"" >their marketable value! That'll increase the quality of code and will
"" >bring us closer to world peace.
"" 
"" Listen bitch, I learned a lot about how to program the Amiga computer
"" and then it died in the marketplace. I don't want something like that
"" to happen ever again. A language isn't fucking useful if you can't get
"" a job programming in it.

I find Perl very useful, but I've never had a job programming it.  I do
use Perl in my job every day though - but that's not because Perl is
`marketable'. My boss cares about the job being done; he doesn't care
whether I pick the hyped language of the week, or a language noone else
uses. As long as it gets the job done.

A language usefullness doesn't have any relationship with getting a job
in it.

"" As for my original question, it was spurred by a comment in a CGI book
"" that Java would take over and Perl would become a legacy language.
"" Someone said the same thing in a message when I did a search on Deja
"" News. So don't act like my question was so fucking stupid, bitch.

So, you got your answer, and your mind is already made up. Why bother asking?



Abigail
-- 
srand 123456;$-=rand$_--=>@[[$-,$_]=@[[$_,$-]for(reverse+1..(@[=split
//=>"IGrACVGQ\x02GJCWVhP\x02PL\x02jNMP"));print+(map{$_^q^"^}@[),"\n"


  -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
   http://www.newsfeeds.com       The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including  Dedicated  Binaries Servers ==-----


------------------------------

Date: Sat, 17 Jul 1999 06:45:48 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Hex dump
Message-Id: <37902613.212394@news.skynet.be>

xdiv@hotmail.com wrote:

>Is there a way in perl to get a hex dump of a binary string?
>
>For example, suppose I did:
>
>      $s = pack("cci", 0x9, 0xff, 399);
>
>I want a routine that would take $s and return "09ff0000018f".

It's easy enough.

	$bin = join '', map { sprintf '%02x', $_ } unpack 'C*',$s;

Personally, I like upper case and spaces between the bytes:

	$bin2 = join ' ', map { sprintf '%02X', $_ } unpack 'C*',$s;

-> "09 FF 00 00 01 8F"

	Bart.


------------------------------

Date: Sat, 17 Jul 1999 01:17:53 -0500
From: "Brandon" <LanChatalot@cableone.net>
Subject: Re: how do i know the PERL version o my Web Server ?
Message-Id: <932192367.510.67@news.remarQ.com>

contact the server administrator or see the server's Frequently Asked
Questions

Alexandre wrote in message <7mou2k$rv2$1@srv4-poa.nutecnet.com.br>...
>I need to know the perl version on my server.
>
>Tanks,
>alrope@zaz.com.br
>
>




------------------------------

Date: 17 Jul 1999 03:47:51 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: how do i know the PERL version o my Web Server ?
Message-Id: <slrn7p0gon.c9j.abigail@alexandra.delanet.com>

Alexandre (alrope@zaz.com.br) wrote on MMCXLVI September MCMXCIII in
<URL:news:7mou2k$rv2$1@srv4-poa.nutecnet.com.br>:
?? I need to know the perl version on my server.


Goodie.

There are different ways to find out.

   -  Buy a case of beer, and offer it to your system admin in exchange
      for the answer.
   -  Use a command line switch - the manual will tell you which.
   -  Buy a nerf gun, and offer it to your sys admin in exchange for
      the answer.
   -  Use a special variable - the manual will tell you which.
   -  Take your sys admin to a sushi place, in exchange for the answer.
   -  strings `which perl`.
   -  Buy a neat electronic gadget, and offer it to your sys admin in
      exchange for the answer.
   -  Download the newest version of Perl, install it, and tattoo its
      version number on the inside of your eyelids.
   -  Buy tickets of his favourite artist, and offer them to your sys
      admin in exchange for the answer.



Abigail
-- 
perl -we 'print q{print q{print q{print q{print q{print q{print q{print q{print 
               qq{Just Another Perl Hacker\n}}}}}}}}}'    |\
perl -w | perl -w | perl -w | perl -w | perl -w | perl -w | perl -w | perl -w


  -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
   http://www.newsfeeds.com       The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including  Dedicated  Binaries Servers ==-----


------------------------------

Date: Sat, 17 Jul 1999 08:50:47 GMT
From: dave@dave.org.uk (Dave Cross)
Subject: Re: how do i know the PERL version o my Web Server ?
Message-Id: <3790433f.1358299@news.demon.co.uk>

On Sat, 17 Jul 1999 00:31:15 -0300, "Alexandre" <alrope@zaz.com.br>
wrote:

>I need to know the perl version on my server.

It's simple enough to write a CGI script that print s out the value of
$] which is the Perl version number.

<plug>
There's a script the prints out the Perl version and a number of other
useful details of the Perl installation available at
<http://www.mag-sol.com/Download.html>. It's called ms-env.pl.

hth,

Dave...

--
Dave Cross <dave@dave.org.uk>
<http://www.dave.org.uk>


------------------------------

Date: 17 Jul 1999 03:49:23 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: How to block a file
Message-Id: <slrn7p0gr7.c9j.abigail@alexandra.delanet.com>

NoCHaX (nochax@bigfoot.com) wrote on MMCXLVI September MCMXCIII in
<URL:news:378FE37A.D1C6C508@bigfoot.com>:
== I need to block a file in Perl. How to do this?


Define "block a file".



Abigail
-- 
%0=map{reverse+chop,$_}ABC,ACB,BAC,BCA,CAB,CBA;$_=shift().AC;1while+s/(\d+)((.)
(.))/($0=$1-1)?"$0$3$0{$2}1$2$0$0{$2}$4":"$3 => $4\n"/xeg;print#Towers of Hanoi


  -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
   http://www.newsfeeds.com       The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including  Dedicated  Binaries Servers ==-----


------------------------------

Date: 17 Jul 1999 05:46:56 GMT
From: Jim Monty <monty@primenet.com>
Subject: Re: how to get command line filename argument back?
Message-Id: <7mp5cg$3ri$1@nnrp03.primenet.com>

Tom Kralidis <tom.kralidis@ccrs.nrcanDOTgc.ca> wrote:
> The script I'm writing peruses a txt file, extracts the info needed and
> stores them to variables.  I now want to create a new file (same id as
> the txt file, given as argument on command line), with a different
> extension.  I have extracted the info from the first file by:
>
> while <> {
> if (stuff) {
> stuff
>   }
> }
>
> After this statement I am ready to write the variables to file.  Any
> suggestions?  I have tried 
> ($file = shift @ARGV);, but get no results (script freezes, dies)

You said _a_ text file, singular, and _a_ new file, singular. For
the case of a single input file and a single output file, the
solution is simple: Don't use the magical angle operator <>.

#!/usr/bin/perl -w

use strict;
use File::Basename;

my $infile  = $ARGV[0] || 'default.in';
my $outfile = (fileparse($ARGV[0], '\.[^.]*$'))[0] . '.out';
my $value   = '';

open INFILE,  "<$infile"  or die "Cannot open file $infile for input: $!\n";
open OUTFILE, ">$outfile" or die "Cannot open file $outfile for output: $!\n";

while (<INFILE>) {
    $value = $_;  # whatever...
}

print OUTFILE $value;

__END__

Hope this helps.

-- 
Jim Monty
monty@primenet.com
Tempe, Arizona USA


------------------------------

Date: Sat, 17 Jul 1999 05:51:58 GMT
From: billy_collins@my-deja.com
Subject: Module to figure out pop3 server names?
Message-Id: <7mp5ls$4n6$1@nnrp1.deja.com>

Hello

Is there a way to figure out the address of a pop3 server from only an
email address? For instance, if I know that the email ID is

    abc@xyz.com

Can I figure out whether the Pop3 server on the xyz.com is:

    pop3.xyz.com
    mail.xyz.com

etc?

Would appreciate if someone could tell me if there is a module that
does this? Havent been able to find one in the Activestate repository.

Thanks a lot in advance!

Regards
Bill

------------------------------------------------
I can resist anything, except temptation. (Anon)






Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


------------------------------

Date: 17 Jul 1999 03:52:47 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: Module to figure out pop3 server names?
Message-Id: <slrn7p0h20.c9j.abigail@alexandra.delanet.com>

billy_collins@my-deja.com (billy_collins@my-deja.com) wrote on MMCXLVI
September MCMXCIII in <URL:news:7mp5ls$4n6$1@nnrp1.deja.com>:
,, Hello
,, 
,, Is there a way to figure out the address of a pop3 server from only an
,, email address? For instance, if I know that the email ID is
,, 
,,     abc@xyz.com
,, 
,, Can I figure out whether the Pop3 server on the xyz.com is:

No. In fact, the domain xyz might not have a pop3 server at all.
Or one that's internal to their network, and unreachable for you.

,,     pop3.xyz.com
,,     mail.xyz.com


That guessing. And while not being the worst guess, you still will
miss a very large segment.


Why would you want to figure out the pop3 server anyway?

What does this have to do with Perl???


Abigail
-- 
%0=map{reverse+chop,$_}ABC,ACB,BAC,BCA,CAB,CBA;$_=shift().AC;1while+s/(\d+)((.)
(.))/($0=$1-1)?"$0$3$0{$2}1$2$0$0{$2}$4":"$3 => $4\n"/xeg;print#Towers of Hanoi


  -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
   http://www.newsfeeds.com       The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including  Dedicated  Binaries Servers ==-----


------------------------------

Date: Sat, 17 Jul 1999 12:00:40 +0500
From: "Faisal Nasim" <swiftkid@bigfoot.com>
Subject: Re: Need help with cookie cgi
Message-Id: <7mqd0r$9jb2@news.cyber.net.pk>

<rn7532@my-deja.com> wrote in message news:7mojl2$vf7$1@nnrp1.deja.com...
: I would like to figure out a way of remembering a
: person's details (name, address, etc) from a form
: so that when they return to the form at a later
: date the it remembers them. Thus saving them the
: tedious task of filling in all their personal info
: again. Is there a Java Script that would better
: handle this? I am fairly new to back end
: programming. Any help is greatly appreciated!

Check out CGI.pm library. CGI will be better for
what you want to do.




------------------------------

Date: Sat, 17 Jul 1999 11:59:19 +0500
From: "Faisal Nasim" <swiftkid@bigfoot.com>
Subject: Re: Newbie.  Quick question about installing packages
Message-Id: <7mqcu5$9jb1@news.cyber.net.pk>

: install DBI
: install DBD::mysql:http://www.mysql.com/Contrib/ppd/DBD-mysql.ppd

install DBI
install DBD-mysql

: The second install didn't and I received this error:
:
: Retrieving package
'DBD::mysql:http://www.mysql.com/Contrib/ppd/DBD-mysql.ppd'..
: Error installing package
'DBD::mysql:http://www.mysql.com/Contrib/ppd/DBD-mysql.
: ppd': Could not locate a PPD file for package
DBD::mysql:http://www.mysql.com/Co
: ntrib/ppd/DBD-mysql.ppd
:
: So I tried:
: install http://www.mysql.com/Contrib/ppd/DBD-mysql.ppd
: and it works.

See its DBD-mysql... the package name on activestate.




------------------------------

Date: 17 Jul 1999 03:54:51 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: NPH mode ?
Message-Id: <slrn7p0h56.c9j.abigail@alexandra.delanet.com>

Alexandre (alrope@zaz.com.br) wrote on MMCXLVI September MCMXCIII in
<URL:news:7mou2n$rv2$2@srv4-poa.nutecnet.com.br>:
?? Friends,
?? 
??   my script read a large text file, and the answer to Navigator is slow.
?? 
?? how to use the nph mode ?


That is not a Perl question.


Goodbye.



Abigail
-- 
perl -we 'print split /(?=(.*))/s => "Just another Perl Hacker\n";'


  -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
   http://www.newsfeeds.com       The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including  Dedicated  Binaries Servers ==-----


------------------------------

Date: 17 Jul 1999 05:28:03 GMT
From: tgy@chocobo.org (Neko)
Subject: Re: Old database is erased when I add new information
Message-Id: <7mp493$2c8$0@216.39.141.200>

On 16 Jul 1999 05:21:55 GMT, stanley@skyking.OCE.ORST.EDU (John Stanley)
wrote:

>In article <7mm42a$l9s$0@216.39.141.200>, Neko <tgy@chocobo.org> wrote:
>>You gain a good reputation by delivery a good product.  You get a better
>>product if you have others pointing out your mistakes.
>
>And too many cooks spoil the broth. Too many people modifying the code
>is a bad thing. Having people modifying your code when you don't even
>know they are doing it does NOTHING good for your code or your
>reputation.

You're the head chef.  You say what goes in the pot and what doesn't.  The
pastry chef wants to put dough in.  The salad chef wants to put lettuce in.
Just because they put dough and lettuce in their pots doesn't mean you have
to do likewise.

>>You shouldn't be writing X-ray machines, missile guidance systems, or dancing
>>dogs in Perl. :)
>
>I'm sorry you missed the point completely. 

The point was irrelevant and meant to be missed.

>>No one ever said open source works for everything.  
>
>Except to do otherwise is "not the perl way" and people are ridiculed
>when they ask how not to have open source.

I say "open source" in reference to the license you use for your code.  The
perl licenses do not force any license upon the code that you write in Perl.
I do not believe that you are being ridiculed for not using an open source
license.

>>You don't.  There is absolutely no reason you must make your code compatible
>>with theirs.  
>
>Unless you know the situation, please don't tell me what I don't have to
>do.

You don't have to write code.  You don't have to get up in the morning.  You
don't have to eat all your vegetables.  You don't have to pay your rent.  You
don't have to take the dog out for a walk.  You don't have to visit Mecca at
least once in your lifetime.  You don't have to reply to me. :)

>>>>Your two users have forked off entirely different programs.  
>>>
>>>No, not entirely different programs. Not unless you count every
>>>modification to a system as an entirely new system. I don't.
>>
>>Yes.  If two programs work differently, I count them as different.
>
>The statement was "entirely different". If they differ in one small
>operation, that's what you call "entirely different"? When you buy a new
>muffler for your truck, is that an entirely new truck? Its not even a
>new or different truck, much less entirely anything.

If the programs differed in only one small operation, then you have
exaggerated the enhancements your two users have made.  On the other hand, if
they have indeed made enough changes to cause you headaches, I certainly
think "entirely different" would be descriptive.

>If I don't merge, I have to program it. Where is this time I save by
>having people send me patches? 

Agreed.  Ignored patches are worthless.  They don't save you any time, and
they waste the time of those who wrote them.

>>someone breaks your software (and calls it adding features), you do not have
>>to twist your software to make it compatible.
>
>Thanks again for not having a clue about the situation yet volunteering
>to tell me what I don't have to do.

I apologize.  I just keep making assumptions without basis.  I assumed you
wanted to hide your source code.  I assumed this meant you didn't want your
users to modify your code.  I assumed you would say so in a license.  I
assumed that even if you didn't have a license, modifying your code would be
breaking your copyright.

So did you or did you not give permission to modify your code?  If you did,
then there's no point in hiding your source code.  If you didn't, then they
are in the wrong and you have no reason to reward them for it.

>>The number of people who corrupt a binary file with FTP ASCII far outnumber
>>those who ever contemplate editing a Perl program.
>
>So what? Accidental modification of a binary is not the issue.

The issue is lusers thinking you're an idiot because they broke something and
it's your fault for allowing them to do it.  If they break it accidentally,
you're an idiot.  If they break it deliberately, you're still an idiot.  If
they drop a basketful of eggs, they blame God for making egg shells so easy
to break.  You just can't win against stupidity.

>Deliberate modification is.

Deliberate modification is handled with a license and a good lawyer.

-- 
Neko | tgy@chocobo.org | Will hack Perl for a moogle stuffy! =^.^=


------------------------------

Date: Sat, 17 Jul 1999 07:36:08 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Parsing a Decisive survey w/ REGEX...need help
Message-Id: <37953244.3333892@news.skynet.be>

[posted and mailed]
Mark R. Cervarich wrote:

>I have a tab-delimited file that contains a decisive survey.  The software
>makers are un(able|willing) to help me, so I have turned to perl and have
>gotten a little bit stuck.
>
>I am able to read the file line by line into an array.
>
>Split the lines on the tabs into another array this creates an array of
>answers from 1..40.
>
>Where I am having problems is writing a regexp to work with the each answer.
>Data can be either:  (I will use {} braces to show where the data actually is)
>
>1) an empty string: {}
>2) a string of text:  ie: {You rarely offer me assigments in my specialty.}
>3) a string that begins with a letter from A..T.  
>   ie: { D- Trade magazine ad (national publications)}
>4) a string that contains answers to multiple questions A..T
>   ie: {" C- Newspaper ad, D- Trade magazine ad (national publications), F- Recruiting web site (Monster.com, Hotjobs.com, etc.)"}
>
>The string gets surrounded by quotes if there happens to be a period "." inside the string.
>
>What i need to output is:
>   If we are in case 2:
>   The question # followed by a period.  A newline.
>   Then the string inside of brackets.
>
>   if we are in case 3 or 4:
>   The question # followed by a period. A newline.
>   Brackets with an x inside of it.  ie:  [  x  ]  
>    followed by the question letter, then a right parenthesis   ie:  D)
>
>So what does that mean?  Well consider this input:
>
>---begin input---
>" A- First name: - Helen M., B- Last name: - Giese, D- email address: - hele@xxxxx.com"###TAB###" A- Street address, first line: - 1758 W. Olive Ave., C- City: - XXXXXXX, D - State: - IL, E- Zip code: - 99999"###TAB###" L- Other, please specify... - Medical writer/editor"###TAB### C- 3-5 years###TAB### A- Laid off or down-sized and started freelancing at that point###TAB### ###TAB###" C- No, I'd rather work for a company"
>---end input---
>
>(here's an easier way to look at it)
>
>---begin input---
>1. {" A- First name: - Helen M., B- Last name: - Giese, D- email address: - hele@xxxxx.com"}
>2. {" A- Street address, first line: - 1758 W. Olive Ave., C- City: - XXXXXXX, D
>- State: - IL, E- Zip code: - 99999"}
>3. {" L- Other, please specify... - Medical writer/editor"}
>4. { C- 3-5 years}
>5. { A- Laid off or down-sized and started freelancing at that point }
>6. {}
>7. {" C- No, I'd rather work for a company"}
>---end input---

I think that, first, you should remove the quotes, and second, that you
look for and split on the pattern /, [A-T]-/, but with lookahead on part
of it in order not to strip it off.

	# $_  is your data string (but without the trailing quote)
	chomp;
	my @record = split /\t/;
	foreach (@record) {
	    s/^"// && s/"$//;
	    my @field = split /,(?= [A-T]-)/;
	    local($\,$,) = ("\n\n","\n");
	    ++$count;
	    print "$count.",@field;
	}
__END__
That, so far, prints:

1.
 A- First name: - Helen M.
 B- Last name: - Giese
 D- email address: - hele@xxxxx.com

2.
 A- Street address, first line: - 1758 W. Olive Ave.
 C- City: - XXXXXXX, D - State: - IL
 E- Zip code: - 99999

3.
 L- Other, please specify... - Medical writer/editor

4.
 C- 3-5 years

5.
 A- Laid off or down-sized and started freelancing at that point

6.


7.
 C- No, I'd rather work for a company


Looking good, huh? Except maybe for the extra empty line for #6. 

Basically, all you still need to do is an additional

	s/ ([A-T])-/[ x ] $1)/;

for each field. That would print:

1.
[ x ] A) First name: - Helen M.
[ x ] B) Last name: - Giese
[ x ] D) email address: - hele@xxxxx.com

etc.

	Bart.


------------------------------

Date: Sat, 17 Jul 1999 00:50:10 -0700
From: "$Bill Luebkert" <dbe@wgn.net>
To: "Mark R. Cervarich" <sunzone@shell14.ba.best.com>
Subject: Re: Parsing a Decisive survey w/ REGEX...need help
Message-Id: <379035B2.DD837ABD@wgn.net>

"Mark R. Cervarich" wrote:
> 
> I have a tab-delimited file that contains a decisive survey.  The software
> makers are un(able|willing) to help me, so I have turned to perl and have
> gotten a little bit stuck.
> 
> I am able to read the file line by line into an array.
> 
> Split the lines on the tabs into another array this creates an array of
> answers from 1..40.
> 
> Where I am having problems is writing a regexp to work with the each answer.
> Data can be either:  (I will use {} braces to show where the data actually is)
> 
> 1) an empty string: {}
> 2) a string of text:  ie: {You rarely offer me assigments in my specialty.}
> 3) a string that begins with a letter from A..T.
>    ie: { D- Trade magazine ad (national publications)}
> 4) a string that contains answers to multiple questions A..T
>    ie: {" C- Newspaper ad, D- Trade magazine ad (national publications), F- Recruiting web site (Monster.com, Hotjobs.com, etc.)"}
> 
> The string gets surrounded by quotes if there happens to be a period "." inside the string.
> 
> What i need to output is:
>    If we are in case 2:
>    The question # followed by a period.  A newline.
>    Then the string inside of brackets.
> 
>    if we are in case 3 or 4:
>    The question # followed by a period. A newline.
>    Brackets with an x inside of it.  ie:  [  x  ]
>     followed by the question letter, then a right parenthesis   ie:  D)
> 
> So what does that mean?  Well consider this input:
> 
> ---begin input---
> " A- First name: - Helen M., B- Last name: - Giese, D- email address: - hele@xxxxx.com"###TAB###" A- Street address, first line: - 1758 W. Olive Ave., C- City: - XXXXXXX, D - State: - IL, E- Zip code: - 99999"###TAB###" L- Other, please specify... - Medical writer/editor"###TAB### C- 3-5 years###TAB### A- Laid off or down-sized and started freelancing at that point###TAB### ###TAB###" C- No, I'd rather work for a company"
> ---end input---
> 
> (here's an easier way to look at it)
> 
> ---begin input---
> 1. {" A- First name: - Helen M., B- Last name: - Giese, D- email address: - hele@xxxxx.com"}
> 2. {" A- Street address, first line: - 1758 W. Olive Ave., C- City: - XXXXXXX, D
> - State: - IL, E- Zip code: - 99999"}
> 3. {" L- Other, please specify... - Medical writer/editor"}
> 4. { C- 3-5 years}
> 5. { A- Laid off or down-sized and started freelancing at that point }
> 6. {}
> 7. {" C- No, I'd rather work for a company"}
> ---end input---
> 
> would produce this output:
> 
> ---begin output---
> 1.
> [ x ] A) First name: - Helen M.
> [ x ] B) Last name: - Giese
> [ x ] D) email address: - hele@xxxx.com
> 2.
> [ x ] A) Street address, first line: - 1758 W. Olive Ave.
> [ x ] C) City: - XXXXXX
> [ x ] D) State: - IL
> [ x ] E) Zip Code: - 99999
> 3.
> [ x ] L) Other, please specify... - Medical writer/edior
> 4.
> [ x ] C) 3-5 years
> 5.
> [ x ] A) Laid off or down-sized and started freelancing at that point
> 6.
> 7.
> [ x ] C) No, I'd rather work for a company
> ---end output---
> 
> ---here's my attempt----
> #!/usr/local/bin/perl
> 
> @all = <>;
> 
> foreach (@all) {
>    $line = $_;
>    chomp($line);
>    (@questions) = split /\t/, $line;
> 
>    $counter = 1;
>    foreach $quest (@questions) {
>       print "$counter.\n";
>       { local $x;
> 
>          $quest =~ /"?( A- .*?)?( B- .*)?( C- .*)?( D- .*)?( E- .*)?( F- .*)?( G- .*)?"?/gs;
> 
>          # i am only checking from A--G, but I really need to check A..T,
>          # I thought I'd try a simple case first.
> 
>          $A = $1; $B=$2; $C=$3; $D=$4; $E=$5; $F=$6;
>          $G = $7;
> 
>          if ($A ne "") { print "[ x ] a) $A\n"; }
>          if ($B ne "") { print "[ x ] b) $B\n"; }
>          if ($C ne "") { print "[ x ] c) $C\n"; }
>          if ($D ne "") { print "[ x ] d) $D\n"; }
>         if ($E ne "") { print "[ x ] e) $E\n"; }
>          if ($F ne "") { print "[ x ] f) $F\n"; }
>          if ($G ne "") { print "[ x ] g) $G\n"; }
>       }
>       $counter++;
>    }
>    print "\n";
> }
> 
> What do you guys/gals think?  Please help me.

while (<>) {

	chomp;
	(@qs) = split /\t/, $_;
	foreach (@qs) {

		s/^["\s]*(.*?)[\s"]*$/$1/;	# drop leading/trailing WS/"
		@flds = split /([A-Z])\s?-\s*/, $_;	# split 0n 'X- '

		foreach (@flds) {

			next if /^\s*$/;	# drop empty fields
			if (/^[A-Z]$/) {
				print "[ x ] $_) ";
			} else {
				print "$_\n";
			}
		}
	}
}


-- 
  ,-/-  __      _  _         $Bill Luebkert   ICQ=14439852
 (_/   /  )    // //       DBE Collectibles   http://www.wgn.net/~dbe/
  / ) /--<  o // //      Mailto:dbe@wgn.net   http://dbecoll.webjump.com/
-/-' /___/_<_</_</_    http://www.freeyellow.com/members/dbecoll/


------------------------------

Date: Sat, 17 Jul 1999 10:45:25 +0200
From: "Simon Verhasselt-Casteele" <leaper2000@hotmail.com>
Subject: Perl on HP-UX
Message-Id: <7mpflg$n0t$1@nickel.uunet.be>

Hi,

I was wondering if I needed to include the year2000.o library
when compiling Perl 5.004 on HP-UX 10.20 ??

SV




------------------------------

Date: 17 Jul 1999 03:57:53 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: Perlshop Question
Message-Id: <slrn7p0hbi.c9j.abigail@alexandra.delanet.com>

halleys_vomit@my-deja.com (halleys_vomit@my-deja.com) wrote on MMCXLVI
September MCMXCIII in <URL:news:7mp0vg$3gq$1@nnrp1.deja.com>:
&& 
&& Invalid Transmission #3 received from: 127.0.0.1
&& If your connection was interrupted, you must Enter the shop from the
&& beginning again

Is this message explained in 'man perldiag'? If yes, go read it, and
ask a specific question about what you don't understand. If it isn't
explained in 'man perldiag', it's not a Perl error. 

I bet it's not explained in 'man perldiag', what do you think?




Abigail
-- 
perl -we 'print split /(?=(.*))/s => "Just another Perl Hacker\n";'


  -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
   http://www.newsfeeds.com       The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including  Dedicated  Binaries Servers ==-----


------------------------------

Date: Sat, 17 Jul 1999 00:49:20 -0700
From: Francisco Romero <fromero@csudh.edu>
Subject: Prime Factorization
Message-Id: <3790357F.7EB18703@csudh.edu>

Does anyone know how to write a perl script for finding the prime
factorization of a number?

Any ideas?

Thanks.



------------------------------

Date: 17 Jul 1999 04:00:47 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: Prime Factorization
Message-Id: <slrn7p0hh0.c9j.abigail@alexandra.delanet.com>

Francisco Romero (fromero@csudh.edu) wrote on MMCXLVI September MCMXCIII
in <URL:news:3790357F.7EB18703@csudh.edu>:
;; Does anyone know how to write a perl script for finding the prime
;; factorization of a number?


See sig for a script that finds one prime factor smaller than the 
number itself.


Abigail
-- 
perl -wle 'print length $1 if (1 x shift) !~ /^1?$|^(11+?)\1+$/' <number>


  -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
   http://www.newsfeeds.com       The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including  Dedicated  Binaries Servers ==-----


------------------------------

Date: 17 Jul 1999 04:02:56 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: Prime Factorization
Message-Id: <slrn7p0hl0.c9j.abigail@alexandra.delanet.com>

Francisco Romero (fromero@csudh.edu) wrote on MMCXLVI September MCMXCIII
in <URL:news:3790357F.7EB18703@csudh.edu>:
;; Does anyone know how to write a perl script for finding the prime
;; factorization of a number?


See sig for a script that finds one prime factor smaller than the 
number itself.


Abigail
-- 
perl -wle 'print length $1 if (1 x shift) !~ /^1?$|^(11+?)\1+$/' <number>


  -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
   http://www.newsfeeds.com       The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including  Dedicated  Binaries Servers ==-----


------------------------------

Date: Sat, 17 Jul 1999 08:19:36 GMT
From: smnayeem7346@my-deja.com
Subject: Problem with forking
Message-Id: <7mpeal$7mp$1@nnrp1.deja.com>

I am having some difficulties doing forking, when I try to connect to my
server program for the 2nd time it hangs up.
here is my server /listener program --
#!/usr/bin/perl

use IO::Socket;
use Net::hostent;

use POSIX "sys_wait_h";

my %kidstatus = undef;

sub REAPER {
	$SIG{CHLD} = \&REAPER;
	my $child;
	while ($child = waitpid(-1, WNOHANG)) {
		$kidstatus{$child} = $?;
	}
}
$SIG{CHLD} = \&REAPER;

my $PORT = 9000;
my $nextport = 9001;

my $server = IO::Socket::INET->new(
	Proto => 'tcp',
	LocalPort => $PORT,
	Listen => SOMAXCONN,
	Reuse => 1) or die "cannot setup server";

my ($pid, $clientport) = undef;
while (my $client = $server->accept()) {
	print "in";
	$client->autoflush(1);
	#find ports for client
	$clientport = $nextport;
	$clientport++ while (getservbyport($clientport, "tcp"));
	$nextport = $clientport + 1;
	print $client ("$clientport\n");
	close $client;
	#fork a process for listening to the client port
	$pid = fork();
	die "cannot fork" unless defined $pid;
	print "entering child";
	print "pid is $pid \n";
	unless ($pid) { #child
		my $newserver = IO::Socket::INET->new(
			Proto => 'tcp',
			LocalPort => $clientport,
			Listen => 1,
			Reuse => 1) or die "cannot setup server for
client";
		my $newclient = $newserver->accept();
		print "inside child\n";
		print "pid is $pid \n";
		$newclient->autoflush(1);
		&talk_to_client($newclient);
		$newclient->close;
		close $newserver;
		exit(0);
	}
	"out";
}
print "ended";

sub talk_to_client {
	my ($remote) = @_;
	print while ($_ = <$remote>);
}

and here is the client program :
#!/usr/bin/perl
use IO::Socket;

my $host = '210.176.135.212'; # please change this to the address of the
server.
#my $host = '210.176.135.15';
my $PORT = 9000;

my $remote = IO::Socket::INET->new(
	Proto => 'tcp',
	PeerAddr => $host,
	PeerPort => $PORT) or die "cannot connect to server";

$remote->autoflush(1);
chop(my $newport = <$remote>);
print $newport;
close $remote;

$remote = IO::Socket::INET->new(
	Proto => 'tcp',
	PeerAddr => $host,
	PeerPort => $newport) or die "cannot connect to special server";

&talk_to_server($remote);
close $remote;
exit(0);

sub talk_to_server {
	my ($remote) = @_;
	print $remote "This is the client\n";
}

Now first I start the server program, and then I run the client, and at
first pass it goes all right and the server gets the msg from the
client. However when I make start the client for a 2nd time the server
and the client sits there doing nothing. I tried to debug this but
debugging multiple processes are very difficult to me (if anyone can
show me some good sources of infos on this i'd be grateful)

Please let me know where I went wrong.
And also does anyone know any script/example archives where I can find
lots of multiple process/and forking/client-server examples?

THanks

SMNayeem
smnayeem@agni.com   # please send me a copy of the reply to my email
thanks :)
Programmer , Agni Systems Ltd.


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


------------------------------

Date: 17 Jul 1999 01:32:06 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: searching man pages, perldoc's, FAQ's, README's, HOWTO's, etc.
Message-Id: <x71ze7kfjd.fsf@home.sysarch.com>

>>>>> "TP" == Tom Phelps <phelps@ecstasy.CS.Berkeley.EDU> writes:

  TP> :Is there a way to search man pages, perldoc's, FAQ's, README's,
  TP> :HOWTO's, etc.?

  TP> Glimpse is a full-text search program, with very small indexes
  TP> (3%-10%, depending on options).  TkMan provides a graphical interface
  TP> for man pages, Texinfo (aka GNU info) files, FAQs, and whatever other
  TP> directories you want indexed.  TkMan hyperlinks from a list of hits to
  TP> the corresponding document, with matching words highlighted.

  TP> It's free software at http://http.cs.berkeley.edu/~phelps/tcltk/

i'll second that. it is very good stuff which can handle many
manual document formats on most platforms. best man replacement i have
ever used. too bad it is not written in perl :-( i have asked tom phelps
to rewrite it in perl/g?tk and he refuses. we should do that as a group
project (maybe funded under those new open source agencies :-), make a
high quality doc reader in perl. 

uri

-- 
Uri Guttman  -----------------  SYStems ARCHitecture and Software Engineering
uri@sysarch.com  ---------------------------  Perl, Internet, UNIX Consulting
Have Perl, Will Travel  -----------------------------  http://www.sysarch.com
The Best Search Engine on the Net -------------  http://www.northernlight.com
"F**king Windows 98", said the general in South Park before shooting Bill.


------------------------------

Date: Sat, 17 Jul 1999 01:09:35 -0700
From: "$Bill Luebkert" <dbe@wgn.net>
To: lhollman@my-deja.com
Subject: Re: tie SDBM_File on Win95
Message-Id: <37903A3F.AA6EF422@wgn.net>

lhollman@my-deja.com wrote:
> 
> Using perl v. 5004_02 (standard dist.) and v. 5.005_03 (Active State)
> on
> Win95 I get '277' as the output from the following test script:
> 
> #/usr/bin/perl -w
> use Fcntl;
> use SDBM_File;
> $| = 1;
> 
> $i = 1;
> tie (%h,
> "SDBM_File", 'db', O_RDWR|O_CREAT, 0640)
>   or die "db: $!\n";
> open (F,
> "file.dat") or die "file.dat: $!\n";
> while (defined($line=<F>)) {
>   chomp
> $line;
>   $h{$i++} = $line;
> }
> close (F);
> print scalar(keys %h), "\n";
> untie
> %h;
> 
> where file.dat is a test file of 1 record per line, of the basic format:
> 
> V1014:S1075:7/30/1998:655.05
> 
> Using the debugger, I see all goes well until
> $i = 218 at which point
> scalar(keys %h) suddenly evaluates to 208.  But
> nothing seems out of
> the ordinary for this record in file.dat.
> 
> I also tried
> $h{$i++} = $i which gave me the expected 500, which
> makes me think something
> is weird with the data.  But I can't see
> anything.
> 
> Can anyone point me in
> the right direction?

You can't do this with SDBM because it is flawed in that it won't allow 
a lot of medium to large records to go into the hash.  Try using a fake 
data file with thousands of small words.  Then try another with the same 
number of large words and it will fail.  I believe it's due to some compiled 
in limits.  I have a 14MB dictionary that works fine with SDBM since the 
words aren't too big.

Look for another DB like GDBM to replace SDBM.

Test case:

use strict;
use Fcntl;
use SDBM_File;

my $dbm_file = "abc";
unlink "$dbm_file.dir";
unlink "$dbm_file.pag";

my %DBM;
my $dbm_type = 'SDBM_File';
tie (%DBM, $dbm_type, $dbm_file, O_RDWR|O_CREAT, 0666) or 
  die "Error, opening $dbm_file: $!";

my $ii;
for ($ii = 1; $ii < 500; $ii++) {

	my @keys_before = keys %DBM;

# try commenting out one of these and then switch to the other

#	$DBM{$ii} = 'a' x 50;	# this fails after 138
	$DBM{$ii} = 'a' x 5;	# this works fine for all 500 or even 5000

	my @keys_after  = keys %DBM;
	print "key=$ii, ", scalar @keys_before, "->",  scalar @keys_after, "\n";

}
untie %DBM;

-- 
  ,-/-  __      _  _         $Bill Luebkert   ICQ=14439852
 (_/   /  )    // //       DBE Collectibles   http://www.wgn.net/~dbe/
  / ) /--<  o // //      Mailto:dbe@wgn.net   http://dbecoll.webjump.com/
-/-' /___/_<_</_</_    http://www.freeyellow.com/members/dbecoll/


------------------------------

Date: Sat, 17 Jul 1999 06:47:11 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Tiny error in perlfaq5
Message-Id: <379126db.413145@news.skynet.be>

John Stanley wrote:

>Mike Guy did by talking about what rand(x) returns
>unless x is something silly.

Oh, I see. Thanks for pointing that out.

	Bart.


------------------------------

Date: Sat, 17 Jul 1999 12:10:43 +0500
From: "Faisal Nasim" <swiftkid@bigfoot.com>
Subject: Re: URL Verification
Message-Id: <7mqdjh$9jb4@news.cyber.net.pk>

Toinbo & Renbo <toinbo@hotmail.com> wrote in message
news:7mo5is$46p$1@news3.Belgium.EU.net...
:     Hi,
:
:     I would like to know how to make a script that tests if an URL given
by
: a visitor exists.

use LWP::Simple;

$url = 'http://wss.hypermart.net/Idontexist.html';

if ( head $url )
{
    print "okie";
}
else
{
    print "lier lier!";
}


better as:
print head $url ? "okie dokie" : "lier lier";




------------------------------

Date: Sat, 17 Jul 1999 00:53:02 -0700
From: Francisco Romero <fromero@csudh.edu>
Subject: Re: Where to start with perl programming ?
Message-Id: <3790365D.26441F65@csudh.edu>

Why don't you use Linux.  There is every thing you need from perl, to a
web server if you need to run CGI scripts.  One thing about Linux is
that it is for free and you can put Linux on a 486 machine.

arpith@hotmail.com wrote:

> Hi,
>
> Hopefully you can help.. I am new to perl and I want to learn it,
> I am right now learning by examples, but I need some sort of server
> to run the scripts.
>
> I have no access to CGI hosting webservers. Can I run the scripts
> on my home computer ?
>
> Like can I get a free web server, install it on my Win95, and use
> that to run the scripts ? or do I need something else to run it ?
>
> What webserver would you recommend ? where can I find more help ?
>
> Or do you recommend I install some Unix clone or something like
> that so that I can run unix pl scripts ?
>
> I really need help starting out and am really lost!
> so could you help out please ? Any help will be appreciated.
>
> Thanks,
>
> Arpith.
>
> Sent via Deja.com http://www.deja.com/
> Share what you know. Learn what you don't.



------------------------------

Date: 1 Jul 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 1 Jul 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.  

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 V9 Issue 174
*************************************


home help back first fref pref prev next nref lref last post