[6791] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 416 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri May 2 18:17:27 1997

Date: Fri, 2 May 97 15:01:33 -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           Fri, 2 May 1997     Volume: 8 Number: 416

Today's topics:
     Re: pre-RFD: comp.lang.perl.{data-structure,inter-proce (Kyzer)
     Re: PRINTF irregularities? (Jeremy T. Elston)
     problem with bootstrap in a module <dmi1@ra.msstate.edu.nospam>
     Re: Problem with CGI form processing (jp)
     Re: Procedure to count unique lines (Tad McClellan)
     Re: RISC vs CISC or SunOS <karlt@ilinks.net.njem>
     Space Substitution (Eric Sheng - PCD ~)
     Re: Space Substitution (Craig Berry)
     Re: Space Substitution (Eric Sheng - PCD ~)
     Re: sybperl to oraperl conersion help (John D Groenveld)
     variable names in array problem <poranski@riter.computize.com>
     Re: What is the best way of learning Perl? <arnie@diac.com>
     when to use untie() (or: how is DESTROY called?) <gtk@walsh2.med.harvard.edu>
     Re: Write form to variable (A. Deckers)
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: 2 May 1997 16:31:18 GMT
From: junkmail@sysa.abdn.ac.uk (Kyzer)
Subject: Re: pre-RFD: comp.lang.perl.{data-structure,inter-process,porters,regex}
Message-Id: <5kd4sm$j88@info.abdn.ac.uk>


Brad Appleton, while sobering up, wrote:
: > 1- whether the proposed additional groups are well chosen, and if not,
: > what the alternatives should be;

: I like them, but I think there should be a separate group expressly
: for newbie questions. So clueless perl newbies who havent the first
: idea which of the above groups to post to will plainly see where to

How about, for clp.new-user, that anything with 'CGI', 'WWW' or 'web'
in it gets posted to c.i.w.a.cgi ? Would save time :)

Just my .02

--
Stuart 'Kyzer' Caie - Kyzer/CSG |undergraduate of Aberdeen University |100%
http://www.abdn.ac.uk/~u13sac   |My opinions aren't those of Aberdeen |Amiga -
kyzer@4u.net kyzer@hotmail.com  |University or AUCC, thankfully.***** |always!
ROGER: Benny? Is that you?    BENNY: No, it's Shirley Temple!!


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

Date: Fri, 02 May 1997 21:04:50 GMT
From: TechSupport@Greenwood.net (Jeremy T. Elston)
Subject: Re: PRINTF irregularities?
Message-Id: <5kdkt9$so5$1@bigdog.ais-gwd.com>

        Thanks for all the replies!  As usual, it was my 
misinterpretation(sp?).  :-)



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

Date: 02 May 1997 13:23:29 -0500
From: David Ishee <dmi1@ra.msstate.edu.nospam>
Subject: problem with bootstrap in a module
Message-Id: <m3iv11pwbi.fsf@gsubc.dot.edu>

I've got a perl script that uses Msql.pm to access a mSQL database
from perl. It was working, but I upgraded my Red Hat Linux system from
4.0 to 4.1 and now the script will not work. When I try to run it I
get this error: 

Can't find loadable object for module Msql in @INC
(/usr/lib/perl5/i386-linux/5.003 /usr/lib/perl5
/usr/lib/perl5/site_perl/i386-linux /usr/lib/perl5/site_perl .) at
/usr/lib/perl5/site_perl/Msql.pm line 70 BEGIN failed--compilation
aborted at ./pbook line 5.

line 70 of Msql.pm is: bootstrap Msql;

I'm using perl 5.003 with EMBED. 

What is going on here? This is very annoying since I use this script
frequently. 

-- 

David

+--------------------------------------------------------------------+
| David Ishee                                                        |
| MS grad student, Mechanical Engineering        dmi1@ra.msstate.edu |
| Mississippi State University                                       |
|                                                                    |
+------------- http://www2.msstate.edu/~dmi1/index.html -------------+


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

Date: Fri, 02 May 1997 17:10:24 GMT
From: jp@here.com (jp)
Subject: Re: Problem with CGI form processing
Message-Id: <336f1f82.3737820@news.cent.com>

If you are recieving form input  perhaps you could try telling the
mailer to print the form input values instead of the file you created
in your directory with the form input. You might find it a lot easier
if you're not too sure about it.

