[7048] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 673 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Jun 27 19:08:36 1997

Date: Fri, 27 Jun 97 16: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           Fri, 27 Jun 1997     Volume: 8 Number: 673

Today's topics:
     Re: .htacces interface through PERL <rootbeer@teleport.com>
     Re: 64-bit compilation of Perl <rootbeer@teleport.com>
     ?: How to copy a file? <mustun@active.ch>
     Re: ?: How to copy a file? <sfairey@adc.metrica.co.uk>
     Re: Bad Filenames <rootbeer@teleport.com>
     Re: BIG databases (Mike Heins)
     Re: Client-Side Execution (VERMA KAKARLAPUDI)
     Re: Concurrency in Perl? (Malcolm Beattie)
     Creating directories? <rxt117@psu.edu>
     Re: decimal to hex conversion? (Dean Inada)
     Re: find.pl Problem <rootbeer@teleport.com>
     Re: finding cgi-lib.pl (Jean-Damien Durand)
     Re: Fun with ".cgi contained no blank line separating h <rootbeer@teleport.com>
     Re: Help with getting file contents <rootbeer@teleport.com>
     Re: HELP with NTPerl 5.02 (Jim Esten)
     Re: HELP: force a <CR> in DOS (Paquin Michel)
     Re: Inconsistent crossplatform Pack!? <rootbeer@teleport.com>
     Re: Newbie needs Elegance <pdcawley@aladdin.net>
     Re: Newbie: Lookup to array not working <sfairey@adc.metrica.co.uk>
     Re: Oraperl or DBD on Mac <boei@trifox.com>
     Re: Perl & SQL <boei@trifox.com>
     Re: Q: an alternative to this use of "goto"? (Malcolm Beattie)
     Re: read serial port perl5 help? chg@jilacg.colorado.edu
     regex: what the ...? (rod)
     Re: regex: what the ...? (rod)
     Re: Regexp with exclusion <pdcawley@aladdin.net>
     Re: Regexps on streams <rootbeer@teleport.com>
     reverse printing order? <guitarweb@hotmail.com>
     Re: Short Circuit Question (Eric Bohlman)
     Re: simple open statement gives me error <rootbeer@teleport.com>
     Re: Stumped ....-  CLEARED <saxena_arun@jpmorgan.com>
     URL Encoder in Perl. (Eric Pan)
     Re: URL Encoder in Perl. <aas@bergen.sn.no>
     Re: Why warnings for this short script? <rootbeer@teleport.com>
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Fri, 27 Jun 1997 10:55:46 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Curt Bousquet <scanline@sover.net>
Subject: Re: .htacces interface through PERL
Message-Id: <Pine.GSO.3.96.970627105512.17693N-100000@kelly.teleport.com>

On Thu, 26 Jun 1997, Curt Bousquet wrote:

>         I would like to automate my maintenance of the site a little by
> building a CGI (with PERL) interface to the password file, the .htaccess
> file and the htpassword program, so I can manage everything from an
> administrative page (adding new accounts and such)....

Have you looked in the module list? It's on CPAN. 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: Fri, 27 Jun 1997 11:14:59 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: jheck@acm.org
Subject: Re: 64-bit compilation of Perl
Message-Id: <Pine.GSO.3.96.970627111422.17693V-100000@kelly.teleport.com>

On Fri, 27 Jun 1997, James J. Heck wrote:

> I am trying to compile Perl in 64-bit mode on a SGI running IRIX 6.2 
> Has anyone run into problems compiling Perl in 64-bit?  

You may find something helpful in the hints files for other 64-bit
machines. 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: Fri, 27 Jun 1997 10:06:58 +0200
From: "M. Mustun" <mustun@active.ch>
Subject: ?: How to copy a file?
Message-Id: <33B374A2.5A39FEF7@active.ch>

Hello

how can I copy a file in perl?

I know link, etc. 

Many thanks

-- 

         Michael Mustun
     mailto:mustun@active.ch
  http://www2.active.ch/~mustun

         Active-Net AG
     Rosengartenstrasse 6
       CH 8608 Bubikon
    Tel:  ++41-55-253 25 45
    Fax:  ++41-55-253 25 46


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

Date: Fri, 27 Jun 1997 11:44:57 +0100
From: Simon Fairey <sfairey@adc.metrica.co.uk>
To: "M. Mustun" <mustun@active.ch>
Subject: Re: ?: How to copy a file?
Message-Id: <33B399A9.167E@adc.metrica.co.uk>

M. Mustun wrote:
> 
> Hello
> 
> how can I copy a file in perl?
> 
> I know link, etc.
> 
> Many thanks
> 
> --
> 
>          Michael Mustun
>      mailto:mustun@active.ch
>   http://www2.active.ch/~mustun
> 
>          Active-Net AG
>      Rosengartenstrasse 6
>        CH 8608 Bubikon
>     Tel:  ++41-55-253 25 45
>     Fax:  ++41-55-253 25 46

Short of using a system command you would be best off getting the
File::Copy module which is available at your local CPAN.

Simon


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

Date: Fri, 27 Jun 1997 10:41:53 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Justin Henry <jch11@airmail.net>
Subject: Re: Bad Filenames
Message-Id: <Pine.GSO.3.96.970627103913.17693K-100000@kelly.teleport.com>

