[13256] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 666 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Aug 28 02:07:29 1999

Date: Fri, 27 Aug 1999 23: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)

Perl-Users Digest           Fri, 27 Aug 1999     Volume: 9 Number: 666

Today's topics:
    Re: bizarre PERL/CGI behavior question <arunas@an!m.org>
        Can someone help PLEASE? alghazn@my-deja.com
    Re: Drop-down menu problem (David Efflandt)
    Re: Dummy question NT&Perl (elephant)
    Re: essentially; making a long file name into a 8.3 fil (Abigail)
    Re: essentially; making a long file name into a 8.3 fil (Gabor)
    Re: essentially; making a long file name into a 8.3 fil (Larry Rosler)
    Re: Find 'sendmail' with only ftp... (David Efflandt)
    Re: Graphs and Charts (T. Alex Beamish)
    Re: Open Source Perl Shell Available olefevre@my-deja.com
    Re: Oraperl bug in Oracle 8.0.5 <rereidy@uswest.net>
    Re: Pattern Matching <anmolnar@videon.wave.ca>
    Re: Perl a Black Sheep? <mpersico@erols.com>
    Re: Perl a Black Sheep? <mpersico@erols.com>
    Re: Perl.exe has an interpreted mode? (elephant)
    Re: STDIN, Arrays and Win32 (elephant)
    Re: STDIN, Arrays and Win32 (elephant)
    Re: The extent of double-quotish interpolation (Randal L. Schwartz)
    Re: The extent of double-quotish interpolation <rick.delaney@home.com>
    Re: The extent of double-quotish interpolation <tchrist@mox.perl.com>
    Re: The extent of double-quotish interpolation <rick.delaney@home.com>
    Re: The extent of double-quotish interpolation (elephant)
    Re: The extent of double-quotish interpolation (Ilya Zakharevich)
    Re: Why use Perl when we've got Python?! (Kent Polk)
        Digest Administrivia (Last modified: 1 Jul 99) (Perl-Users-Digest Admin)

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

Date: Fri, 27 Aug 1999 23:58:45 -0600
From: "Arunas Salkauskas" <arunas@an!m.org>
Subject: Re: bizarre PERL/CGI behavior question
Message-Id: <37c77aa4@news.cadvision.com>

Have you tried refreshing your cache?  On the browser?  What works for some
browsers is to hold down shift while clicking on the refresh/reload button,
I've also seen CTRL+SHIFT have a stronger effect...

I just looked again, and the page still works fine.

--
- Arunas Salkauskas
High Point Designs
www.highpointdesigns.com

rancid@best.com wrote in message <37c6eb0f.145757984@nntp.best.com>...
>On Fri, 27 Aug 1999 13:27:40 -0600, "Arunas Salkauskas"
><arunas@an!m.org> wrote:
>
>>I gather you found the problem, since Audible Deafenings was there, and
the
>>link was fine.
>>
>
>Hmm, that's interesting. It isn't showing up for me (still), but it is
>for you. That's weird.
>
>chanel
>
>>
>>rancid@best.com wrote in message <37c6cd93.138209076@nntp.best.com>...
>>>
>>>I have flat-file "database" containing record labels and the URL of
>>>their web page that consists of 3 fields delimited by the pipe
>>>character (|). The first field is for alphabetization purposes, the
>>>second field is the name of the label, and the third field is the URL.
>>>To speed lookup (users can retrieve labels by the first letter),
>>>there's another file that contains the byte location of where each
>>>chunk of the alphabet begins and for how many lines that chunk
>>>continues.
>><SNIP>
>>>You can see the lack of output in action at
>>>http://www.arancidamoeba.com/lettersearch.cgi?a
>>>Scroll down the page to where the label Audible Deafenings ought to be
>>>located.
>>>
>>>Thanks for any help you can provide! This has me scratching my head
>>>verging on pulling hair out.
>>>
>>>chanel
>>>rancid@best.com
>>
>>
>




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

Date: Sat, 28 Aug 1999 04:43:24 GMT
From: alghazn@my-deja.com
Subject: Can someone help PLEASE?
Message-Id: <7q7pdc$lpc$1@nnrp1.deja.com>

I am trying to setup a form such that depending on some input, either
scriptA.cgi is called or scriptB.cgi is called. Don't want to use
javascript.
Don't want to make scriptA&B subroutines of another script.
Thought I could write a mainscript which either calls A or B depending
on the input.
BUT HAVING PROBLEMS with the format (presumably).
For example, if I try even a test single line script, say,
testscript.cgi:
exec "scriptA.cgi?id=abc&pass=12incz&type=first";
I get a premature end of header error for TESTSCRIPT.cgi . scriptA.cgi
DOESN'T even get called.

If instead I put in the line:
exec  ("scriptA.cgi" , "qwert100", "hello", "first");
I still get the same  error.
 What doesn't give an error is:
