[7132] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 757 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jul 23 17:19:05 1997

Date: Wed, 23 Jul 97 14:00:25 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Wed, 23 Jul 1997     Volume: 8 Number: 757

Today's topics:
     Re: ?: stupid script call q (Brad Johnson)
     Re: Checking for valid Email... <sfairey@adc.metrica.co.uk>
     Re: Confirmation messages & bogus email addresses. Help <sibsib@hotmail.com>
     Re: Creating a directory in a Unix1 (Gabor)
     Re: DB_FILE versus dbmopen (Chris Nandor)
     Easy question-new user <edbid@cobe.com>
     Re: Formating text: changing the \n to a <P> <rootbeer@teleport.com>
     Formatted printing and arrays (Sylvain Robitaille)
     Help: can't delete entry from DB file <javafan@poboxes.com>
     Help: can't delete entry from DB file <javafan@poboxes.com>
     Re: How to get rid of junkmail (A. Deckers)
     Integer arrays in an XS extension.. <marius@funcom.com>
     Re: Perl Editor for Win32? (Bob)
     Re: Perl Editor for Win32? <cmiller@intermind.com>
     Re: perl in NT (Jim Michael)
     Re: PERLIS.dll (Brian - DKOnline)
     Re: Please Help: Pattern Matching <rootbeer@teleport.com>
     Re: printing labels <sfairey@adc.metrica.co.uk>
     Problem using CGI.pm -- "Can't find ... 'END_OF_AUTOLOA <mholsen@esmprods.com>
     Re: Regex: Email format <rootbeer@teleport.com>
     Re: Regex: Email format <rootbeer@teleport.com>
     Re: Regex: Email format <sfairey@adc.metrica.co.uk>
     Re: Req help: Any easy way to CRC a file? <rootbeer@teleport.com>
     Re: Shared memory variables <rootbeer@teleport.com>
     Re: Sorting <sfairey@adc.metrica.co.uk>
     Syntax junkies ! <allied@pair.com>
     Re: Syntax junkies ! (Faust Gertz)
     Re: Tie a hash of hashes ? (Roger Espinosa)
     Re: Unique File Creation (Andrew M. Langmead)
     Re: Unique File Creation <steinkf@cs.purdue.edu>
     Re: Unix <rootbeer@teleport.com>
     Re: WEB discussion tool <sales@idi-ut.com>
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: 22 Jul 97 14:43:37 GMT
From: bgjohnso@unix.amherst.edu (Brad Johnson)
Subject: Re: ?: stupid script call q
Message-Id: <33d4c719.0@amhnt2.amherst.edu>

Ronald L. Parker (ron@farmworks.com) wrote:
: [posted and emailed]
: On 21 Jul 97 19:28:21 GMT, bgjohnso@unix.amherst.edu (Brad Johnson)
: wrote:
: >$cmd = "perl archiver_go.pl";
: >system $cmd \"$cats[$i]\" > $output;
: I think you'll find that this works if you use

: system qq($cmd "$cats[$i]" > $output);

