[10155] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3748 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Sep 18 08:07:22 1998

Date: Fri, 18 Sep 98 05:00:44 -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, 18 Sep 1998     Volume: 8 Number: 3748

Today's topics:
        ** Can I use 'split' here ? ** <r19610@email.sps.mot.com>
    Re: ** Can I use 'split' here ? ** <Tony.Curtis+usenet@vcpc.univie.ac.at>
    Re: ** Can I use 'split' here ? ** (Michael Fuhr)
    Re: ** Can I use 'split' here ? ** <tom@smart.ruhr.de>
    Re: ** Can I use 'split' here ? ** (Dermot McKay)
    Re: .htpasswd generation on NT (Roland Schneider)
    Re: Can I run Perl program regularly? <postmaster@localhost.net>
    Re: Can I run Perl program regularly? dave@mag-sol.com
        CPAN / LWP error - please help. <pgregg@blackhole.nyx.net>
    Re: Finding strings from one file in another <hessler@NOSPAMcns.mpg.de>
        forking problem, isp may terminate my account dwiesel@my-dejanews.com
    Re: How to "execute" a CGI (Perl) script inside a HTML  jzobel@my-dejanews.com
        I need a script writen, can someone help me please (Gareth Hall)
    Re: leading  space <aqumsieh@tigre.matrox.com>
    Re: making number a decimal (Mike Stok)
    Re: more regex/pattern substitution jzobel@my-dejanews.com
    Re: MS Access Module? jzobel@my-dejanews.com
    Re: Perl & Java - differences and uses  <arb@connect.com.au>
    Re: Perl & Java - differences and uses <zenin@bawdycaste.org>
    Re: Perl & Java - differences and uses <zenin@bawdycaste.org>
    Re: Perl & Java - differences and uses <zenin@bawdycaste.org>
    Re: perl compiler <sbarbera@usa.net>
    Re: Perl implementation question <hessler@NOSPAMcns.mpg.de>
    Re: Regular Expressions for Reading Data <tom@smart.ruhr.de>
        Runtime evaluation of required modules <amarden@ibm.net>
    Re: Searching a File for String <aqumsieh@tigre.matrox.com>
    Re: win32:ODBC/Oracle->terrible perormance joachim.zobel@syseca.de
        Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)

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

Date: Fri, 18 Sep 1998 18:17:21 +0800
From: Dayang Lily <r19610@email.sps.mot.com>
Subject: ** Can I use 'split' here ? **
Message-Id: <36023331.B4696981@email.sps.mot.com>

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

Hi,

Here's the scenario:

I have defined :
$MY_DIR = "/usr/home"

And I have a variable $TheFile = "/usr/home/new_file".

How can I extract the filename, new_file from $TheFile? I tried to with :
split(/$MY_DIR/,$TheFile) but failed.
Any help is greatly appreciated.

Thanks.

Regards,
Lily.

--------------6746461E765B53E85D4AF155
Content-Type: text/x-vcard; charset=us-ascii; name="vcard.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: Card for Dayang Lily
Content-Disposition: attachment; filename="vcard.vcf"

begin:          vcard
fn:             Dayang Lily
n:              Lily;Dayang
org:            Motorola Malaysia Sdn Bhd
email;internet: r19610@email.sps.mot.com
title:          Test Development Engineer
tel;work:       6037734523
x-mozilla-cpt:  ;-11312
x-mozilla-html: FALSE
version:        2.1
end:            vcard


--------------6746461E765B53E85D4AF155--



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

Date: 18 Sep 1998 13:13:29 +0200
From: Tony Curtis <Tony.Curtis+usenet@vcpc.univie.ac.at>
Subject: Re: ** Can I use 'split' here ? **
Message-Id: <8367elptba.fsf@vcpc.univie.ac.at>

Re: ** Can I use 'split' here ? **, Dayang
<r19610@email.sps.mot.com> said:

Dayang> I have defined : $MY_DIR = "/usr/home"

Dayang> And I have a variable $TheFile =
Dayang> "/usr/home/new_file".

Dayang> How can I extract the filename, new_file from
Dayang> $TheFile?

use File::Basename;

hth
tony

PS I'd get rid of the vcard stuff, it just clutters up
usenet postings (like HTML does).

-- 
Tony Curtis, Systems Manager, VCPC,    | Tel +43 1 310 93 96 - 12; Fax - 13
Liechtensteinstrasse 22, A-1090 Wien,  | <URI:http://www.vcpc.univie.ac.at/>
"You see? You see? Your stupid minds!  | private email:
    Stupid! Stupid!" ~ Eros, Plan9 fOS.| <URI:mailto:tony_curtis32@hotmail.com>


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

Date: Fri, 18 Sep 1998 11:17:10 GMT
From: mfuhr@dimensional.com (Michael Fuhr)
Subject: Re: ** Can I use 'split' here ? **
Message-Id: <6ttfff$kv0@flatland.dimensional.com>

Dayang Lily <r19610@email.sps.mot.com> writes:

> Here's the scenario:
>
> I have defined :
> $MY_DIR = "/usr/home"
>
> And I have a variable $TheFile = "/usr/home/new_file".
>
> How can I extract the filename, new_file from $TheFile? I tried to with :
> split(/$MY_DIR/,$TheFile) but failed.