exec  ("perl scriptA.cgi \"abc\" \"hello\" \"first\" ");
BUT the argumnets are ignored (though I think I'm doing the right thing
with @ARGV
Basically what I want is how should the arguments be added to  the call
so that the  arguments get passed correctly?
thanks for any help anyone can give!


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: 28 Aug 1999 03:12:00 GMT
From: efflandt@xnet.com (David Efflandt)
Subject: Re: Drop-down menu problem
Message-Id: <slrn7sel45.173.efflandt@efflandt.xnet.com>

On Fri, 27 Aug 1999 20:04:43 GMT, deuce25@hotmail.com
<deuce25@hotmail.com> wrote:
>...It would probably be easiest if you just took a look at
>http://www.empirewireless.com/phone_acc/batteries/audiovox/401_700m.htm
>to see what I mean.  If you look at the source code, I need the model
># to show up on the line
>...value="|orders@empirewireless.com,1,27.95,Audiovox Battery-Nimh
>700mah model ?,|"> after model. 
>
>Is this a problem in the html or the cgi script? Am I overlooking
>something totally obvious or am I just brain-dead?

I guess it is the latter, since you posted this in multiple newsgroups
without cross posting (shame on you), and since it has nothing at all to
do with Perl.  I answered this in another newsgroup, but I forget if it
was *.html or *.cgi.

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


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

Date: Sat, 28 Aug 1999 15:32:50 +1000
From: elephant@squirrelgroup.com (elephant)
Subject: Re: Dummy question NT&Perl
Message-Id: <MPG.12321f92aad3aa45989c92@news-server>

Sylvain Bissonnette writes ..
>    I'm completly lost, I install perl on my NT4.0 server with the web
>server on my perl is in
>c:\perl my web is in e:\wwwroot\myweb and my script in e:\wwwroot\scripts I
>had put
>/scripts in the virtual directory in the web server (by the way the web
>server work fine and
>i can acces the /scripts)
>
>I had wote a very simple dummy script named hello.pl
>print "hello\n";
>
>if I type in the command line of the server hello.pl and crlf that work I
>see hello.
>the permision on /sripts & hello.pl are execute & read
>
>but if I put in my web page
>http://www.microsyl.com/scripts/hello.pl I never got back the reply of
>hello,
>
>please if some one can help me I don't know where to go with this problem.

this and many other issues are covered in the Perl FAQs .. you should 
have them with your installation .. assuming that you're using the 
standard Win32 Perl you should be able to type the following command at 
the command line to see where to get help

  perldoc -q "CGI.*command line"

-- 
 jason - elephant@squirrelgroup.com -


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

Date: 27 Aug 1999 20:16:17 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: essentially; making a long file name into a 8.3 filename..
Message-Id: <slrn7see8g.tt.abigail@alexandra.delanet.com>

Jim Matzdorff (syran@best.com) wrote on MMCLXXXVIII September MCMXCIII in
<URL:news:7q7aik$rd5$1@shell18.ba.best.com>:
** 
** I want to essentially take a string that is a long filename, with any
** number of periods being replaced by "_" except for the last, all to make
** it into a 8.3 valid format.


Assuming the filename contains at least one dot:

   $filename =~ s((.*)\.(.{,3}).*)(my ($l = $1) =~ y(.)(_); "$l.$2")s;



Abigail
-- 
sub _'_{$_'_=~s/$a/$_/}map{$$_=$Z++}Y,a..z,A..X;*{($_::_=sprintf+q=%X==>"$A$Y".
"$b$r$T$u")=~s~0~O~g;map+_::_,U=>T=>L=>$Z;$_::_}=*_;sub _{print+/.*::(.*)/s}
*_'_=*{chr($b*$e)};*__=*{chr(1<<$e)};
_::_(r(e(k(c(a(H(__(l(r(e(P(__(r(e(h(t(o(n(a(__(t(us(J())))))))))))))))))))))))


  -----------== 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: 27 Aug 1999 21:38:07 -0400
From: gabor@vmunix.com (Gabor)
Subject: Re: essentially; making a long file name into a 8.3 filename..
Message-Id: <slrn7sefbu.7v6.gabor@vnode.vmunix.com>

In comp.lang.perl.misc, Jim Matzdorff <syran@best.com> wrote :
# Hello all,
# 
# I want to essentially take a string that is a long filename, with any
# number of periods being replaced by "_" except for the last, all to make
# it into a 8.3 valid format.
# 
# So, 
# 
# "thislongfile.name" -> "thislong.nam"
# 
# and
# 
# "a.long.file.description" -> "a_long_f.des"
# 
# and
# 
# "noextention" -> "noextent.ion"

I hope this is what you meant.  You could fix it up a bit, of course. ;)  But
it does work.

$_ = $ARGV[0];

@words = split /\./;
if(@words > 1) {
    $_ = substr $words[-1],0,3;
    pop @words;
    $prefix = join '_',@words;
    $_ = substr ($prefix,0,8) . '.' . $_;
}
else {
    $_ = substr $words[0],0,8;
    if(length($words[0]) > 8) {
        $_ .= '.' . substr $words[0],8,3;
    }
}
print $_,"\n";


# I've stared at my computer for a bit figuring out the way to pattern
# match and substitute, but being honest with myself, I have no clue.
# 
# I had eventually was getting to this: (well, this was my last attempt)
# $file =~ /(\w{0,8}).*(\.\w{0,3})$/;
# 
# but that doesn't do alot of things, and I was getting a bit lost and
# getting a headache.  Something tells me someone can spit it out in a
# minute so I figured I would try.  Thanks!
# 
# --jim
# 
# -- 
# --
# 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: Fri, 27 Aug 1999 20:15:46 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: essentially; making a long file name into a 8.3 filename..
Message-Id: <MPG.1230f43a9199a80a989ec0@nntp.hpl.hp.com>