On 26 Jun 1997, Justin Henry wrote:

> I can't get this script to open the header files by using $list_line. 

>    open (HEADERS, $list_line) || die $!;	# THIS LINE IS BAD,

Well, maybe you want to improve on the error message so that you can see
exactly what's wrong.

    open HEADERS, $list_line
	or die "Can't open '$list_line' for input: $!";

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: 27 Jun 1997 11:30:07 GMT
From: mheins@prairienet.org (Mike Heins)
Subject: Re: BIG databases
Message-Id: <5p087v$mei$1@vixen.cso.uiuc.edu>

Patrick Verdon (patrick@Smallworld.co.uk) wrote:
: Hi all,
: 
: I'm needing to find a database, accessible from PERL, ideally free,
: that can cope with up to 2,000,000 records, consisting of user
: name, id and probably a couple of other fields. 
: 
: I don't really know where to start; I've read through some archives
: at www.dejanews.com, that refer to things like GDBM, or DS_file and
: I've also been recommended 'postgres 95'.
: 
: Can anyone make any other suggestions, or offer working examples?

GDBM_File or DB_File, mostly for their cache capability.

: 
: What kind of lookup times (for a given user, say) can I expect from a 
: database of this size on perhaps a SPARCstation 20 or an UltraSPARC?

Milliseconds. I have done similar size databases, with much larger
record size, and have achieved 1000 lookups in less than 2 seconds,
with a Pentium 166-200.

: 
: What do I need to do to optimise speed of access?

Store the data with a single key, and break out the fields with
MLDBM, Data::Dumper, or the like.

-- 
Regards,
Mike Heins

This post reflects the
opinion of my employer.


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

Date: Thu, 26 Jun 1997 23:12:24 -0400
From: vermak@webtv.net (VERMA KAKARLAPUDI)
Subject: Re: Client-Side Execution
Message-Id: <5ovb2o$6s3$1@newsd-112.bryant.webtv.net>

I don't know,  hink i am in the wrong site


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

Date: 25 Jun 1997 09:10:49 GMT
From: mbeattie@sable.ox.ac.uk (Malcolm Beattie)
Subject: Re: Concurrency in Perl?
Message-Id: <5oqnap$n65@news.ox.ac.uk>

In article <33AF30DD.75B2@wellspring.com>,
Elliot Mednick  <elliot@wellspring.com> wrote:
>Hello,
>I would like to be able to have a script (program, whatever) in which
>there are multiple code streams running concurrently (conceptually),
>each with its own separate stack, but sharing a common address space.  I
>also need a way to synchronize them with wait/notify primitives or the
>like.
>
>I'm not sure what name to associate with this, because terms like
>"threads", "processes", and "multitasking" have changed meaning and
>become ambiguous.  
>
>I don't need POSIX threads.  Only a way to seperate Perl's internal
>stacks into seperate "processes".  But threads *may* gice me what I
>need.
>
>There used to be a way to compile Perl with "MULTIPLICITY".  That would
>give me part of what I need, but that hasn't worked in a while, but I'm
>a little behind an my most recent version of Perl is 5.002.

Multithreading is currently in the development tree and will be in
5.005 (or possibly 5.006). It does what you want. The current
version depends on your O/S supporting the POSIX.1c threads API or
the older POSIX draft API but there'll be "fake threads" added for
less capable O/Ses.

--Malcolm

-- 
Malcolm Beattie <mbeattie@sable.ox.ac.uk>
Oxford University Computing Services
"I permitted that as a demonstration of futility" --Grey Roger


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

Date: Fri, 27 Jun 1997 15:56:10 -0400
From: Rei Baker <rxt117@psu.edu>
Subject: Creating directories?
Message-Id: <33B41ADA.48B4@psu.edu>

Is there any way I can create new directories with Perl?

Rei


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

Date: 27 Jun 1997 04:41:25 GMT
From: dmi@deltanet.com (Dean Inada)
Subject: Re: decimal to hex conversion?
Message-Id: <5ovg9l$ejt$1@news01.deltanet.com>

In article <33b1c161.4227348@snews5.zippo.com>,
Scott Johnson <scottj@insane.com> wrote:
>Does anybody know (I'm sure somebody must) how to convert decimal
>numbers to hex?  I've tried a few things with pack, but everything I
Things like
	unpack "H*",pack "N",987654321
?
>try either comes up as the wrong number or zero.  I've seen the
>postings here on how to do this with printf, but I need to data to
By now, he should have seen the postings on how to do it with sprintf...
>remain in variables.  Thanks in advance!
>




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

Date: Fri, 27 Jun 1997 10:53:37 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Brent Johnson <brent@AAC.MsState.Edu>
Subject: Re: find.pl Problem
Message-Id: <Pine.GSO.3.96.970627105028.17693M-100000@kelly.teleport.com>

On 26 Jun 1997, Brent Johnson wrote:

> Subject: find.pl Problem

> the find feature doesnt seem to follow symbolic links.  

If I'm not mistaken, that's so that you won't search the same directories
forever if some user on your system has a symlink back to /usr. :-)

