[7351] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 976 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Sep 4 16:08:01 1997

Date: Thu, 4 Sep 97 13:00:35 -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           Thu, 4 Sep 1997     Volume: 8 Number: 976

Today's topics:
     Re: "Odd number of elements in hash list": So? (Doug Claar)
     balanced delimiter, a subroutine <jbolden@math.ucla.edu>
     Can you us DB_File or a DBM in Win95? (Michael R Ingenito)
     Re: Crypt::IDEA and blocksize <leon@twoshortplanks.com>
     Re: Does tie hash require an flock? <jbc@west.net>
     DynaLoader problem : not exporting vars! help! (Harte-Hanks Data Tech)
     Emailing from  CGI's scripts on Win32 <amias@mindless.com>
     eval warning "Backslash found ..." <kareny@junglee.com>
     Re: Executing Java App from Perl <rjo100@york.ac.uk>
     Extremely simple script to check brackets matching y0h8797@acs.tamu.edu
     Re: Extremely simple script to check brackets matching (Jason Gloudon)
     Re: Finding files - idiom? <cberry@cinenet.net>
     form <dianne@jot.nb.ca>
     Help! Book needed!! <Bernhard.Streit@gmx.de>
     Re: Help! Book needed!! (brian d foy)
     Help! How to make http request from perl CGI? <mgwong@cedar.ca.goc>
     Re: Help! How to make http request from perl CGI? (brian d foy)
     Re: installing perl <hovnania@atc.boeing.com>
     Re: List of perl books, which one should I buy? <rjo100@york.ac.uk>
     looking for: Perl MQ Interface <roland@intershop.de>
     newbie: how do I break a WHILE loop? <KenVogt@rkymtnhi.com>
     Re: newbie: how do I break a WHILE loop? <sudomo@vee.cs.colorado.edu>
     Re: newbie: how do I break a WHILE loop? (courtesy)
     Re: perl and XEmacs <csdayton+usenet@cs.uchicago.edu>
     Re: perl and XEmacs (Gary D. Foster)
     Re: perl and XEmacs (I R A Aggie)
     Shakespearian insult program <eric@semaphore.com>
     Re: SQL access to Access via Perl? <joneil@cks.ssd.k12.wa.us>
     stat on win95 (Alex Krohn)
     Weighting elements of an array (Terry Michael Fletcher - PCD ~)
     Re: yesterday's date (Jason Gloudon)
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: 3 Sep 1997 20:05:46 GMT
From: dclaar@cup.hp.com (Doug Claar)
Subject: Re: "Odd number of elements in hash list": So?
Message-Id: <5ukfuq$3hd$3@ocean.cup.hp.com>


Thanks for the fish (the answer), and the way to fish (perldiag)!

==Doug Claar


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

Date: Thu, 04 Sep 1997 11:49:19 -0700
From: Jeffrey Bolden <jbolden@math.ucla.edu>
Subject: balanced delimiter, a subroutine
Message-Id: <340F02AF.5269@math.ucla.edu>

This subroutine is meant to address an issue raised at 
http://www.perl.com/CPAN-local/doc/manual/html/pod/perlfaq6/
Can_I_use_Perl_regular_expresio.html
To quote:
Can I use Perl regular expressions to match balanced text? 

No, regular expressions just aren't powerful enough. Perl regular
expressions aren't strictly ``regular'', mathematically speaking, because
they feature conveniences like backreferences (\1 and its ilk). But they
are not the proper tool for every nail. You still need to use non-regex
techniques to parse balanced text, such as the text enclosed between
matching parentheses or braces, for example. 

