[13428] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 838 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Sep 18 00:07:30 1999

Date: Fri, 17 Sep 1999 21:05:09 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <937627509-v9-i838@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Fri, 17 Sep 1999     Volume: 9 Number: 838

Today's topics:
    Re: A New Resource <uri@sysarch.com>
    Re: A question about some functions from CGI.pm. (David Efflandt)
        backref problem <ericne@microsoft.com>
    Re: backref problem <rick.delaney@home.com>
        Be careful about using constants <johnlin@chttl.com.tw>
    Re: Can Perl interface a compiled C program and a web s (Abigail)
    Re: cgi not working (David Efflandt)
    Re: Checking for Modules in Perl <bwalton@rochester.rr.com>
    Re: CONTEST: Range Searching <ltl@rgsun40.viasystems.com>
        HELP ! BOOTSTRAP PROBLEM ! *** <alrope@zaz.com.br>
        Help me PLEASE <losasso@rice.edu>
    Re: Help on Perl/Cgi script (Abigail)
    Re: How do I print Array of hash? (Randal L. Schwartz)
    Re: how to create (and ref) anonymous objects (Kragen Sitaker)
    Re: how to create (and ref) anonymous objects <ptrainor@bettyjo.downcity.net>
        how to create temporary cookie and destroy it <skywing@home.com>
    Re: How to test for file Perl (Kragen Sitaker)
    Re: Lambda calculus stuff in Perl <rick.delaney@home.com>
    Re: List files in a dir (Abigail)
    Re: List files in a dir (Abigail)
        make in Windows 98 <losasso@rice.edu>
    Re: regexp odity with (?s-x:) <bwalton@rochester.rr.com>
    Re: regexp odity with (?s-x:) <ltl@rgsun40.viasystems.com>
    Re: regexp odity with (?s-x:) <rick.delaney@home.com>
        Sorting on a string, by value. (Jim Matzdorff)
    Re: Sorting on a string, by value. <uri@sysarch.com>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: 17 Sep 1999 22:29:40 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: A New Resource
Message-Id: <x76719ar57.fsf@home.sysarch.com>

>>>>> "DC" == David Cassell <cassell@mail.cor.epa.gov> writes:

  DC> Even worse, you can't even get in there unless you turn JavaScript
  DC> on first.  Yuck.