In article <slrn7see8g.tt.abigail@alexandra.delanet.com> on 27 Aug 1999 
20:16:17 -0500, Abigail <abigail@delanet.com> says...
> Jim Matzdorff (syran@best.com) wrote on MMCLXXXVIII September MCMXCIII in
> <URL:news:7q7aik$rd5$1@shell18.ba.best.com>:
> ** 
> ** I want to essentially take a string that is a long filename, with any
> ** number of periods being replaced by "_" except for the last, all to make
> ** it into a 8.3 valid format.
> 
> Assuming the filename contains at least one dot:

But what about the other case:

> ** "noextention" -> "noextent.ion"
 
>    $filename =~ s((.*)\.(.{,3}).*)(my ($l = $1) =~ y(.)(_); "$l.$2")s;

I found four (4!) errors in that one-liner.  What gives?

$filename =~ s((.*)\.(.{0,3}).*)
              ((my $l = substr $1, 0, 8) =~ y(.)(_); "$l.$2")e;

1.  It doesn't match with {,3}.

2.  The 'my' has to be within the parentheses.

3.  The eight-character limit has to be added.

4.  The '/s' has to be '/e'.  No 's' needed, because for sure no 
newlines in Win/DOS filenames.

For golf, I can save a bit, but it's not as pretty.  At least it meets 
all the requirements.

$filename =~ s/(.{1,8}).*?(?:\.(.{0,3})[^.]*|(.{3}))$/
               (my $l = $1) =~ y!.!_!; "$l.$+"/e;

Maybe that should be {0,8} or {1,3}.  I don't know what the poster wants 
done with filenames with leading or trailing dots, or three characters 
with no dots.

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: 28 Aug 1999 03:29:49 GMT
From: efflandt@xnet.com (David Efflandt)
Subject: Re: Find 'sendmail' with only ftp...
Message-Id: <slrn7sem5h.173.efflandt@efflandt.xnet.com>

On 28 Aug 1999 00:42:55 GMT, Hartgeorge <hartgeorge@aol.com> wrote:
>
>I have an assignment in which I am writing a autoresponder on a unix server in
>which I only have ftp access.  The problem: I need to know where sendmail is
>located on their server to send out messages.  I asked their technical support
>folks but they had no idea what I was talking about. So I am desperate.  I do
>have the ability to write cgi programs on their server so I thought to create a
>cgi program returning an html document  that included the command -> system
>("whereis sendmail")  but this did not work.  Any ideas?

Check all possible paths to see if you can execute any of them.
Otherwise, get a different web host.  It sounds like yours is clueless.
The most common path is /usr/lib/sendmail (not in your path, so 'which' or
'type' will not find it).  If all else fails, you could grab the
Mail::Sendmail module from your favorite CPAN site.

#!/usr/local/bin/perl
# Add to this list with single quoted comma separated paths
@sendmail = (
'/usr/lib/sendmail',
'/usr/sbin/sendmail',
'/usr/bin/sendmail',
'/bin/sendmail',
);

print "Content-type: text/html\n\n",
"<HTML><HEAD><TITLE>Mail Path Test</TITLE></HEAD><BODY>\n",
"<H1>MAIL PATH TEST</H1><HR>\n";
foreach $key (@sendmail) { if (-x $key) { $sendmail = $key; last; } }
if ($sendmail) {
    print "<p>You can execute sendmail at: $sendmail\n";
} else {
    print "<p>Sendmail CANNOT be executed at any of these:<p>\n";
    foreach $key (@sendmail) { print "$key<BR>\n"; }
}

>
>Thank you
>George Hart
>hart@rohan.sdsu.edu
>San Diego 
>


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


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

Date: Sat, 28 Aug 1999 02:55:44 GMT
From: talexb@tabsoft.on.ca (T. Alex Beamish)
Subject: Re: Graphs and Charts
Message-Id: <37c74e1d.108684064@news1.on.sympatico.ca>

On Fri, 27 Aug 1999 18:52:36 GMT, Stone Cold <paulm@dirigo.com> wrote:

>How does Perl handle graphics?  I'd like to create some code that will
>1. connect to a database via DBI module 2. grab data from database and
>3. Output the data via web interface into a graph/chart using CGI.
>
>Can this be done?  Is there a module already created that I could
>call?

Paul,

Yes, it can be done. I've done it on the Carlson Online site at
www.carlsononline.com.

You connect to a database from a mod-perl script by doing something
like

  #  Connect to the database.
  my $dbhThisDatabase = DBI->connect ( database, user, password,
options );

You grab data from the database through DBI by doing something like

  #  Defined and start the query.
  $dbhThisDatabase->prepare ( query );
  $dbhThisDatabase->execute;

  #  To get a single row of data.
  $Result = $dbhThisDatabase->fetchrow_hashref;

  #  To close the connection to the database.
  $dbhThisDatabase->finish;

Actually displaying the data is a bit more detailed .. basically I
dumped the data (after some ritual massage) to a temporary file. Then
I created a command file for GnuPlot to use that refers to the
temporary data file. Then I run GnuPlot, creating a GIF (or two,
depending). Then I output a bit of HTML that refers to the GIF or GIFs
that I created.

Voila! .. grapics from a database.


No, I can't send you my scripts.


T. Alex Beamish, Principal -- TAB Software
  Toronto, Ontario -- www.tabsoft.on.ca


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