An elaborate subroutine (for 7-bit ASCII only) to pull out balanced and
possibly nested single chars, like ` and ', { and }, or ( and ) can be
found in CPAN/authors/id/TOMC/scripts/pull_quotes.gz . 

The C::Scan module from CPAN also contains such subs for internal usage,
but they are undocumented. 

____________________________________

The routine below is designed to offer some measure of balanced test 
handling.  When given the proper arguments, it returns:

the string between the balanced delimiters in a scaler context, or an 
array consisting of (material to the left of the delimiters, material to 
the right of the delimiters, material inside the delimiters).  The user 
enters from 0 to 4 types of arguments.
balanced ($parse_string,$left_delimiter,$right_delimiter, @ignore_strings)

If no parse string is given balanced uses $_.  If no left delimiter is 
given it searches the parse string for one.  If no right delimiter is 
given it takes a guess based on the left delimiter.  All the remaining 
arguments are taken as strings to be ignored.  

An example on a TeX string: 

balanced ('This text is in bold since it is the \bold{$set \{x\in A\}$ } 
of', '{','}''\{','\}') 

would return 
  
('This text is in bold since it is the \bold', 'of','$set \{x\in A\}$' )

Anybody's advice for improvements, etc... would be warmly regarded.  Well 
here is the routine:


sub balanced { #functional sets up the 3 element array
	my ($string, $left, $right) = @_;
	my $i; #dummy counter variable
	if(!defined($string)) { #no input string
		$string = $_;
	} 
	if(!defined($left)) { #no leftdelim
		my @chararray = split //, $string;
		for ($i=0; $i < @chararray; $i++) {
			if($chararray[$i] !~ /\w|\s/) {
				$left = $chararray[$i];
				last;
			}
		} #end for
		if(!defined($left)) {
			die "\nI can't figure out what the left delimiter is";
		}               
	} #end if no left delim  
	if(!defined($right)) { #no rightdelim
		$right = $left;
		$right =~ tr/([{`</)]}'>/;
	} 
	if(@_ > 3) {#ignore values these are moded out of the string
		for ( $i = 3; $i<@_; $i++) {
			my $repchar = chr($i+125);# starts at 128
			$string =~ s/\Q$_[$i]/chr($i+125)/ge;
		}
	}               
	my @sp = split /([$left,$right])/,$string;
	my ($lcount,$rcount) = (0,0);
	for ($i=0;$i<@sp;$i++) { 
		if($sp[$i] eq $left) {
			$lcount++;
		}
		if($sp[$i] eq $right) {
			$rcount++;
			if($rcount == $lcount) {
				$left = $sp[0];
				$right = join('',@sp[$i+1..@sp-1]),
				$string = join('',@sp[2..$i-1]), 
				last;
			}# end if $rcount == $lcount
		} #end if $i eq $ right
	}#end for
        if($i==@sp) {   #if the loop has gotten to here then no match 
                        #return everything to left
		$left = join('',@sp); 
		$right =""; 
		$string="";
	}
	if(@_ >3) { #repair the string by reincluding ignore values
		for ( $i = 3; $i<@_; $i++) {
			my $repchar = chr($i+125); 
			map {s/$repchar/$_[$i]/g;} ($left,$right,$string);
		}
	}
        return ($left,$right,$string);
} # end balanced
          



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

Date: 4 Sep 1997 17:13:37 GMT
From: ingenito@acsu.buffalo.edu (Michael R Ingenito)
Subject: Can you us DB_File or a DBM in Win95?
Message-Id: <5umq81$23q$1@prometheus.acsu.buffalo.edu>

Can someone please help me.  I have a DBM database that works perfectly fine
in Linux.  But when I try to run it on Win95 it says that there is no DBM on
this machine.  If I add the "use DB_File" to the script it gives me this error

Can't locate DB_File.pm in @INC at view.pl line 4.
BEGIN failed--compilation aborted at view.pl line 4.

Can some please help because I need to run a DBM in Win95.  Thanks...

Mike



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

Date: Thu, 04 Sep 1997 21:35:28 +0100
From: Leon Brocard <leon@twoshortplanks.com>
Subject: Re: Crypt::IDEA and blocksize
Message-Id: <340F1B90.B9CACE73@twoshortplanks.com>

Chris Schoenfeld wrote:
 
> Am I nuts, or can Crypt::IDEA only encrypt 8 bytes of data.
> There seems no way in the interface to override this.

Well, the following _may_ help you:

use Crypt::IDEA
my $idea = new IDEA(pack("H32", $md5->hexhash($password)));
$file =~ s|(........)|$idea->encrypt($1)|egs;

But again, bear in mind that using the same key for the 
whole file is not cryptographically brilliant.

--
Moi


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

Date: Thu, 04 Sep 1997 11:22:40 -0700
From: John Callender <jbc@west.net>
To: pmh@edison.ioppublishing.com
Subject: Re: Does tie hash require an flock?
Message-Id: <340EFC70.3B43094F@west.net>

Peter Haworth wrote:
> 
> In article <5tsdsc$a5t$2@nntp2.ba.best.com>,
>         Zenin <zenin@best.com> writes:
> > Robert Nicholson <steffi@shell8.ba.best.com> wrote:
> >> Is there an implicit flock at the time of an unbind?
> >       Depends on how the tied classes is designed.  Check the
> >       docs for the one you're using.  I don't think many (or any)
> >       of the DBM classes shipped with perl flock anything by
> default.
> 
> GDBM_File does. And with perl 5.004, it's implementation of flock() is
> the
> same as perl's.

Forgive me for being dense, but I'm faced with just this issue at the
moment, and am trying to figure it out.

Does this mean I can use Perl's flocking mechanism to lock and unlock
the GDBM filehandle I've opened in 'WRCREAT' mode, just as I would a
regular filehandle?

A pointer to appropriate documentation (a pointer that even an
accidental programmer like me can understand) will be appreciated
(almost) as much as an explicit answer.

Either way, thank you very much for any help you can give me.

--
John Callender
jbc@west.net
http://www.west.net/~jbc/


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

Date: Thu, 4 Sep 1997 18:23:17 GMT
From: hhanks@world.std.com (Harte-Hanks Data Tech)
Subject: DynaLoader problem : not exporting vars! help!
Message-Id: <EFzxqu.7In@world.std.com>

I am using DynaLoader::bootstrap to load Win32::Process
as needed.  The problem I`m having is that when the module
is loaded, or rather, after it is loaded, I DO NOT have the
constants (?) listed in the @EXPORT list found in the 
module.  I need them to send as params to the module`s
method Create.  Anyone had any similar experience with
DynaLoader and NOT getting exports?

