[6976] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 601 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jun 11 21:08:00 1997

Date: Wed, 11 Jun 97 18:00:27 -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, 11 Jun 1997     Volume: 8 Number: 601

Today's topics:
     Re: (no subject) <rootbeer@teleport.com>
     ?absolute path for "use" clause (Jeff Zeitlin)
     Re: ?absolute path for "use" clause (A. Deckers)
     Re: Better way to split long strings into equal length  <rootbeer@teleport.com>
     Re: Disk Space and Free INODES <rootbeer@teleport.com>
     Re: global regex in an "if" statement <staci@datahost.com>
     Re: Help on executing DOS commands through perl (Clay Irving)
     Help! perl -d under OpenWindows (Mark Shaw)
     Re: hpux perl 5.003 binaries <rootbeer@teleport.com>
     Re: Mail using Perl <turloughg@aol.com>
     Re: newbie question about the sort function and hashes <rootbeer@teleport.com>
     Re: Passwording (on UNIX) <parmjit.bal@gecm.com>
     Perl 5.004/Tk402.000 MainWindow <mroth@wgate.com>
     Re: Perl script as login shell? (Ken Fox)
     Re: Perl script controlling MSDEV? <dada@divinf.it>
     Perl training in the D.C. metro area bclark@auanet.org
     Re: Perl, TK, CGI (Quentin Fennessy)
     Re: Premature end of script (Michael Fuhr)
     Re: regexp question: greener than godzilla... (A. Deckers)
     Re: Regular expression with double bytes (Abigail)
     Sorting by key (Shoemaker Garth B D)
     Sorting Numerically <jefpin@bergen.org>
     Tie Scalar ?? (David Tauzell)
     tie() not creating new database? <turloughg@aol.com>
     Very technical question - memory sharing & fork <simonk@telebusiness.co.nz>
     Re: VISUAL BASIC 5 <jim.michael@gecm.com>
     while(<>){if(/cond/){while(<> ~= /cond2/) ... (Darwin O.V. Alonso)
     Re: write a new htmp page (Dave Cross)
     Re: Y2K Compliant? <aas@bergen.sn.no>
     Re: Y2K Compliant? (Kyzer)
     Re: Y2K Compliant? <jhi@alpha.hut.fi>
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Wed, 11 Jun 1997 15:40:53 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: "Douglas M. Croft" <dcroft@zoo.uvm.edu>
Subject: Re: (no subject)
Message-Id: <Pine.GSO.3.96.970611153934.5767N-100000@kelly.teleport.com>

On Wed, 11 Jun 1997, Douglas M. Croft wrote:

> Date: Wed, 11 Jun 1997 14:28:38 -0400
> From: "Douglas M. Croft" <dcroft@zoo.uvm.edu>
> Newsgroups: comp.lang.perl.misc
> Subject: (no subject)
> 
> where did my posting go?

I don't know. Where did you see it last? :-)

-- 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, 11 Jun 1997 23:15:13 GMT
From: jeff.zeitlin@execnet.com (Jeff Zeitlin)
Subject: ?absolute path for "use" clause
Message-Id: <33a03168.82727372@nntp.execnet.com>

I'm using a web presence provider that provides limited
capability for CGI programming - they provide perl4 and perl5
interpreters, but no modules/libraries (I think this is an
erroneous decision, but...), and they provide *IX shell (sh and
tcsh, I believe).  As a result of their decisions, if I want to
use any perl5 modules, I must, according to their support staff,
supply the full pathname of the module.  None of the references I
have on either perl or CGI discuss this (or at least I couldn't
find any such discussion).  Would someone please be so kind as to
enlighten me?

Please copy me by email; while I _do_ check news at least three
times per week, I have extremely strong reason to believe that my
provider's upstream provider is _not_ providing a complete feed,
irrespective of their statement to my provider (and my provider's
to me).


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

Date: 11 Jun 1997 23:23:39 GMT
From: deckers@man.ac.uk (A. Deckers)
Subject: Re: ?absolute path for "use" clause
Message-Id: <slrn5pucrn.hoa.deckers@news.rediris.es>

In <33a03168.82727372@nntp.execnet.com>,
	Jeff Zeitlin <jeff.zeitlin@execnet.com> wrote:
>I'm using a web presence provider that provides limited
>capability for CGI programming - they provide perl4 and perl5
>interpreters, but no modules/libraries (I think this is an
>erroneous decision, but...), and they provide *IX shell (sh and
>tcsh, I believe).  As a result of their decisions, if I want to
>use any perl5 modules, I must, according to their support staff,
>supply the full pathname of the module.  None of the references I
>have on either perl or CGI discuss this (or at least I couldn't
>find any such discussion).  Would someone please be so kind as to
>enlighten me?

At the top of your script, you want:

use lib '/path/to/my/modules';

Where /path/to/my/modules is the directory where you have installed
your private copies of the necessary modules. After that you just:

use Module;

I'm surprised you didn't find this information in the docs. I bet it's
in the FAQ and it certainly is mentioned in the README or INSTALL file
of quite a few modules, among them CGI.pm, IIRC.

HTH,

Alain

-- 
Perl information: <URL:http://www.perl.com/perl/>
    Perl archive: <URL:http://www.perl.com/CPAN/>
        Perl FAQ: <URL:http://www.perl.com/CPAN/doc/FAQs/FAQ/>
>>>>>>>>>>>>> NB: comp.lang.perl.misc is NOT a CGI group <<<<<<<<<<<<<<


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

Date: Wed, 11 Jun 1997 15:28:30 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Kjetil Skotheim <kjetil.skotheim@usit.uio.no>
Subject: Re: Better way to split long strings into equal length parts?
Message-Id: <Pine.GSO.3.96.970611151655.5767M-100000@kelly.teleport.com>

On 11 Jun 1997, Kjetil Skotheim wrote:

> What is the fastest and/or most elegant way to split a long
> string into equal length parts into a list.

> (With unpack?)

You got it!

    sub breakup ($$) {
	my($string, $chunk_size) = @_;
	my $times = length($string)/$chunk_size;
	$times++ if $times > int($times);
	my $format = ('a' . $chunk_size) x $times;
	unpack $format, $string;
    }

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, 11 Jun 1997 14:59:18 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: The Old Wolf <kane@accesscomm.net>
Subject: Re: Disk Space and Free INODES
Message-Id: <Pine.GSO.3.96.970611145639.5767I-100000@kelly.teleport.com>

On Wed, 11 Jun 1997, The Old Wolf wrote:

> I need a platform independent method of determining free space in a file
> system (Preferably faster then writing a test file till it fails ;) )

There isn't one. :-(  But you could make people happy by making an
extensible module which works on as many systems as possible. On many
systems, it could run a program like df and parse the output. Good luck! 

-- 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, 11 Jun 1997 17:04:04 -0700
From: Michael Stearns <staci@datahost.com>
Subject: Re: global regex in an "if" statement
Message-Id: <339F3CF3.5800@datahost.com>

Tad McClellan wrote:
> 
> Michael Stearns (staci@datahost.com) wrote:

> : put it into one scalar variable and then do a bunch of global
> : replacements. My problem is with the if statement at the bottom. I
> : cannot figure out how to make this work globally. It only works on the
> : first instance that it matches.
> 
> I don't understand what it is you want. If you had supplied some
> sample data illustrating your problem, I would have attempted to
> answer your question.

Fair enough. This is what a relevant section of my document looks like
when I get to this point in the script:


#############################################
<P>Curriculum requirements are being reviewed by the faculty. A list of
requirements for 1997&#173;98 
is available from the program's graduate secretary.
<P><B><I>Ph.D. Degree Requirements     155 credits</I></B>
<P>Psychological foundations     27
<P>Research competencies     41
<P>Practitioner competencies     63
<P>Professional competencies     9
<P>Elective seminars     15
<P>The D.Ed. program in counseling psychology is inactive.
<H3>
<B>School Psychology</B>
#############################################

There are many instances of this pattern throughout my set of documents.
I am trying to get the credit requirements to be listed in html tables. 

> 
> : Are there any modifiers I can use to make this work globally or are
> : there other techniques that will make it work?
> 
> : ################################
> : foreach (@ARGV) {
> 
> : open (INFILE,"$_") || die ("Cannot Open $_\n");
> 
> : @text=<INFILE>;
> : $text=join("",@text);
> 
> You don't need that @text intermediate array:
> 
> $text = join '', <INFILE>;  # this is slower than other slurping methods...


I came up with this method on my own and it has seemed to work for me.
Do you have a better method you would suggest?


> 
> : <--------lots of other stuff in here----------------->
> 
> : ####This is what many of my lines look like. This works well for doig a
> : global search and replace.
> 
> : $text=~ s^foo^bar^gs;
> 
> The 's' modifier has no effect on matching that regex, you don't it.

Are you referring to the "trailing" s? I do need the preceding s, don't
I? 

> 
> [ using a regex metacharacter as your regex delimiter is not a good habit
>   to get into
> ]

It seemed like every special character I could think of had some regex
meaning. What character shoud I use? 
> 
> : #### Here's where I am stuck. This only works on one instance and I so
>                                           ^^^^^^^^^^^^^^^^^^^^^
> 
> I wonder what that instance looks like. Hard to interpret a pattern
> match when the string to be matched against is not given...
> 
> : far can't get any modifiers to make it work differently.
> 
> : if ( $text =~ /foo/ &&  $text !~ /bar/) {
>        ^^^^^^^^^^^^^^
> 
> This part will always be false, if you ran that s^foo^bar^s first.


OK. This is a bad example. I see it wouldn't work right.

> 
> So the second part never needs to be evaluated...
> 
> : print "YEAH\n";
> : }
> : ###################################

So I guess what I am trying to figure out is a way to pull out a section
of my document (since this is a course catalog, there are lots of
sections like this) and convert it into a table.

These paragraphs are unique in that they have 5 spaces followed by a
digit. I believe I can turn lines that have this pattern into a two cell
table line, but I do not see how to establish, in the context of my
document where the table starts and where it ends. Any help would be
appreciated?

Michael Stearns
University of Oregon


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

Date: 11 Jun 1997 10:02:39 -0400
From: clay@panix.com (Clay Irving)
Subject: Re: Help on executing DOS commands through perl
Message-Id: <5nmb5v$gh@panix.com>

In <01bc75c6$e9b292e0$371c9bcf@pc10.adrenalin.com> "Chris" <coke@adrenalin.com> writes:

>Try:

>    open(DIR,"dir") || die "Couldn't run dir";
>    local(@output)=<DIR>;              # get dir output
>    close(DIR);

Don't you have to do this?

     open(DIR, "dir |") || die "Couldn't run dir";

-- 
Clay Irving                                        See the happy moron,
clay@panix.com                                     He doesn't give a damn,
http://www.panix.com/~clay                         I wish I were a moron,
                                                   My God! Perhaps I am!


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

Date: 11 Jun 1997 20:17:31 GMT
From: mshaw@Jasic.Usc.Nti.Kcom (Mark Shaw)
Subject: Help! perl -d under OpenWindows
Message-Id: <5nn14r$p2d$1@spock.asic.sc.ti.com>

Anyone run into this problem?
 
I'm using OpenWindows version 3 on a Sun Sparc20 running SunOS 5.5.
If I try to run the perl (version 5.003) debugger in a cmdtool win-
dow, I get the following (the first line is my script invokation,
where the script has #!/usr/local/bin/perl -d as the first line):
 
   % pins < EL00128004040.lef
   Stack dump during die enabled outside of evals.
 
   Loading DB routines from perl5db.pl patch level 0.94
   Emacs support available.
 
   Enter h or `h h' for help.
 
   resize: Time out occurred
   Unable to get Terminal Size. The TIOCGWINSZ ioctl didn't work. The COLUMNS
   and LINES environment variables didn't work. The resize program didn't work.
   at /apps/perl5.003/lib/site_perl/Term/ReadKey.pm line 291.
    Term::ReadLine::Perl::new called at /apps/perl5.003/lib/perl5db.pl line 996
    DB::setterm called at /apps/perl5.003/lib/perl5db.pl line 297
    DB::DB called at pins line 39
 
Note that this does NOT occur if I start the script in an xterm --
everything works fine -- but I really don't want to have to go to an
xterm anytime I need to use the debugger!
 
Any ideas?  Thanks in advance....
 



-- 
Mark Shaw
My opinions only
PGP public key available at ftp.netcom.com:/pub/ms/mshaw
(to email me, remove all capital letters from my address)




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

Date: Wed, 11 Jun 1997 15:05:27 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: RL <rligonzo@geocities.com>
Subject: Re: hpux perl 5.003 binaries
Message-Id: <Pine.GSO.3.96.970611150423.5767J-100000@kelly.teleport.com>

On Wed, 11 Jun 1997, RL wrote:

> Hi at all , our problem is to retrieve the binaries version of perl
> 5.003 for hp-ux v.10.10 , we have find one but it seems not work fine
> _(depot file), may anybody help us to find the correct one if exist???

I heartily encourage you to seek 5.004 instead of 5.003. And it's easier
to compile the source than you might think; give it a try!

-- 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, 11 Jun 1997 16:14:45 -0400
From: Gary Geniesse <turloughg@aol.com>
Subject: Re: Mail using Perl
Message-Id: <339F0735.109C@aol.com>

> I am working on a website , using Perl.What I want to know is that how
> can we send mail to a particular address from the web site.

If you're dealing with UN*X, this might help.  The following snippet of
code is paraphrased from Matt Wright's Guestbook program
(http://www.worldwidemart.com/scripts/).  It opens a pipe to the
sendmail program to send mail to a particular address based on data
entered at the website.

Be sure to modify $mailprog to point to the appropriate place on your
system.

-Gary Geniesse
turloughg@aol.com

----------------------------------------------------------------------
$mailprog = '/usr/lib/sendmail';
$recipient = 'you$your.addr';

open (MAIL, "|$mailprog $recipient") || die "Can't open $mailprog!\n";
print MAIL "Reply-to: $recipient (your_name)\n";
print MAIL "From: an_address (a_name)\n";
print MAIL "Subject: a_subject\n\n";
print MAIL "text_of_message\n\n";
close (MAIL);
----------------------------------------------------------------------


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

Date: Wed, 11 Jun 1997 11:36:08 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: hakan keskin <e105578@orca.cc.metu.edu.tr>
Subject: Re: newbie question about the sort function and hashes
Message-Id: <Pine.GSO.3.96.970611113327.18839K-100000@kelly.teleport.com>

On 11 Jun 1997, hakan keskin quoted me:

> :       chomp($name=<STDIN>);
> :       last unless defined $name;
>    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> I do not know why this line does not work..
> but  this works:
>         last unless ($name);

Ah, but you're doing something different. Your code is bad if the $name
might be 0.

If my code doesn't work, you're probably using an ancient version of Perl.
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: 11 Jun 1997 13:49:29 GMT
From: P Bal <parmjit.bal@gecm.com>
Subject: Re: Passwording (on UNIX)
Message-Id: <5nmad9$26f@gcsin3.geccs.gecm.com>

Try this:

system("stty -echo");
$input=<STDIN>;
system("stty echo");

Parmjit Bal



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

Date: Wed, 11 Jun 1997 13:51:34 -0400
From: Mike Roth <mroth@wgate.com>
Subject: Perl 5.004/Tk402.000 MainWindow
Message-Id: <339EE5A6.41C67EA6@wgate.com>

After having installed perl5.004/Tk402.000 on
FreeBsd I cannot run the demos (even the simplest).
I get an error  that is the following:

Use of inherited AUTOLOAD for non-method MainWindow::_Destroyed() is
deprecated at /usr/local/lib/perl5/Tk/MainWindow.pm line 27.
Use of uninitialized value at /usr/local/lib/perl5/Tk/MainWindow.pm line
27.
71048 () is not a hash at /usr/local/lib/perl5/Tk/MainWindow.pm line 27.
Abort (core dumped)

Did I miss something in the config process? 
Any help would be appreciated
Thanks in advance
Mike
mroth@wgate.com
-- 
+-------------------------------------------+
| Mike Roth	WorldGate Communcations	    |	
|                                           |
| Ph: (215) 633-5134	Fax: (215) 633-9590 |
|                                           |
|       3120 Tillman Drive, Suite 300       |
|            Bensalem, PA  19020            |
+-------------------------------------------+


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

Date: 11 Jun 1997 21:49:47 GMT
From: fox@pt0204.pto.ford.com (Ken Fox)
Subject: Re: Perl script as login shell?
Message-Id: <5nn6hr$o1g12@eccws1.dearborn.ford.com>

In article <5njuk1$l5f$1@joe.rice.edu>, gerdemb@rice.edu (Ben Neil Gerdemann) writes:
> We are writing a perl script that allows users to automatically create a
> login account for themselves by telneting to a certain account. We are of
> course concerned about this script's security.

Let me get this straight.  You want users to be able to automatically
issue themselves accounts, but you're also concerned about security.
I think we have different definitions of security... ;-)

> The only system we can think of, is turning the Perl script into the
> account's login shell. Is this possible using the new Perl compiler?

We've used scripts as login shells before.  The most popular one was
to start/restart xdm.  We're using Solaris, but I'm pretty sure that other
OS would allow it.  (Check if any accounts use /bin/true as the shell.
Usually /bin/true is a script.)

> Is this secure?

Perl has excellent support for writing secure programs.  I'd question
your basic approach more than I would Perl as the implementation language.

- Ken

-- 
Ken Fox (kfox@ford.com)                   | My opinions or statements do
                                          | not represent those of, nor are
Ford Motor Company, Powertrain            | endorsed by, Ford Motor Company.
Analytical Powertrain Methods Department  |
Software Development Section              | "Is this some sort of trick
                                          |  question or what?" -- Calvin


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

Date: Thu, 12 Jun 1997 00:02:59 +0200
From: Aldo Calpini <dada@divinf.it>
To: Randy Chou <randyc@csua.berkeley.edu>
Subject: Re: Perl script controlling MSDEV?
Message-Id: <339F2093.7FCCE5F9@divinf.it>

Randy Chou wrote:
> 
> Hi,
> 
> I'm new to perl/win32/ole so I apologize if this is a stupid
> question...But I understand that perl's OLE extensions
> allows perl scripts to send and control applications containing
> an OLE server (like Excel).  Is there anyway to control
> MSDEV (Visual C++ 4.2) through a perl script?  I can't
> seem to find a file describing MSDEV's OLE interfaces.
> Basically, I'd like to be able to write a perl script that
> will automatically bring up MSDEV, open a makefile,
> and compile or run dependencies.  Is this doable?

Hi Randy,
I think it would be much much easier (and faster) to have a Perl script
that simply does a system call to NMAKE...
However, if you find a documentation of the OLE interfaces for MSDEV,
please forward it to me! :-)

Bye,
Aldo Calpini
---/\-----------------------------------------------------------
--/  \--------------------------------- mailto:dada@divinf.it --
-<dada>-- POPULUS VULT DECIPI, -------- mailto:sis@divinf.it ---
--\  /------- ERGO DECIPIATUR --------- http://sis.divinf.it ---
---\/-----------------------------------------------------------


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

Date: Wed, 11 Jun 1997 13:15:11 -0600
From: bclark@auanet.org
Subject: Perl training in the D.C. metro area
Message-Id: <866052314.19245@dejanews.com>

I am looking for a perl class in the Washington, D.C. metro area.  I found
Learning Tree, but they cost over $2K for a 4 day course.  I am willing to
travel to learn.  Please help me learn Perl.  Thanks.

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


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

Date: 11 Jun 1997 14:08:44 GMT
From: quentin@remington.amd.com (Quentin Fennessy)
Subject: Re: Perl, TK, CGI
Message-Id: <5nmbhc$i4d$1@amdint2.amd.com>

In article <3392F4AE.2781E494@austx.tandem.com>,
David Rosen  <drosen@austx.tandem.com> wrote:
>OK folks, I need some help.  My problem is I have a logfile with
>percentages and times and want a graphical representation.  I was
>planning on using perl and Tk, but if there is a simple Java program I
>am more than willing to look at it too.  Are there any perl programs
>prewritten or maybe one I can modify for this task?

I have had excellent luck using gnuplot -- it will output graphs
in several formats.  It is not perl - but old-fashioned compiled C.



-- 
Quentin Fennessy			AMD, Austin Texas


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

Date: 11 Jun 1997 07:57:53 -0600
From: mfuhr@dimensional.com (Michael Fuhr)
Subject: Re: Premature end of script
Message-Id: <5nmat1$f1m@flatland.dimensional.com>

"DAVID GILMARTIN" <david@gilmartin.uk.com> writes:

[ script omitted ]

> but I get the follow message
>
> [Mon Jun  9 14:26:10 1997] access to
> /ftp/webs/gilmartin.uk.com/bulletinboardgilmartin/test03.cgi failed for
> powerproxy.powernet.co.uk, reason: Premature end of script headers
>
> i am sure it is simple

Since this appears to be a CGI problem, you're better off asking in
comp.infosystems.www.authoring.cgi.  But as long as you're here, check
out The Idiot's Guide to Solving Perl CGI Problems:

    http://www.perl.org/CPAN/doc/FAQs/cgi/idiots-guide.html

Hope this helps.

-- 
Michael Fuhr
http://www.dimensional.com/~mfuhr/


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

Date: 11 Jun 1997 23:11:47 GMT
From: deckers@man.ac.uk (A. Deckers)
Subject: Re: regexp question: greener than godzilla...
Message-Id: <slrn5puc5i.hoa.deckers@news.rediris.es>

In <01bc76b1$43728980$5ae004d0@kennyv>,
	Ken Van Allen <kennyv@montana.com> wrote:
>Hi all:
>	I've been racking my brains to find a regexp that will replace ALL
>instances of a given character in a line, and not just the first!  I know
>this must be relatively simple.  I've been through the FAQ, CPAN, and other
>resources, but can't seem to hit upon what I want.  I would appreciate any
>help...

#!/usr/bin/perl

#     1 2 3 4 5 6
$t = 'acacacacacac';
$n = ($t =~ s/a/b/g); # Use the /g option.
print "$n times!\n";

__END__

Output:

6 times!

Looks like you need to read the perlre manual page again.

HTH,

Alain

-- 
Perl information: <URL:http://www.perl.com/perl/>
    Perl archive: <URL:http://www.perl.com/CPAN/>
        Perl FAQ: <URL:http://www.perl.com/CPAN/doc/FAQs/FAQ/>
>>>>>>>>>>>>> NB: comp.lang.perl.misc is NOT a CGI group <<<<<<<<<<<<<<


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

Date: Wed, 11 Jun 1997 18:35:01 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Regular expression with double bytes
Message-Id: <EBMJMD.5Cn@nonexistent.com>

Martin Yan (mkyan@cse.cuhk.edu.hk) wrote on 1380 September 1993 in
<URL: news:5nlkqu$879@eng-ser1.erg.cuhk.edu.hk>:
++ Hello all,
++ 
++ 	I am trying write to a search engine with the capability to search 
++ a database blend with signle byte and double bytes characters(such as 
++ chinese).  But i found that some of the double bytes character are 
++ composed of some regular expression keywords, such as ^, %,........
++ 	Can someone show me the correct way to tackle this problem??


I was about to say: /\Qbytebytebytebytebytebyte\E/, but then,
what if there's a double char '\E' ? 

So:
my $tmp = quotemeta $string;
/$tmp/;


Abigail
-- 
perl5.004 -wMMath::BigInt -e'$^V=new Math::BigInt+qq;$^F$^W783$[$%9889$^F47$|88768$^W596577669$%$^W5$^F3364$[$^W$^F$|838747$[8889739$%$|$^F673$%$^W98$^F76777$=56;;$^U=$]*(q.25..($^W=@^V))=>do{print+chr$^V%$^U;$^V/=$^U}while$^V!=$^W'


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

Date: 10 Jun 1997 23:39:05 GMT
From: 4gbds@qlink.queensu.ca (Shoemaker Garth B D)
Subject: Sorting by key
Message-Id: <5nkoip$daq@knot.queensu.ca>

I have an associative array that has integers as keys and strings as
values. I want to order the strings in the descending order of the integer
values. I have found routines for sorting values and keys independantly,
and sorting by value, but I can't find anything to do what I want. (I
looked in the FAQs, nothing did what I need)

Any ideas?

Thanks.
	Garth Shoemaker


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

Date: Wed, 11 Jun 1997 19:47:48 -0400
From: TechMaster Pinyan <jefpin@bergen.org>
Subject: Sorting Numerically
Message-Id: <Pine.SGI.3.96.970611194547.18738B-100000@davinci.bergen.org>

I have a hash called %hitArray, and it has the format:
url	no. of hits
for some pages...

how do I sort it numerically?  i.e.:

foreach $file (sort keys %hitArray){
	do the stuff
}

How do I modify the "sort keys" part?

----------------
| "A bird in the hand leaves a nasty stain."
| 	- Me
----------------
Jeff "TechMaster" Pinyan | http://www.bergen.org/~jefpin
HTML/CGI Designer and Consultant and JavaScripter
jefpin@bergen.org | TechMasterJeff@juno.com | TechMasterJeff@usa.net
Got a JavaScript question or problem?  Let me know!



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

Date: 11 Jun 1997 21:14:02 GMT
From: tauzell@math.umn.edu (David Tauzell)
Subject: Tie Scalar ??
Message-Id: <5nn4eq$244@epx.cis.umn.edu>

I would like to create a tied scalar that can return an array if
used in array context.

e.g. @array = $tiedScalar,

In scalar context it just returns a scalar.
I tried implementing the FETCH function with something like:

  if (wantarray()) {
      return <some array>
  }
  else {
      return <some scalar>
  }

, but it always returns a scalar.

Any ideas?


--
---
David Tauzell.  I like unix.


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

Date: Wed, 11 Jun 1997 09:16:26 -0400
From: Gary Geniesse <turloughg@aol.com>
Subject: tie() not creating new database?
Message-Id: <339EA52A.418C@aol.com>

Hi misc perl'ers,

I am trying to use the tie() function to create (and ultimately
maintain) a database.  Unfortunately, I can't seem to get it to create
the file.

Here is what I am trying:

#!/usr/bin/perl
use AnyDBM_File;
tie(%DBDATA, DB_File, 'myDB', O_CREAT|O_RDWR) || die("$0: open myDB
($!)\n");
untie(%DBDATA);
exit;

And here is what I am getting (using perl 5.001 patch 1m on a RedHat
Linux system):
createdb.pl: open myDB (No such file or directory)

Could anybody tell me what I might be doing wrong?

* Even if I don't "die" here, no file appears to be created.
* I've tried numerous different filename/pathing names.
* I made sure I have read/write access to the directory.

* I've also tried creating a zero length file for it to use, yielding:
createdb.pl: open myDB (Invalid arguement)

* I've tried using NDBM_File instead, but it indicates:
Can't locate object method "TIEHASH" via package "NDBM_File" at
createdb.pl line 3.

Thanks, 
Gary Geniesse
turloughg@aol.com


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

Date: 11 Jun 1997 21:50:29 GMT
From: "Simon Kitching" <simonk@telebusiness.co.nz>
Subject: Very technical question - memory sharing & fork
Message-Id: <01bc76b1$a124be40$77e824ca@simonk>

This is a fairly technical question, probably answerable only by one of the
perl porters. Unfortunately, perl.porters-gw appears to be a moderated news
group (probably to deflect all those questions which should go to
perl.misc). 
If someone here can answer this, great! Otherwise, if anyone reading this
could move this to the perl porters group for me, or draw the correct
person's attention to it, I would appreciate it greatly.

I have a Perl program which initialises lots of large data structures on
startup.
The process then forks a child to handle client application requests (ie
standard client-server stuff) as required. I need to handle up to 500
client processes simultaneously, ie 500 copies of the program running plus
the original parent process.

It all works fine, but I am concerned by the lack of memory sharing between
the parent and child processes. The system was carefully designed so that
lots of "read-only" data structures were initialised in the parent process
- these pages should be shared by all the child processes. IE when the
child process is created, all these pages are marked "copy-on-write", but
the child never writes to these "read-only" pages, so the data page exists
only once no matter how many child processes exist.

Unfortunately, this data sharing does not seem to be happening. Each child
process should be about 3.5Mb, where 3.4Mb of that is shared with its
parent (and all siblings). Instead, each process shares much less with its
parent & siblings. When I start 500 processes, I should need about 50MB of
ram, but need (estimated) 0.5GB instead. Ouch!

My questions are:

1) Does the garbage collector write to each page, triggering the
"copy-on-write"?

2) Does Perl update the parse tree of the Perl files it loads? ie is there
"administration" information which gets updated in the data structures it
builds to hold its "executable code".

3) Is there any way of managing the way Perl allocates memory for its
variables? It would make sense to allocate all the scalars, lists and
hashes which are "read-only" from the child processes' point of view in one
set of memory pages, and all other variables in another set of memory
pages. I suspect that there may be small "holes" in between the "read-only"
data structures caused by temporary variables used by the initialisation
routines, and that the child instances are using these holes for their
temporary variables, thus dirtying many of the pages. Ideally, I could
"malloc" a (eg) 10 MB block and do all memory allocation from this block
during initialisation, then switch back to normal memory allocation. Child
processes would then never mix their variables in with the initialised
"read-only" variables.

Please note that using the Unix shared memory routines is NOT an option, as
most of the data I was hoping to share between parent & children is
allocated by modules such as DBD, DBI, libwww, etc. I have no control over
how they allocate (as far as I know... but perhaps (3) above might work).

I am using an RS6000 running AIX , and Perl 5.003_01

Of course, the proper solution for all this is to use multi-threading, but
I cannot wait for the next version of Perl + all the required modules to be
made thread-safe. *sigh*

Any information would be appreciated. Thanks in advance....


Notes on Unix fork() call:
When a process calls fork() in UNIX, an EXACT memory image is created for
the child process.
This means that the child process has a virtual-memory-to-real-memory
mapping table of its own, but that each virtual memory table entry points
to exactly the same physical page as the parent process's virtual memory
table does. There is an entry in this table for each "page" of memory used
by the process, where the size of a page is system-dependent, but usually
1kb. The system also sets a "copy on write" flag on each page of the
childs' virtual memory table (well, something like it..)
Because of this setup, as long as neither the parent process nor the child
process writes to the shared page, they both share the memory. When either
writes to any byte in a shared page, it is transparently duplicated, and
the writing process continues to run without noticing that it no longer
shares the page.
The overall effect is that each child process can behave as if it has its
own copy of all the parent process's data, but as long as it does not write
to a page, the OS doesn't need to allocate separate RAM.

All the above is standard UNIX, and should work no matter what language the
parent and child processes are written in. However, when I try to do this
in Perl, I don't get the amount of memory sharing that I expect. It looks
like Perl is writing to most/all of the data pages in each child process,
triggering the page duplication. Why, and what to do about it are the
questions I need answered..

-- 
-- Simon Kitching
simonk@telebusiness.co.nz


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

Date: Wed, 11 Jun 1997 10:02:06 -0400
From: Jim Michael <jim.michael@gecm.com>
Subject: Re: VISUAL BASIC 5
Message-Id: <339EAFDE.33A8@gecm.com>

roger adams wrote:
> 
> How do i include a perl script in a vb5 program under windows 95 with
> the perl interpreter
> 
> thank you

Look up the Shell command in your VB 5.0 manual.

Cheers,

Jim


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

Date: 11 Jun 1997 23:06:30 GMT
From: dalonso@u.washington.edu (Darwin O.V. Alonso)
Subject: while(<>){if(/cond/){while(<> ~= /cond2/) ...
Message-Id: <5nnb1m$g7u@nntp6.u.washington.edu>

My general goal is to match a start pattern (START) in a file, then
do something to all the lines until a stop pattern (STOP) is reached.
The following perl script does that (5.000).
However, the more concise construct commented out below, doesn't work.

#!/usr/local/bin/perl -w
open(IN,"infile");
while(<IN>){
  if ( /START/){ TB: { while( <IN> ){ (/STOP/) and last TB; print ;}}} #works
  #if ( /START/){ while( <IN> !~ /STOP/){ print $_; }}
}


I.E.:
The above prints: yes1\nyes2\n for "infile" (see below).
However if the comment is shifted to the first if statement,
it prints: START\nSTART\n for the infile. I.E. the $_ no longer
contains to the current line, but (/STOP/) compares to the current line.

Why? How can I make the second construct work? I can't use
"print if /START/ .. /STOP/"
due to the complexity of what I want to do before, after and between
these conditions.

Thanks,
Darwin

----  infile --------
no1
no2
START
yes1
yes2
STOP
no3
no4


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

Date: Wed, 11 Jun 1997 13:26:01 GMT
From: Dave.Cross@gb.swissbank.com (Dave Cross)
Subject: Re: write a new htmp page
Message-Id: <DAVE.CROSS.97Jun11142601@ln4d110swk.gb.swissbank.com>

In article <01bc736f$7d80fa20$74053cc3@mallordp60> "DAVID GILMARTIN" <surgery@powernet.co.uk> writes:

> i am new and you may think i am stupid
> 
> please give a bit of code to for a cgi file that creates a new page in the
> same directory.
> 
> i can write a page on the fly but it's not saved

David,

This should really be in a CGI group, not a perl group.

Try something along the lines of this:

open(HTML, 'file.html') || die;

print HTML '<HTML>\n<HEAD>\n<TITLE>\n";
 ...
(other lines that print the rest of your page)
 ...
print HTML '</HTML>';
close(HTML);

print "Location: file.html\n\n";


 ...or somthing like that.

Dave...
-- 
Opinions are mine, not the company's - hell I don't think the
company even knows who I am.

Dave.Cross@gb.swissbank.com


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

Date: 11 Jun 1997 14:15:14 +0200
From: Gisle Aas <aas@bergen.sn.no>
Subject: Re: Y2K Compliant?
Message-Id: <hn2oxe3ot.fsf@bergen.sn.no>

mike@stok.co.uk (Mike Stok) writes:

> Given that one of the things that attraced me to perl was that it was a
> scripting language which gave me reasonably transparent access to system
> calls which were implemented in the C library then I think that the C
> library does have a lot to do with perl.

But you don't mind that most calls return TRUE when the C library
function would return FALSE :-)

> If the unix designers had been really awkward they could have stored year
> - 1970 in the tm structure...

This would in fact have been better. Adding 1970 is just as easy as
adding 1900.  Nobody would then confuse it with year%100.

> Getting back to the year 2K, I am working on a project where they want 2
> character year fields for dates in the system regardless of the
> implemetation language's capabilities, so even in 1997 it would seem that
> the year 2000 is still a long way off :-(

Can't you convince them to treat these 2 characters as a 16-bit value
then?

-- 
Gisle Aas <aas@sn.no>


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

Date: 11 Jun 1997 08:37:42 GMT
From: junkmail@sysa.abdn.ac.uk (Kyzer)
Subject: Re: Y2K Compliant?
Message-Id: <5nlo4m$qf5@info.abdn.ac.uk>

>From the lips of Darin Morgan sprang:
: Please don't flame me.  I do not use perl but have been asked by my
: employer to find out if Perl4 and Perl5 are Year 2000 compliant?

You can tell him 'yes, they are' :)

--
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!

-- 
Random sig of the day:
$a=0;foreach(`df -k`){$a+=(split/\s+/)[1];}printf"%.2fMB mounted\n",$a/1024;


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

Date: 11 Jun 1997 17:19:00 +0300
From: Jarkko Hietaniemi <jhi@alpha.hut.fi>
Subject: Re: Y2K Compliant?
Message-Id: <oeehgf5ql2j.fsf@alpha.hut.fi>


: I disagree.  Perl did not have to do it like this just because the C
: library did.  But, there is not much to do about it now.  I have not
: had too much problem getting used to always adding 1900 to localtime's
: year.  I just think it is silly.

I must disagree.  If we are talking localtime() (or gmtime()) here,
we cannot change the standard, now can we?

Obeying the standards and thus nicely co-operating with all the other
application that obey the standards one can, well, enjoy the very idea
of standards.

It is completely different thing to define user-friendly interfaces
that are easy to understand.

If I had been there we would have full years in tm_year, not
"% something" or "- something else".  But that would not stop stupid
people using four digit fields and being sorry in 8003 years :-)

-- 
$jhi++; # http://www.iki.fi/~jhi/
        # There is this special biologist word we use for 'stable'.
        # It is 'dead'. -- Jack Cohen


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

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

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