Date: Sat, 28 Aug 1999 05:47:06 GMT
From: olefevre@my-deja.com
Subject: Re: Open Source Perl Shell Available
Message-Id: <7q7t4p$o50$1@nnrp1.deja.com>

It suffers from the prb that a new shell is spawned for each
command, so it has no history, doesn't remember variables etc.
In other words it doesn't behave like a real shell; only on the
perl side is really functional.

Regards,

-- O.L.


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: Fri, 27 Aug 1999 20:06:11 -0600
From: Ron Reidy <rereidy@uswest.net>
Subject: Re: Oraperl bug in Oracle 8.0.5
Message-Id: <37C74413.FA61CE57@uswest.net>


--------------DCF91A824BFD80D5145CDE72
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

maya_ganesan@hp.com wrote:

> Hello,
>
> I have migrated my Oracle database from 7.3.3 to 8.0.2.
> There has been no change in the UNIX platform which
> is HP-UX 10.2.
>
> I encountered this unique bug in Oraperl where I cannot
> select 2 date columns using the conversion
>  format "TO_CHAR".
>
> Example, the following script will not yield any values..
>
> $lda =
> &ora_login($ENV{'ORACLE_SID'},$ENV{'ORAUSER'},
> $ENV{'ORAPASSWD'}) || die $ora_errstr;
>
> $query = "select to_char(sysdate,'MM/DD/YYYY'),
>  to_char(sysdate,'MM/DD/YYYY hh24.mi.ss')from dual";
>
> $csr = &ora_open($lda, $query) || die $ora_errstr;
>
> while (($today) = &ora_fetch($csr)) {
>
> $todays_date = $today;
> $todays_datetime = $now;
> }
>
> &ora_close($csr)        || die $ora_errstr;
>
> The above script gave no output. I canot have
>  2 "to_char" in 1 sql in oraperl with 8.0.5.
>
> For example, the following would work very well:-
>
> $lda =
> &ora_login($ENV{'ORACLE_SID'},$ENV{'ORAUSER'}
> ,$ENV{'ORAPASSWD'}) || die $ora_errstr;
>
> $query = "select sysdate,
> to_char(sysdate,'MM/DD/YYYY hh24.mi.ss') from dual";
>
> $csr = &ora_open($lda, $query) || die $ora_errstr;
>
> while (($today) = &ora_fetch($csr)){
>
> $todays_date = $today;
> $todays_datetime = $now;
>
> }
>
> &ora_close($csr)        || die $ora_errstr;
>
> So I do not understand how multiple to_char's in a SQL
> against any table (not only dual) could yield no result
> I would like to know if there are any ORAPERL drivers
>  for Oracle 8.0.5. And if available, where can I get it.
> Oracle corp was not able to help me out and you are
>  my last resort.
>
> Thank you for all your help and please reply to my email
> maya_ganesan@hp.com
> or
> mganesan@yahoo.com
>
> Regards,
> Maya Ganesan

So, what is $now and where does it get assigned?

Trye this...

#!/usr/local/bin/perl -w

use strict;

at the begining of every script.


--
Ron Reidy
Oracle DBA
Reidy Consulting, L.L.C.


--------------DCF91A824BFD80D5145CDE72
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit

<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
maya_ganesan@hp.com wrote:
<blockquote TYPE=CITE>Hello,
<p>I have migrated my Oracle database from 7.3.3 to 8.0.2.
<br>There has been no change in the UNIX platform which
<br>is HP-UX 10.2.
<p>I encountered this unique bug in Oraperl where I cannot
<br>select 2 date columns using the conversion
<br>&nbsp;format "TO_CHAR".
<p>Example, the following script will not yield any values..
<p>$lda =
<br>&amp;ora_login($ENV{'ORACLE_SID'},$ENV{'ORAUSER'},
<br>$ENV{'ORAPASSWD'}) || die $ora_errstr;
<p>$query = "select to_char(sysdate,'MM/DD/YYYY'),
<br>&nbsp;to_char(sysdate,'MM/DD/YYYY hh24.mi.ss')from dual";
<p>$csr = &amp;ora_open($lda, $query) || die $ora_errstr;
<p>while (($today) = &amp;ora_fetch($csr)) {
<p>$todays_date = $today;
<br>$todays_datetime = $now;
<br>}
<p>&amp;ora_close($csr)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; || die
$ora_errstr;
<p>The above script gave no output. I canot have
<br>&nbsp;2 "to_char" in 1 sql in oraperl with 8.0.5.
<p>For example, the following would work very well:-
<p>$lda =
<br>&amp;ora_login($ENV{'ORACLE_SID'},$ENV{'ORAUSER'}
<br>,$ENV{'ORAPASSWD'}) || die $ora_errstr;
<p>$query = "select sysdate,
<br>to_char(sysdate,'MM/DD/YYYY hh24.mi.ss') from dual";
<p>$csr = &amp;ora_open($lda, $query) || die $ora_errstr;
<p>while (($today) = &amp;ora_fetch($csr)){
<p>$todays_date = $today;
<br>$todays_datetime = $now;
<p>}
<p>&amp;ora_close($csr)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; || die
$ora_errstr;
<p>So I do not understand how multiple to_char's in a SQL
<br>against any table (not only dual) could yield no result
<br>I would like to know if there are any ORAPERL drivers
<br>&nbsp;for Oracle 8.0.5. And if available, where can I get it.
<br>Oracle corp was not able to help me out and you are
<br>&nbsp;my last resort.
<p>Thank you for all your help and please reply to my email
<br>maya_ganesan@hp.com
<br>or
<br>mganesan@yahoo.com
<p>Regards,
<br>Maya Ganesan</blockquote>