If you want to follow symlinks, one method would be to use find.pl to find
them, use readlink to resolve the ones you want, and then use find.pl to
find some more. 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: Fri, 27 Jun 1997 07:06:03 GMT
From: ddurand@hpplus03.cern.ch (Jean-Damien Durand)
To: vbyerly@lakeside.net
Subject: Re: finding cgi-lib.pl
Message-Id: <ECFAE3.1xu@news.cern.ch>



> can anyone direct me to a place that I can download the cgi-lib.pl file,
> thanks in advance...
> 
> Victor Byerly

  Simply at the cgi-lib.pl Home Page... http://www.bio.cam.ac.uk/cgi-lib/

  Jean-Damien.
--
       *******************************************************
       *   Jean-Damien Durand (Jean-Damien.Durand@cern.ch)   *
       *         www : http://wwwcn1.cern.ch/~ddurand/       *
       *******************************************************


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

Date: Fri, 27 Jun 1997 11:11:09 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Shelle <shelle@interaccess.com>
Subject: Re: Fun with ".cgi contained no blank line separating header and data"
Message-Id: <Pine.GSO.3.96.970627110948.17693T-100000@kelly.teleport.com>

On Fri, 27 Jun 1997, Shelle wrote:

> Subject: Fun with ".cgi contained no blank line separating header and data"

> I can see the content-type info followed by 2 spaces print from the DOS
> command line,

Are you saying that you have two spaces instead of one blank line between
the headers and the data?

When you're having trouble with a CGI program in Perl, you should first
look at the please-don't-be-offended-by-the-name Idiot's Guide to
solving such problems. It's available on the perl.com web pages. Hope
this helps!

   http://www.perl.com/perl/
   http://www.perl.com/perl/faq/
   http://www.perl.com/perl/faq/idiots-guide.html

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



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

Date: Fri, 27 Jun 1997 11:33:21 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: perrella andrew c <perrella@ehsn6.cen.uiuc.edu>
Subject: Re: Help with getting file contents
Message-Id: <Pine.GSO.3.96.970627113028.17693a-100000@kelly.teleport.com>

On Fri, 27 Jun 1997, perrella andrew c wrote:

> How do you get read the contents of a file into a scalar variable?

    {				# Naked block for temporary scope
	local(*FILE);
	my($filename) = '/path/to/file';
	open FILE, $filename
	    or die "Can't open '$filename' for input: $!";
	local($/);		# Slurp mode
	$scalar = <FILE>;	# Slurp it in here
	close FILE
	    or warn "Problem reading from $filename: $!";
    }

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: 27 Jun 1997 07:33:00 -0500
From: jesten@earth.execpc.com (Jim Esten)
Subject: Re: HELP with NTPerl 5.02
Message-Id: <5p0bts$rpc$1@earth.execpc.com>


Check out www.activeware.com for the latest Win32 perl. Includes
binarary and source distributions of perl, as well as the PerlIS
and PerlScript stuff.

Jim

kahuna (kahuna@surfr.com) wrote:
: i have written a script for acessing a database using the file sprite.pm
: i got from an author for "O'Reiley and Associates". teh bottom line is I
: need version 5.02 in order for sprite to run, i can only find the unix
: version which are up to 5.03. Where can I find the NT version
-- 
Jim Esten
(temporarily between .sigs)


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

Date: Fri, 27 Jun 1997 11:06:18 -0400
From: m.paquin@nfb.ca (Paquin Michel)
Subject: Re: HELP: force a <CR> in DOS
Message-Id: <m.paquin-2706971106180001@qawhaq.nfb-onf.ca>

Have you tried: print "$databit\n";   ?


In article <867412180.7994@dejanews.com>, a.maclennan@rgu.ac.uk wrote:

> I'm running Perl 5.001, in a  DOS window under Win95. Iwant to get the
> current date into a scalar, so I thought I'd do it like this:
> 
> open(DIR, 'date |') ;
> 
> 
> while (<DIR>){
>         /^Current date is (\w+) (\S+)/ && ($datebit = $2);
>         }
> print $datebit;
> 
> close (DIR);
> 
> (Thanks for the help with my last pipe, BTW - wrong version on home
> machine ;-<)
> 
> This (sort of) works, but I need to hit Return to display $datebit. Is
> ther any way I can make the script do this? I've tried
> 
> print "\r\n"; which I saw in this newsgroup, in another context (probably
> the wrong one :-), but that doesn't seem to make any difference.
> 
> Now, I realise, I'm probably going at it the wrong way completely, so I'd
> expect some abuse, but would be grateful for suggestions - I *have*
> searched myself, tried the FAQ's, but no joy.
> 
> Alan
> 
> -------------------==== Posted via Deja News ====-----------------------
>       http://www.dejanews.com/     Search, Read, Post to Usenet
-- 
Michel Paquin
National Film Board of Canada / Office National du Film du Canada
m.paquin@nfb.ca


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

Date: Fri, 27 Jun 1997 11:22:27 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: "John W. Komp" <jk0101@medtronic.com>
Subject: Re: Inconsistent crossplatform Pack!?
Message-Id: <Pine.GSO.3.96.970627112054.17693Y-100000@kelly.teleport.com>

On 27 Jun 1997, John W. Komp wrote:

> On a Unix box using version 4.0.1.8 patch level 36