and it caused my netscape to crash openwindows. big :-(

overuse of javascript makes for a crappy and noisy and buggy page. even
on winblows it shows up a javascript bug. this place is a landmine!

uri

-- 
Uri Guttman  -----------------  SYStems ARCHitecture and Software Engineering
uri@sysarch.com  ---------------------------  Perl, Internet, UNIX Consulting
Have Perl, Will Travel  -----------------------------  http://www.sysarch.com
The Best Search Engine on the Net -------------  http://www.northernlight.com
"F**king Windows 98", said the general in South Park before shooting Bill.


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

Date: 18 Sep 1999 02:36:38 GMT
From: efflandt@xnet.com (David Efflandt)
Subject: Re: A question about some functions from CGI.pm.
Message-Id: <slrn7u5ult.lq.efflandt@efflandt.xnet.com>

On Fri, 17 Sep 1999 15:49:37 -0500, zzhang <zzhang@bayou.uh.edu> wrote:
>I am afraid that I didn't express my question clearly.
(snip)
>Now I want to display 'please' in red. Of course I cannot add the html
>tags <font color='red'></font> to the above file, since it is generated
>by Perl/CGI dynamically. I tried to use:
>
>    %labels = ('eenie'=>"<font color='red'>please</font>",
>                     'meenie'=>'stop',
>                     'minie'=>'that');
>
>It didn't work, since everything between the double quotation marks was
>taken as a part of the label to be displayed (means '<' will be changed
>to '&lt;' and so on). Is there a simple trick to do this while still
>using CGI.pm function radio_group()? Thanks.


#!/usr/local/bin/perl
use CGI qw/:standard/;
autoEscape(undef);	# does this give you a clue?

%labels = ('eenie'=>font({color=>'red',size=>'+1'},'please'),
	'meenie'=>'stop',
	'minie'=>'that',
	'moe'=>'now');

print header,start_html,start_form,
	font({face=>'arial,helvetica',color=>'blue'},
	radio_group(-name=>'pick_one',
	-values=>['eenie', 'meenie','minie','moe'],
	-default=>'meenie',
	-linebreak=>1,
	-labels=>\%labels)),end_form;

-- 
David Efflandt   efflandt@xnet.com   http://www.xnet.com/~efflandt/
http://www.de-srv.com/   http://cgi-help.virtualave.net/
http://thunder.prohosting.com/~cv-elgin/


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

Date: Fri, 17 Sep 1999 19:39:25 -0700
From: "Eric Niebler" <ericne@microsoft.com>
Subject: backref problem
Message-Id: <7ruu11$ug0@news.dns.microsoft.com>

I have the following script:

$foo = 'foobar';
if( $foo =~ m/((foo)|bar)+/ ) {
    print "0=$&\n";
    print "1=$1\n";
    print "2=$2\n";
}

It prints out:
0=foobar
1=bar
2=foo

Why is $2 "foo"?  Shouldn't it be empty?  The last time ((foo)|bar) matches,
it matches "bar", so the (foo) group didn't match anything. Doesn't that
mean $2 should be empty?

I'm running ActivePerl 519 .

Thanks,
Eric
ericne@microsoft.com





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

Date: Sat, 18 Sep 1999 03:44:21 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: backref problem
Message-Id: <37E30A90.C2A66EA2@home.com>

[posted & mailed]

Eric Niebler wrote:
> 
> $foo = 'foobar';
> if( $foo =~ m/((foo)|bar)+/ ) {
[...]
> Why is $2 "foo"?  Shouldn't it be empty?  The last time ((foo)|bar) matches,
> it matches "bar", so the (foo) group didn't match anything. Doesn't that
> mean $2 should be empty?

I don't know, it seems like it might be a feature since this way you can
tell there was a foo in a sequence of foos and bars.

If you're only interested in the last match of the sequence then why
capture $2 at all?

-- 
Rick Delaney
rick.delaney@home.com


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

Date: Sat, 18 Sep 1999 11:43:20 +0800
From: "John Lin" <johnlin@chttl.com.tw>
Subject: Be careful about using constants
Message-Id: <7rv1jh$bnr@netnews.hinet.net>

Dear all,

    Perl constants don't seem to be so natural.  In this program

use strict;
use Fcntl ':flock';

print LOCK_EX,"\n";    # 2
print LOCK_NB,"\n";    # 4
print LOCK_EX+LOCK_NB,"\n";    # 2, and missing "\n"
print (LOCK_EX+LOCK_NB),"\n";    # 2, and missing "\n"
print LOCK_EX|LOCK_NB,"\n";    # 6
print (LOCK_EX)+(LOCK_NB),"\n";    # 6

if you are not careful enough you can easily make an invisible bug
because -w won't warn you.

John Lin





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

Date: 17 Sep 1999 22:16:32 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: Can Perl interface a compiled C program and a web site in HTML?
Message-Id: <slrn7u615e.1s4.abigail@alexandra.delanet.com>

Jim (jkrogerDONCHA_SPAM_ME@earthlink.net) wrote on MMCCIX September
MCMXCIII in <URL:news:jkrogerDONCHA_SPAM_ME-1709992135140001@ip58.princeton.nj.pub-ip.psi.net>:
-- I have a large C program I'd like to connect to a web site for users to execute.
-- I don't know how to start. Can I use Perl?


Yes.


Read the various manpages about embedding Perl.



Abigail
-- 
perl -MLWP::UserAgent -MHTML::TreeBuilder -MHTML::FormatText -wle'print +(
HTML::FormatText -> new -> format (HTML::TreeBuilder -> new -> parse (
LWP::UserAgent -> new -> request (HTTP::Request -> new ("GET",
"http://work.ucsd.edu:5141/cgi-bin/http_webster?isindex=perl")) -> content))
=~ /(.*\))[-\s]+Addition/s) [0]'


  -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
   http://www.newsfeeds.com       The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including  Dedicated  Binaries Servers ==-----


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

Date: 18 Sep 1999 02:44:59 GMT
From: efflandt@xnet.com (David Efflandt)
Subject: Re: cgi not working
Message-Id: <slrn7u5v5i.lq.efflandt@efflandt.xnet.com>

On Fri, 17 Sep 1999 08:31:32 GMT, soulierb@my-deja.com
<soulierb@my-deja.com> wrote:

>Question : what can I do ?
>Why my script works good on a freehosting webserver (APache server too),
>and not on mine ?
>Nota : I have other script (mail.pl or search.pl) who works realy good.
>Is this a problem with my .cgi extension ?
>
>Bertrand (France)
>soulierb@bigfo

As root type the following in the (Linux) shell, so either path works in
1st line of a script:

ln -s /usr/bin/perl /usr/local/bin/perl

-- 
David Efflandt   efflandt@xnet.com   http://www.xnet.com/~efflandt/
http://www.de-srv.com/   http://cgi-help.virtualave.net/
http://thunder.prohosting.com/~cv-elgin/


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

Date: Fri, 17 Sep 1999 22:12:28 -0400
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: Checking for Modules in Perl
Message-Id: <37E2F50C.E67DBB77@rochester.rr.com>