<p><br>So, what is $now and where does it get assigned?
<p>Trye this...
<p>#!/usr/local/bin/perl <b>-w</b>
<p><b>use strict;</b>
<p>at the begining of every script.
<br>&nbsp;
<p>--
<br>Ron Reidy
<br>Oracle DBA
<br>Reidy Consulting, L.L.C.
<br>&nbsp;</html>

--------------DCF91A824BFD80D5145CDE72--



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

Date: Sat, 28 Aug 1999 02:13:48 GMT
From: Andy Molnar <anmolnar@videon.wave.ca>
Subject: Re: Pattern Matching
Message-Id: <37C745AC.53611705@videon.wave.ca>

DANG! I knew about the backslash's purpose.  Why the h3ll didn't I think of
trying that???

Thanks!
Andy


Bart Lateur wrote:

> Andy Molnar wrote:
>
> >How do use pattern matching to check only the last character of a
> >string?  I'm passing a value with a period at the end, which seems to
> >screw up at the destination.  (Such as "Washington D.C.").
>
> It's not the fact that it's the last character that matters. It's the
> fact that the dot is a special character for regexes, AKA "meta
> characters". The dot means "any character but a newline".
>
> There's a special function, called "quotemeta", which makes all
> contained meta characters harmless. It does this by putting a backslash
> in front of them. A backslash means "take the next character literally",
> except when it's a digit or a letter in regexes; but digits and letters
> cannot be meta characters, so that's allright. On the contrary: a
> backslash followed by a letter and or a digit is special in regexes.
>
> You can even use the quotemeta() mechaism directly inside a regex, by
> including "\Q" (quotemeta) before, and "\E" (end ) after your included
> pattern (which may contain variables). An example:
>
>         $_ = "your text here";
>         $pattern = "Washington D.C.";
>         if(/\Q$pattern\E/) {
>                 print "Found Washington!\n";
>         } else {
>                 print "Nope.\n";
>         }
>
>
> Oh, and if you still want to check the final character on the line
> (ignoring an optional terminating newline), use "$", which means "end of
> string".
>
>         if($pattern =~ /\.$/) {
>                 print "The pattern \"$pattern\" ends with a dot.\n";
>         }
>
>    HTH,
>    Bart.



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

Date: Fri, 27 Aug 1999 22:48:09 -0400
From: "Matthew O. Persico" <mpersico@erols.com>
Subject: Re: Perl a Black Sheep?
Message-Id: <37C74DE9.30B09AEE@erols.com>

The Glauber wrote:

<snip>

> Perl also inherits from C the possibility to write "read only" programs
> that nobody else can understand. This is a problem with the programmer,
> not with the language.

Um, wouldn't that make it a 'write only' language?

> 
> Do yourself (and us) a favor and "use strict", comment your programs
> and include POD documentation in anything you install in a production
> environment.

Bingo. I have one nasty narly five liner that opens up a directory and uses
two greps, two maps and a sort to transform the contents into a hash I use
to figure out what to print and in what order. I don't even want to think
about how long the corresponding 'C' code would be.

But this narly five liner is preceded by a five paragraph comment that
explains what it does. The comment probably runs 30 lines.

One of my fellow workers sniffed and said that it was stupid to do such a
thing - write the code clearer. I reminded him that the comments are not
executed and showed him how fast the five-liner was. :-)
> 
> glauber
> --
> Glauber Ribeiro
> theglauber@my-deja.com
> 
> Sent via Deja.com http://www.deja.com/
> Share what you know. Learn what you don't.


-- 
Matthew O. Persico
    
You'll have to pry my Emacs from my cold dead oversized
   control-pressing left pinky finger. -- Randal L. Schwartz


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

Date: Fri, 27 Aug 1999 22:56:12 -0400
From: "Matthew O. Persico" <mpersico@erols.com>
Subject: Re: Perl a Black Sheep?
Message-Id: <37C74FCC.84B2420E@erols.com>

Ala Qumsieh wrote:
> 
<snip>
> 
> There is a problem with some of the "older" programmers. They learnt C
> (or some other useful language), and are comfortable with it although
> programming simple things with it (like opening files, and
> manipulating their contents) can be a real pain in the ass. They
> refuse to accept that a younger person knows how to do that in one
> line of Perl (which does the job much more efficiently in most
> cases). They don't want to evolve and admit that their expertise is
> out-dated. Or perhaps they don't really know what Perl can do, and
> need someone to show them. Moreover, being open-source, Perl scares
> them because they think that it's full of bugs, and no support is
> offered. Of course these people are completely in the dark (hint:
> Linux usage is growing at a much faster rate than all other OS's
> combined. Apache serves more than 60% of the web).

It's got nothing to do with age per-se. I'm 34. I've been doing 'C' since
17. I've been doing Perl since 33. Guess which one I love more (clue: this
is comp.lang.PERL.misc). It has to do with open-mindedness though,
admittedly, older does tend to be less open minded. It has more to do with
whether you are a programmer/coder versus scientist/hacker. The former
applies lessons in college to problem at hand and goes home at 5. The
latter tinker till 3am with code just for kicks. The former see no reason
to change. For the latter is it  raison-d'atre.

-- 
Matthew O. Persico
    