On Mon, 28 Apr 1997 19:09:22 +0200, Sondre Johan Walla
<sondrejw@stud.hitos.no> wrote:

>Ive been trying to get a perl script CGI to run correctly. It is
>supposed to process a form and then send a mail to me. The problem is
>that the mail I get is totally empty. Can anyone help?? 
>TIA
>
>Sondre J. Walla
>http://samson.stud.hitos.no/~sondrejw/main.htm
>
>Perl procedure for mail enclosed:
>
>sub do_mail
>{
>  local($filename) = "/tmp/cf-$$";
>  open(TFILE,">$filename");
>  @filetext = <TFILE>;
>
>#<...print a lot of shit to file...>
>
>close(TFILE);
>
>  open (MAIL, "|/usr/lib/sendmail $mailreceiver") || die "No can
>do!!\n";
>  print MAIL "Subject: Membership application\n\n";
>  print MAIL "$filetext\n";
>  close MAIL;
>  unlink("$filename\n");
>}
>
>
># The variable $mailreceiver is declared in the main prog.



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

Date: Fri, 2 May 1997 09:57:39 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Procedure to count unique lines
Message-Id: <3dvck5.du1.ln@localhost>

Aram Mirzadeh (awm@luers.qosina.com) wrote:

: Greetings, 

: I have a 3.4MB text file with one entry per line.  I'm trying to count the
: number of times each line item is listed.  I tried doing it via sort and 
: count the number of items before the item itself changes, to no avail, and
: it was VERY VERY slow.  

: Has anyone already done this?  I would appreciate any pointers. 


while (<>) {       # UNTESTED
   $cnt{$_}++;
}

foreach (sort keys %cnt) {
   printf("%9d: %s", $cnt{$_}, $_);
}


--
    Tad McClellan                          SGML Consulting
    Tag And Document Consulting            Perl programming
    tadmc@flash.net


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

Date: 2 May 1997 20:38:52 GMT
From: "Karl Thomas" <karlt@ilinks.net.njem>
Subject: Re: RISC vs CISC or SunOS
Message-Id: <01bc5738$a9c0c820$b8c289ce@hitachi>

John Nagle <nagle@netcom.com> wrote in article
<nagleE9JoKC.34z@netcom.com>...

>      Suprisingly, no.  The Pentium Pro gets about as much out of the
> x86 architecture as you could get from a RISC instruction set.  It's
> a technical tour de force.   Inside, the Pentium Pro is a superscalar
> dataflow machine with about 40 registers, with a front end that decodes
> x86 instructions and a back end that synchronizes the completion of
> everything to create the illusion that execution is sequential.
> It even works if you modify instructions during execution.

But with all of the money and man power spent on the Pentium Pro, it's
performance increase over the Pentium is still a disappointment as well as
its disappointment compared to the PPC 604, etc.



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

Date: 2 May 1997 17:01:26 GMT
From: eshengx@pcocd2.intel.com (Eric Sheng - PCD ~)
Subject: Space Substitution
Message-Id: <5kd6l6$16n$1@news.fm.intel.com>

Dear all,

	My name is Eric.  I am having problem with substituting things into double spaces.
I want to replace *all* double spaces  with the string "&nbsp&nbsp" on all the lines of a file
without touching any of the single spaces.
My code goes something like:

while (<INFILE>)  {
  $_ =~ s/\  /\&nbsp&nbsp/;
  print OUTFILE;
}

	The problem is that it *only* replaces the first double space that it sees on each
line.  The rest are untouched.  What's the reason for that?

								Thanx in advance,

									Eric


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

Date: 2 May 1997 21:03:15 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Space Substitution
Message-Id: <5kdkqj$lc3$1@marina.cinenet.net>

Eric Sheng - PCD ~ (eshengx@pcocd2.intel.com) wrote:
: 	Never mind.  I just forgot to put in the "g" at the end of
: 
:    $_ =~ s/\  /\&nbsp&nbsp/    

Three free additional pieces of advice:

1. $_ is the default target of the substitution operator, so you may
   omit "$_ =~ " should you wish to do so.
2. Backslash-quoting the first of the two spaces accomplishes nothing
   (other than confusing readers of your code).  The same applies to
   the first & in the substitution text.
3. If you're trying to replace with the non-breaking space HTML character
   entity, you should be using &nbsp; -- note the trailing semicolon.
   You need one at the end of each entity.