Craig Vincent wrote:
> 
> Is there a way to have Perl check to see if particular modules are installed
> without doing an exist check in the standard library directories?
> 
> Craig Vincent

Sure.  Just type in:

perl -Mmodulename

where "modulename" is replaced by the name of your module.  If
you get an error message, the module isn't installed.  For example:

perl -Mxxx

gives

H:\Bob\junk>perl -Mxxx
Can't locate xxx.pm in @INC (@INC contains: D:/perl/lib D:/perl/site/lib
 .).
BEGIN failed--compilation aborted.


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

Date: 18 Sep 1999 02:01:59 GMT
From: lt lindley <ltl@rgsun40.viasystems.com>
Subject: Re: CONTEST: Range Searching
Message-Id: <7rurqn$7hi$1@rguxd.viasystems.com>

In a fit of machoistic tenacity, I force-fit a kludge onto the regular
expression so that it can appear to reap the bonus points.  I tested
this a bit and it passes my tests.

Even though it doesn't meet Tom's other contest critera, I hope
it will be included in the inevitable "benchmark" comparisons 
and other "completeness" torture tests.

Also note that this solution is the only one I have seen so far that
will match a pattern that crosses line boundaries.

#!/usr/lib/lprgs/perl -w
use strict;

# Print a pattern and up to N lines of text before the pattern.
# and up to N lines after the pattern, including continuation
# of the lines printed if pattern appears in the "after" lines


# Assumptions:
# 1) the pattern can match across a line boundary!
# 2) Memory is cheap.  This is the barbarian "all memory should be free!"
#   entry.  Not some namby pamby space conservation algorithm.
#   Seriously, memory is way too cheap to worry about like we used to do.
#
# Interesting code moved to the top.  Not normally how I would have
# layed this out.

my (%opts, $USAGE);
use vars qw/$continue_match/;

my $pattern = parse_args();

# Should I assume that when the user gives a space char that they
# really mean \s and that it includes newline?  Assume so unless
# they are sophisticated enough to tell me to leave their sacred pattern
# alone.  Otherwise, I'm going to expect unsophisticated users who
# provide the string "black ice" and expect it to match when one line
# ends with "black" and the next line starts with "ice".  Therefore,
# I mangle the user supplied pattern by default.
$pattern =~ s/ +/\\s+/g unless exists $opts{S};

use re 'eval';
#$pattern = qr{
#    (
#	(?:.*\n){0,$opts{B}} 	# Match up to -B arbitrary lines
#	(?m:			# ^ and $ match on newline for this part
#		^.*		# 0 or more chars begining of this line
#		(?s-x:$pattern)	# Whatever they want to match
#				# where . and \s match newline too
#				# but space has meaning within $pattern
#				#HEY! Fix perlre to say that \s matches
#				#newline just like . does under /s!!!!
#				#That is expected, but not obvious!!!!
#		.*$		# Match to end of line containing $pattern
#	)			
#	\n			# Throw in final newline of line containing
#				# pattern -- m modifier dropped it.
#	# Give trailing lines that don't contain pattern
#	(?m:
#		(?!^.*(?s-x:$pattern).*$)
#		.*\n
#	){0,$opts{A}}  		# Well, up to -A lines anyway
#    )				# End of what is returned in $1
#
#    # Now set a flag if $pattern appears in the next line
#    (?(?=			# If pos lookahead is true
#    	(?m:			
#		^.*(?s-x:$pattern).*$
#         )
#      )			
#      (?{$continue_match = 1})	# Then set this flag for the printing function
#    )
#}xo;  

# Well, there seems to be a bug with (?s-x:), so I must get rid
# of all the readability drek.  Good luck reading it.  Or
# just take my work that is the same as above except for the "-x" stuff.
$pattern = qr{((?:.*\n){0,$opts{B}}(?m:^.*(?s:$pattern).*$)\n(?m:(?!^.*(?s:$pattern).*$).*\n){0,$opts{A}})(?(?=(?m:^.*(?s:$pattern).*$))(?{$continue_match=1}))}o;  
     
			

sub find_pattern_in_file {
	my ($fh, $file_name) = @_;
	print "\n\n$file_name --\n" if (defined $file_name);
	# Screw memory requirements.  Memory is cheap and modern books aren't
	# that long.  
	local $/;
	my $string = <$fh>;
	while ($string =~ /$pattern/g) {
		print $1;
		# If at this point in the matching, the next
		# line (or lines if the user pattern can cross line
		# boundaries) contains $pattern,
		# then don't print a separator.  Just let it continue
		# printing the lines together.
		# The $continue_match var is set in the regexp
		$continue_match ?  $continue_match = 0 : print "\n--\n" ;

		# Bug.  Get "\n--\n" after last match.
	}
}