You'll have to pry my Emacs from my cold dead oversized
   control-pressing left pinky finger. -- Randal L. Schwartz


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

Date: Sat, 28 Aug 1999 15:23:39 +1000
From: elephant@squirrelgroup.com (elephant)
Subject: Re: Perl.exe has an interpreted mode?
Message-Id: <MPG.12321d6749230d46989c91@news-server>

revjack writes ..
>Martien Verbruggen explains it all:
>:In article <7q528s$t6a$1@news1.radix.net>,
>:	revjack <revjack@radix.net> writes:
>:> I noted that "perl.exe" was cited, and MS software was used to post the
>:> article, so I presumed an MS OS. Ctrl-Z exits perl.exe on those systems
>:> without running the program; Ctrl-D submits the program and runs it.
>
>:On NT both ^D and ^Z will end the input for perl, but they do need to
>:be followed by a return, which is slightly unnatural behaviour. ^Z is
>:the normal EOF for NT and other MS products. I suspect the allowance
>:of ^D and ^Z both is programmed as opposed to a shell thing. But I
>:might be wrong.
>
>That's true for NT, thank you for the clarification.
>
>Under Win98, ^D runs the input, ^Z exits without running.
>
>I don't know what happens under Win95.
>
>I recommend that users of any Windows-based perl use ^D.

oh god - here we go .. don't tell me they've changed it in Windows98

I'm on WinNT v4.0 SP4 .. using cmd.exe .. here's a copy-paste of a 
session .. this supports my statement that ^Z (at least on NT .. I'm 
almost certain on Win95 .. no idea on Win98) is the EOF character .. the 
only reason that ^D works below is because Perl is clever (or stupid - 
depending on your perspective)

you'll see me run the Perl interpreter ending the script with ^Z and ^D 
and both times the script runs .. then you'll see me use a standard 
shell command (copy) to show that NT's command shell doesn't think that 
^D is an EOF character (see the '?' output in the first 'type' - that's 
the ^D control character) .. but it does think that ^Z is

C:\>perl
print "test123\n";
^Z
test123

C:\>perl
print "test456\n";
^D
test456

C:\>copy con test.txt
abc
def
^D
^Z
        1 file(s) copied.

C:\>type test.txt
abc
def
?

C:\>copy con test.txt
abc
def
^Z
        1 file(s) copied.

C:\>type test.txt
abc
def

C:\>

-- 
 jason - elephant@squirrelgroup.com -


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

Date: Sat, 28 Aug 1999 15:36:01 +1000
From: elephant@squirrelgroup.com (elephant)
Subject: Re: STDIN, Arrays and Win32
Message-Id: <MPG.123220482d966efc989c93@news-server>

mfergus98@hotmail.com writes ..
>I'm a newbie...
>
>How do you end an array using STDIN in Win32?  I've tried both CTRL-D
>and CTRL-Z, but neither have worked correctly.

so specific in your problem details .. the following works with ^Z and 
taking STDIN into an array .. this was on WinNT (apparently there are 
some differences between EOF characters in NT and Win98 .. possibly 
Win95 as well)

C:\>copy con x.pl
#!perl -w
use strict;

my @a = <STDIN>;

print ":: $_" for @a;
__END__
^Z
        1 file(s) copied.

C:\>perl x.pl
abc
def
ghi
^Z
:: abc
:: def
:: ghi

C:\>

-- 
 jason - elephant@squirrelgroup.com -


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

Date: Sat, 28 Aug 1999 15:43:12 +1000
From: elephant@squirrelgroup.com (elephant)
Subject: Re: STDIN, Arrays and Win32
Message-Id: <MPG.123221ffeb697dad989c94@news-server>

I should add a small note to my post that occurred to me after posting

elephant writes ..
>C:\>copy con x.pl
>#!perl -w
>use strict;
>
>my @a = <STDIN>;
>
>print ":: $_" for @a;
>__END__
>^Z

after the ^Z you have to hit enter on WinNT and Win95 (again - I'm not 
making any statements about Win98 until I get it up and running and can 
test some of these things out)

-- 
 jason - elephant@squirrelgroup.com -


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

Date: 27 Aug 1999 18:53:13 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: The extent of double-quotish interpolation
Message-Id: <m1so54fz7a.fsf@halfdome.holdit.com>

>>>>> "M" == M J T Guy <mjtg@cus.cam.ac.uk> writes:

M> That's exactly the answer I would have given, if Randal hadn't got there
M> first (or rather, with the qualification "scalar or array variables").
M> But it also caused me to predict the last example incorrectly:

M>        print "@a[2..$f->()]";

M> That isn't a variable.  It's a list of variables.  So it seems like
M> some fudging is needed.

It's not.  It's a slice (closer to an "array" than "list").  It's like
@a[3..5].

	@a[2..$f->()] = (13..19);

It fits on the left of an equals, so it's more of a "variable" than
an "expression", and therefore can be interpolated.

Again, the rule isn't perfect, but gets you 90% of the answer
correctly.

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, 28 Aug 1999 02:58:47 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: The extent of double-quotish interpolation
Message-Id: <37C75050.64FED25B@home.com>

[posted & mailed]

Randal L. Schwartz wrote:
> 
> >>>>> "M" == M J T Guy <mjtg@cus.cam.ac.uk> writes:
> 
> M>        print "@a[2..$f->()]";
> 
> M> That isn't a variable.  It's a list of variables.  So it seems like
> M> some fudging is needed.
> 
> It's not.  It's a slice (closer to an "array" than "list").  It's like
> @a[3..5].