Also, as you note, you need the 'g' (global) modifier at the end.
So, applying all of these, your substitution becomes:

  s/  /&nbsp;&nbsp;/g;

Hope this helps!

---------------------------------------------------------------------
   |   Craig Berry - cberry@cinenet.net
 --*--    Home Page: http://www.cinenet.net/users/cberry/home.html
   |      Member of The HTML Writers Guild: http://www.hwg.org/   
       "Every man and every woman is a star."


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

Date: 2 May 1997 17:10:16 GMT
From: eshengx@pcocd2.intel.com (Eric Sheng - PCD ~)
Subject: Re: Space Substitution
Message-Id: <5kd75o$16n$2@news.fm.intel.com>


Eric Sheng - PCD ~ (eshengx@pcocd2.intel.com) wrote:
: Dear all,
: 
: 	My name is Eric.  I am having problem with substituting things into double spaces.
: I want to replace *all* double spaces  with the string "&nbsp&nbsp" on all the lines of a file
: without touching any of the single spaces.
: My code goes something like:
: 
: while (<INFILE>)  {
:   $_ =~ s/\  /\&nbsp&nbsp/;
:   print OUTFILE;
: }
: 
: 	The problem is that it *only* replaces the first double space that it sees on each
: line.  The rest are untouched.  What's the reason for that?
: 
: 								Thanx in advance,
: 
:
 									Eric


Hey all,

	Never mind.  I just forgot to put in the "g" at the end of

   $_ =~ s/\  /\&nbsp&nbsp/    


									Eric


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

Date: 2 May 1997 16:45:05 -0400
From: groenvel@cse.psu.edu (John D Groenveld)
Subject: Re: sybperl to oraperl conersion help
Message-Id: <5kdjoh$g7h$1@tholian.cse.psu.edu>

In article <862532727.20823@dejanews.com>,  <sanjiv@wst.bri.com> wrote:
>We need some help for porting Sybperl code into Oraperl code. Are there

You might try asking the DBI-user mailing list. See 
http://www.hermetica.com/technologia/DBI/ for details.
John
groenvel@cse.psu.edu


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

Date: Fri, 02 May 1997 16:17:33 -0500
From: Peter Poranski <poranski@riter.computize.com>
Subject: variable names in array problem
Message-Id: <336A59ED.699E95BF@riter.computize.com>


This is a multi-part message in MIME format.
--------------1451751FF44CE1217602BFD2
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

What I need help with is storing variable names in a array, but not the
variable.

lets sat that

                 $example[0] = "varName1";
                 $example[1] = "varName2";

if I wanted to call the variable $varName1 using the Array, how would I?

I have tried quite a few combos including  $$example[0]  (which, by the
way, did not work)

Any help would be wonderful...

peter.poranski@wcom.com

--------------1451751FF44CE1217602BFD2
Content-Type: text/x-vcard; charset=us-ascii; name="vcard.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: Card for Peter  Poranski
Content-Disposition: attachment; filename="vcard.vcf"

begin:vcard

fn:Peter  Poranski

n:Poranski;Peter 

org:WorldCom

email;internet:poranski@riter.computize.com

title:Webmaster

x-mozilla-cpt:;0

x-mozilla-html:FALSE

end:vcard




--------------1451751FF44CE1217602BFD2--



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

Date: 2 May 1997 19:22:18 GMT
From: "arnie sherman" <arnie@diac.com>
Subject: Re: What is the best way of learning Perl?
Message-Id: <01bc572f$f5750e60$648e4dcf@frenomulax>

hi,
i'm also pretty much a beginner to perl. i've maintained and adapted a few
scripts from other authors, but programming from scratch is another
matter...
i use the llama book, but also the "perl 5 interactive course" from waite
group press. it's prety good, but i also need to refer to the llama & the
web for clarification at times. one nice thing though is you get access to
their web site, w/ an online version of the quizes in the book, as well as
help from what they call "mentors" - perl programers who will return your
email questions w/in 24 hours. they give you up to 10 questions per chapter
& this has been pretty helpful for me. you also get a cd w/ perl 5, the
cpan archives, etc. though of course anyone w/ web access can get those. it
is convenient to have them local to yr cd, too.
at about 50 bucks it's a bit pricey, but so are the o'reilly books.
-- 
arnie sherman
arnie@diac.com