Thanks for any leads!  Jean 


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

Date: Thu, 04 Sep 1997 19:25:50 +0100
From: Amias <amias@mindless.com>
Subject: Emailing from  CGI's scripts on Win32
Message-Id: <340EFD2E.4D43@mindless.com>

Does anyone know how to go about sending emails from HTML froms when
your using an NT server ? I know that with unix there's that sendmail
thingy but NT (or at least my installation) dosen't have anything
comparable to shell to . The nearest i've got is to do an OLE thing with
a Win32 mail program , this is just about OK on my machine but when i
put it on the server it's going to explode .
I' m using CGI.pm with Activeware's PERL for win32 (no more than 2
months old) . Thanks in advance 

Toodle-pip
Amias



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

Date: Thu, 04 Sep 1997 10:48:18 -0700
From: Karen Yao <kareny@junglee.com>
Subject: eval warning "Backslash found ..."
Message-Id: <340EF461.F1D855D6@junglee.com>

Greetings -

I have an eval statement that occasionally generates the following
warning:

"Backslash found where operator expected at (eval 1212) line 1, near
"min_to_max(\"

The eval statement is:

        $new_row->[$i] = eval($function_ref->[$i]);

Where $function_ref->[$i] is the string
        min_to_max(\@set10)

min_to_max is a function that accepts a reference to an array. It simply
finds
the min and max in the list and returns a string "<min> to <max>"

At the time in which the warning occurs, @set10 has 2 elements [1, 3].
The eval returns a string "1 to 3" and all seems well.

This eval is invoked thousands of times. Once in a blue moon, this
warning
appears.

Do you know what causes this?

Just curious. For now, I have suppressed the warning (via sig handler)
from
stdout/stderr unless the eval returns an undefined value.

Please email your reponse to me directly at kareny@junglee.com

Thanks!
   Karen



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

Date: Thu, 04 Sep 1997 17:54:56 +0100
From: Russell Odom <rjo100@york.ac.uk>
Subject: Re: Executing Java App from Perl
Message-Id: <340EE7DF.7B8A5DDA@york.ac.uk>

lbj_ccsi@atl.mindspring.com wrote:
> 
> $return = system "D:\\VisualCafePro\\Java\bin\\java.exe NewAccount
                                          ^^^
Shouldn't that be a double slash ("...Java\\bin...")?

HTH,

Russ