# The rest of this just handles the argument processing and
# file manipulation.
if (@ARGV == 0) {
	if (exists $opts{D}) {
		# Specail test case
		find_pattern_in_file(\*DATA);
	} else {
		# No file name provided as an argument
		find_pattern_in_file(\*STDIN);
	}
} else {
	foreach my $file_name (@ARGV) {
		# Rather than simply using magic <ARGV> processing,
		# I want to print the file name.
		local *FH;
		open(FH, $file_name) 
			or die "Failed to open $file_name: $!\n\t$USAGE";
		find_pattern_in_file(\*FH, $file_name);
	}
}
exit 0;

sub parse_args {
$USAGE = "patfore [-A X] [-B T] [-C N] [-S] pattern [files ...| -D]
\twhere T is number of lines before pattern to display and
\twhere X is number of lines after pattern to display and
\twhere N is number of lines both before and after pattern to display
\t-S indicates a strict pattern that should not be white space pampered
\tand -D says use the testing data at the bottom of the source";

use Getopt::Std;

die $USAGE unless getopts('DSA:B:C:', \%opts);
$opts{B} = 0 unless exists $opts{B};	# Number of lines before pat to print
$opts{A} = 0 unless exists $opts{A};	# Number of lines after pat to print
$opts{B} = $opts{A} = $opts{C} if (exists $opts{C}); # Overrides both A and B
# There must be at leat one pattern arg and at least A or B must be set
die $USAGE unless (@ARGV >= 1 && ($opts{A} > 0 || $opts{B} > 0));		
shift @ARGV;				# return pattern
}
__END__
This is line 1
and line 2
and line 3
and yet a line 4
and a line 5
and 6 don't you know MATCH
and a line 7
and 8 was the last. MATCH
but now there are 9 
and yet still more is 10
insert some more here
because I needed more room
to match before and after
and too see if it really works. MATCH
-- 
// Lee.Lindley   /// Programmer shortage?  What programmer shortage?
// @bigfoot.com  ///  Only *cheap* programmers are in short supply.
////////////////////    50 cent beers are in short supply too.


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

Date: Fri, 17 Sep 1999 23:49:32 -0300
From: "Alexandre" <alrope@zaz.com.br>
Subject: HELP ! BOOTSTRAP PROBLEM ! ***
Message-Id: <7ruu9p$tgu$1@srv4-poa.zaz.com.br>

Please Programmers,

   I installed the DBD-ODBC in my system, and when a run a simple programm
appear the message:

" Install_driver(ODBC) failed: DBD::ODBC object version 0.21 does not match
bootstrap parameter
  0 at C:\Perl\5.005\lib/MSWin32-x86-object/DynaLoader.pm line 187."

  What should i make ?
  The package was installed by VMP in the Internet.

 Tanks,
Alexandre Roberto Perestrelo
alrope@zaz.com.br













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

Date: Fri, 17 Sep 1999 21:45:09 -0500
From: Frank Losasso <losasso@rice.edu>
Subject: Help me PLEASE
Message-Id: <37E2FCB4.1AF4BED5@rice.edu>

 i have done searches of my perl directory (i'm running activePerl on a
win98 system) for make.*, but there is none... in previous posts about
not finding make you have all said that the path must be set to it...
but my path was set by the installation program, and everything else
works EXCEPT for make



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

Date: 17 Sep 1999 22:21:57 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: Help on Perl/Cgi script
Message-Id: <slrn7u61fj.1s4.abigail@alexandra.delanet.com>

byuan (byuan@eee.hku.hk) wrote on MMCCIX September MCMXCIII in
<URL:news:37E2EF5F.6C3D2F68@eee.hku.hk>:
{} 
{} Perl is a new tool for me, who can tell me where I can download some
{} free Perl /CGI script so that
{} I can test it in my web server?
{} 
{} I want to build a remote server, i.e. web users can run our Fortran/C
{} application through Internet,
{} but I do not know how to write the Perl/CGI script in the server side,
{} anyone can help me?


So, why don't you write it in Fortran and or C?