Which is much closer to a "list" than an "array".


>         @a[2..$f->()] = (13..19);
> 
> It fits on the left of an equals, so it's more of a "variable" than
> an "expression", and therefore can be interpolated.

True, but a list of variables fits quite nicely on the left of an
equals.

($An, $array, $slice) = qw(not an array);

> Again, the rule isn't perfect, but gets you 90% of the answer
> correctly.

Okay, but let's not confuse the *other* rules by saying a slice is
closer to an "array" than a "list" when it's not.

($\, $,) = ("\n", ' ');
@a = qw(A slice is not an array);
print @a;
print @a[3..5];
print scalar(@a);
print scalar(@a[3..5]);
print \@a;
print \@a[3..5];
__END__
A slice is not an array
not an array
6
array
ARRAY(0x80da368)
SCALAR(0x80ddc80) SCALAR(0x80ddc8c) SCALAR(0x80ddcf8)

-- 
Rick Delaney
rick.delaney@home.com


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

Date: 27 Aug 1999 21:31:16 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: The extent of double-quotish interpolation
Message-Id: <37c75804@cs.colorado.edu>

     [courtesy cc of this posting mailed to cited author]

In comp.lang.perl.misc, 
    Rick Delaney <rick.delaney@home.com> writes:
:Okay, but let's not confuse the *other* rules by saying a slice is
:closer to an "array" than a "list" when it's not.

Of course it's not.  Don't be ridiculous.  A slice is a list, not an
array.  And there's no "closer to" involved here.  It's amazing what
people who only know a little Perl will say.  Sigh.  

  % man perldata
  ...

  Slices

    A common way access an array or a hash is one scalar element
    at a time. You can also subscript a list to get a single
    element from it.

        $whoami = $ENV{"USER"};             # one element from the hash
        $parent = $ISA[0];                  # one element from the array
        $dir    = (getpwnam("daemon"))[7];  # likewise, but with list

    A slice accesses several elements of a list, an array, or a
    hash simultaneously using a list of subscripts. It's a more
    convenient that writing out the individual elements as a list
    of separate scalar values.

        ($him, $her)   = @folks[0,-1];              # array slice
        @them          = @folks[0 .. 3];            # array slice
        ($who, $home)  = @ENV{"USER", "HOME"};      # hash slice
        ($uid, $dir)   = (getpwnam("daemon"))[2,7]; # list slice

    Since you can assign to a list of variables, you can also
    assign to an array or hash slice.

        @days[3..5]    = qw/Wed Thu Fri/;
        @colors{'red','blue','green'} 
                       = (0xff0000, 0x0000ff, 0x00ff00);
        @folks[0, -1]  = @folks[-1, 0];

    The previous assignments are exactly equivalent to

        ($days[3], $days[4], $days[5]) = qw/Wed Thu Fri/;
        ($colors{'red'}, $colors{'blue'}, $colors{'green'})
                       = (0xff0000, 0x0000ff, 0x00ff00);
        ($folks[0], $folks[-1]) = ($folks[0], $folks[-1]);

    Since changing a slice changes the original array or hash that
    it's slicing, a `foreach' construct will alter through some--
    or even all--of the values of the array or hash.

        foreach (@array[ 4 .. 10 ]) { s/peter/paul/ } 

        foreach (@hash{keys %hash}) {
            s/^\s+//;           # trim leading whitespace
            s/\s+$//;           # trim trailing whitespace
            s/(\w+)/\u\L$1/g;   # "titlecase" words
        }

    You couldn't just loop through `values %hash' to do this
    because that function produces a new list which is a copy of
    the values, so changing them doesn't change the original.

    As a special rule, if a list slice would produce a list
    consisting entirely of undefined values, the null list is
    produced instead. This makes it easy to write loops that
    terminate when a null list is returned:

        while ( ($home, $user) = (getpwent)[7,0]) {
            printf "%-8s %s\n", $user, $home;
        }

    As noted earlier in this document, the scalar sense of list
    assignment is the number of elements on the right-hand side of
    the assignment. The null list contains no elements, so when
    the password file is exhausted, the result is 0, not 2.

    If you're confused about why you use an '@' there on a hash
    slice instead of a '%', think of it like this. The type of
    bracket (square or curly) governs whether it's an array or a
    hash being looked at. On the other hand, the leading symbol
    ('$' or '@') on the array or hash indicates whether you are
    getting back a singular value (a scalar) or a plural one (a
    list).

-- 
"I know of no country in which there is so little independence of mind and 
 real freedom of discussion as in America." 
				- Alexis de Toqueville


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

Date: Sat, 28 Aug 1999 04:29:04 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: The extent of double-quotish interpolation
Message-Id: <37C7657C.31EBBD3@home.com>

[posted & mailed]

Tom Christiansen wrote:
> 
>   % man perldata
>   ...
> 
>   Slices

Thanks for this addition.  This is much more comprehensive than my copy.

[snip]
 
>     As a special rule, if a list slice would produce a list
>     consisting entirely of undefined values, the null list is
>     produced instead. This makes it easy to write loops that
>     terminate when a null list is returned:
> 
>         while ( ($home, $user) = (getpwent)[7,0]) {
>             printf "%-8s %s\n", $user, $home;
>         }