---------------------------------------------------------------------
--[ R u s s e l l    O d o m ]---[    mailto:rjo100@york.ac.uk    ]--
--[  University of York, UK  ]---[ http://www.york.ac.uk/~rjo100/ ]--
---------------------------------------------------------------------
--[    FAQ maintainer, news:comp.os.ms-windows.win95.moderated    ]--
---------------------------------------------------------------------



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

Date: 4 Sep 1997 17:22:08 GMT
From: y0h8797@acs.tamu.edu
Subject: Extremely simple script to check brackets matching
Message-Id: <5umqo0$r2q$1@news.tamu.edu>

#!usr/local/bin/perl
 
while (<>) {
   $leftbrace++ if /{/;
   $rightbrace++ if /}/;
   $leftparen++ if /\(/;
   $rightparen++ if /\)/;
   $leftcomment++ if /\/\*/;
   $rightcomment++ if /\*\//;
   $leftbracket++ if /\[/;
   $rightbracket++ if /\]/;
}
print "{ counts ".$leftbrace." times.\n";
print "} counts ".$rightbrace." times.\n";
print "\( counts ".$leftparen." times.\n"; 
print "\) counts ".$rightparen." times.\n";
print "\/\* counts ".$leftcomment." times.\n"; 
print "\*\/ counts ".$rightcomment." times.\n";
print "\[ counts ".$leftbracket." times.\n"; 
print "\] counts ".$rightbracket." times.\n";



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

Date: 4 Sep 1997 19:48:28 GMT
From: jgloudon@bbn.com (Jason Gloudon)
Subject: Re: Extremely simple script to check brackets matching
Message-Id: <5un3ac$a6e$1@daily.bbnplanet.com>

In article <5umqo0$r2q$1@news.tamu.edu>,  <y0h8797@acs.tamu.edu> wrote:
>#!usr/local/bin/perl
> 
>while (<>) {
>   $leftbrace++ if /{/;
>   $rightbrace++ if /}/;
*SPLICE*
>print "\) counts ".$rightparen." times.\n";
>print "\/\* counts ".$leftcomment." times.\n"; 
>print "\*\/ counts ".$rightcomment." times.\n";
>print "\[ counts ".$leftbracket." times.\n"; 
>print "\] counts ".$rightbracket." times.\n";
>
This version is simple in another way. 

#!/bin/perl
use strict; # look I didnt' break any rules

my %delims = ( '{' => 0,
            '}' => 0,
            '(' => 0,
            ')' => 0,
            ']' => 0,
            '[' => 0,
            '\*' => 0,
            '*/' => 0
);
while (<>) {
   while(m~(
            {| # count { }
            }|
           \(| # count ( )
           \)|
         \\\*| # count \* */
         \*\/|
           \[| # count [ ]
           \])
          ~gx) # x - allow comments in regexp
	{
	$delims{$1}++;
   }
}

foreach(keys %delims){
   print "$_ counts $delims{$_} times.\n";
}


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

Date: Thu, 4 Sep 1997 11:21:10 -0700
From: Craig Berry <cberry@cinenet.net>
To: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Finding files - idiom?
Message-Id: <Pine.GSO.3.95.970904111936.7154H-100000@hollywood.cinenet.net>


On Wed, 3 Sep 1997, Tom Phoenix wrote:

> On 3 Sep 1997, Craig Berry wrote:
> 
> > I am writing a Perl app which will take a filename argument, possibly
> > containing wildcards, and search the current filesystem (from root on
> > down) for files matching that argument. 
> 
> Sounds like you want to start with find2perl, or something like it, since
> that's just about what it does. Hope this helps!

As I mentioned in another part of my original post, this is (primarily)
targeted for DOS, so 'find' isn't directly applicable.  However, it's
certainly worth looking at the 'find2perl' source for ideas, and I'm
currently doing so.  Thanks for the tip.

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



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

Date: 4 Sep 1997 17:43:23 GMT
From: "dianne" <dianne@jot.nb.ca>
Subject: form
Message-Id: <01bcb959$b6a62160$cd67a4c6@dianne>


Okay, I'm really a newbie  here.  I'm doing an on-line registration form,
is perl the best way to go or is there another route?  If so, can anyone
point me to a quick-n-dirty reference or a good manual?  As usual, I needed
it for yesterday.

Thanks.


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

Date: 4 Sep 1997 19:09:09 GMT
From: "Bernhard" <Bernhard.Streit@gmx.de>
Subject: Help! Book needed!!
Message-Id: <01bcb965$b9ea3260$c64e2dc2@bstreit.rhein-zeitung.de>

HI!
Who knows a good BEGINNER (!!) book for learning perl? It could be in
english or german language.

Bernhard
-- 
Bernhard.Streit@gmx.de
http://home.rhein-zeitung.de/~bstreit/
RZ-Online-FAQ: http://home.rhein-zeitung.de/~bstreit/faq/


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

Date: Thu, 04 Sep 1997 15:48:49 -0400
From: comdog@computerdog.com (brian d foy)
Subject: Re: Help! Book needed!!
Message-Id: <comdog-ya02408000R0409971548490001@news.panix.com>

In article <01bcb965$b9ea3260$c64e2dc2@bstreit.rhein-zeitung.de>, "Bernhard" <Bernhard.Streit@gmx.de> wrote:

>HI!
>Who knows a good BEGINNER (!!) book for learning perl? It could be in
>english or german language.

how about:

Learning Perl
Randal L. Schwartz & Tom Christensen
ISBN 1-56592-284-0. 
<URL:http://www.ora.com>

-- 
brian d foy                                  <comdog@computerdog.com>


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

Date: Thu, 04 Sep 1997 12:15:11 -0700
From: Mike Wong <mgwong@cedar.ca.goc>
Subject: Help! How to make http request from perl CGI?
Message-Id: <340F08BF.32DE@cedar.ca.goc>

I'd like to know how to write a perl CGI script that would make an
http request for an html document, do some stuff to the document, and
then push the results to the browser.

  Writing a CGI doesn't trip me at all--but making the http
request--that's the trick. If anyone can help me, I'd greatly appreciate
the knowledge.

  Thanks in advance!

- mike


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

Date: Thu, 04 Sep 1997 15:58:17 -0400
From: comdog@computerdog.com (brian d foy)
Subject: Re: Help! How to make http request from perl CGI?
Message-Id: <comdog-ya02408000R0409971558170001@news.panix.com>


In article <340F08BF.32DE@cedar.ca.goc>, mgwong@cedar.ca.gov wrote:

>I'd like to know how to write a perl CGI script that would make an
>http request for an html document, do some stuff to the document, and
>then push the results to the browser.
>
>  Writing a CGI doesn't trip me at all--but making the http
>request--that's the trick. If anyone can help me, I'd greatly appreciate
>the knowledge.

check out the LWP family of modules [1] to see if they are the tool that
you need (there are plenty of examples and lots ot documentation).  you
might also want to take a look at Web Client Programming with Perl [2].

good luck :)

[1] available from the Comprehensive Perl Archive Network
find one near you at <URL:http://www.perl.com>

[2]
Web Client Programming with Perl
Clinton Wong
ISBN 1-56592-214-X
<URL:http://www.ora.com>

-- 
brian d foy                                  <comdog@computerdog.com>


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

Date: Thu, 4 Sep 1997 18:15:54 GMT
From: Paul Hovnanian <hovnania@atc.boeing.com>
Subject: Re: installing perl
Message-Id: <340EFADA.51023F87@atc.boeing.com>

the count wrote:
> 
> We just got a new server and I am trying to install perl but the
> configure script is complaining that I don't have a working C compiler
> (which is silly, cause I've been compiling lots of C programs for the
> new system and they all work fine...)
> 
> % uname -a
> SunOS mpr-nj 5.5.1 Generic_103640-08 sun4u sparc SUNW,Ultra-2
> 
> % cc -V
> cc: SC4.0 18 Oct 1995 C++ 4.1
> 
> From running Configure:
> 
> Use which C compiler? [cc]
> 
> Checking for GNU cc in disguise and/or its version number...
> 
> *** WHOA THERE!!! ***
>     Your C compiler "cc" doesn't seem to be working!
>     You'd better start hunting for one and let me know about it.

Is cc an ANSI C compiler (like gcc) or is it that crappy "bundled"
one that seems to come with alot of Suns? I can't tell from its
version number. I don't think perl will build without an ANSI-compliant
compiler.
  
-- 
Paul Hovnanian 		hovnania@atc.boeing.com
------------------------------------------------------------------------ 
If the first attempt at making a drawing board had been a failure,
what would they go back to?
Opinions the sole property of the above, available for a nominal fee.


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

Date: Thu, 04 Sep 1997 15:16:58 +0100
From: Russell Odom <rjo100@york.ac.uk>
Subject: Re: List of perl books, which one should I buy?
Message-Id: <340EC2DA.7B76AB7D@york.ac.uk>

Mark Worsdall wrote:
> 
> Can anyone give recommendations to any of these books before I invest in
> one?
>[...]
> 10873   Learning Perl

I got this a few weeks ago, I gather the 2nd Edition is now out (I wish
I'd waited). It's quite good, arranged in chapters with excercises at
the end of each, solutions given at the end of the book, and lots of
examples of what things do.

HTH,

Russ

---------------------------------------------------------------------
--[ R u s s e l l    O d o m ]---[    mailto:rjo100@york.ac.uk    ]--
--[  University of York, UK  ]---[ http://www.york.ac.uk/~rjo100/ ]--
---------------------------------------------------------------------
--[    FAQ maintainer, news:comp.os.ms-windows.win95.moderated    ]--
---------------------------------------------------------------------




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

Date: Thu, 04 Sep 1997 21:12:10 +0200
From: Roland Faszauer <roland@intershop.de>
Subject: looking for: Perl MQ Interface
Message-Id: <340F080A.1BA4@intershop.de>

Hi folks,

has anybody a clue if there is an MQ (MQ - the IBM Message Queuing
thing) interface for Perl ?

Don't laugh - we have a project where we need to communicate between 
our perl scripts with mainframes through MQ.

I know that we can write a perl extension using the C API.
Is something like this already out there ?


Thanks in advance

Roland Fassauer


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

Date: Thu, 04 Sep 1997 12:31:26 -0600
From: Kenneth Vogt <KenVogt@rkymtnhi.com>
Subject: newbie: how do I break a WHILE loop?
Message-Id: <340EFE7E.46F5@rkymtnhi.com>


Here's my code:

open (CATEGORIES, "$category_file") || &file_open_error('File',
"$category_file", 'product_header', __FILE__, __LINE__);
while (<CATEGORIES>)
{
	@database_row = split (/\|/, $_);
	if ($database_row[0] eq $FORM{'category'})
	{
		$category_description = $database_row[1];

		# I got what I wanted.
		#  How do I break out of the WHILE loop?
	}
}
close (CATEGORIES);

Please not the comment lines with my question.  Thanks!
-- 
Kenneth Vogt      
KenVogt@rkymtnhi.com

http://ModernShopping.com
Buy Tupperware(r) products right on the WWW!


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

Date: 4 Sep 1997 18:54:43 GMT
From: Ronald Sudomo <sudomo@vee.cs.colorado.edu>
Subject: Re: newbie: how do I break a WHILE loop?
Message-Id: <5un05j$eqq$1@csnews.cs.colorado.edu>


Hi Ken,
try 'last' (without the quote of course). It will get you out of
the innermost loop. 

Kenneth Vogt <KenVogt@rkymtnhi.com> wrote:

> Here's my code:

> open (CATEGORIES, "$category_file") || &file_open_error('File',
> "$category_file", 'product_header', __FILE__, __LINE__);
> while (<CATEGORIES>)
> {
> 	@database_row = split (/\|/, $_);
> 	if ($database_row[0] eq $FORM{'category'})
> 	{
> 		$category_description = $database_row[1];

> 		# I got what I wanted.
> 		#  How do I break out of the WHILE loop?
> 	}
> }
> close (CATEGORIES);

> Please not the comment lines with my question.  Thanks!
> -- 
> Kenneth Vogt      
> KenVogt@rkymtnhi.com

> http://ModernShopping.com
> Buy Tupperware(r) products right on the WWW!

-- 
+-+-+-+-+-+-+ +-+-+-+-+-+-+
|R|o|n|a|l|d| |S|u|d|o|m|o|
+-+-+-+-+-+-+ +-+-+-+-+-+-+
Ronald.Sudomo@Colorado.EDU


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

Date: 4 Sep 1997 18:57:31 GMT
From: Bob Shair (courtesy) <rmshair@delphi.beckman.uiuc.edu>
Subject: Re: newbie: how do I break a WHILE loop?
Message-Id: <5un0ar$elg$2@vixen.cso.uiuc.edu>


Kenneth Vogt <KenVogt@rkymtnhi.com> wrote:
 Here's my code:

 open (CATEGORIES, "$category_file") || &file_open_error('File',
 "$category_file", 'product_header', __FILE__, __LINE__);
CATS: while (<CATEGORIES>)	#<========
 {
 	@database_row = split (/\|/, $_);
 	if ($database_row[0] eq $FORM{'category'})
 	{
 		$category_description = $database_row[1];
 		# I got what I wanted.
 		#  How do I break out of the WHILE loop?
		last CATS;	#<========
 	}
 }
 close (CATEGORIES);

p.25 Programming Perl(2nd edition)
-- 
Bob Shair                          rmshair@delphi.beckman.uiuc.edu
Open Systems Specialist    	   Champaign, Illinois		   
/* Not employed by or representing the University of Illinois */


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

Date: Thu, 4 Sep 1997 18:09:19 GMT
From: Soren Dayton <csdayton+usenet@cs.uchicago.edu>
Subject: Re: perl and XEmacs
Message-Id: <xcdafhtc5o0.fsf@ra.cs.uchicago.edu>


fl_aggie@hotmail.com (I R A Aggie) writes:

> In article <bcilo1ecexx.fsf@corp.Sun.COM>, Gary.Foster@corp.Sun.COM (Gary
> D. Foster) wrote:
> 
> + >>>>> "Chris" == Chris Nandor <pudge@pobox.com> writes:
> + 
> +     Chris> I know this was all supposed to be humourous, but it wasn't
> +     Chris> particularly funny.
> + 
> + Depends on your sense of humor, now doesn't it?
> 
> Let's see if I got this right: you attribute perl to anti-semetic
> Nazis, and then get miffed when perl users object?

No no no.  anti-semantic nazis.  That is anti-`clear semantic' nazi's.
 
> Ok, maybe I'm humor-impaired. Please explain to me, which part of
> 
> +  Perl is for nazi's and oppresion.
> 
> is supposed to be funny?

Well, partially.  It was also supposed to get people to stop.

Soren


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

Date: 04 Sep 1997 11:09:45 -0700
From: Gary.Foster@corp.Sun.COM (Gary D. Foster)
Subject: Re: perl and XEmacs
Message-Id: <bci2035ar2u.fsf@corp.Sun.COM>

>>>>> "I" == I R A Aggie <fl_aggie@hotmail.com> writes:

    I> Let's see if I got this right: you attribute perl to
    I> anti-semetic Nazis, and then get miffed when perl users object?

    I> Ok, maybe I'm humor-impaired. Please explain to me, which part
    I> of

    I> + Perl is for nazi's and oppresion.

    I> is supposed to be funny?

Ever heard of something called satire?

Hmm... you appear to be, as dogbert would say, an "Induhvidual".

Take your sense of humor into the shop for a tuneup, it's overdue.

Perhaps you would have found it funny if I had reversed "perl" and
"lisp"?  Or perhaps you should just realize it was all just tongue in
cheek.  Or perhaps you don't even realize what Godwin's law is, and
therefore are completely clueless.  If that's the case, read the first 
line of my reply again, carefully, slowly, and sounding out the big
words.

Geez, get a grip.

-- Gary F.


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

Date: Thu, 04 Sep 1997 15:41:45 -0400
From: fl_aggie@hotmail.com (I R A Aggie)
Subject: Re: perl and XEmacs
Message-Id: <fl_aggie-ya02408000R0409971541450001@news.fsu.edu>

In article <bci2035ar2u.fsf@corp.Sun.COM>, Gary.Foster@corp.Sun.COM (Gary
D. Foster) wrote:

+ >>>>> "I" == I R A Aggie <fl_aggie@hotmail.com> writes:
+ 
+     I> Let's see if I got this right: you attribute perl to
+     I> anti-semetic Nazis, and then get miffed when perl users object?
+ 
+     I> Ok, maybe I'm humor-impaired. Please explain to me, which part
+     I> of
+ 
+     I> + Perl is for nazi's and oppresion.
+ 
+     I> is supposed to be funny?
+ 
+ Ever heard of something called satire?

I have. I'm a licensed practioner. And you?

+ Hmm... you appear to be, as dogbert would say, an "Induhvidual".

Read the sig, dude.
 
+ Take your sense of humor into the shop for a tuneup, it's overdue.

Well, I would if I could. But something you need to understand is
that Nazism isn't a laughing matter for a _significant_ number of people.
Often-times, it's a hot-button that shuts down rational thought, and
puts the blinders up.

+ Perhaps you would have found it funny if I had reversed "perl" and
+ "lisp"?

Nope. Hello, McFly, that's not what I'm objecting to. Had you said
"Darth Vader invented Perl to help eliminate all the Jedi Knights",
*that* would have been funny...

"Luke, join the Perl Way, it is the only way you can save your friends."

+ Or perhaps you should just realize it was all just tongue in
+ cheek.

Which you probably need to get re-treaded, since you're subjecting it
to extreme wear-and-tear.

+ Or perhaps you don't even realize what Godwin's law is, and
+ therefore are completely clueless.

I realize what Godwin's law is. Cross-reference my remarks above on
"hot-button", "shuts down rational thought" and "puts the blinders up".
That's the *heart* of Godwin's law.

Of course, only someone without a clue -- or maybe someone not thinking --
would _not_ know that _purposely_ invoking Nazism does _not_ invoke 
Godwin's law. Its a corrollary. Go look it up...

+ If that's the case, read the first 
+ line of my reply again, carefully, slowly, and sounding out the big
+ words.

Oooooo...is that a flame?

Followups set appropriately...

James - maybe I should get my asbestos undies out? Naaaaaahhhh...

-- 
Consulting Minister for Consultants, DNRC
Support the anti-Spam amendment <url:http://www.cauce.org/>
To cure your perl CGI problems, please look at:
<url:http://www.perl.com/perl/faq/idiots-guide.html>


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

Date: 4 Sep 1997 18:31:38 GMT
From: Eric Anderson <eric@semaphore.com>
Subject: Shakespearian insult program
Message-Id: <5umuqa$i16$0@207.17.114.19>

Hello,

A friend emailed me a shakespearian insult kit. With it, you choose one
word from each of three columns, put them together with a 'Thou' on the
front of it, and you have a fully functional shakespearian insult. I've
turned it into a small perl program. I have it set to run in my .bashrc
file so I have the pleasure of a quality insult every time I login.
Please feel free to use/misuse it however you see fit.

---cut here---
#!/usr/bin/perl

@column_1 = (
	"artless",
	"bawdy",
	"beslubbering",
	"bootless",
	"churlish",
	"clouted",
	"cockered",
	"craven",
	"currish",
	"dankish",
	"dissembling",
	"droning",
	"errant",
	"fawning",
	"fobbing",
	"frothy",
	"froward",
	"gleeking",
	"goatish",
	"gorbellied",
	"impertinent",
	"infectious",
	"jarring",
	"loggerheaded",
	"lumpish",
	"mammering",
	"mangled",
	"mewling",
	"paunchy",
	"pribbling",
	"puking",
	"puny",
	"qualling",
	"rank",
	"reeky",
	"roguish",
	"ruttish",
	"saucy",
	"spleeny",
	"spongy",
	"surly",
	"tottering",
	"unmuzzled",
	"vain",
	"venomed",
	"villainous",
	"warped",
	"wayward",
	"weedy",
	"yeasty"
);

@column_2 = (
	"base-court",
	"bat-fowling",
	"beef-witted",
	"beetle-headed",
	"boil-brained",
	"clapper-clawed",
	"clay-brained",
	"common-kissing",
	"crook-pated",
	"dismal-dreaming",
	"dizzy-eyed",
	"doghearted",
	"dread-bolted",
	"earth-vexing",
	"elf-skinned",
	"fat-kidneyed",
	"fen-sucked",
	"flap-mouthed",
	"fly-bitten",
	"folly-fallen",
	"fool-born",
	"full-gorged",
	"guts-griping",
	"half-faced",
	"hasty-witted",
	"hedge-born",
	"hell-hated",
	"idle-headed",
	"ill-breeding",
	"ill-nurtured",
	"knotty-pated",
	"milk-livered",
	"motley-minded",
	"onion-eyed",
	"plume-plucked",
	"pottle-deep",
	"pox-marked",
	"reeling-ripe",
	"rough-hewn",
	"rude-growing",
	"rump-fed",
	"shard-borne",
	"sheep-biting",
	"spur-galled",
	"swag-bellied",
	"tardy-gaited",
	"tickle-brained",
	"toad-spotted",
	"urchin-snouted",
	"weather-bitten"
);

@column_3 = (
	"apple-john",
	"baggage",
	"barnacle",
	"bladder",
	"boar-pig",
	"bugbear",
	"bum-bailey",
	"canker-blossom",
	"clack-dish",
	"clotpole",
	"codpiece",
	"coxcomb",
	"death-token",
	"dewberry",
	"flap-dragon",
	"flax-wench",
	"flirt-gill",
	"foot-licker",
	"fustilarian",
	"giglet",
	"gudgeon",
	"haggard",
	"harpy",
	"hedge-pig",
	"horn-beast",
	"hugger-mugger",
	"joithead",
	"lewdster",
	"lout",
	"maggot-pie",
	"malt-worm",
	"mammet",
	"measle",
	"minnow",
	"miscreant",
	"moldwarp",
	"mumble-news",
	"nut-hook",
	"pigeon-egg",
	"pignut",
	"pumpion",
	"puttock",
	"ratsbane",
	"scut",
	"skainsmate",
	"strumpet",
	"varlet",
	"vassal",
	"wagtail",
	"whey-face"
);

srand;
$word_1 = @column_1[int(rand(48))];
$word_2 = @column_2[int(rand(48))];
$word_3 = @column_3[int(rand(48))];

print "\nThou $word_1 $word_2 $word_3!\n\n";

---cut here---
-- 
---------------------------------------------------------------
Eric Anderson			Email: eric@semaphore.com
Software Developer		URL  : http://www.semaphore.com
Semaphore Corporation		Voice: 206.443.0651
2001 6th Ave., Suite 400	Fax  : 206.443.0718
Seattle, WA  98121		
---------------------------------------------------------------
"genius is one percent inspiration and ninety-nine percent perspiration"
-Thomas Edison


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

Date: Thu, 04 Sep 1997 12:44:11 -0700
From: Jerome O'Neil <joneil@cks.ssd.k12.wa.us>
To: cjbradshaw@dera.gov.uk
Subject: Re: SQL access to Access via Perl?
Message-Id: <340F0F8B.4AFE471@cks.ssd.k12.wa.us>

Cliff Bradshaw wrote:
> 
> Anyone know if it's possible to access an Access database on a network
> via SQL using perl..?

Yes.  It is easily done.
 
> The aim is to provide a Web front end to the database.
> 
> Any advice gratefully received.

Get the Win32:ODBC.pm module from your favorite CPAN site.  Read the
documentation.  SQL 'till you drop!

Jerome


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

Date: Thu, 04 Sep 1997 17:28:51 GMT
From: akrohn@spc.ca (Alex Krohn)
Subject: stat on win95
Message-Id: <340eef4b.73210580@news.supernews.com>

Does stat work with Perl for Win32? Specificily, I want to get the
last access/modified or creation time of a file. 

I've got a list of files from readdir, but only the "." and ".."
entries seem to give back anything for stat. The rest seem to return
empty arrays.. 

Am I doing something wrong? Are there any other ways to get the
access/modify/creation times on perl for win32?

Thanks,

Alex


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

Date: 4 Sep 1997 17:49:26 GMT
From: tfletche@pcocd2.intel.com (Terry Michael Fletcher - PCD ~)
Subject: Weighting elements of an array
Message-Id: <5umsb6$5l0$1@news.fm.intel.com>

i would like to be able to create an array of commands to execute, and
then randomly execute some commands from this array a large number of
times.

doing this really is not a problem:

@commands = (
	'cmd1();',
	'cmd2();',
	'cmd3();'	# etc...
);
for (1..100) {	# do a hundred random commands
	eval $commands[int(rand(@commands))]
}

but now, say i want ~60% of the commands to be cmd1, ~30% to be cmd2, and
~10% to be cmd3, i am doing this:

# ignore the fact that i could use an array of length 10 please... :)
# these numbers in this example were just arbitrary...
for(0..59){ $commands[$_] = 'cmd1();' }
for(60..89){ $commands[$_] = 'cmd2();' }
for(90..99){ $commands[$_] = 'cmd3();' }

what i would like to be able to do is something along these lines:
(yes i know this doesnt work, because this is string repeating...)

@commands = (
	'cmd1();', x 60
	'cmd2();', x 30
	'cmd3();', x 10
);

the idea is to be able to simply modify the repeater value, without having
to take into account the new size of the array, e.g. i want to avoid this
situation, even though it would work:

for(0..$x){}
for($x..$x+$y){}
for($x+$y..$x+$y+$z){}

it would just be nice to be able to show users how they could do something
like this easily, without caring about what ANY of the indexes to the
array are.  by the way, a hash is also fine, but repeating an element for
different keys doesnt seem any simpler.

just something to ponder, if its possible.

-- 
#!/usr/local/bin/perl -w
print   "J"                      ."u".        #    -- Terry Fletcher
        "s"    ."t".    " A",     "n"         # tfletche@pcocd2.intel.com
   .    "o"   ,""."".   "the",    "r ","P".   #  Views expressed....not
   "e"."rl"   ." Ha",   "c",''    .""  ."".   #  INTeL's....yadda yadda
      ""            ,   "k".      "e"  ."r"  ;#          yadda....



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

Date: 4 Sep 1997 16:52:30 GMT
From: jgloudon@bbn.com (Jason Gloudon)
Subject: Re: yesterday's date
Message-Id: <5ump0e$opd$1@daily.bbnplanet.com>

In article <340EB0B7.4DA9755E@mid-states.com>,
Jeremy Finke  <webmaster@mid-states.com> wrote:
>Hello all-
>
>I have a question that I am having difficulty with.  I have a script
>that parses through a group of files that have date formats in them.  I
>have this working all right.  My problem now comes from the fact that
>one of the fields has the previous day's date.  Is there an easy way to
>get yesterday's date from the system.  I was subtracting one from

A quick hack at this would be to subtract the number of seconds in a day
from the return value of time. The return value from localtime would contain
the date and time more or less 24 hours prior to the current time.

# There are 24 hours containing 60 minutes each lasting 60 seconds in a day
($sec,$min,$hour,$mday,$mon,$year,undef,undef,undef) =
                                                      localtime(time-24*60*60);

However, from what you are describing you might want an actual time value that
represents the start of that day. If that's the case, you could use the
timelocal function in the Time::Local package which calculates time values
for arbitrary dates.

use Time::Local;
($sec,$min,$hour,$mday,$mon,$year,undef,undef,undef) =
                                                      localtime(time-24*60*60);
$startofyesterday = timelocal(0,0,0,$mday,$mon,$year);


Jason Gloudon


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

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

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