Software gets older in dog years; that software is old enough to vote. 
:-)  You can get a modern version of Perl from CPAN. 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: 27 Jun 1997 10:08:01 +0100
From: Piers Cawley <pdcawley@aladdin.net>
Subject: Re: Newbie needs Elegance
Message-Id: <54hgekh0r2.fsf@gunnar.aladdin.net>

Scott Blanksteen <sibsib@hotmail.com> writes:

> Simon Fairey wrote:
> > 
> > mashfiel wrote:
> > > $logfile = pop(@ARGV);
> > > $report = $logfile;
> > > $report =~ s/.log/.html/;
> > 
> > # Use $report = shift; if you want the first and not the last arg.
> > # pop() and shift() will default to @ARGV.
> > $report = pop;
> > $report = $report =~ s/^(.*)\.log/REPORT$1.html/;
>                          ^         ^
>             unnecessary  |         | $ in here!
> 
> What about just
> 
> ($report = pop) =~ s/(.*)\.log$/REPORT$1.html/;

Hold on, given that we haven't actually opened the logfile yet we do
really need to be hanging onto a copy of the old value so:

open LOGFILE, ($report = pop) or die "Couldn't open $report: $!";
$report =~ s/\.log$/.html/;

I'm not entirely sure that this is elegant mind you. For clarity I'd
probably do:

my $logfile = pop;
my $report  = $logfile;

$report     =~ s/\.log$/.html/ or warn "Logfile name has no .log\n";

Sure it's less compact, but it's a great deal more maintainable. It
might be safer to do:

$report =~ s/(.*)(\.log)?$/REPORT-$1.html/;

which will never have problems with surprisingly named logfiles.