I see this addition is still in there (you first showed it to me when I
sent a bug report about this).  Do we really want to set this behaviour
in stone so it can never be changed?

I can see the use for it in your example, though it wouldn't be a big
deal to code that as:

    while ( @ent = getpwent) {
        ($home, $user) = @ent[7,0];
        printf "%-8s %s\n", $user, $home;
    }

I think for a list slice to act so differently from an array slice can
only lead to more gotchas.  What about code like this (or something more
complicated)?

@x = ($def1, $undef1, $undef2, $def2)[1,2];
@y = (0, @x, 3);
print "$y[3]\n";# uninitialize value warning--gotcha!

It seems like the intention in your example is really to return a null
list when taking a slice of a null list, NOT a slice of undefs.  Or does
getpwent really return a list of undefs instead of a null list when it
runs out of entries?

I'd prefer to see slices of null lists return null lists
and slices of lists of undefs return lists of undefs.

If you agree with me, can you change this part of perdata to reflect
this (or remove this section entirely until Perl actually does this)?

If you don't agree, why not?

-- 
Rick Delaney
rick.delaney@home.com


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

Date: Sat, 28 Aug 1999 15:12:49 +1000
From: elephant@squirrelgroup.com (elephant)
Subject: Re: The extent of double-quotish interpolation
Message-Id: <MPG.12321ae0e36f186989c90@news-server>

Anno Siegel writes ..
>David Cassell  <cassell@mail.cor.epa.gov> wrote in comp.lang.perl.misc:
>>elephant wrote:
>>> 
>>> David Cassell writes ..
>>> >elephant wrote:
>>> >[a nice, long, interesting discussion, followed by:]
>>> >> you're right there .. the doco seems to be quite sparse on this topic
>>> >
>>> >Well, you just wrote a good explication.  Why don't you submit
>>> >it, so it can go into the docs somewhere, in the near future?
>>> >
>>> >Perhaps it's more suitable for one of the FMTEYEWTK series...
>>> 
>>> why ? .. because I don't know that it's true .. I just guessed .. I
>>> don't think I could say absolutely unless I knew the Perl source -
>>> and I don't like looking at the Perl source code (a lot of Larry's
>>> comments make me nervous *8^) and I'm sure I wouldn't understand it if I
>>> did
>>
>>Perhaps.  But your list of examples with discussion seems
>>to provide a clear set of working examples for a beginner
>>to use while building his/her intuition.  I think it could 
>>be an asset to have those somewhere in the docs or references,
>>even if it's a file at your website people can point others
>>to.
>
>I agree.  The issue is murky and the original list has fooled me
>and others in various places.  Just the examples with results and,
>where necessary, an explanation what happened (not why it had to
>happen, leave that to the rtfsource folks) would find a branch in
>the document tree to roost on.
>
>We're lucky to have MTOWTDI, and probably string interpolation should
>generally be avoided, except for the most straightforward cases.  Come
>to think of it, I rarely see it used in good code outside print's and
>maybe building up of file names.

ok .. bowing to the weight of public pressure .. I will put something up 
within the week regarding this issue

at the very least it will make me feel like a contributing member of the 
wider Perl community *8^)

-- 
 jason - elephant@squirrelgroup.com -


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

Date: 28 Aug 1999 05:27:13 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: The extent of double-quotish interpolation
Message-Id: <7q7rvh$brh$1@charm.magnus.acs.ohio-state.edu>

[A complimentary Cc of this posting was sent to Rick Delaney 
<rick.delaney@home.com>],
who wrote in article <37C7657C.31EBBD3@home.com>:
> >     As a special rule, if a list slice would produce a list
> >     consisting entirely of undefined values, the null list is
> >     produced instead. This makes it easy to write loops that
> >     terminate when a null list is returned:
> > 
> >         while ( ($home, $user) = (getpwent)[7,0]) {
> >             printf "%-8s %s\n", $user, $home;
> >         }
> 
> I see this addition is still in there (you first showed it to me when I
> sent a bug report about this).  Do we really want to set this behaviour
> in stone so it can never be changed?

If I remember the discussion on p5p correctly, this feature was added
per Tim's request.  Later Tim agreed that this was not used as he
wanted, and there was a better alternative to this ugly hack.

I Cc to p5p to clarify things.

Ilya


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

Date: 27 Aug 1999 23:04:47 GMT
From: kent@tiamat.goathill.org (Kent Polk)
Subject: Re: Why use Perl when we've got Python?!
Message-Id: <935793922.672565@fezzik.endicor.com>

On Fri, 27 Aug 1999 15:33:04 +1000, Factory wrote:
>
>  Hmm that might be a bit off, the anchient Greeks had no concept of 
>variables, thus you would never see f(x)= 2y in any old greek 
>mathematics. IIRC variables were discovered(?) by Al-Jabar sometime 
>after.

I believe you are thinking of Al'Khwarizmi, who wrote the book
"Hisab al-jabr w'al-muqabala". 'Algebra' came from 'al-jabr' and
'Algorithm' came from the name Al'Khwarizmi. Later Greeks certainly
appear to have used the concept of variables, but did have not the
algebraic notation.



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

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

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" from
almanac@ruby.oce.orst.edu. The real FAQ, as it appeared last in the
newsgroup, can be retrieved with the request "send perl-users FAQ" from
almanac@ruby.oce.orst.edu. 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" from
almanac@ruby.oce.orst.edu. 

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


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