That didn't work (note: am running perl for Win); it 
produced the same buggy result, but using backticks (`)
worked. Hmm. 

Is there a better way to call other perl programs within
a program than this, though? I should probably build
a module...

--bradj.
------------------------Nullus Oppidenda Est--------------------------
brad johnson (bgjohnso@unix.amherst.edu)    'Disc, God, Country, Pork'
http://www.amherst.edu/~bgjohnso/             'Chickens! No Cynics!'
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 


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

Date: Tue, 22 Jul 1997 12:18:06 +0100
From: Simon Fairey <sfairey@adc.metrica.co.uk>
To: Maelstrom <maelstrom@deathsdoor.com>
Subject: Re: Checking for valid Email...
Message-Id: <33D496ED.5765FC5E@adc.metrica.co.uk>

Maelstrom wrote:

> In article <5q2oaj$147@fridge-nf0.shore.net>,
>   nvp@shore.net (Nathan V. Patwardhan) wrote:
> >
> > Brandon Wilkins (wilkins@digitaldaze.com) wrote:
> >
> > : How do I go about checking if a email address is basically valid
> (In
> > : form...)?
> >
> > You check Dejanews for the answer to this frequently asked question,
>
> > and use the examples you find there to answer your question.
>
> Oh _very_ nice.  I am in a similair position to the original poster
> and I
> just decided to do this.  All I can find is whiney posts telling
> people
> to look in Deja News.  So I checked the old database and found what I
> suppose was the original thread being referred to.  So I started
> reading
> that and could find nothing but flames and arguments in varying
> intensity
> on varous subjects.  After 30 minutes I was disconected, having just
> used
> my four hours worth of time. Incidentally I had just come from the FAQ
> at
> www.perl.com and looking at the section for 'How do validate input' I
> recieved the following gem of information "See the more specific
> questions(numbers, email addresses, etc.) for details". Where?  Is
> there
> some kind of lobotomy you need to have before you can understand Perl
> that takes away any ability to communicate helpful information in
> written
> english?
>
> Last time I asked for help here I got about three helpful replies and
> 7
> flames. I guess that's a standard ratio for any comp group so I'm
> hoping
> for similair good results this time.  Does anyone want to tell me how
> I
> can make sure a form input ($RESULTS{'email'}) contains a '@'
> character
> and no spaces?
>
>  Bear in mind that I'm writing this free, for a friend who wont be
> making
> any profit of it either so it's hardly fair to disembowl me for asking
> a
> stupid question.  If anyone would like to help me and thinks they can
> do
> so without causing this newsgroup to implode in a bandwith-wasting
> inferno it would be great.  If you would rather flame then feel free
> but
> don't be suprised or offended when you're ignored.
>
> --Maelstrom

  Firstly I did the same as you, that is a search for 'valid email
address comp.lang.perl' at DejaNews and the 6th entry had the required
information!

Secondly the question of a valid email address is one that IS addressed
( no pun intended ) in the very Perl FAQ which you refer to. As the FAQ
says, "see the more specific questions", at that point simply searching
the FAQ for 'email' might not have been a too unreasonable idea.

Thirdly I have found that provided you do some research beforehand, i.e.
look at DejaNews,  ALL the relevant FAQs and shock horror read the
manual pages, that when you ask your question you will be much more
likely to get a decent response. To be honest I have seen very few posts
here that I would term as flames. Most of the slightly more curt
responses come from occasions where people ask questions which shows
that they have done absolutely bugger all in the way of research and
just want a quick answer. Now granted some people are new to usenet and
the concept of FAQs, so I personally tend to be fairly tolerant and just
pont someone to the FAQ but every now and again frequent users of this
group may lose thier temper when they see the same question asked more
than once within a few days.

Finally to your question, ( I am assuming you are v.v.v.new to Perl and
are not familiar with scripting ). What you need to look at are Regular
Expressions, they will do everything you need, see the perlre man page.
Checking for a '@' is simply a case of using the // operator and as for
checking there are no spaces, I would suggest that you consider the
alternative which is to just remove all white spaces from the string
itself. If you choose this option then much as it pains me to say it the
question has been covered on more than a few occasions and a search of
DejaNews will give you the answer ( 'remove space comp.lang.perl.misc'
worked for me ).

Simon

PS: $string =~ tr/\s//; #One alternative to the answer you will find at
DejaNews for removing spaces.



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

Date: Wed, 23 Jul 1997 15:02:45 -0400
From: Scott Blanksteen <sibsib@hotmail.com>
Subject: Re: Confirmation messages & bogus email addresses. Help!
Message-Id: <33D65555.EA428CCE@hotmail.com>

Robyn Wagner wrote:
>       I recently created an online Shop using Selena Sol's Web_store
> Front and I have a question/problem concerning bounced email messages
> using sendmail. You see, after a customer places an order at my
> 
> confirmation message to the bogus email address submitted? Doesn't
> sendmail always return a copy that says "undeliverable" to the FROM
> address? If not, where does the message go?!?

Robyn - 

Two points:

1.  Sendmail may very well be sending an error message to the sender of
the message.  However, "I do not think the *sender* of the message is
who you think it is..."  The sender is probably "nobody" (or whichever
user the web server is running as), rather than "orders@orders.com",
which is most likely the "reply-to" header.

2.  Perhaps asking Selena Sol directly might help.  :-)

Scott

-- 
Scott I. Blanksteen
sib (at) worldnet (dot) att (dot) net


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

Date: 22 Jul 1997 18:24:15 GMT
From: gabor@vinyl.quickweb.com (Gabor)
Subject: Re: Creating a directory in a Unix1
Message-Id: <5r2tsf$qbq$1@flint.sentex.net>

Brandon Yoo (byoo@celerity.com) wrote:
: I'm trying to create a directory in Unix with perl:

: mkdir ("xx", 777);

: This does not give me a "drwxrwxrwx" access. What mode number should I
: have to use ?

an octal one
mkdir "foo", 0777 or die "$!";
your umask will affect the actual permissions

: Thanks in advance.

: byoo@hotmail.com


--
Gabor Egressy : gabor@quickweb.com
    No, I am not going to explain it.  If you can't figure it out, you
    didn't want to know anyway...  -- Larry Wall, 1991


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

Date: Wed, 23 Jul 1997 08:19:42 -0500
From: pudge@pobox.com (Chris Nandor)
Subject: Re: DB_FILE versus dbmopen
Message-Id: <pudge-ya02408000R2307970819420001@news.idt.net>

In article <33D2D78C.A22D817B@wco.com>, Kenneth Kin Lum <kinlum@wco.com> wrote:

# DB_FILE uses Berkeley's DB, and creates one file per database (table).
# dbmopen, etc, uses two files per database (table).
# 
# Is one more efficient than the other in speed?  Or is DB_FILE just a 
# concatenation of those two files per database?

There are many different types of DBM packages.  dbmopen() uses the most
common one, which has some limitations.  DB_File has very few limitations,
is significantly faster, etc.  The only problem is getting Berkeley DB
installed.  Can be harsh (for me anyway).

Regardless, yes, DB_File is basically the same thing, but done a different
way in the background.  The interface you will use to tie to the database
is virtually the same as the other DB module (NDBM_File, SDBM_File, &c.).

--
Chris Nandor             pudge@pobox.com             http://pudge.net/
%PGPKey=('B76E72AD',[1024,'0824 090B CE73 CA10  1FF7 7F13 8180 B6B6'])


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

Date: Tue, 22 Jul 1997 14:52:37 -0600
From: Edward Bidinotto <edbid@cobe.com>
Subject: Easy question-new user
Message-Id: <33D51D95.153B@cobe.com>

I am just getting started with Perl.
Here's what I'd like to do but can't make it work.
I can't figure out how to mail messages to console every minute
that the logs are down and at the same time actually mail a message
to $recipients every 5 minutes that the logs are down.

I know this is an easy fix but I'm not a programmer and I'm trying to
get something in place and decided to learn Perl.

Any ideas are appreciated.

Tks..Ed
edbid@cobe.com



$date = `date`;
$recipients = "root informix prodadmn";
$mail = "The logical log process is not running\nas of $date";
$subject = "The Informix ontape -c process has stopped";
$mail_command = "echo \"$mail\" | /usr/bin/mailx -s \"$subject\"
$recipients";

$sent = 0;
while (1)
{
        $gotit = `ps -fe | grep -v grep | egrep "ontape -c"`;
        if ($gotit)
        {
                # Continous logging is operational-just keep looping
                $sent = 0;
        }
        else
        {
                # Logs are down send out messages to the console every
minute
                # Until the operators do something

                        print "Logs are down - send out msg to
console\n";
                        sleep 1;

                # Also mail out a message and notify $recipients
                # every 5 minutes that logs are down.

                if ( $sent != 12 && $sent %3 == 0 )
                  {
                        system($mail_command);
                        $sent++;
                  }
        }
}


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

Date: Tue, 22 Jul 1997 16:40:51 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Mark McDonald <mark@nhgir.nih.gov>
Subject: Re: Formating text: changing the \n to a <P>
Message-Id: <Pine.GSO.3.96.970722163947.28607G-100000@kelly.teleport.com>

On Tue, 22 Jul 1997, Mark McDonald wrote:

> Here is a hard one that has me puzzled! I need to kake the text out of a
> textarea re-format it to put a <P> where there is a line break. 

It sounds as if you want one of the Text:: modules on CPAN to format the
text, then you want to use s/// to put <P> tags in to the right places.
Hope this helps!

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/



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

Date: 22 Jul 1997 22:31:38 GMT
From: sp_robi@sinclair.concordia.ca (Sylvain Robitaille)
Subject: Formatted printing and arrays
Message-Id: <slrn5tad5i.k6r.sp_robi@sinclair.concordia.ca>

Well, I'm resorting to asking for help again, (still marvelling at the
help I got *last* time I posted a request for help).

I'm trying to use formatted printing on a hash of arrays. Essentially the
output I'm after is something like, (borrowing of course from the much
worshipped Camel):

flintstones            fred
                       barney
											 pebbles
											 bambam
											 dino

simpsons               homer
                       bart
											 marge
											 maggie

jetsons                george
                       jane
											 elroy
											 judy

Now, I've had very little success in getting this to work, but I'm *sure*
it can be done. Hopefully someone can point out what I'm missing. I have
tried several variations of the following, but the one I'm posting results
in the fewest complaints, (I think it simply complains immediately, and
aborts):

--- 8< --- 8< --- 8< --- BEGIN --- 8< --- 8< --- 8< ---
#!/local/bin/perl -w

format My_Format =
@<<<<<<<<<<<<<<<<<~~ @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
$familyname,         @members
 .
# Note that I get the same runaway format error, wether I use a '@' or a
# '^' as the field specifier in the format.

$families{"flintstones"} = ["fred", "barney", "pebbles", "bambam", "dino"];
$families{"simpsons"} = ["homer", "bart", "marge", "maggie"];
$families{"jetsons"} = ["george", "jane", "elroy", "judy"];

$saveformat = $~;
$~ = "My_Format";

foreach $familyname (keys %families) {
    @members = @{$families{$familyname}};
    write;
}

$~ = $saveformat;
--- 8< --- 8< --- 8< ---  END  --- 8< --- 8< --- 8< ---

The error this causes is:
~>src/perl/arrayformat
Runaway format at src/perl/arrayformat line 7.

There *has* to be way to do what I'm after. Can anyone offer suggestions?

-- 
----------------------------------------------------------------------
Sylvain Robitaille                          sp_robi@alcor.concordia.ca

Assistant to the System Manager
Computing Services Department
Concordia University                          Montreal, Quebec, Canada
----------------------------------------------------------------------


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

Date: 22 Jul 1997 15:42:47 +0200
From: JavaFan <javafan@poboxes.com>
Subject: Help: can't delete entry from DB file
Message-Id: <199707221342.GAA27190@www18.geocities.com>

The following code for updating and inserting new
entries works correctly. But neither dbminsert nor dbmdelete
seens to be working. How do I delete entry from this 
database? Which module should I use?
Thanks in advance

 ..
use sdbm_file;
use anydbm_file;
 ..
dbmopen(%counters, "counters",0666);
if(!(defined( $counters{$pageID} )))
 {
 $counters{$pageID}=0;
 }

$counters{$pageID}++;
$count=$counters{$pageID};

reset(%counters);
dbmclose(%counters);
 ..



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

Date: 22 Jul 1997 15:52:16 +0200
From: JavaFan <javafan@poboxes.com>
Subject: Help: can't delete entry from DB file
Message-Id: <199707221351.GAA29186@www18.geocities.com>

The following code for updating and inserting new
entries works correctly. But neither dbminsert nor dbmdelete
seens to be working. How do I delete entry from this 
database? Which module should I use?
Thanks in advance

 ..
use sdbm_file;
use anydbm_file;
 ..
dbmopen(%counters, "counters",0666);
if(!(defined( $counters{$pageID} )))
 {
 $counters{$pageID}=0;
 }

$counters{$pageID}++;
$count=$counters{$pageID};

reset(%counters);
dbmclose(%counters);
 ..



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

Date: 23 Jul 1997 10:29:45 GMT
From: I-hate-cyber-promo@man.ac.uk (A. Deckers)
Subject: Re: How to get rid of junkmail
Message-Id: <slrn5tbn8p.7qg.I-hate-cyber-promo@news.rediris.es>

[NB: Followup-To: news.admin.net-abuse.email]

In <33D5D7B3.1BBD@mucsun.sps.mot.com>,
	Klaus Foerster <klausf@mucsun.sps.mot.com> wrote:
>Just a sort of questions.
>
>
>Since I started posting to newsgroups I'm getting loads of
>junkmail.
>
>Is there any way to identify this junkmail automatically
>(faked mail headers) and to post them to the right postmaster
>of the offensive site.
>
>The amount of junkmail is just increasing.
>
>A perl solution would be prefered. If you can point me to other
>soultions I'm quite happy as well.

There are quite a few scripts available out there. The folks on
news.admin.net-abuse.email can probablty point you in the right
direction.

Alain



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

Date: 22 Jul 1997 16:57:01 +0200
From: Marius Kjeldahl <marius@funcom.com>
Subject: Integer arrays in an XS extension..
Message-Id: <52afjfnnia.fsf@ace.funcom.com>

I am trying to interface some C code that I do not have the source for
(only object files). One of the files has a declarations like these:

void func1();

void func2(int ar1[12], int i1, int i2, int i3, int i4, int i5,
           int ar2[4], int ar3[4])

Now, I know I have done most of the stuff correct, because calling
func1 (from perl after building the module) works fine. However, in
calling func2 I am experiencing problem, and I feel pretty sure this
is because of the integer arrays that are being passed. 

I have been studying perlxs, perlxstut and perlguts, but have not been
able to figure out exactly what I need to do to make sure that the
integer arrays are correctly passed back and forth in C and perl
(since routines in both C and perl will manipulate the array values).

I think I have to define a typemap for the 'int *' type, but I am
unsure what "perl type" I should use. Just for the heck of it, I tried
with T_PV and T_ARRAY, but without any success.

Could somebody give me a hint what kind of types I need to define in
typemap, and the necessary routines for translating the data back and
forth in perl?

Thanks in advance,

Marius Kjeldahl


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

Date: Tue, 22 Jul 1997 19:14:39 GMT
From: xxbbell@voicenet.com (Bob)
Subject: Re: Perl Editor for Win32?
Message-Id: <33d50665.682227149@netnews.voicenet.com>

peak@ulc199.residence.gatech.edu (Jason Peak) wrote:
>Does anyone know of a Perl editor for 
>Win32 Platforms?  If so, please post or reply.
>Thanks.
>
>Jason Peak
>peak@ulc199.residence.gatech.edu

	Yeah, there's a (FREE!) program that comes with Windows you
can use.  It's call Notepad :)

--
          - Bob
          http://www.voicenet.com/~bbell
          xxbbell@voicenet.com
          remove x's to reply


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

Date: Tue, 22 Jul 1997 13:47:27 -0700
From: "intermind" <cmiller@intermind.com>
Subject: Re: Perl Editor for Win32?
Message-Id: <5r361m$nma@oly3-s16.intermind.com>

Seriously though...

My fav is PFE32, very stable with lots o options.

It also has the ability to recognize a language so it can match
brackets/indents etc.  It doesn't have a Perl entry, but if you use C as the
language it works pretty well (no more indenting by hand!)

Search for it in AltaVista, you'll find it from there.

-Craig



Bob wrote in article <33d50665.682227149@netnews.voicenet.com>...

>peak@ulc199.residence.gatech.edu (Jason Peak) wrote:
>>Does anyone know of a Perl editor for
>>Win32 Platforms?  If so, please post or reply.
>>Thanks.
>>
>>Jason Peak
>>peak@ulc199.residence.gatech.edu
>
> Yeah, there's a (FREE!) program that comes with Windows you
>can use.  It's call Notepad :)
>
>--
>          - Bob
>          http://www.voicenet.com/~bbell
>          xxbbell@voicenet.com
>          remove x's to reply




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

Date: Tue, 22 Jul 1997 21:50:50 GMT
From: genepool@netcom.com (Jim Michael)
Subject: Re: perl in NT
Message-Id: <genepoolEDqq0q.oo@netcom.com>

anu.hariharan@compaq.com wrote:
: Hello,

Howdy.

: I am using Microsoft FrontPage to create a web site

God help you.

: and am using Netscape for viewing the page. 

That's better.

: I am trying to process a form with a CGI script
: written in perl. I am on NT, so the perl script has extension .bat.

Whatever for? 

: But when I submit the form, it gets executed as a .bat file does on
: the DOS prompt. 

And you're surprised by this behavior?

: Can someone please tell me how I can get this executed as a
: perl script ? What paths etc. do I need to specify ?

If you name a perl script file with a .bat extension and execute it from 
the NT command line it will try to interpret the file as a batch file. 
Perhaps you intend to call the perl script from a batch file? You can 
change the path in the command shell temporarily if the path to /perl/bin
is not defined (SysAdmin doesn't know how to change the path, etc.), and 
then call your perl script:

path=c:\perl\bin;%path%
perl myperlprogram.pl arg1 arg2 .... argn
REM The arg1, etc. are arguments passed to the perl program, if needed.

Or you can associate .pl extension to perl.exe. You know, I could have 
sworn I've seen an article about doing this very thing somewhere 
recently. Do you get dejanews?

: Thanks

You're very welcome.

Cheers,

Jim


: Anu

: -------------------==== Posted via Deja News ====-----------------------
:       http://www.dejanews.com/     Search, Read, Post to Usenet



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

Date: Tue, 22 Jul 1997 13:22:46 GMT
From: Brian@dkonline.com (Brian - DKOnline)
Subject: Re: PERLIS.dll
Message-Id: <33d5b3d0.4866788@pub.news.uk.psi.net>

On Mon, 14 Jul 1997 18:01:05 -0700, "Joseph M. Scott"
<jmscott@ainet.com> wrote:

>If you already did the Perl5/Win32 install ( which it sounds like you
>did ), I believe all you have do to for the ISAPI is to do the install
>on that, if I recall the newest one does all the reg edits and
>everything needed during the install.
>
>	-=joseph
>		jmscott@ainet.com=-
>
>Gary Austin wrote:
>> 
>> This is a bigginers question.  I loaded perl5 from activeware and also
>> loaded perlis.dll.  The documentation that I can find says it is less
>> resource intensive if you use the perlis.dll.  How does one set up
>> windowsnt4.0 using iis3.0 to use the dll instead of the default
>> perl.exe?  Thanks in advance.
>> 
>>                                         Gary Austin


If you use the .dll, it doesn't behave properly for headers so you
can't do anything other than text/html output (ie. no redirection). So
I'm back to using the .exe.

Brian


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

Date: Tue, 22 Jul 1997 22:57:03 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Devin Anderson <dev@sgi.net>
Subject: Re: Please Help: Pattern Matching
Message-Id: <Pine.GSO.3.96.970722225415.23134F-100000@kelly.teleport.com>

On Tue, 22 Jul 1997, Devin Anderson wrote:

> Try escaping the " like so:
> 
> s/<xDQx>/\"/g;

That's a nice try, but a double quote mark is not one of the four
characters which would need escaping there. In a double-quotish string
(which the replacement part of s/// is) you need escape only '$', '@', the
backslash itself, and the character which is quoting the construct. In
this case, the quote is '/', so that's the fourth. Hope this helps! 

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/



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

Date: Wed, 23 Jul 1997 11:00:53 +0100
From: Simon Fairey <sfairey@adc.metrica.co.uk>
To: Jonathan Hughes <hughesj@westminster.ac.uk>
Subject: Re: printing labels
Message-Id: <33D5D653.DCAA9BA3@adc.metrica.co.uk>

I would suggest you try and pick a better subject line, this one is a
bit vague.

Jonathan Hughes wrote:

> I'm new to perl and cant get tab delimited address labels to print
> Format:
> hughes  hughes  address city    zip     United Kingdom  Type of
> infopac
>
> Here is script so far, :
>
> #!/usr/bin/perl
>
> $count=0;
>
> while(<>) {
>         chop;

You should really be using chomp().

>         @data = split(/\t/,$_);
>         $labels[$count] = \@data;
>         @data = undef;
>         $count++;

There are a coupleof problems with this chunk of code. Primarily you are
storing a reference to an array which you are then imediately undef'ing
so the reference will not point to anything. Secondly since you are
storing a reference when you change the contents of @data you will
affect everything that points to it, so in the end you are going to end
up with an array of references which all pont to the same array and
hence the same data ( which in this case will be nothing as the last
thing which will happen to @data is the undef; youou could store the
entire array in @labels each time( if memory is a problem then you will
have to look at an alternative solution ). Finally pay close attention
to the value of $count as it will be one greater than the end of @labels
( see modified for() condition below ).

> }
>
> for $var (0..$count) {
>
> print "$var - $count - $labels[0]->[1]\n";
> #print <<EOF;
> #$labels[$var][0]
> #$$labels[$var][1]
> #EOF
>
> }
>
> --
> Jonathan Hughes - University of Westminster -
> http://www.bmss.wmin.ac.uk
> +44(0)171 911 5000   Fx.+44(01)171 911 5175  London W1P 4DJ
> --

Ok the following is one way to do it.

$count=0;
while(<>) {
        chomp;
        @{$labels[$count++]} = split /\t/;
}

for $var (0..$count-1) {
        print "$var - $count - $labels[$var][1]\n";
}

You could also change the above for condition from:
  for $var (0..$count-1) {
to
  for $var (0..$#labels ) {

Hope this sorts your problem.

Simon



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

Date: Thu, 24 Jul 1997 05:45:21 -0400
From: Matt Holsen <mholsen@esmprods.com>
Subject: Problem using CGI.pm -- "Can't find ... 'END_OF_AUTOLOAD',  [etc.]"
Message-Id: <33D72431.4F97@esmprods.com>

Trying to use CGI.pm I keep getting this message:

Can't find string terminator "END_OF_AUTOLOAD" anywhere before EOF at
CGI.pm line 645

But when I look at the file that string is there many times after line
645 (although sometimes it has a semicolon sort of stranded on the next
line, which seems odd).  Does anyone know what that is about?  I thought
the file might be corrupted somehow in decompressing, so I downloaded
the "module only" (uncompressed).  Same thing.  Anyone know what's
wrong?

Matt Holsen
ESM Productions, Inc.


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

Date: Tue, 22 Jul 1997 13:12:20 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Simon Fairey <sfairey@adc.metrica.co.uk>
Subject: Re: Regex: Email format
Message-Id: <Pine.GSO.3.96.970722131031.6115R-100000@kelly.teleport.com>

On Tue, 22 Jul 1997, Simon Fairey wrote:

> I don't believe you to escape the '@'.

Actually, regular expressions are double-quote interpolated, so it's
normal to need to escape an @-sign. But trying validate an e-mail address
is an exercise in futility. There are more details in the FAQ. Hope this
helps!

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/



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

Date: Tue, 22 Jul 1997 11:34:18 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Mark Schwartz <mcs@in.net>
Subject: Re: Regex: Email format
Message-Id: <Pine.GSO.3.96.970722113008.6115E-100000@kelly.teleport.com>

On Tue, 22 Jul 1997, Mark Schwartz wrote:

> I have written a regex to verify data input to the 'Email Address' field
> of a form I have written. 

You're not the first to try to do this, and you won't be the last. 

    http://www.perl.com/CPAN/doc/FAQs/FAQ/html/perlfaq9/
          How_do_I_check_a_valid_email_ad.html

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/



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

Date: Tue, 22 Jul 1997 17:16:38 +0100
From: Simon Fairey <sfairey@adc.metrica.co.uk>
To: Mark Schwartz <mcs@in.net>
Subject: Re: Regex: Email format
Message-Id: <33D4DCE6.560B16D@adc.metrica.co.uk>

Mark Schwartz wrote:

> I have written a regex to verify data input to the 'Email Address'
> field
> of a form I have written.
>
> The regex is:
>
> if (($regdata{"Email Address"}) !~
> /^(?:[\w]+)\.?(?:[\w]*)\@(?:[\w]+)\.(?:[\w]+)(?:[\.][\w]+)*/) {

I don't believe you to escape the '@'.

Hope thats all it needs.

Simon



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

Date: Tue, 22 Jul 1997 12:30:06 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Brian - DKOnline <Brian@dkonline.com>
Subject: Re: Req help: Any easy way to CRC a file?
Message-Id: <Pine.GSO.3.96.970722122934.6115K-100000@kelly.teleport.com>

On Tue, 22 Jul 1997, Brian - DKOnline wrote:

> I'd like a way to uniquely identify a file (or be pretty certain) so
> that I can flag duplicate files even if (and especially if) their
> filename varies.

Would the MD5 module do what you want? It might be overkill... :-)

Hope this helps!

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/



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

Date: Tue, 22 Jul 1997 07:29:14 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Jason E Holt <holt@puree.cs.byu.edu>
Subject: Re: Shared memory variables
Message-Id: <Pine.GSO.3.96.970722072810.19892F-100000@kelly.teleport.com>

On 22 Jul 1997, Jason E Holt wrote:

> 	How hard would it be to provide some sort of variable space in
> Perl in which variables are kept in a shared memory segment and thus
> kept accessable to children after a fork()? 

Not too hard, if you do it with tie'd variables and the methods in
perlipc(1). In fact, if you can't find a module that does what you want,
you should write one. Thanks!

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/



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

Date: Wed, 23 Jul 1997 11:45:21 +0100
From: Simon Fairey <sfairey@adc.metrica.co.uk>
Subject: Re: Sorting
Message-Id: <33D5E0BF.131EE406@adc.metrica.co.uk>

Russ Allbery wrote:

> [ Posted and mailed. ]
>
> Sanjay Varma <sanjay@rocketship.com> writes:
>
> > If I have a huge text file containing data I wish to sort. Is there
> any
> > way it could be done with Perl without reading the entire file into
> an
> > associative array? Say coz of memory constraints.
>
> If you have a huge text file you want to sort, you want to use the
> standard Unix command "sort".  It does all sorts of buffering, paging,
> and
> other interesting things to make the sort faster that you don't want
> to
> try to reimplement in Perl.
>
> It'll also consume less memory than the same algorithm implemented in
> Perl.
>
> --
> #!/usr/bin/perl -- Russ Allbery, Just Another Perl Hacker
> $^=q;@!>~|{>krw>yn{u<$$<[~||<Juukn{=,<S~|}<Jwx}qn{<Yn{u<Qjltn{ > 0gFzD
> gD,
>  00Fz, 0,,( 0hF 0g)F/=, 0> "L$/GEIFewe{,$/ 0C$~> "@=,m,|,(e 0.),
> 01,pnn,y{
> rw} >;,$0=q,$,,($_=$^)=~y,$/ C-~><@=\n\r,-~$:-u/
> #y,d,s,(\$.),$1,gee,print

   Just a note but depending on how good the sort that comes with your
OS is  would seriously consider looking at GNU sort. I was running the
sort that comes with AIX 3.2.5 and incomparison with GNU sort on a
120Meg file it used 1/2 the amount of temporary file space, considerably
less memory and took 10mins rather than 1hr 45mins; as you can
appreciated I was rather suprised.

Simon



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

Date: Tue, 22 Jul 1997 16:44:58 GMT
From: "Bruce Davidson" <allied@pair.com>
Subject: Syntax junkies !
Message-Id: <01bc96bb$e03742e0$0422989e@allied.demon.co.uk>

hi,
this kindly donated from this group.
My choice of opening and closing handles.

#!/usr/bin/perl

{
open (SOURCE,"/mydir/file1.html");
open (DESTINATION, ">/mydir/file2.html");
while (<SOURCE>) {
	print DESTINATION $_;
	}
close (SOURCE);
close (DESTINATION);
}
# end of file

Purpose - to use a browser to copy one file over another at the server. Why
- who cares :)

Works on telnet login with free bsd C shell in cgi-bin using "perl
script.pl".
My other small scripts  just need  "script.pl" to operate. 
Don't understand why this needs the "perl" prefix.

I'd like to call this from my browser links, but when I try, the server
reports an error
so I don't even get as far as when on telnet.
I'd also like the browser to print NEWFILE = OK chum, we overwrote file 2
with file 1.
Syntax needed.

Any folks got a steer on this please.
Could it be file permissions on the server.
The script is chmod 755.
thanks
BD
allied@pair.com


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

Date: Tue, 22 Jul 1997 21:08:15 GMT
From: faust@wwa.com (Faust Gertz)
Subject: Re: Syntax junkies !
Message-Id: <33d61fc6.7276024@news.wwa.com>

On Tue, 22 Jul 1997 12:51:50 -0700, Tom Phoenix
<rootbeer@teleport.com> wrote:

>On Tue, 22 Jul 1997, Bruce Davidson wrote:

>> this kindly donated from this group.
>
>That sentence no verb.


Isn't 'donated' a verb?


Streben nach Wahrheit

Faust Gertz
Philosopher at Large

My name is Yon Yonson, I work in Wisconsin, I work in a lumbermill
there.  The people I meet when I walk down the street, they say,
"What's your name?"  And I say, "My name is Yon Yonson, I work in
Wisconsin..." 



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

Date: Tue, 22 Jul 1997 18:20:29 -0400
From: roger@umich.edu (Roger Espinosa)
Subject: Re: Tie a hash of hashes ?
Message-Id: <roger-2207971820300001@eeyore.oit.itd.umich.edu>



In article <01bc96c6$46e3da80$36601ec6@bach>, "Noone Special"
<jpm@iti-oh.comNOSPAM> wrote:

> If you find a way to tie the hash, please tell me. 
> I searched a while back, and was unable to find a solution.
> My solution was to make a script that writes the hash into an ASCII file,
> then a script that would restore it.
> -- 
> Josh,
> Gavin Dragon...
> Remove NOSPAM from address...
> 
> 
> 
> Calle Aasman <calle@studentREMOVETOREPLY.adb.gu.se> wrote in article
> <33D4649B.20EF@studentREMOVETOREPLY.adb.gu.se>...
> > I would like to put a hash-of-hashes in a DBM, this can't be done, what
> > are the options?
> > Is there a way to use tie somehow?
> > 
> > If anyone could help me out on this I would be very happy...
> > 
> > /Calle

There are a few options for storing, available on CPAN:

Storable -- lets you save data structures out and load them back in. It's
zippy, it's fun, and is one way to deal with persistent hashes-of-hashes.

MLDBM/Data::Dumper -- it works more like what you'd expect a tie'd hash to
do, but you can't do everything (e.g. {}{}{} accesses) directly from the
MLDBM hash.

Currently, my favored scheme is a combination of MLDBM and Stones (from
the BoulderIO libraries, at

   http://www.genome.wi.mit.edu/genome_software/other/boulder.html

where the hashes-of-hashes get implemented in the Stones, and these saved
via MLDBM.
-- 
Roger Espinosa                         roger@umich.edu
Office of Instructional Technology     313/763-4677 (FAX: 313/763-4663)
University of Michigan                 http://www.oit.itd.umich.edu/~roger/



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

Date: Tue, 22 Jul 1997 14:58:30 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: Unique File Creation
Message-Id: <EDq6xJ.Esp@world.std.com>

"Karyl F. Stein" <steinkf@cs.purdue.edu> writes:

>I am trying to write a subroutine that takes a seed, creates a unique
>file based on that seed, and returns the nme and a filehandle to the new
>file.  What I did is this:

You are using the same filehandle, named FILEHANDLE over each
execution of your subroutine.

One solution would be to use the FileHandle or IO::File module to
create a new filehandle each time.

$handle = new IO::Handle "$File$Postfix", O_WRONLY | O_CREAT | O_EXCL;

Another would be to make the filehandle local with the local()
operator. 

local(FILEHANDLE);

Another would be to skip this whole thing and use the
IO::File->new_tmpfile() method.
-- 
Andrew Langmead


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

Date: 22 Jul 1997 19:16:28 GMT
From: "Karyl F. Stein" <steinkf@cs.purdue.edu>
Subject: Re: Unique File Creation
Message-Id: <5r30uc$4v9$0@206.85.222.24>

Mike Stok wrote:
> 
> In article <5r0cb5$549$0@206.85.222.24>,
> Karyl F. Stein <steinkf@cs.purdue.edu> wrote:
> >I am trying to write a subroutine that takes a seed, creates a unique
> >file based on that seed, and returns the nme and a filehandle to the new
> >file.  What I did is this:
> >
> >sub CreateFile {
> >    my $File = $_[0];
> >    my $Postfix = $$;
> 
>   [...]
> 
> >}
> You could use the IO::File module and have code like
> 
>   while (...) {
>     $fh = new IO::File $fileName, O_RDWR|O_EXCL;
>     if (defined $fh) {
>       return ($fileName, $fh);
>     }
>     # generate a new filename etc.
>   }
> 
> which returns a filename and an an IO::File ref, maybe.

This is what I needed--thanks.  I wanted to make the create and open
atomic to aviod any possible race conditions which is why I was
using sysopen instead of open.  This module appears to do just that
if you pass a mode line to it.


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

Date: Tue, 22 Jul 1997 07:24:15 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Danny Aldham <danny@lennon.postino.com>
Subject: Re: Unix
Message-Id: <Pine.GSO.3.96.970722072107.19892E-100000@kelly.teleport.com>

On 21 Jul 1997, Danny Aldham wrote:

> #!/usr/bin/perl -w
> $|=1;
> require 'cgi_handlers.pl' ;
> print $rqpairs{'command'} ; from forms <Input Name="command" > tag 
> &get_request();
> &html_header("Run Unix Command");
> print "Command to run: ", $rqpairs{'command'},"\n";
> @output = `$rqpairs{'command'}`;
> print "Command output: ", @output ;
> &html_trailer();

It's a good thing that that script doesn't work. If you fixed it up, it
would be dangerous. Any good webmaster should disable scripts like this on
sight. 

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/



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

Date: Mon, 21 Jul 1997 14:20:43 -0600
From: Douglas Munn <sales@idi-ut.com>
Subject: Re: WEB discussion tool
Message-Id: <33D3C49A.3239@idi-ut.com>

Kjetil Palmquist wrote:
> 
> Where can I find tools for running web based discussion groups?
Although it is not PERL, we use WebBoard from O'reilly & Assoc.  The
limited version is free on the web and is very complete.

doug


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

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 757
*************************************

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