-- 
Piers Cawley -- Systems Genie for Aladdin
If a `religion' is defined to be a system of ideas that contains
unprovable statements, then Godel taught us that mathematics is not
only a religion, it is the only religion that can prove itself to be
one. -- John Barrow


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

Date: Fri, 27 Jun 1997 15:45:05 +0100
From: Simon Fairey <sfairey@adc.metrica.co.uk>
To: dundee@ccnet.com
Subject: Re: Newbie: Lookup to array not working
Message-Id: <33B3D1F1.ABD@adc.metrica.co.uk>

Sean Scannell wrote:
> 
> I guess I'm missing something basic, and can't pick it from the examples
> in the camel or llama book.  I'm trying to return default info about a
> user to a form, but I get all the records in the file instead of just
> the just the one I want.  Any tips really appreciated.  This is my test
> script:
> 
> ###### Get Manager default info #########
> print "Enter your User ID:  ";
> $this_user = <STDIN>;
> chop($this_user);
> open(MGR_DATA,"mgr_data");
> while (<MGR_DATA>) {
> ($user_id,$mgr_records)= split(",");
> $mgr_record{$user_id} = $mgr_records;
> ($nameprefix,$firstname,$lastname,$title,$areacode,$prefix,$phone,$ext,$email,$company,$dept,$dept_no,$address1,$city,$state,$zip,$div_mgr)
> = split /:/,$mgr_records;
> 
> if ($this_user = $user_id) {;

This is your problem. See the perlop man page.
For stringwise equality use 'eq' for numerical equality use '=='.

> print "USER_ID $user_id \n";
> print "MGR_RECORDS  $mgr_records \n";
> print "nameprefix $nameprefix \n";
> print "first name $firstname \n";
> print "last name $lastname \n";
> } else { }
> 
> }
> close (MGR_DATA);

Simon


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

Date: Thu, 26 Jun 1997 21:41:05 -0700
From: Bob Eisner <boei@trifox.com>
To: jamesh@nortel.ca
Subject: Re: Oraperl or DBD on Mac
Message-Id: <33B34461.35F7@trifox.com>

James Hyjek wrote:
> 
> Hi,
> 
>   Does anyone know where I can find an Oraperl for the Mac?
>   Has anyone actually tried it out? Does it work?
> 
>   Does anyone know where I can find a DBD for Oracle on Mac?
>   Has anyone actually tried it out? Does it work?
> 
>                                            Thanks in advance,
> 
>                                            James Hyjek
>                                            jamesh@nortel.ca

Hi James,

Trifox has a product, VORTEXperl.  It talks to multiple RDBMS
and support Oracle.  It uses Perl Sockets so there is no need
to re-build the Perl runtime.

VORTEXPerl provides a simple interface for Perl applications to
access all leading relational and legacy databases via the
VORTEX database access and performance boosters, like
VORTEXaccelerator, the industry-leading high performance
transaction process monitor. With VORTEXPerl you can quickly
access DBMS information from CGI applications and spend your
time making your application great without bothering with DBMS
details. 

You can obtain an evaluation copy of VORTEXperl from our WEB site
at http://www.trifox.com/j/vortex/vtxperl.html

Regards,

Bob Eisner
408 369-2392


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

Date: Thu, 26 Jun 1997 21:47:25 -0700
From: Bob Eisner <boei@trifox.com>
To: mpolly@miint.net
Subject: Re: Perl & SQL
Message-Id: <33B345DD.70FC@trifox.com>

Michael Polikoff wrote:
> 
> I'm currently working on a databasing project in which I'm designing an
> applications interface in HTML.  In order to interface with the database
> (Oracle), I need to write CGI scripts with embedded SQL.  I know this
> can be accomplished with C or Visual Basic, but I don't have time to
> learn a new language.  Does anyone know how this could be done with
> Perl?
> 
> Desperate for any help anyone could give me -- even a link to a good
> source of info.  Thanks.
> 
> Mike Polikoff
> michael@uss.net
> mpolly@miint.net

Hi Mike,

Trifox has a product, VORTEXperl.  It talks to multiple RDBMS
and supports Oracle.  It uses Perl Sockets so there is no need
to re-build the Perl runtime.

VORTEXPerl provides a simple interface for Perl applications to
access all leading relational and legacy databases via the
VORTEX database access and performance boosters, like
VORTEXaccelerator, the industry-leading high performance
transaction process monitor. With VORTEXPerl you can quickly
access DBMS information from CGI applications and spend your
time making your application great without bothering with DBMS
details. 

You can obtain an evaluation copy of VORTEXperl from our WEB site
at http://www.trifox.com/j/vortex/vtxperl.html

Regards,

Bob Eisner
408 369-2392


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

Date: 25 Jun 1997 09:29:51 GMT
From: mbeattie@sable.ox.ac.uk (Malcolm Beattie)
Subject: Re: Q: an alternative to this use of "goto"?
Message-Id: <5oqoef$npp@news.ox.ac.uk>

In article <ECAvDu.7yo@nonexistent.com>, Abigail <abigail@fnx.com> wrote:
>Randal Schwartz (merlyn@stonehenge.com) wrote on 1393 September 1993 in
><URL: news:8cvi3482e5.fsf@gadget.cscaper.com>:
>++ >>>>> "Lloyd" == Lloyd Zusman <asfast@asfast.com> writes:
>++ 
>++ Lloyd> Of course.  But in the subset of cases where "redo" and "goto" are
>++ Lloyd> equivalent, there is nothing wrong with "goto" ... or at least
>++ nothing
>++ Lloyd> worse about it than using the equivalent "redo" construct.
>++ 
>++ ... except speed, which has already been pointed out elsewhere in this
>++ thread.  A "goto" is implemented by a *linear* search of all opcodes
>++ from beginning to end looking for the goto target.
>
>Hmmm, you should perlbug that. The compiler could have stored
>at least all the lables in a hash.

Nope, for two reasons. Firstly, the search isn't actually a straight
"beginning to end" scan. It starts at the enclosing scope and searches
outwards via the context stack for the label. Secondly, assuming by
"compiler" you mean perl's usual internal compile-and-go system, there
is too much overhead in taking time to optimise things like goto. Perl
optimises for the common case and it can't afford the luxury of too
much static optimisation or else the "-and-go" part is hurt. If by
compiler your meant the external compiler, then I'm even harsher in a
way. An ordinary Perl "goto foo" statement is mapped to a real C goto
statement but I use lexical scoping to find the target since that's
all that's known at compile-time. Without depending on non-standard
C compiler extensions (such as gcc's void*-as-label feature), you
can't mimic perl's native goto semantics. Similarly for "last",
"next" and "redo". Consider, for example,

    perl -le 'sub out { last foo } foo: while (1) { out() } print "here"'

which reaches the print statement with ordinary perl but the
external compiler produces the error:

    Label not found at compile time for "last foo"

>If Perl allows goto's, it should do them efficiently.

Not if it hurts performance for sane perl usage.

--Malcolm

-- 
Malcolm Beattie <mbeattie@sable.ox.ac.uk>
Oxford University Computing Services
"I permitted that as a demonstration of futility" --Grey Roger


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

Date: Fri, 27 Jun 1997 13:40:01 GMT
From: chg@jilacg.colorado.edu
Subject: Re: read serial port perl5 help?
Message-Id: <5p0frq$iaq@lace.colorado.edu>

bobm@cunix.com (Bob Mariotti) wrote:

>We asked the SAME quesions a week or so ago and found NO simple
>solution.  What we ended up doing was create a c program to write/read
>the port and called it from perl (    $IN=`cprogram device`;
>Seems to work relatively reliably.

>We are not C programmers, just bought a bunch of c books and hacked
>away.


I would love to see your detailed solution!  I am interested both in
your C program to write/read the port and also your method of calling
it from Perl.  I know some of both languages but little enough about
how they work together that I encourage you to post both your program
and your Perl script.  

BTW, I attempted to implement the very interesting and relevant script
sent in by Jim Buttafuoco, but it hangs on the "use POSIX" line, on my
Win95 system.  I am a little puzzled because a search of my system
found no POSIX modules with my Perl 5.003 installation, even though
the main PERL web sites say that POSIX is part of the "standard
distribution".  Does anybody know more about this apparent
inconsistency?

Thanks,
Chris



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

Date: 27 Jun 1997 08:26:20 GMT
From: serling@davids.psyberlink.net (rod)
Subject: regex: what the ...?
Message-Id: <slrn5r6tit.9ap.serling@davids.psyberlink.net>

	ok. I give up and sure, I can live without having to write
	this like this, but I don't see why I cannot. It's worth
	the rtfm abuse to know, so:
	
print "error" if($var =~ /[\000-\039]/);	=>  prints error
print "error" if($var =~ /[\000-\040]/);        =>  prints nothing

	So far, so bizarre,
	
print "error = $1" if($var =~ /([\000-\039])/);	=>  prints error = 9
print "error = $1" if($var =~ /([\000-\038])/);	=>  prints error = 8

print "\038 "    =>    "does not translate well to usenet" 8 


	okay, so it reads the (non-existent) \038, \039 as 003 & 8,9
	
	Is this correct (as in what is supposed to happen) or am I a few
	expressions short of a regex, (in the mentally figurative sense)?
	

drs
-- 
Would you put the worlds best wooden
wagon wheels on your car? Then why
buy 56k anti-technology?


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

Date: 27 Jun 1997 09:19:16 GMT
From: serling@davids.psyberlink.net (rod)
Subject: Re: regex: what the ...?
Message-Id: <slrn5r70m8.9fg.serling@davids.psyberlink.net>

rod, serling@davids.psyberlink.net journeyed into


	If that post didn't get cancelled, ignore it. My bone headed
	error. That's what happens when you forget octal means 8.
	WHACK!!!!


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

Date: 27 Jun 1997 09:57:51 +0100
From: Piers Cawley <pdcawley@aladdin.net>
Subject: Re: Regexp with exclusion
Message-Id: <54iuz0h180.fsf@gunnar.aladdin.net>

Piers Cawley <pdcawley@aladdin.net> writes:

> Piers Cawley <pdcawley@aladdin.net> writes:
> 
> > danpel@pluto.dannet.dk (Per Olesen) writes:
> > 
> > > Hello
> > > 
> > > I need a way to substituate multi whitespace with 
> > > single whitespace globally in a string. BUT. Everything
> > > in the string, which is enclosed within " must NOT 
> > > participate in the substitution.
> > > 
> > > example:
> > > 
> > > $line = 'hello   world "dab   dab   dab"   more';
> > 
> > Okay, lets see if I've remembered enough of the Hip Owls book...
> > 
> > s/([^"\s]*|"(?:[^"\\]+|\\.)*")\s+/$1 /g
> > 
> > seems to do the job (and it allows you to have escaped `"'s inside the
> > quotes. I'll bet Mr Friedl could make it faster though.
> 
> Oops, I just noticed, it also replaces any newlines with spaces. A
> better bet would probably be:
> 
> s/([^"\s]*|"(?:[^"\\]+|\\.)*"|\n)\s+/$1 /g
> 
> unless of course that's what you want.

This is the last time I do this, honest, but if you want to be able to
escape " in the main string then you would do:

s/([^"\\\s]*|"(?:[^"\\]+|\\.)*"|\n|\\"?)\s+/$1 /g

Also, if you wanted to do things so that you used the same whitespace
character as the first one in any group you could do:

s/([^"\\\s]*|"(?:[^"\\]+|\\.)*"|\\"?)(\s)\s*/$1$2/g

which also gets rid of the need for explicitly catching the newline.

Right, that's it, I'm not going to follow-up to my own posts again.

-- 
Piers Cawley -- Systems Genie for Aladdin
If a `religion' is defined to be a system of ideas that contains
unprovable statements, then Godel taught us that mathematics is not
only a religion, it is the only religion that can prove itself to be
one. -- John Barrow


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

Date: Fri, 27 Jun 1997 12:08:23 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Ilya Zakharevich <ilya@math.ohio-state.edu>
Subject: Re: Regexps on streams
Message-Id: <Pine.GSO.3.96.970627115501.17693c-100000@kelly.teleport.com>

On 26 Jun 1997, Ilya Zakharevich wrote:

> Cc: rootbeer@teleport.com

[How odd. I don't think I got this copy. Hmmm...]

> Tom Phoenix  <rootbeer@teleport.com> wrote:
> > If using a RE on a stream does get into the core, it would
> > really help if there were some way for Perl to be able to warn or abort
> > when a regular expression is thrashing, since it will be an easy feature
> > to misunderstand and misuse.
> 
> What does it mean "thrashing" in this context?  Anything specific can
> be implemented, but you need to know first what to implement.

I was thinking of repeatedly reloading the string again and again. We
could warn on, say, the one hundredth occurrence of backtracking that
forces reloading. (Although it might be nice if there were a way to tweak
that number, or turn the warning off...)

If the stream-sourcing function returns inconsistent values, will this be
able to dump core? Not that that would _have_ to be considered a bug in
perl, since that sort of thing can happen now with sort's function, of
course. ("Just don't do that, then.")

-- 
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: Fri, 27 Jun 1997 01:42:33 -0700
From: "I, me, myself" <guitarweb@hotmail.com>
Subject: reverse printing order?
Message-Id: <33B37CF9.1531@hotmail.com>

Hi, I have a chat script that I got from the Selena Sol site. And I'm
only learning perl, but I've looked in Deja-news and other's, net
searches, etc. And I've been watching the news groups for hints on
this., yet nothing. I only have one book (learn CGI programming with
PERL in a week).. needless to say, it's not very informative. (saving
money for the famed "camel" book)

Anyway, if someone could help, or point me where to look for this info,
I would greatly appreciate it. Now. Onward to the actual ranting---

I want to have the messages show the newes chat messages at the bottom
of the screen, and oldest at the top. (therefore making it so people
don't have to scroll UP the screen to go in the order the messages were
posted, then go back down to post) It should be simple, but again, I've
found nothing. It could be the chat code I'm trying to alter? Also, I
have it show a user list of chatters, to select a name to send a message
to, I tried all the ways I saw for it to print the names in alphabetical
order, but it didn't work? 

Something like this --
     
               open (WHOFILE, "$chat_room_dir/$whofile");
               $wholine = <WHOFILE>;
               $wholine = &OtherHtmlFilter($wholine);
               @whofields = split (/\|/, $wholine);
               close (WHOFILE);
              
               if ($whofields[0] ne "")
               {
               $chat_buffer .= qq!<option>$whofields[0]!;
	       

Anyway, onto the order of messages:
 Here's the code (please forgive me for posting so much, it's only to
give you an idea of how it works. I'm sure you'll be able to just skip
over most of it) --

if ($submit_message ne "")
    {
    if ($chat_to_user eq "" ||
     $chat_to_user =~ /^all$/i ||
     $chat_to_user =~ /everyone/i) {
     $chat_to_user  = "ALL";
    }
  
    $high_number = &GetHighMessageNumber;
    $high_number++; 
    $high_number = sprintf("%6d",$high_number);
    $high_number =~ tr/ /0/;           
    open(MSGFILE, ">$chat_room_dir/$high_number.msg");
    print MSGFILE "$user_name\n";
    print MSGFILE "$user_email\n";
    print MSGFILE "$chat_to_user\n";
    print MSGFILE "$current_date_time\n";
    print MSGFILE "$chat_message\n";
    close(MSGFILE);

# we need to get rid of old messages...
    &PruneOldMessages($chat_room_dir);


# We need to be able to GetSessionInfo again since the state of the
messages 
# that are available have changed since the user last read the
information.

# How, last_read has not changed, so we keep track of it with a
temporary 
# variable (old_last_read) and reset it afterwards...

    $old_last_read = $user_last_read;
    ($user_name, $user_email, 
    $refresh_rate, $how_many_old, 
    $user_last_read, $high_message) = 
         &GetSessionInfo($session, $fsubmit, $frames);
    $user_last_read = $old_last_read;

}


More stuff here ---

$msg_to_read = $user_last_read + 1;
$msg_to_read -= $how_many_old;						

if ($msg_to_read < 1) {	 $msg_to_read = 1;	 }

if ($high_message >= $msg_to_read)  
   {
    for ($x = 0; $x <= $high_message; $x++) 
        {
         $x = sprintf("%6d",$x);
         $x =~ tr/ /0/;   

         if (-e "$chat_room_dir/$x.msg") #   if the file exists...
            {

													# open the "chat_room_dir/file.msg"	file...
             open(MSG,"$chat_room_dir/$x.msg") ||	&CgiDie("Could not
open $x.msg");
             $msg_from_user = &HtmlFilter(<MSG>);
             $msg_email     = &OtherHtmlFilter(<MSG>);
             $msg_to_user   = &HtmlFilter(<MSG>);
            
	  ## etc..
												# chop off \n
             chop($msg_from_user);    
              chop($msg_email);
             chop($msg_to_user);    
             
             if ($msg_to_user   eq "ALL"            ||
                 $msg_to_user   =~ /^$user_name$/i  ||
                 $msg_from_user =~ /^$user_name$/i) 
                {  
                 $chat_buffer .= "  \n";
                 $chat_buffer .= "";
                 $chat_buffer .= "<B>";

                # much wasted space here...

                  if ($x > $user_last_read) { $chat_buffer .= "" }

                  $chat_buffer .= " $msg_from_host";
                  $chat_buffer .= "";
                  $chat_buffer .= "  $msg_date_time";
                  $chat_buffer .= "\n";

                 if ($msg_to_user =~ /^$user_name$/i ||
                    ($msg_from_user =~ /^$user_name$/i &&
                     $msg_to_user ne "ALL")) 
                    {
                      $chat_buffer .= "";
                      $chat_buffer .= "<BR>
<DD>
<B>Private Msg To: </B> " .
           " <B> <I> $msg_to_user </I>
</B>
</DD>" . 
           "\n";
                    }

                 $chat_buffer .= "\n";

                 while(<MSG>) 
                 {
                  $_ = &HtmlFilter($_);
                  $chat_buffer .= "$_";
                 }

                close(MSG);
                $chat_buffer .= "</BLOCKQUOTE>\n";
          }		# end 
         $chat_buffer .= "\n";
        } # end 

# End of IF msg is to all or just us...

      }	
   }

}



More -- 

sub GetSessionInfo
{
 local($session, $fsubmit,$frames) = @_;
 local($session_file);
 local($temp,@fields, @f);
 local($high_number, $high_message);
 $session_file = "$session.dat";


# Open the session file...

 open (SESSIONFILE, "$chat_session_dir/$session_file");
 while (<SESSIONFILE>) {
 $temp = $_;
} 
chop($temp);


@fields = split(/\|/, $temp);

close (SESSIONFILE);                  


# Get the highest message number...

$high_message = &GetHighMessageNumber;

# Keep track of old fields...

@f = @fields;

# Update last read field

@fields[@fields - 1] = $high_message;

# We need to write the new last read variable out to the session file...

if ($fsubmit ne "on" && $frames ne "on") 
   {
    open (SESSIONFILE, ">$chat_session_dir/$session_file");
    print SESSIONFILE join ("\|", @fields);
    print SESSIONFILE "\n";
    close (SESSIONFILE);
   }
(@f, $high_message);
} 

# End of GetSessionInfo...


-- last part


sub GetHighMessageNumber 
{
 local($last_file, @files);

# Read in all the files and sort them... 
 opendir(CHATDIR, "$chat_room_dir");
 @files = sort(grep(/msg/, readdir(CHATDIR)));
 closedir(CHATDIR);

# Return highest message or 0 if no files...
 if (@files > 0) 
  {
   $last_file = $files[@files - 1];
    }
    else
    {
    $last_file = "0000000";
   }

# Return the first 6 characters of the filename...

substr($last_file,0,6);

}


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

Date: Fri, 27 Jun 1997 11:38:09 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: Short Circuit Question
Message-Id: <ebohlmanECFMzL.Crn@netcom.com>

Craig M. Votava (craig@lucent.com) wrote:

: I'm trying to do this, and an additional step -- return from the current
: subroutine. So I tried:

: open(FILE, "somefile") || die "Cannot open somefile: $!\n" && return;

: No dice. The return works, but the die stuff never gets printed out.
: Okay, so I try a test script:

This won't work because "&&" has a higher precedence than "||" so your 
statement is parsed as:

(open(FILE, "somefile")) || (die "Cannot open somefile: $!\n" && return);

Since die() will never evaluate to anything, the "&&" never even gets tested.



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

Date: Fri, 27 Jun 1997 12:45:04 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: SS <ss51@columbia.edu>
Subject: Re: simple open statement gives me error
Message-Id: <Pine.GSO.3.96.970627124402.17693g-100000@kelly.teleport.com>

On Fri, 27 Jun 1997, SS wrote:

> what is wrong with
> 
> open(MOL1, "$ARGV[0]") || die "$ARGV[0] doesn't exist\n";
> 
> it gives me the warning (when run with -w flag)
> 
> Possible typo: "MOL1" at int_area line 3

Unless you're using an antique version of Perl, I'd guess that something
on an earlier line of your code is confusing the compiler. Could that be
it? 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: Thu, 26 Jun 1997 10:58:20 -0400
From: Arun Saxena <saxena_arun@jpmorgan.com>
Subject: Re: Stumped ....-  CLEARED
Message-Id: <33B2838C.7939@jpmorgan.com>

Thanks alot for all those who replied. 
I was able to solve the problem.

Most of the replies suggested something of the follwing 
nature and that is what worked for me....


	s/(\s{4,})/'\\'.length($1).' '/ge;

Hurrah for the Net!

Arun




Arun Saxena wrote:
> 
> --
> 
> Folks,
> 
> This is what I am trying to do ..... Replace the following
> text
> 
>          kkkk     d;ckdk  ;dkckd kkk   k    kd
>         ddk      dkd   dkkdk     dkkd
>         kkdk kddd kkk d      kkk
> 
> with
> 
>         kkkk\5 d:ckdk   ;dkckd  kkk\7 k\8 kd
>         ...
> 
> ( Basicall replace 4 or more spaces w "\<cnt # of spaces> "
>  I am having one hell of a time with this. I would think the
> following would work, but it does not
> 
>         s/(\s{4,})/join (\s, \ length$1)/eg
> 
> Please also email me any suggestions...
> 
> Arun
> 
> saxena_arun@jpmorgan.com

--


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

Date: 26 Jun 1997 22:10:44 GMT
From: yep5826@cc.utah.edu (Eric Pan)
Subject: URL Encoder in Perl.
Message-Id: <5oupd4$k9b$1@dorothy.cc.utah.edu>

Are there any scripts that can convert a string into url-encoded string?

If not, how do I a character such as '=' into a two digit hexadecimal 
representation of the lower 16-bits of the charater?

Thanks.

-- 
Eric Pan :-)


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

Date: 27 Jun 1997 09:51:55 +0200
From: Gisle Aas <aas@bergen.sn.no>
Subject: Re: URL Encoder in Perl.
Message-Id: <hoh8sjxes.fsf@bergen.sn.no>

yep5826@cc.utah.edu (Eric Pan) writes:

> Are there any scripts that can convert a string into url-encoded string?

Try this:

  use URI::URL;
  $u = url("http://dummy");
  $u->query_form(foo => 'bar', baz => '4&1 == 0');
  print $u->equery, "\n";

URI::URL comes with the LWP.

-- 
Gisle Aas <aas@sn.no>


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

Date: Fri, 27 Jun 1997 11:13:42 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Otto Hell <Otto.Hell@desy.de>
Subject: Re: Why warnings for this short script?
Message-Id: <Pine.GSO.3.96.970627111239.17693U-100000@kelly.teleport.com>

On Fri, 27 Jun 1997, Otto Hell wrote:

> Subject: Why warnings for this short script?

Any recent version of Perl should come with the perldiag(1) manpage which
explains why each warning occurs. If you have an older version of Perl,
you can get the source for 5.004 from CPAN. 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: 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 673
*************************************

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