Abigail
-- 
srand 123456;$-=rand$_--=>@[[$-,$_]=@[[$_,$-]for(reverse+1..(@[=split
//=>"IGrACVGQ\x02GJCWVhP\x02PL\x02jNMP"));print+(map{$_^q^"^}@[),"\n"


  -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
   http://www.newsfeeds.com       The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including  Dedicated  Binaries Servers ==-----


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

Date: 17 Sep 1999 19:04:36 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: How do I print Array of hash?
Message-Id: <m1lna5vutn.fsf@halfdome.holdit.com>

>>>>> "nation" == nation  <martyr160@yahoo.com> writes:

nation> I'm new to Perl and am completely confused on how to print the records
nation> in this type of variable.  I need to print the records in a
nation> subroutine.  Any help would be very appreciated

perldoc Data::Dumper

If that doesn't do exactly what you want, you can study the code and
see how it works.  If your data is defined recursively, it's often
best to use a recursive subroutine to dump it. :)

print "Just another Perl hacker,"

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!


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

Date: Sat, 18 Sep 1999 03:29:12 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: how to create (and ref) anonymous objects
Message-Id: <cGDE3.17791$N77.1313801@typ11.nn.bcandid.com>

In article <Pine.LNX.3.96.990917171635.15845A-100000@bettyjo.downcity.net>,
Pat Trainor  <ptrainor@bettyjo.downcity.net> wrote:
>same. How to name objects of the same class on the fly, have them all
>exist at run time, and access data from each other.

Sounds like you want a hash.  What do you mean 'access data from each
other'?  Are these OO objects with methods?

>	I am (this close) to creating the equivelent of an SQL-ish table
>in perl that exists only when the program is running.

Sounds like a hash.

>	I'd like to have multiple objects in memory at a time. Each
>'instantiation' will have multiple, same, attributes. I will not know
>ahead of time what each object's name will be, but I have the name and all
>values ready to go once the object is made.

Sounds like a hash of hashes, or a hash of arrays.

>	While still at run time I'll be loading these objects up, changing
>values in them and ultimately either releasing them or allowing perl's
>cleanup to do the trick. It is essential that one object be able to
>reference another at run time.

What does it mean for one object to reference another?  Have a method
that accesses data in another?  Have a pointer to another object?  Have
a field that contains the primary key of another object?

>	So when I said SQL-ish, I meant that one record could be compared
>to another-or in the perl case one object against another.

You want to compare to see if all fields are equal?

>	My problem so far has been the simple act of naming objects (this
>is where the 'anonymous' came in) and then retrieving the values they
>hold. Again, all objects will have the same type and amount of items they
>are string data for.

Sounds like you want a hash.  Your objects can be hashes or arrays.
-- 
<kragen@pobox.com>       Kragen Sitaker     <http://www.pobox.com/~kragen/>
Fri Sep 17 1999
52 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>


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

Date: Fri, 17 Sep 1999 22:59:51 -0400
From: Pat Trainor <ptrainor@bettyjo.downcity.net>
To: Kragen Sitaker <kragen@dnaco.net>
Subject: Re: how to create (and ref) anonymous objects
Message-Id: <Pine.LNX.3.96.990917225842.23360A-100000@bettyjo.downcity.net>

On Sat, 18 Sep 1999, Kragen Sitaker wrote:

> In article <Pine.LNX.3.96.990917171635.15845A-100000@bettyjo.downcity.net>,
> Pat Trainor  <ptrainor@bettyjo.downcity.net> wrote:
> >same. How to name objects of the same class on the fly, have them all
> >exist at run time, and access data from each other.
> 
> Sounds like you want a hash.  What do you mean 'access data from each
> other'?  Are these OO objects with methods?

	I did as you suggested and scrapped the whole initial concept.
Your big picture showed me I was barking down the wrong alley... :)



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

Date: Fri, 17 Sep 1999 23:29:31 -0400
From: "ken" <skywing@home.com>
Subject: how to create temporary cookie and destroy it
Message-Id: <7rv0ss$m4v$1@winter.news.rcn.net>

Hi:
    Can someone show me how to create a temporary cookie in perl so I can
passing the value from page to page in my website, and how to delete the
cookie from the user browser when they leaving my website. Thanks.




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

Date: Sat, 18 Sep 1999 03:00:33 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: How to test for file Perl
Message-Id: <lfDE3.17747$N77.1307127@typ11.nn.bcandid.com>

In article <37E2610D.F6495D3A@ERASEjps.net>,
Warren Bell  <resource@ERASEjps.net> wrote:
>First, What's a race condition?

It's a kind of concurrency bug.  The general definition is that when
you have two concurrent processes executing, and the results depend on
which one executes faster, you have a race condition.

In general, if you are testing to see if the file exists because you
want to do something if it does exist, but something else if it doesn't
exist, then one of 
	doing "something" when the file doesn't exist
	doing "something else" when the file does exist
is Bad, by some definition.

So what happens if, after you check the file's existence, and discover
that it does not exist, but before you do "something else", the file
gets created?  Something Bad Happens.

Likewise, if you discover it exists, but it disappears before you do
"something", Something Bad Happens.

How bad is Bad?  Dunno.  You should think about that.
-- 
<kragen@pobox.com>       Kragen Sitaker     <http://www.pobox.com/~kragen/>
Fri Sep 17 1999
52 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>


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

Date: Sat, 18 Sep 1999 02:26:24 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: Lambda calculus stuff in Perl
Message-Id: <37E2F84B.528EAFF0@home.com>

[posted & mailed]

Kragen Sitaker wrote:
> 
> # X = V + LX + AX^2

That's not the canonical form for a quadratic.

    0 = V + (L - 1)X + AX^2

> # So it's just a plain old quadratic equation; result is (-b +- 
> # sqrt(b^2- 4ac)) / 2a, or (-L +- sqrt(L^2 - 4 * A * V))/2A.  
                              ^^         ^^^
                              1-L        (L-1)^2

> # In this case, that's (-0.5 +- sqrt(0.25 - 4 * 0.2 * 0.3)/(2 * 0.2)
                          ^^^^
                          +0.5

> # Unfortunately, this comes out to -1.5 and -1, which are obviously
                                     ^^^^     ^^
                                     +1.5     +1

> # wrong.  So I made a mistake somewhere in here.

Looks like it will stop.  :-)

-- 
Rick Delaney
rick.delaney@home.com


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

Date: 17 Sep 1999 22:02:37 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: List files in a dir
Message-Id: <slrn7u60b1.1s4.abigail@alexandra.delanet.com>

Pierre-Luc Soucy (plsoucy@yahoo.com) wrote on MMCCVIII September MCMXCIII
in <URL:news:37E28AF4.8B00F534@yahoo.com>:
@@ 
@@ Anybody could tell me how to list the files in a dir and print the
@@ result in an HTML format with PERL?


perl -we 'system "Foo";'


Where `Foo' is the program in your favourite language that lists the
files in a dir and print the result in an HTML format.


Alternatively:

#!/opt/perl/bin/perl -w

use strict;

print <<HTML;
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"
    "http://www.w3.org/TR/REC-html40/strict.dtd">
<title>Files</title>
<pre>@{[`ls`]}</pre>
HTML

__END__


Abigail
-- 
echo "==== ======= ==== ======"|perl -pes/=/J/|perl -pes/==/us/|perl -pes/=/t/\
 |perl -pes/=/A/|perl -pes/=/n/|perl -pes/=/o/|perl -pes/==/th/|perl -pes/=/e/\
 |perl -pes/=/r/|perl -pes/=/P/|perl -pes/=/e/|perl -pes/==/rl/|perl -pes/=/H/\
 |perl -pes/=/a/|perl -pes/=/c/|perl -pes/=/k/|perl -pes/==/er/|perl -pes/=/./;


  -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
   http://www.newsfeeds.com       The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including  Dedicated  Binaries Servers ==-----


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

Date: 17 Sep 1999 22:07:11 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: List files in a dir
Message-Id: <slrn7u60jt.1s4.abigail@alexandra.delanet.com>

Randal L. Schwartz (merlyn@stonehenge.com) wrote on MMCCIX September
MCMXCIII in <URL:news:m1ogf1vuxd.fsf@halfdome.holdit.com>:
## >>>>> "Tom" == Tom Christiansen <tchrist@mox.perl.com> writes:
## 
## Tom>      [courtesy cc of this posting mailed to cited author]
## Tom> In comp.lang.perl.misc, plsoucy@yahoo.com writes:
## Tom> :Anybody could tell me how to list the files in a dir and print the
## Tom> :result in an HTML format with PERL?
## 
## Tom>     print "<PRE>", `ls $directory`, "</PRE>";
## 
## That's missing HTML-encoding, however.  If you want that too:
## 
## 	use HTML::Entities qw(encode_entities);
## 	print "<PRE>", map(encode_entities($_), `ls $directory`), "</PRE>";

\begin{pedantic}
Since (Unix) files names can contain characters 0x01 - 0xFF, with the
exception of a '/', there are a lot of possible characters for which
there isn't an encoding; AFAIK, Unicode doesn't have characters for
the various control characters.
\end{pedantic}



Abigail
-- 
perl -we '$@="\145\143\150\157\040\042\112\165\163\164\040\141\156\157\164".
             "\150\145\162\040\120\145\162\154\040\110\141\143\153\145\162".
             "\042\040\076\040\057\144\145\166\057\164\164\171";`$@`'


  -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
   http://www.newsfeeds.com       The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including  Dedicated  Binaries Servers ==-----


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

Date: Fri, 17 Sep 1999 20:28:28 -0500
From: Frank Losasso <losasso@rice.edu>
Subject: make in Windows 98
Message-Id: <37E2EABC.8671D11F@rice.edu>

i got activeperl and i'm running windows 98... a program i downloaded
has the following instalation instructions:



Installation:

  The usual installation strategy

    perl Makefile.PL
    make
    make test
    make install

  should produce viable modules.

  Note: Under 4Dos do not run dmake.  "command /c dmake" should work.

and i can do the perl Makefile.PL without any problems, but i can't do
the others.

can anyone help <franklosasso@yahoo.com>




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

Date: Fri, 17 Sep 1999 22:07:27 -0400
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: regexp odity with (?s-x:)
Message-Id: <37E2F3DF.46C3D253@rochester.rr.com>

lt lindley wrote:
> 
> Observe:
> 
> $pattern = 'aa|bb';
> 
> $pattern_works = qr{
>     (
>                 (?s:$pattern)
>     )}xo;
> $pattern_dont = qr{
>     (
>                 (?s-x:$pattern)
>     )}xo;
>

lt, in the pattern above, you have turned off the "x" option with
(?s-x for the rest of the pattern.  Therefore, it is going to attempt
to match the newline and tab or whatever whitespace you entered 
following the (?s-x.  You can make "$patterndont" work by removing
that whitespace, as in:

$pattern_dont = qr{
    (
                (?s-x:$pattern))}xo;
 
> print "$1 from pattern_works\n" while "ccbbdd\n" =~ /$pattern_works/g;
> print "$1 from pattern_dont\n" while "ccbbdd\n" =~ /$pattern_dont/g;
> __END__
> Try it please and let me know what you see.   pattern_dont
> gives me nothing with 5.005_03 on Solaris 2.5.1.
> 
> More straight-forward patterns work with both.
> 
> I think this is a bug.  If it is something I have misread
> in the documentation, please point me in the right direction.
> 
> --
> // Lee.Lindley   /// Programmer shortage?  What programmer shortage?
> // @bigfoot.com  ///  Only *cheap* programmers are in short supply.
> ////////////////////    50 cent beers are in short supply too.
-- 
Bob Walton


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

Date: 18 Sep 1999 02:53:08 GMT
From: lt lindley <ltl@rgsun40.viasystems.com>
Subject: Re: regexp odity with (?s-x:)
Message-Id: <7ruuqk$87n$1@rguxd.viasystems.com>

Bob Walton <bwalton@rochester.rr.com> wrote:
:>> $pattern_dont = qr{
:>>     (
:>>                 (?s-x:$pattern)
:>>     )}xo;
:>>

:>lt, in the pattern above, you have turned off the "x" option with
:>(?s-x for the rest of the pattern.  Therefore, it is going to attempt

That is not my understanding.  I think I just turned it off until
the closing paren.

:>to match the newline and tab or whatever whitespace you entered 
:>following the (?s-x.  You can make "$patterndont" work by removing
:>that whitespace, as in:

:>$pattern_dont = qr{
:>    (
:>                (?s-x:$pattern))}xo;

If you are right, then somebody should get busy on a rewrite of perlre.

EEEEKKKK!  Bob is right!  It did work.

Which is wrong?  perl or perlre?  Or am I really misreading perlre
that badly?

These lines about (?imsx-imsx):
               These modifiers are localized inside an enclosing
               group (if any).  Say,
and these about (?:imsx-imsx:pattern):
               The letters between ? and : act as flags
               modifiers, see the (?imsx-imsx) manpage.  In
               particular,

                   /(?s-i:more.*than).*million/i

               is equivalent to more verbose

                   /(?:(?s-i)more.*than).*million/i

all lead me to still believe that my expectations from the
documentation were reasonable.  Please tell me this is a bug.

-- 
// Lee.Lindley   /// Programmer shortags?  What programmer shortage?
// @bigfoot.com  ///  Only *cheap* programmers are in short supply.
////////////////////    50 cent beers are in short supply too.


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

Date: Sat, 18 Sep 1999 03:22:20 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: regexp odity with (?s-x:)
Message-Id: <37E30567.118FA46D@home.com>

[posted & mailed]

Bob Walton wrote:
> 
> lt lindley wrote:
> >
> > $pattern_dont = qr{
> >     (
> >                 (?s-x:$pattern)
> >     )}xo;
> >
> 
> lt, in the pattern above, you have turned off the "x" option with
> (?s-x for the rest of the pattern.

No, it should not apply for the rest of the pattern.  From perlre:

  These modifiers are localized inside an enclosing group (if any).

(?:) looks like an enclosing group to me.

This is a bug which has been fixed in devel perls (it is in 5005_61
anyway).

-- 
Rick Delaney
rick.delaney@home.com


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

Date: 18 Sep 1999 02:36:14 GMT
From: syran@best.com (Jim Matzdorff)
Subject: Sorting on a string, by value.
Message-Id: <37e2fa9e$0$215@nntp1.ba.best.com>

Err.. horrible title, but oh well.

I have an array that contains strings, say...

2_3_4_5.me
2_3_4_6.me
2_3_4_1.me
2_3_4_1.me2
2_3_4_1.me3
2_3_4_10.me
2_3_4_11.me
2_3_4_11.me2

ie: the format will always be #_#_#_#.(chars)#
(or in regexp terms: \d+_\d+_\d+_\d+.[A-Za-z]+[\d+])

And I want them to be sorted first by the prefix to the period, as if
they are numeric (2345, 2346, 23411, etc.) and if they are the same numerical
value, by the postfix to the period (me, me2, me3) numerically if it
contains a number, else by the string.

Well, using my advanced (not) knowledge, i figured I would have to make
a sort routine, then sort the array on that routine.  Hence I came up
with the following (below).  But there has GOT to be a better way of
doing this.  So, with the ambition of learning from it, I ask for some
better ways :).... here's my pathetic (but works) attempt:

sub diff_sort
{
        if ($a eq $b) { return 0 }
# don't wanna touch $a or $b....
        my ($parta1, $parta2) = split /\./, $a;
        my ($partb1, $partb2) = split /\./, $b;
        
        $parta1 =~ s/_//g;
        $partb1 =~ s/_//g;
        $parta2 =~ s/[A-Za-z]+(\d+)/$1/;
        $partb2 =~ s/[A-Za-z]+(\d+)/$1/;

        return ( ( $parta1 == $partb1) ? (( $parta2 > $partb2 ) ? 1 : -1) :
		(($parta1 > $partb1) ? 1 : -1 ));
}

@sorted_var =  sort diff_sort @need_2_sort;

I leave in peace :)
--jim

ps: i am always an message behind (nature of the newsgroups) but thanks
to everyone who helped me with my last question.  i really appreciate
the time it takes (even if it is a bit of fun) for the responses.  one
things I may suggest (beggars can't be chooser, i know) if you could
explain a bit more of what you are doing it would really help.  half the
time i just grab the answers cut/paste wise ... when I try to dissect
them i get completely lost.  but then again, i'll take any help i can
get.
--
--
If life is a waste of time, and time is a waste of life,
then let's all get wasted together and have the time of our lives.


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

Date: 17 Sep 1999 23:44:43 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Sorting on a string, by value.
Message-Id: <x7yae4ano4.fsf@home.sysarch.com>

>>>>> "JM" == Jim Matzdorff <syran@best.com> writes:

  JM> ie: the format will always be #_#_#_#.(chars)#
  JM> (or in regexp terms: \d+_\d+_\d+_\d+.[A-Za-z]+[\d+])
                                                    ^^^^^
that is not good regex code. do you mean just \d+ or i gather from
the data, you mean \d*.

  JM> And I want them to be sorted first by the prefix to the period, as
  JM> if they are numeric (2345, 2346, 23411, etc.) and if they are the
  JM> same numerical value, by the postfix to the period (me, me2, me3)
  JM> numerically if it contains a number, else by the string.

that makes no sense. you can't simply compare a field (the last one) by both a
number and a string. you have to define a proper ordering for all
possible cases. is any number before any string? if so, then you can
sort by that field.

  JM> Well, using my advanced (not) knowledge, i figured I would have to make
  JM> a sort routine, then sort the array on that routine.  Hence I came up
  JM> with the following (below).  But there has GOT to be a better way of
  JM> doing this.  So, with the ambition of learning from it, I ask for some
  JM> better ways :).... here's my pathetic (but works) attempt:

<snip of awful sort sub>

  JM>         $partb2 =~ s/[A-Za-z]+(\d+)/$1/;

that looks like the suffix string is never used in the compare. that
contradicts what you said earlier.


my head is in agony looking at that code. please read my paper at
http://www.sysarch.com/perl/sort-paper.html

it may help you understand how to sort things like this. but in the mean
time here is a whack at it using the ST (tested):

@out =	map $_->[0],			# get back original records
	sort {	$a->[1] <=> $b->[1]	# compare numeric prefix first
			||
		$a->[2] <=> $b->[2]	# compare numeric suffix next
			||
		$a->[3] <=> $b->[3]	# compare string suffix last
	}
	map {
		( $num1, $str, $num2 ) = /([\d_]+)\.([a-z]+)(\d*)/i ;

		$num1 =~ tr/_//d ;	# cleanup prefix number
		$num2 ||= 0 ;		# make suffix number defined

# create the anon array list for the sort sub

		[ $_, $num1, $str, $num2 ] ;

	} @in ;


i leave it as an exercise to create a packed sort version of this.

uri

-- 
Uri Guttman  -----------------  SYStems ARCHitecture and Software Engineering
uri@sysarch.com  ---------------------------  Perl, Internet, UNIX Consulting
Have Perl, Will Travel  -----------------------------  http://www.sysarch.com
The Best Search Engine on the Net -------------  http://www.northernlight.com
"F**king Windows 98", said the general in South Park before shooting Bill.


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

Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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.  

| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

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.

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 V9 Issue 838
*************************************


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