Here's a generic way to get the filename, whatever the directory is:

    use File::Basename;
    $filename = basename($TheFile);

-- 
Michael Fuhr
http://www.fuhr.net/~mfuhr/


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

Date: 18 Sep 1998 13:28:54 +0200
From: Thomas Neumann <tom@smart.ruhr.de>
Subject: Re: ** Can I use 'split' here ? **
Message-Id: <87zpbx64nd.fsf@smart.ruhr.de>

Dayang Lily <r19610@email.sps.mot.com> writes:

> Here's the scenario:
> 
> I have defined :
> $MY_DIR = "/usr/home"
> 
> And I have a variable $TheFile = "/usr/home/new_file".
> 
> How can I extract the filename, new_file from $TheFile? I tried to with :
> split(/$MY_DIR/,$TheFile) but failed.

my $filename = (split /\//, "/usr/home/new_file")[-1];


-t



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

Date: Fri, 18 Sep 1998 11:23:20 GMT
From: MCKAYD@aplbt1.agw.bt.co.uk (Dermot McKay)
Subject: Re: ** Can I use 'split' here ? **
Message-Id: <6ttg6l$hn0$1@pheidippides.axion.bt.co.uk>

In article <36023331.B4696981@email.sps.mot.com>, r19610@email.mot.com wrote:
>This is a multi-part message in MIME format.
>--------------6746461E765B53E85D4AF155
>Content-Type: text/plain; charset=us-ascii
>Content-Transfer-Encoding: 7bit
>
>Hi,
>
>Here's the scenario:
>
>I have defined :
>$MY_DIR = "/usr/home"
>
>And I have a variable $TheFile = "/usr/home/new_file".
>
>How can I extract the filename, new_file from $TheFile? I tried to with :
>split(/$MY_DIR/,$TheFile) but failed.
>Any help is greatly appreciated.
>
Try this ok

$MY_DIR = "/usr/home/";
$TheFile = "/usr/home/new_file";
($empty,$filename)=(split/$MY_DIR/,$TheFile);
print "$filename";

it will return the filename you require.

OK Dermot




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

Date: Fri, 18 Sep 1998 10:35:30 GMT
From: rs@9809.fish.ch (Roland Schneider)
Subject: Re: .htpasswd generation on NT
Message-Id: <360236a3.3662195@news.lan>


Thats an apache/nt-question (if its that you are using)
Dont encrypt the passwords, just stored them in clear-text.

Roland


Simon Wistow <simon@targeting.co.uk> wrote in comp.lang.perl.misc:

>I've written a script (based on one by David Levy) that will generate
>'.htpasswd's for me. It's being run from the command line with
>Activestate Perl (build 502, August 11) on NT4SP3. Howvere it doesn't
>seem to work
>The script I copied it from was
>http://world.inch.com/Scripts/htpasswd.pl.html
>and my version below doesn't produce the same answer as their CGI
>version at.
>http://www.inch.com/info/tech/HOWTOS/htaccess/htpasswd.html
>Any ideas?
>
><code>
> #!/usr/bin/perl
> ($user,$passwd)  =3D split (/:/,$ARGV[0],2);
> srand($$|time);
> @saltchars=3D(a..z,A..Z,0..9,'.','/');
> $salt=3D$saltchars[int(rand($#saltchars+1))];
> $salt.=3D$saltchars[int(rand($#saltchars+1))];
> $passwdcrypt =3D crypt($passwd,$salt);
>  print "\n\n$user\:$passwdcrypt";
>  exit 1;
>
></code>



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

Date: 18 Sep 1998 12:56:54 +0400
From: Sergei S. Laskavy <postmaster@localhost.net>
Subject: Re: Can I run Perl program regularly?
Message-Id: <nqg1dpg5nt.fsf@Peru.Gambit.Msk.SU>

"Paul Marsh" <pjm@hplb.hpl.hp.com> writes:

> If your using windows nt use the AT command,

> D wrote in message <358ecba4.0@rapeme.kirov.ru>...

> >How can I make a program that can run my Perl program regularly
> >(daily)?

UNIX: man crontab

-- 
FreeBSD Project: http://FreeBSD.org/docproj/    Vim: http://www.vim.org/
$_='$6C86:P$^P|2D<2GJPl=2D<2GJp82>3:E^>D<^DFn';tr#P-~\x20-O#\x20-~#;print


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

Date: Fri, 18 Sep 1998 11:02:06 GMT
From: dave@mag-sol.com
Subject: Re: Can I run Perl program regularly?
Message-Id: <6tteje$dig$1@nnrp1.dejanews.com>

 ...and if you're using any kind of Unix, you can do this using cron. Type 'man
crontab' for details.

Dave...

In article <EzH0HE.8GC@hplb.hpl.hp.com>,
  "Paul Marsh" <pjm@hplb.hpl.hp.com> wrote:

> If your using windows nt use the AT command,
>
> D wrote in message <358ecba4.0@rapeme.kirov.ru>...
> >
> >How can I make a program that can run my Perl program regularly (daily)?

--
dave@mag-sol.com
London Perl M[ou]ngers: <http://www.mag-sol.com/London.pm/>

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum


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

Date: Fri, 18 Sep 1998 10:17:09 GMT
From: Paul Gregg <pgregg@blackhole.nyx.net>
Subject: CPAN / LWP error - please help.
Message-Id: <906117404.726026@sparc.tibus.net>

I installed the libwww-perl (LWP) package a little while ago for a project and
it appeared to install ok and my project works fine.  However now when I
go into the cpan shell I can't download any more modules - see:

cpan shell -- CPAN exploration and modules installation (v1.40)
ReadLine support enabled
 
cpan> i /Authen/ 
Fetching with LWP:
  ftp://ftp.cis.ufl.edu/pub/perl/CPAN/authors/01mailrc.txt.gz
Can't call method "mirror" without a package or object reference at /usr/local/lib/perl5/CPAN.pm line 1810.
 

Prior to installing LWP, cpan used Net::Ftp which worked fine.  Cpan shell
won't unistall LWP either.

Can anyone help?

Tia,

Paul.
-- 
Email pgregg at tibus.net | Email pgregg at nyx.net    | Eight out of every
Technical Director        | System Administrator       | five people are math
The Internet Business Ltd | Nyx Public Access Internet | illiterates.
http://www.tibus.net      | http://www.nyx.net         |             - Anon.


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

Date: Fri, 18 Sep 1998 11:57:02 +0200
From: Sven Hessler <hessler@NOSPAMcns.mpg.de>
To: EricGoforth@csi.com
Subject: Re: Finding strings from one file in another
Message-Id: <36022E6D.9B6E5BA6@NOSPAMcns.mpg.de>

Eric Goforth wrote:

> Here's the code that I've written
>
> #!/usr/bin/perl
>
> # Perl program to print the contents of the include file.
>
> open (SEARCH_FILE, "search.lst");  #filehandle is SEARCH_FILE
>
> while ($search_line = <SEARCH_FILE>)
> # while (<STDIN>)  # Changed to redirect input
> {
>
> #   print "Search string is $search_line";
>    $search_string = $search_line;

>    $ucase_search_string = "\U$search_line\E";
>    $lcase_search_string = "\L$search_line\E";

You do not need this. Use /search_string/i instead of this. This means,
that the search will be case insensitive.

>    print "Search string is $search_string\n";
>    open (INCLUDE_FILE, "INCLUDE.INC");  #filehandle is INCLUDE_FILE
>
>    while ($line_to_search = <INCLUDE_FILE>)
>    {
>       print if /$search_string/;
>       print if /$ucase_search_string/;
>       print if /$lcase_search_string/;
>    }

Either you write:

print if $line_to_search =~ /$search_string/i;

or you change the while loop:

while (<INCLUDE_FILE>) {
     print if /$search_string/i;
}

Your example could not work because you read the content of the line

into the variable $line_to_search, the variable $_ is unset in this case.

This code should work:

#!/usr/bin/perl

open (SEARCH_FILE, "search.lst") || die "can't open search file $!";

while ($search_string = <SEARCH_FILE>) {

   open (INCLUDE_FILE, "INCLUDE.INC") || die "can't open include file $!";

   while (<INCLUDE_FILE>) {

      print if /$search_string/i;

   }

   close INCLUDE_FILE;

}

close SEARCH_FILE;

That's all.

Sven

--

Please remove NOSPAM from E-Mail address, when reply.





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

Date: Fri, 18 Sep 1998 09:13:16 GMT
From: dwiesel@my-dejanews.com
Subject: forking problem, isp may terminate my account
Message-Id: <6tt87b$7ms$1@nnrp1.dejanews.com>

Hi,

I've built a program that compares other companies prices on certain products.

Yesterday I got this letter from my ISP:

--snip--
Your script sometimes goes into a mode where it forks about 50 processes
that are about 4 MB each, taking up about 200 MB of RAM.

This caused the machine to crash.

Due to the problem of your script crashing the server multiple times we
have several other customers considering leaving us.

Unless you are able to identify the bug in your program without running it
further (we are beyond the point of crashing the machine for the sake of
figuring out what problem your script has) we cannot allow you to run it.
--snip--

I got very surprised because

1. I could not understand why the main program takes 4 MB of RAM.

2. I could not understand why every child also takes 4 MB of RAM.

The main search program is pretty small and the only thing the childs are
doing is to fetch a webpage from an url and extract a price from it.

After thinking of it for a while I realised that every fork inharites from
its parent. That's not what I want. How can I do a fork that doesn't
inharites from its parent (just like an ordinary sub)?

Well, since my ISP says that I can't even test my program anymore and because
there migth be some other problem with it, the only solution for me is to
post part of the code here and hope that you might see some problems with it
(and if you've got the time maby point me in the right direction on solving
it/them).

So here we go:


THE LOGIC
=========

Do a search in database for the keywords that the user has entered.

For each search result

	print on screen

	fork

		for each company that I wan't to compare prices at

			fork

				fetch that compays webpage

				extract price

				save on file

		wait for all childs to finish

	print cheepest price

wait for all childs to finish

print "everything is done"


THE CODE (i have omitted some error checking...)
========

#!/usr/local/bin/perl

print "Content-Type: text/html\n\n";

use CGI;
CGI->nph(1);

require "main.config"; # just some variables
require "main.sub";    # nothing particulary

$| = 1;

$query = new CGI;

$query->import_names('R');

if ($query->referer() =~ /http:\/\/www.bokfynd.nu\//)
{
	use Mysql;

	&connectToDatabase;      # own short method (in main.sub)

	require "search.config"; # just som variables

	use LWP::UserAgent;
	$ua = new LWP::UserAgent;
	$ua->agent("search agent by $myname");
	$ua->timeout(15);

	# Fist search my own database for matching products, store in @products
	# code not included

	$waitedpid = 0;
	sub REAPER
	{
		$waitedpid = wait;
		$SIG{CHLD} = \&REAPER;
	}
	$SIG{CHLD} = \&REAPER;

	# For each product
	foreach $product_id (@products)
	{
		$pid = fork;

		# Parent
		if ($pid)
		{ print "<B>Product id: $product_id</B><BR>"; }

		else
		{
			# Child
			if (defined $pid) {

				# Create a filemane for this product id
				$price_file = $product_id.".price";

				if (open (FILE, ">>$price_file"))
				{
					flock(FILE, 2);
				}

				# Do a query on my mySQL database
				# Code not included

				if ($sth)				{    
				  while (($company_id, $company_searchurl_1,
$company_searchurl_2, $company_regexp) = $sth->FetchRow())		     
	       {					       $pid = fork;

						# Parent
						if (!$pid) {}

						else {

							# Child
							if (defined $pid) {

								my $req = new
HTTP::Request GET => $company_searchurl_1 . $product_id .$company_searchurl_2;

								my $res =
$ua->request($req);

								if
($res->is_success)
								{
									#
Extract price

$res->content =~ /$company_regexp/g;
									$price =
$1;

									print
FILE "${price}|${company_id}\n";
							}

							# Failure
							else {
								print "Fork by
$$ failed\n";
							}
							exit 0;
						}
					}

					wait;

					close FILE;

					if (open(F, "<$price_file"))
					{

						flock(F, 1);

						while ($string = <F>)
						{
							chomp $string;

							($price, $company_id) =
split(/\|/, $string, 2);

							# Store the price in a
hash
							# Code not included
						}

						close F;

						# Compare prices and print the
cheepest.
						# Code not included
					}

				}
				else
				{
					print "error: $Mysql::db_errstr<BR>";
				}

			}
			# Failure
			else
			{
				print "Fork by $$ failed\n";
			}
			exit 0;
		}
	}

	wait;
}

print "Everything is done";

-----------END OF CODE-------------

Thank you

// Daniel

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum


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

Date: Fri, 18 Sep 1998 11:10:57 GMT
From: jzobel@my-dejanews.com
Subject: Re: How to "execute" a CGI (Perl) script inside a HTML page.
Message-Id: <6ttf40$e33$1@nnrp1.dejanews.com>

In article <3601586A.9C187ED3@cisco.com>,
  Jian Zhang <jian@cisco.com> wrote:
> I need to "execute" a short perl CGI script inside a HTML page
> automatically when a page is loaded.

Look for embedded perl / eperl.

--
Also the from header has a valid email adress
replies to user@kud.com where user = jzobel
are pref

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum


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

Date: Fri, 18 Sep 1998 10:40:15 GMT
From: guruchoc@bigpond.com (Gareth Hall)
Subject: I need a script writen, can someone help me please
Message-Id: <360237ba.9502483@news.bigpond.com>

Can somone write a script for me. Anyone who is fimiliar with MAME
would have an advantage. I need a script that will generate a table
for my web page from mame -listfull -noclones, it will have to be able
to have the number of columns inputted at the command line, also the
url where the .zip files can be downloaded from. i have one allready,
but it only worls from the mamelist.txt file and this isn't really
good for my purpose. I can send anyone more info if they want it.

Thank for the help in advance.
Answers by email please.


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

Date: 17 Sep 1998 10:42:59 -0400
From: Ala Qumsieh <aqumsieh@tigre.matrox.com>
Subject: Re: leading  space
Message-Id: <x3ylnniby18.fsf@tigre.matrox.com>


Eric Wong <egwong@netcom.com> writes:

> A quick fix is to run the array through a foreach loop and
> just remove the leading space before you print it out again:
>   foreach (@array) { s/\s+//; }
> 

This removes ALL spaces!!! the regexp should be s/^\s+//;

But, if you really have to do that then use map .. it's faster:

map s/^\s+//, @array;

-- 
Ala Qumsieh             |  No .. not Just Another
ASIC Design Engineer    |  Perl Hacker!!!!!
Matrox Graphics Inc.    |
Montreal, Quebec        |  (Not yet!)


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

Date: 18 Sep 1998 11:50:15 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: making number a decimal
Message-Id: <6tthdn$1su@news-central.tiac.net>

In article <6trg3f$b49$1@nnrp1.dejanews.com>,  <splonka@my-dejanews.com> wrote:
>I'm stuck trying to get my number to print out in decimal format, like dollar
>amounts.
>
>see the output of http://www.plonka.com/phentex/products.html
>
>I'm using
>
>$sub =~ s/(\d+)\.*(\d*)/$1\.$2/;
>
>but its not quite right. Can anybody help??

You might want to use sprintf to format your data for you.  Section 4 of
the frequently asked questions deals with things like this, on recent perl
installations

  perldoc perlfaq4

should get it for you (failing that visiting http://www.perl.com and
following the FAQs links might work.)

printf & sprintf are documented in the perlfunc man page - try

  perldoc -f sprintf

to see it.  The format string will be familiar to you if you have any C
experience, otherwise you might need to experiment with some of the code
fragments from the FAQ.

Hope this helps,

Mike

-- 
mike@stok.co.uk                    |           The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/       |   PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/    |                   65 F3 3F 1D 27 22 B7 41
stok@colltech.com                  |            Collective Technologies (work)


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

Date: Fri, 18 Sep 1998 11:03:35 GMT
From: jzobel@my-dejanews.com
Subject: Re: more regex/pattern substitution
Message-Id: <6ttem7$dit$1@nnrp1.dejanews.com>

In article <36013091.76032E4C@qmw.ac.uk>,
[Problem: Replacing abbreviations with ones using standardized case]
> Why not something like:
>
> @abbrevs = ("PhD", "BBC", "EdD", BSc");
> foreach $abbrev @abbrevs { s/$abbrev/$abbrev/ig; }
>
> Unfortunately, this requires the regexp to be interpreted each time.
>

This can be avoided by

$all_abbrevs = join('|',@abbrevs);

$document =~ s/($all_abbrevs)/$1/ig;

Joachim

--
Also the from header has a valid email adress
replies to user@kud.com where user = jzobel
are pref

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum


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

Date: Fri, 18 Sep 1998 11:22:47 GMT
From: jzobel@my-dejanews.com
Subject: Re: MS Access Module?
Message-Id: <6ttfq6$eke$1@nnrp1.dejanews.com>

In article <6tshoo$sf9$1@mercury.wright.edu>,
  s002mdh@news.wright.edu (MICHAEL HOLLAND) wrote:
> Does anyone know of a module for the manipulation of an MS Access Database?

Perl for Win32 has an ODBC-Module.

Joachim

--
Also the from header has a valid email adress
replies to user@kud.com where user = jzobel
are pref

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum


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

Date: Fri, 18 Sep 1998 09:36:41 GMT
From: Anthony Baxter <arb@connect.com.au>
Subject: Re: Perl & Java - differences and uses 
Message-Id: <199809180936.TAA27522@koro.off.connect.com.au>


I believe that we can safely propose a modification of Godwin's Law
(about threads being dead when a reference to Hitler or Nazis occurs)
for comp.lang.python. 

Any time a thread crossposted from comp.lang.perl.* mentions "whitespace
is bad" the thread should be considered over.

A more general modification might say that any thread crossposted to 
comp.lang.perl.misc should be considered over immediately.

I do believe it's time to crank up some filters.

Anthony


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

Date: 18 Sep 1998 10:32:14 GMT
From: Zenin <zenin@bawdycaste.org>
Subject: Re: Perl & Java - differences and uses
Message-Id: <906114693.419028@thrush.omix.com>

bjohnsto_usa_net@my-dejanews.com wrote:
: In article <905807943.326889@thrush.omix.com>,
:   Zenin <zenin@bawdycaste.org> wrote:
	>snip<
: HTTP would be slower than the current systems for a small number of
: connections with high volume.

	Which is why no one does it in the core.

: However a protocol in which clients occasionally established a TCP/IP
: connection only when they needed it would not cause the TCP/IP stack to hog
: as much resources on the server as a protocol which kept the connections up
: all the time.  The resources that a DB needed for a connection could drop to
: a some kind of session id, current database, and current user name.

	Aka, an application server.

: Remembering that clients are connecting to the web/application server with the
: same HTTP protocol a connection directly to the database with HTTP should not
: severly impact performance.

	The application level wire protocol isn't an issue, HTTP or
	otherwise.

: I would propose the low overhead connection as an alternative, not the only
: means of access.

	Agreed.

: >         It depends.  Most generic application servers do far, far more
: >         then simply add a buffer to database calls.
:
: They add a massive memory and speed overhead,

	Funny, mine (in Perl) run in under 10 Megs and handle 5k
	clients with typical requests.

: a boatload of dependancies to lock customers in, a mountain of bugs
: and idiosyncrasies.
: The one I use also has an text editor from the the dark ages, a GUI SQL
: generator which can not do subselects, self joins or retrieve result sets from
: Oracle PL/SQL functions which return cursors.
: Still its complexity help ensure that I can pay my bills I should not whine.

	This sounds like you're simply running shit software.  This isn't a
	problem with application servers as a design, just your judgement
	for picking this software.

	>snip<
: Systems based on application servers I have used perform better than a well
: designed product based on cheap, well understood, industry standard products.
: Actually they perform much worse.

	Huh?  Are you not contradicting yourself here?

	>snip<
: I have never had any difficulty evolving into being able to manage NT servers,
: using only 1% of my time.
: I feel that unix would require me to take a big leap.  This leap may be worth
: it.  But the evolution into being NT literate was quite painless.

	It's an issue of what you want the system to do and how well.  Sure,
	if everything you're looking for is just a click away you're best
	bet is NT.  If you're like most of the rest of the planet however,
	you'll likely have custom needs that require going beyond the pretty
	buttons, at which point NT becomes much, much harder to work with
	not to mention that many times what you really want is simply not
	possible.

: On an unrelated subject I thought I might have found a use for select and
: could not get it to work.
	>snip<
:     $rin = $win = $ein = "";
:     vec($rin, fileno(STDIN), 1) = 1;
:     vec($win, fileno(STDOUT), 1) = 1;
:     $ein = $rin | $win;
:     ($nfound, $timeleft) = select($rout = $rin, $wout=$win, $eout=$ein, 0);
:     print ("Found $nfound, Timeleft $timeleft\n\n");
: prints - Found -1, Timeleft 0
: Any Clues?

	$ perl foo.pl
	Found 1, Timeleft 0
	$ perl foo.pl < /dev/null
	Found 3, Timeleft 0

: For what is worth I think what separate the good from the great is being able
: to really understand the problem and see simple solutions.  Low level
: understanding it only one building block to help see what is and what is not
: a solution. The precise qualities that separate the good from the great will
: change all the time.

	Good points.

: Java and Perl's greatness as languages would have been for nought if it were
: not for the internet creating new niches for mobile secure code and server
: based text processing.

	Perl go into WebWeek et al as a language for CGI, however it may
	supprise you that most perl code has never seen a web site.  Perl
	had a good life before the Web.

: Perl is quite capable as a scripting language, but its explosive growth does
: not come from this alone.

	Right.  It's explosive growth IMHO has had more to do with Perl's
	ability to jump between powerful one liners and small admin scripts,
	to large scale application fairly easily, and without the user
	needing to learn all of one of these worlds to do work in the other.

	In short, it bridged the gap between mear glue languages such as
	the shells and tcl, and application languages such as C.  Yes, yes,
	Python and a couple others did this as well, but with different
	goals.

	While Python wants to live completely on its own (for better or
	worse) both syntax and functionality wise (its closest relative
	is ABC), Perl maintains links to both the scripting/h world and
	the application world with both syntax and functionality.  Java
	followed a similar route, but since it never wanted to be used
	for ad-hoc scripting it only need to maintain links to the main
	application languages of the would, most all based in C syntax,
	for good or bad.

	I guess a better question is where the user is comming from, and
	what ties they want to keep.  If they have been using C and C like
	languages, they likely have also been using shells or tcl for the
	lighter glue work.  Jumping into Perl for such a user would
	arguably be nearly transparent (glue sed with C and you've got the
	bulk of Perl), as was the case for me and many people I've led to
	Perl (yes, even the "line noise" made perfect sense to use at first
	site without needing to look nearly anything up).  Such a user
	would also likely still keep C and the shells in there tool box
	for a number of reasons.  Because of this, keeping the same family
	of syntaxes helps a lot when jumping between languages a lot and
	trying to maintain code in all of them at once.

	Now, if the user wasn't already familiar and comfortable with C
	style languages or the shells, Python would arguably be easier
	to pick up from scratch then Perl.  If the user wasn't going to
	need to use C style languages (C, Java et al) or the shells and
	Unix tools (sed, awk, etc) then there would be little reason to
	shy away from Python for language jumping argument.

	I personally think these are much better issues to look at then
	the simply inflammatory "such as such language isn't maintainable"
	crap.  Of course Perl and C are maintainable "in the large", or I
	and many others wouldn't have a job.  I'll tell ya, I've had far
	more problems with archaic systems like raw RCS when working with
	many programmers on the same project then I've ever had with any
	language (I try to push everyone to CVS now BTW), and don't even
	get me started about makefiles.

	So what if only experienced <insert language> programmers can
	maintain <insert language> code with ease.  Anyone that picked
	Joe Programmer with zero <insert language> experience to work
	on a project writen in <insert language> that was large enough
	to be an example of "programming in the large", should be fired
	plain and simple.  How anyone can think that a language should
	allow any random monkey to sit down and write applications in it
	without looking at the manual is beyond me.
-- 
-Zenin (zenin@archive.rhps.org)           From The Blue Camel we learn:
BSD:  A psychoactive drug, popular in the 80s, probably developed at UC
Berkeley or thereabouts.  Similar in many ways to the prescription-only
medication called "System V", but infinitely more useful. (Or, at least,
more fun.)  The full chemical name is "Berkeley Standard Distribution".


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

Date: 18 Sep 1998 11:23:22 GMT
From: Zenin <zenin@bawdycaste.org>
Subject: Re: Perl & Java - differences and uses
Message-Id: <906117760.2620@thrush.omix.com>

Mike Meyer <bouncenews@contessa.phone.net> wrote:
: In <906047183.589733@thrush.omix.com>, Zenin <zenin@bawdycaste.org> wrote:
: > Garrett G. Hodgson <garry@sage.att.com> wrote:
: > : the "magic whitespace" rant is getting tiresome.
: > 	Maybe, but it's also quite valid.
	>snip<
: About as valid as flaming about Perl using special characters to
: determina a variables type. The only other language I know of that
: uses that silly trick is BASIC.

	Which BASIC?  The ones I've used haven't done this.

	In any event, when "programming in the large" many, many
	places will build the same system anyway for C, Java, Python,
	etc.  Common prefixes like 'L_' for a long double, etc.
	Yes, this is very lame, but even lamer is the language that
	makes this a requirement for the maintainability of large
	amounts of code.

: BLISS uses magic characters to determine the kind of access, but
: that's difference. Add in all the other magic characters and
: operators,

	Other?  This isn't a magic issue, and neither are Perl
	operators unless you've overloaded them.

: and Perl takes a silver (behind TECO) in the executable line noise
: category.

	<weak flame bait ignored>

	>snip<
: Harping on a
: syntactc feature you dislike about a language is at best a waste of
: time. Better to ignore it, and concentrate on the real features of the
: language, to better understand them and incorporate them into a
: language you like.

	Agreed, in part.  Languages change to meet the needs and wishes
	of there users.  Without debate over such issues language implementors
	wouldn't have any information to make decisions on, and Python
	would never have existed.

-- 
-Zenin (zenin@archive.rhps.org)           From The Blue Camel we learn:
BSD:  A psychoactive drug, popular in the 80s, probably developed at UC
Berkeley or thereabouts.  Similar in many ways to the prescription-only
medication called "System V", but infinitely more useful. (Or, at least,
more fun.)  The full chemical name is "Berkeley Standard Distribution".


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

Date: 18 Sep 1998 11:32:38 GMT
From: Zenin <zenin@bawdycaste.org>
Subject: Re: Perl & Java - differences and uses
Message-Id: <906118316.600024@thrush.omix.com>

Garrett G. Hodgson <garry@sage.att.com> wrote:
	>snip<
: indeed, that might be convenient, but this is an editor design,
: not language syntax, issue.

	A language can be hard to work with for many reasons.  Lack of
	support from the common editors can most defiantly be one of them.

	Imagine coding <insert nearly any language> without auto-indent for
	instance.

	>snip<
: besides, from a freedom standpoint, the requirement that i inform
: the interpreter of the type of each variable reference seems far more
: intrusive.  i guess we all choose our own shackles.

	$foo and @foo are two different variables.  Therefore, simply
	think of it as:

		function (\VARNAME);

	Since $ and @ are part of VARNAME, you aren't really informing
	perl of the type just of the reference.  Indeed, if you have
	the reference stored in a scalar, you can just pass that
	without informing perl:

		function ($scalar_containing_a_reference);

	$scalar_containing_a_referernce could hold an array, scalar,
	hash, glob, lvalue, etc ref.

-- 
-Zenin (zenin@archive.rhps.org)           From The Blue Camel we learn:
BSD:  A psychoactive drug, popular in the 80s, probably developed at UC
Berkeley or thereabouts.  Similar in many ways to the prescription-only
medication called "System V", but infinitely more useful. (Or, at least,
more fun.)  The full chemical name is "Berkeley Standard Distribution".


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

Date: 18 Sep 1998 11:54:07 GMT
From: "Serge Barbera" <sbarbera@usa.net>
Subject: Re: perl compiler
Message-Id: <01bde2fa$504d8180$9b9412cb@serge>

Try here...

http://www.demobuilder.com/perl2exe.htm

 ...only win95 though.

-- 
Serge Barbera
sbarbera@usa.net


John Smith <CHANGE_THIS@CHANGE_THIS_ALSO.ch> wrote in article
<36013D22.B9101F82@CHANGE_THIS_ALSO.ch>...
> I'am searching for a perl compiler (WINDOWS95/NT  and UNIX) .
> I would like to do that not to make it faster but to have an executable
> programme for Windows and UNIX plateforme and this for people that does
> not have the perl interpreter...
> 
> i looked at the www.perl.com and it seems that there is an experimental
> compiler for Unix, it looks quit complexe ...
> 
> any body could help me ???
> 
> many thanks .
> 
> 
> 


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

Date: Fri, 18 Sep 1998 12:47:47 +0200
From: Sven Hessler <hessler@NOSPAMcns.mpg.de>
To: empower.eng@mci2000.com
Subject: Re: Perl implementation question
Message-Id: <36023A53.9283FC95@NOSPAMcns.mpg.de>

empower.eng wrote:

> What I like to be able to do is (not correct Perl syntax).
> $Header = ($H1, $H2);
> $Data = ($D1, $D2, $D3);
> Then
> ($Header, $Data) = split(/:/);
> And better yet able to use $Header and $Data to print.

Maybe this code snippet will help you:

($Header[0], $Header[1], $Data[0], $Data[1], $Data[2]) = split(/:/);

print "@Header\n";
print "@Data\n";


Sven

--

Please remove NOSPAM from E-Mail address, when reply.





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

Date: 18 Sep 1998 11:01:58 +0200
From: Thomas Neumann <tom@smart.ruhr.de>
Subject: Re: Regular Expressions for Reading Data
Message-Id: <874su57q0p.fsf@smart.ruhr.de>

jzobel@my-dejanews.com writes:
> I would like to use something like for example
> 
> /(?:(?:(\d*);)*\n)/go
> 
> to read data like
> 
> 33;44;55;23524538;
> 2;
> 33;64576;2353425234;
> 
> Unfortunately $1 is a bit 'small'. It only reads 2353425234. It should better
> be a reference to an array of references to arrays:
> 
> $1 = [[33,44,55,23524538],[2], [33,64576,2353425234]]

Probably not, but what about


my $rows = [ map { chomp; [ split /;/ ] } <> ];

# To test it out...
for (@$rows) {
  for (@$_) { print "$_ " }
  print "\n";
}


Should be faster, too.

-t



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

Date: Fri, 18 Sep 1998 10:26:56 +0100
From: Andy Marden <amarden@ibm.net>
Subject: Runtime evaluation of required modules
Message-Id: <36022760.B10A8AF9@ibm.net>

I've written an application in Perl, originally on Windows NT and am now
attempting to run it on Unix (HPUX actually). The code was written to be
portable: any platform specific parts are colocated in their own module.

Common.pm uses Platform.pm. The latter tests the operating system at run
time and uses either Platform_NT.pm or Platform_Unix.pm as appropriate.
The subroutines within are then passed up to Common.pm, the application
blissfully unaware that they are platform specific.

What I didn't count on was that the contents of any module used are
evaluated at compile time, even if the use if in a conditional
statement. Hence, Platform_NT.pm is evaluated initially even under HPUX,
and of course it can't find the Win32:: modules which are used in
Platform_NT.pm

Is there a way of deferring the checking of these modules until the use
statementis actually encountered at run time rather than compile time?
I've tried requiring them all first and then conditionally importing
them, but it fails with the same error at the require step.

The code in Platform.pm is shown below.

Thanks in advance

Andy.

##################################################################
# Filename: Platform.pm
# Language: Perl 5.004
# Description: Defines all routines that are platform-dependent.
#              Uses the platform-dependent module according to the
#              operating system name. Each such module contains
#              exactly the same routines, implemented differently.
#              All routines in here should simply be exported in 
#              Common.pm
##################################################################

package Platform;

use Config;

require Exporter;

@ISA = qw(Exporter);

$_ = $Config{'osname'};

SWITCH:
{
    # Windows NT
    /^MSWin32$/ && do { use Platform_NT;   last SWITCH; };
    # HP-UX
    /^hpux$/    && do { use Platform_Unix; last SWITCH; };

    die "Unrecognised Operating System!!: $_";
}

# The Platform_* module exports should match the assignments below.

@EXPORT = qw(get_hostname
             move_file
             create_remote_access_point
             create_user);
@EXPORT_OK = qw();

1;


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

Date: 17 Sep 1998 10:54:08 -0400
From: Ala Qumsieh <aqumsieh@tigre.matrox.com>
Subject: Re: Searching a File for String
Message-Id: <x3yk932bxin.fsf@tigre.matrox.com>


"finortis" <finortis@intrex.net> writes:

> 
> 
> Gees guys,
> 
> It's not that hard to do....And some of you shouldn't have such attitudes
> about helping out others, even if they ask pretty basic questions....Here
> you go.
> 
> my $filename = "actual file name";
> open (HANDLE,"$filename") || die "can't open $filename\n";
> my @FILE = <HANDLE>;
> my $line = "";
> my $searchString = "whatever";
> my $secSearch = "";
> my @toRight = ();
> 
> foreach $line (@FILE) {
>     my @searchNum = ($line =~ m/$searchString/g;)
>     foreach $secSearch (@searchNum) {
>         $line =~ m/$searchString (\S+)/g;)
>         push (@toRight,$1);
>     }
> }
> 
> I gotta run...I haven't tested this, but I think this should work. I'll run
> it later, and post any changes if needed.
> 
> Finortis
> 

You're right .. searching a file is not that hard to do. But you make
it look so complicated!!!

how about a one-liner??

perl -ne '/string (\w+)/ && print "$1\n"' file_name


-- 
Ala Qumsieh             |  No .. not Just Another
ASIC Design Engineer    |  Perl Hacker!!!!!
Matrox Graphics Inc.    |
Montreal, Quebec        |  (Not yet!)


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

Date: Fri, 18 Sep 1998 09:07:17 GMT
From: joachim.zobel@syseca.de
Subject: Re: win32:ODBC/Oracle->terrible perormance
Message-Id: <6tt7s4$7iv$1@nnrp1.dejanews.com>

In article <35FF75EB.C3D14EBF@deutschland.de>,
> I just developed a cgi script which runs under NT 4.0 and connects to an
> Oracle 8.0 DB-Server (on the same machine) via ODBC (oracle driver) and
> win32:ODBC.
>
> My problem is, that my queries are incredibly slow, that means, that
> there are about 4000 datasets in a table. I do a SELECT which should
> return about 50 rows and it takes about 5 minutes to get the results
> :-(
>
> Do I realy have to use ASP to get my queries done? PLEASE HELP.

The question is, where the performance bottleneck is. Do you connect to the
database each time the script is called. How long does this take. In this
case a tool like fastcgi would help.

Run some tests with MSQuery or do ODBC via Access. Does the problem show
up?

Which ODBC driver do you use?

Basically, I don't think your problem is a Perl problem. You might run some
tests with ASP, too.

Hope this helps,
Joachim

Also the from header contains a valid email adress replies to user@kud.com
where user = jzobel are preferred.




-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum


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

Date: 12 Jul 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Special: Digest Administrivia (Last modified: 12 Mar 98)
Message-Id: <null>


Administrivia:

Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.

If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu. 


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

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