Tom Phoenix <rootbeer@teleport.com> wrote in article
<Pine.GSO.3.96.970502084211.2421A-100000@kelly.teleport.com>...
> On 2 May 1997, Philippe Benichou wrote:
> 
> > What is the best way for learning Perl?  Looking at other people's
scripts
> > is too confusing, and the O'Rielly book doesn't explain things well.
> 
> Which O'Reilly book? The Camel is a reference, but the Llama is a
> tutorial. Have you tried the Llama? I recommend it. Hope this helps!



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

Date: 02 May 1997 13:11:01 -0400
From: Gregory Tucker-Kellogg <gtk@walsh2.med.harvard.edu>
Subject: when to use untie() (or: how is DESTROY called?)
Message-Id: <w2vi51240q.fsf@walsh2.med.harvard.edu>


Here is a simple program I wrote (test.pl) to test a tied hash.  The
tie() is used because I need to stick to a very specific
implementation of certain file types (ASCII database files used by
another program).

  #!/bin/perl -w
   use strict;
   use lib "./lib";
   use NMR::AtomFile;
   use vars qw(*atoms $num $atom);
   use Fcntl;

   my $spinfile = $ARGV[0];
   $atoms =    tie(%atoms,   'NMR::AtomFile',$spinfile,O_RDWR);
   delete $atoms{1000};
   untie %atoms;

The changed ASCII file is written out in the DESTROY method for the
class.  That method is

  sub DESTROY { 
    carp whowasi() if $DEBUG;
    my $self = shift;
    return unless ($self->{FILEOPS} && (O_WRONLY | O_RDWR | O_CREAT));
    rename("$self->{FILE}","$self->{FILE}.old") or 
      croak "Cannot make backup file for $self->{FILE}";
    my $atomfile = new IO::File;
    $atomfile->open($self->{FILE},O_WRONLY|O_CREAT|O_EXCL)
      or die "Can't open $self->{file}: $!\n";
    my ($num,$atom);
    foreach $num (sort {$a <=> $b} keys(%{$self->{ATOM}})) {
      $atom = $self->{ATOM}{$num};
      $atomfile->printf ("%4d %7.3f %6.3f %-6s %3d \n",
                 $num,$atom->ppm(),$atom->error(),$atom->name(),
                 $atom->fragment);
    }
    $atomfile->close();
  }

Here's the test:

  [gtk ] ./test.pl foo.prot 
  [gtk ] diff foo.prot{,.old}
  999a1000
  > 1000   3.991  0.000 HB2     59 

That seems OK, but if I comment out the *one* line "untie %atoms" in
test.pl, I get

  [gtk ] ./test.pl foo.prot 
  [gtk ] diff foo.prot{,.old}
  999a1000
  > 1000   3.991  0.000 HB2     59 
  1578a1580,1589
  > 1580   6.112  0.000 HA      92 
  > 1581   3.289  0.000 HB2     92 
  > 1582   3.289  0.000 HB3     92 
  > 1583   7.916  0.000 HD21    92 
  > 1584   8.096  0.000 HD22    92 
  > 1585   9.995  0.000 HN      92 
  > 1586 120.071  0.000 N       92 
  > 1587 114.611  0.000 ND2     92 
  > 1588   0.000  0.000 QB      92 
  > 1589   0.000  0.000 QD2     92 

I thought the untie() would be unnecessary, since the program's
termination would force a call to the class's DESTROY.  In fact
DESTROY is called (since the new file is written out) but the tied
hash is always a bit smaller than it should be.

What gives?

TIA,

Greg

--
Gregory Tucker-Kellogg
Department of Biological Chemistry and Molecular Pharmacology
Harvard Medical School, Boston MA 02115
"Mojo Dobro"    Finger for PGP info



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

Date: 2 May 1997 17:02:26 GMT
From: I-hate-cyber-promo@man.ac.uk (A. Deckers)
Subject: Re: Write form to variable
Message-Id: <slrn5mk7gm.nju.I-hate-cyber-promo@nessie.mcc.ac.uk>

In comp.lang.perl.misc,
	erich@powerwareintl.com wrote:
>how would I write a format to a variable instead of writing it out to a
>file handle?

You read read the FAQ (part 5) and then RTFM man perlform.

Alain

-- 
Perl information: <URL:http://www.perl.com/perl/>
        Perl FAQ: <URL:http://www.perl.com/perl/faq/>
    Perl archive: <URL:http://www.perl.com/CPAN/>


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

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

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