[13477] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 887 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Sep 23 12:07:31 1999

Date: Thu, 23 Sep 1999 09:05:10 -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: <938102710-v9-i887@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Thu, 23 Sep 1999     Volume: 9 Number: 887

Today's topics:
        100 levels deep - in debugger (David R. Throop)
    Re: ActivePerl on Windows95 HELP <qianyin@singnet.com.sg>
    Re: ActivePerl on Windows95 HELP <gellyfish@gellyfish.com>
        CGI sending email with attachment <BurtHwangSPAMSUCKS@SPAMSUCKS.ufsltd.com>
    Re: CGI sending email with attachment <gellyfish@gellyfish.com>
    Re: Comparing lines in two files using arrays. (Kragen Sitaker)
    Re: Comparing lines in two files using arrays. (Larry Rosler)
    Re: Grouping in REs, no doc found <rhomberg@ife.ee.ethz.ch>
    Re: How to validate a URL? <rootbeer@redcat.com>
        HTTP file upload on NT problem <warddc@cat.com>
    Re: image upload using form (JeffM)
        injecting "my" varibales into caller's scope <pjl@be-NOSPAM-st.com>
    Re: injecting "my" varibales into caller's scope <gellyfish@gellyfish.com>
        New trolling strategy ? c_j_marshall@hotmail.com
        pattern matching options cleat@umich.edu
    Re: pattern matching options (Kragen Sitaker)
    Re: pattern matching options (Larry Rosler)
    Re: Perl - CGI -MySQL c_j_marshall@hotmail.com
    Re: Perl Script Within VB for Web Pages <alain.borgo@ratp.fr>
    Re: Perl/CGI and counter questions <amonotod@netscape.net>
        Pre-release Perl Beta-Testers <examtesting@recruitsource.com>
    Re: proper 'my' usage <espen@nextel.no>
    Re: proper 'my' usage <marty@catnmoose.com>
    Re: proper 'my' usage (Kragen Sitaker)
        Substitution fails intermittently drew3966@my-deja.com
    Re: toLowercase?? (Randal L. Schwartz)
    Re: toLowercase?? (Larry Rosler)
    Re: You should be admired <gellyfish@gellyfish.com>
    Re: You should be admired (Kragen Sitaker)
    Re: You should be admired <mike@crusaders.no>
    Re: You should be admired (Henry Penninkilampi)
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: 23 Sep 1999 10:27:44 -0500
From: throop@cs.utexas.edu (David R. Throop)
Subject: 100 levels deep - in debugger
Message-Id: <7sdgtg$146$1@cascade.cs.utexas.edu>

I'm trying to debug a large Perl program.  The debugger version is:
  Loading DB routines from perl5db.pl version 1.01

The program is breaking on my 'clist' function with the message

    100 levels deep in subroutine calls!



Thing is, 'T' shows me only to be 10 levels deep, and clist is not a
recursive function.  (Levels 4 thru 6 of those 10 levels are from a
function calling itself recursively, though, if it matters.)

The expression that calls clist is of the form
  if(&clist($arg1) and &clist($arg2) and ... and &clist($arg12)){...}

Is the debugger adding some overhead with all these and'ed function
calls?  Any ideas about the right way to tackle this?

David Throop



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

Date: Thu, 23 Sep 1999 23:29:31 +0800
From: qian yin <qianyin@singnet.com.sg>
Subject: Re: ActivePerl on Windows95 HELP
Message-Id: <37EA475B.8D3AC8FB@singnet.com.sg>

Hi
I am a new Perl user, I try ActivePerl on my NT workstation and get the
same problem as Daniel. The results seem only send to a MS-DOS window and
not send back to my browser. The fact is the script has been executed since
the job of opening and writting to a file have been done.
So please help me if you know how to solve it.
My e-mail address is: qianyin@hotmail.com

Regards,

Qian Yin
--------------

Daniel wrote:

> Hello,
>
> I just now installed ActivePerl build 519 on my Windows95 Computer. I
> wrote this file "readarticlecgi.pl":
>
> *************************************************
>
> #!/usr/bin/perl
> print "Content-type: text/html\n\n";
> print "<HTML>\n<BODY BGCOLOR=\"#FFFFFF\">\n\n";
>
> open(ARTICLE1,"article1.txt");
> while (<ARTICLE1>)
> {
>    print;
> }
> close (ARTICLE1);
> print "</BODY>\n";
> print "</HTML>";
>
> *************************************************
>
> With my Netscape Browser I loaded it with File/Open Page (Ctrl+O) and I
> just see an MS-DOS window, which shows quickly my "article1.txt" !
>
> What is wrong ? I thought see my file (article1.txt) in my Netscape
> Browser.
>
> Thank you for any help
>
> My e-mail is Daniel.LaMarra.at.unige.ch
> (replace .at. by @, this is to avoid spam)
>
> Regards Daniel.





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

Date: 23 Sep 1999 16:42:13 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: ActivePerl on Windows95 HELP
Message-Id: <37ea4a55_1@newsread3.dircon.co.uk>

qian yin <qianyin@singnet.com.sg> wrote:
> Hi
> I am a new Perl user, I try ActivePerl on my NT workstation and get the
> same problem as Daniel. The results seem only send to a MS-DOS window and
> not send back to my browser. The fact is the script has been executed since
> the job of opening and writting to a file have been done.
> So please help me if you know how to solve it.
> 

yes and as I said to in response to Daniels post this is a question 
about Web Servers please ask in comp.infosystems.www.servers.ms-windows.

/J\
-- 
"People say money brings its own problems. Rubbish, rubbish - I'm loaded -
it's fantastic" -


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

Date: Thu, 23 Sep 1999 11:21:36 -0400
From: "Burt Hwang" <BurtHwangSPAMSUCKS@SPAMSUCKS.ufsltd.com>
Subject: CGI sending email with attachment
Message-Id: <QzrG3.33$RA1.1835@client>

Hi,

I have no clue why I can't receive attachments correctly with my email
program.  I'll get the attachment, but when I open it, it looks nothing like
when I sent it.


Here's my code:
  open (MAIL, "|/usr/sbin/sendmail -t") || die "Cannot send mail\n";
  print MAIL "To:$emailto\n";
  print MAIL "From:$emailfromName <$emailfrom>\n";
  print MAIL "Subject: Proofreadme.com - job #XXXXXXX\n";
  print MAIL "MIME-Version: 1.0\n";
  print MAIL "Content-Type: multipart/mixed; boundary=\"gc0y0pkb9ex\"\n";
  print MAIL "\n--gc0y0pkb9ex\n";
  print MAIL "Content-Type: text/plain;\n
charset=us-ascii\nContent-Transfer-Encoding: 7bit\n\n";

  print MAIL "Hello Everyone!!!  This is a test.\n";
  print MAIL "\n--gc0y0pkb9ex\n";
  print MAIL "Content-Type: application/msword;\n name=\"$filename\"\n";
  print MAIL "Content-Disposition: attachment;\n
filename=\"$filename\"\nContent-Transfer-Encoding: base64\n";
  open (FILE_FP, "DATA/attachedFile.doc");
  while (<FILE_FP>){
    print MAIL $_;
  }
  close FILE_FP;
  print MAIL "\n--gc0y0pkb9ex\n";
  close MAIL;




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

Date: 23 Sep 1999 16:36:13 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: CGI sending email with attachment
Message-Id: <37ea48ed_1@newsread3.dircon.co.uk>

Burt Hwang <BurtHwangSPAMSUCKS@SPAMSUCKS.ufsltd.com> wrote:
> 
> 
>   print MAIL "Content-Type: multipart/mixed; boundary=\"gc0y0pkb9ex\"\n";

In the rest of the output you are using a different boundary.  If you dont
understand what you are doing with this code then I would recommend
that you use the module MIME::Lite available from CPAN.

/J\
-- 
"When the boys in the playground found out that I had a potentially
fatal peanut alergy they would shove me up against a wall and make me
play Russian roulette with a bag of Revels" - Milton Jones


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

Date: Thu, 23 Sep 1999 15:26:10 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: Comparing lines in two files using arrays.
Message-Id: <mErG3.5851$QJ.356383@typ11.nn.bcandid.com>

In article <7sdf7d$6vq$1@bmerhc5e.ca.nortel.com>,
WyneGum <keithcp@hotmail.com> wrote:
>The code for this is below.
>Can you tell me why it doesn't work, ie. no match comes cack even though I
>know that there are matches in the two files:

What defines a 'match'?  The two lines have identical contents, one of
them contains the other, or something more complex?

>#!/usr/bin/perl -w
>
>open (FILE1,"/path_to_file1");
>open (FILE2, "/path_to_file2");
>@file2= <FILE2>;
>while (<FILE1>) {
>      $line_file1 = $_;
>      chomp;
>      grep(/$line_file1/, @file2);
> }

Well, you're throwing away the result of the grep; maybe that's why?
Did you want to print it?

If I were doing it, I'd do it like this:
#!/usr/bin/perl -w
use strict;
open DICTIONARY, "/usr/dict/words" or die "Can't open /usr/dict/words: $!\n";
open FILE, "filename" or die "Can't open filename: $!\n";
my %dict;
$dict{$_} = 1 while <DICTIONARY>;
while (<FILE>) {
	print if $dict{$_};
}

This only gets exact matches, unlike your solution, but maybe that's
what you want.  It also runs much, much faster if both files are more
than a few lines long.

HTH.
-- 
<kragen@pobox.com>       Kragen Sitaker     <http://www.pobox.com/~kragen/>
Thu Sep 23 1999
46 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>


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

Date: Thu, 23 Sep 1999 08:23:39 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Comparing lines in two files using arrays.
Message-Id: <MPG.1253e5da8b30d715989fc5@nntp.hpl.hp.com>

In article <7sdajj$3n3$1@bmerhc5e.ca.nortel.com> on Thu, 23 Sep 1999 
09:43:39 -0400, WyneGum <keithcp@hotmail.com> says...
> Could anyone tell me the best way to compare one line from one file with
> every line from another file, (each line in each file consists of only one
> word).

Not necessarily anyone, but many of us could tell you.

> Would it be best to use nested while loops and read the data in from two
> arrays, or a foreach inside of a while loop.

No and no.

> Or, am I trying the hard way and there is a much easier way?

Yes and yes.

Read perlfaq4: "How can I tell whether a list or array contains a 
certain element?" and the next few entries in the FAQ.

> Thanks in advance.

You're welcome.

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


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

Date: Thu, 23 Sep 1999 17:46:03 +0200
From: Alex Rhomberg <rhomberg@ife.ee.ethz.ch>
Subject: Re: Grouping in REs, no doc found
Message-Id: <37EA4B3B.8517D624@ife.ee.ethz.ch>

lt lindley wrote:

> :>I didn't find the info that nested groups map to $<digit> in the order
> :>that parentheses open.
> 
> perlre says
> 
> Subpatterns are numbered based on the left to right order of their
> opening parenthesis.

This is correct, it is my fault that I didn't find it. Thank you for
pointing this out

> :>I didn't find info about what happens when a group is followed by a
> :>quantifier *?+{}
> 
> That is silly.  There is a huge amount of info about this subject in
> perlre.  You just haven't read it carefully enough.

Can you point me to it? I'm sorry, I again didn't find it.

> :>The following questions came up:
> :>- Is there some information about this?
> :>- If there isn't, what can I do to update one of the manpages mentioned
> :>above?
> 
> perlre and perlop are very large complex documents, but they cover a
> very large complex subject.  If you can write them more clearly, then
> go for it.  But I think it is going to be a while before you are up
> to the task.

I don't want to rewrite it. IMHO something along the following lines is
missing from perlre:

<PROPOSED DOC TEXT>
If a subpattern in parentheses is followed by a quantifier ?*+{}, the
value stored in the corresponding \<digit> or $<digit> is the last match
of the subpattern (the empty string if the subpattern didn't match).
Examples:
"12343" =~ /((\d)+).+\2/  # $1 = 123, $2 = 3
"1234" =~ /(\s)*/  # $1 is the empty string
</PROPOSED DOC TEXT>

if this is really missing from the documentation, it would be good to
include it. I don't know what to do about it.

> :>- What can I do to get the desired result? (Meaning every \d as an
> :>element in @x)
> 
> Assuming your English requirement statement is complete:
> 
> my @x = /(\d)/g;

btw, you don't need the () here :-)

It should only take the digits anchored at the beginning of the string,
like
@x = split //, (/^(\d+)/)[0]; #this does the trick

- Alex


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

Date: Thu, 23 Sep 1999 08:58:55 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: How to validate a URL?
Message-Id: <Pine.GSO.4.10.9909230848480.26916-100000@user2.teleport.com>

On Wed, 22 Sep 1999, Paul Carter wrote:

> But, I want to make sure that they enter a valid e-mail address 

See the FAQ, already!

> and a valid URL for their site.

Use LWP::Simple. 

> So, for the e-mail address.. it's pretty much valid if it doesn't contain
>  .@.
>  ..
>  ,
>  )
>  &
>  ?
>  >
>  " "  (space)

Have you written to Fred and Barney yet? Try it and see for yourself!

    <"fred and barney"(.@.&?<b>valid!</b>.@,,)@redcat.com>

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Thu, 23 Sep 1999 10:46:30 -0500
From: Daniel Ward <warddc@cat.com>
Subject: HTTP file upload on NT problem
Message-Id: <37EA4B56.7DC7C0B5@cat.com>

How do I tell perl to use a different hard drive for its temp
files? It creates CGITEM999999 files in c:\temp, I want
to tell perl to place the CGI temp files on d:\temp
how do I do that?

Dan Ward
Caterpillar Inc.





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

Date: Tue, 21 Sep 1999 17:52:51 GMT
From: jmontany@clarityconnect.com (JeffM)
Subject: Re: image upload using form
Message-Id: <37e7c473.3339586@news1.clarityconnect.com>

I understand your point, I am trying desperately to learn Linux. I
just built a linux box but I am having some trouble getting my modem
and ethernet card working. Thats a story of a different news group!
Anyhow, once I get it running and get off windows, my perl programming
will be a lot happier!
Thanks for the help on the gif. I'll get right to it!

On Wed, 22 Sep 1999 19:22:55 GMT, kragen@dnaco.net (Kragen Sitaker)
wrote:

>In article <37e78f7c.1145148@news1.clarityconnect.com>,
>JeffM <jmontany@clarityconnect.com> wrote:
>>If you opened a gif file using a text editor, then saved it without
>>making any changes, the file will be corrupted. This seems to be
>>simular to what this program is doing. Its not saving the data in the
>>proper format.
>
>BTW, this is not true if you're using a decent text editor on a decent
>platform, such as Emacs on Unix.  I have, in the past, edited
>executable files with Emacs (generally to change the values of strings
>within them; although you can patch in program code this way too, it's
>not recommended) and run them successfully afterwards.
>
>It has no trouble with .gif files.
>-- 
><kragen@pobox.com>       Kragen Sitaker     <http://www.pobox.com/~kragen/>
>Wed Sep 22 1999
>47 days until the Internet stock bubble bursts on Monday, 1999-11-08.
><URL:http://www.pobox.com/~kragen/bubble.html>



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

Date: 23 Sep 1999 15:48:24 GMT
From: "Paul J. Lucas" <pjl@be-NOSPAM-st.com>
Subject: injecting "my" varibales into caller's scope
Message-Id: <37ea4bc8$0$204@nntp1.ba.best.com>

	Is there you any way to inject "my" variables into a scope in
	Perl?

                sub injector {
                        # Do something nifty using "caller" to inject a
                        # variable "$foo" into caller's local scope.
                }

                sub func {
                        injector( ..... );
                        # the "my" varibale "$foo" now exists here
                }

	Normally, you can create variables with eval; but, to my
	knowledge, only into the caller's package not the caller's
	local scope.

	Any ideas?

	- Paul

	P.S.: E-mail replies preferred; remember to despam my address.


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

Date: 23 Sep 1999 17:00:18 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: injecting "my" varibales into caller's scope
Message-Id: <37ea4e92_1@newsread3.dircon.co.uk>

Paul J. Lucas <pjl@be-NOSPAM-st.com> wrote:
> 	Is there you any way to inject "my" variables into a scope in
> 	Perl?
> 

As far as I can determine there is no way you can do this because 'my' or
lexical variables do not exist in the symbol table like package variables.

If you can determine the package of the caller you could do this with a
package variable though.

> 	P.S.: E-mail replies preferred; remember to despam my address.

despammed addresses preferred - no e-mail sent.

/J\
-- 
"Gary Glitter pulls out of Children in Need" - BBC News Website


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

Date: Thu, 23 Sep 1999 15:43:41 GMT
From: c_j_marshall@hotmail.com
Subject: New trolling strategy ?
Message-Id: <7sdhr9$ase$1@nnrp1.deja.com>

I've just been wondering (after reading some of the recent posts to this
newsgroup) whether the 12 year old children who plague most newsgroups
with rubbish have just learned a new strategy to wind us all up - namely
by posting sensible looking, yet consistantly off topic, mails.

Just a thought I had after thinking for 100th time "oh come on - you
must know that has absolutely nothing to do with perl so why post it
here?"



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


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

Date: Thu, 23 Sep 1999 11:24:58 -0400
From: cleat@umich.edu
Subject: pattern matching options
Message-Id: <37EA464A.58F6D1DC@umich.edu>

Hello,

Is there a way to make options to pattern match dynamic?

while ( $string =~ /$term/$searchops )
            {   $count++;   }

where $searchops is either "gi" or "g"

does not work.

Thanks in advance,  Cleat



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

Date: Thu, 23 Sep 1999 15:52:40 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: pattern matching options
Message-Id: <c1sG3.6015$QJ.359326@typ11.nn.bcandid.com>

In article <37EA464A.58F6D1DC@umich.edu>,  <cleat@umich.edu> wrote:
>Hello,
>
>Is there a way to make options to pattern match dynamic?
>
>while ( $string =~ /$term/$searchops )
>            {   $count++;   }
>
>where $searchops is either "gi" or "g"
>
>does not work.

Well, you can always use eval STRING, but you might want (?i) in this
case.  perldoc perlre explains this.

You can't use (?g), but you probably don't want to.
-- 
<kragen@pobox.com>       Kragen Sitaker     <http://www.pobox.com/~kragen/>
Thu Sep 23 1999
46 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>


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

Date: Thu, 23 Sep 1999 08:53:56 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: pattern matching options
Message-Id: <MPG.1253ecf1fad60b45989fc6@nntp.hpl.hp.com>

In article <37EA464A.58F6D1DC@umich.edu> on Thu, 23 Sep 1999 11:24:58 -
0400, cleat@umich.edu <cleat@umich.edu> says...
> Is there a way to make options to pattern match dynamic?

Yes, to a certain extent.
 
> while ( $string =~ /$term/$searchops )
>             {   $count++;   }
> 
> where $searchops is either "gi" or "g"
> 
> does not work.

Leave the 'g' where it belongs, as a literal 'g' following the regex.  
For the 'i', look under the following heading in perlre:

    (?imsx-imsx)

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


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

Date: Thu, 23 Sep 1999 15:36:36 GMT
From: c_j_marshall@hotmail.com
Subject: Re: Perl - CGI -MySQL
Message-Id: <7sdhe3$an4$1@nnrp1.deja.com>

In article <18727-37E99A35-1@newsd-211.iap.bryant.webtv.net>,
  KernelKlink@webtv.net wrote:
> I wrote a perl script that when called via a web browser, will first
> connect to a MySQL server, then add a table, then disconnect.
>
> I ran into a problem after the 10th table was added. It won't add any
> more tables even after I delete all the tables. I can still add tables
> via the command line.
>
> Is there usually an option on a MySQL server that might turn off the
> ability to add tables via a Perl/cgi-bin connect after a certain
amount
> has been reached?
>
>

Good question. And I'm sure the guys on the MySQL newsgroup would be
delighted to receive it.

But not us.


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


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

Date: Thu, 23 Sep 1999 17:05:55 +0100
From: Alain BORGO <alain.borgo@ratp.fr>
Subject: Re: Perl Script Within VB for Web Pages
Message-Id: <37EA4FE3.99728ACD@ratp.fr>

Hello,

Chaos a écrit:
> 
> I have an ASP web page that is mostly all Visual Basic. I want to insert a
> perl script though. I also need to pass a VB variable into the Perl script.
> Does anyone know how to do this?

The answer is in the examples which come with the ActiveState port of
Perl for Win32.

-- 
A bientôt.
---------------------------------------------------------------------------------
Je ne suis pas sûr d'avoir raison mais je suis sûr d'avoir essayé
d'avoir raison.


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

Date: Thu, 23 Sep 1999 15:06:59 GMT
From: amonotod <amonotod@netscape.net>
Subject: Re: Perl/CGI and counter questions
Message-Id: <7sdfm8$99k$1@nnrp1.deja.com>

In article <Ro5G3.3209$QJ.180590@typ11.nn.bcandid.com>,
  kragen@dnaco.net (Kragen Sitaker) wrote:
> In article <w97oN6Oeb9FEDyHw61NkZAU+uyIL@4ax.com>,
> Frodo  <littledude@wizards.org> wrote:
> >1) A graphical counter
> >2) That can be called from an HTML document.
> >
> >I have found several examples that require the source document to
have
> >either an ".shtm" or an ".asp" extension.
> >
> >My host is 9NetAve, and they supposedly have server-side includes.  I
> >am hosted on an NT box.  Any help that you could provide would be
> >deeply appreciated.  Thank you.
>
> This is a Perl newsgroup, not a CGI or web newsgroup.  If you have CGI
> or web questions that aren't Perl questions, go ask them in a CGI or
> web newsgroup.
> --
> <kragen@pobox.com>       Kragen Sitaker
<http://www.pobox.com/~kragen/>
> Wed Sep 22 1999
> 47 days until the Internet stock bubble bursts on Monday, 1999-11-08.
> <URL:http://www.pobox.com/~kragen/bubble.html>
>

While I cannot discount the validity of the
statment kragen makes, I will help anyway.
Go here:
http://www.beseen.com/hitcounter.html

Next time, do like kragen said, go to:
comp.infosystems.www.authoring.cgi,
and you'll get less attitude too!

--
    `\|||/                     amonotod@
      (@@)                     netscape.net
  ooO_(_)_Ooo________________________________
  _____|_____|_____|_____|_____|_____|_____|_____|


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


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

Date: Thu, 23 Sep 1999 11:22:16 -0400
From: "RecruitSource" <examtesting@recruitsource.com>
Subject: Pre-release Perl Beta-Testers
Message-Id: <rukh53brlg760@corp.supernews.com>

Our company, http://www.recruitsource.com, is looking for people to
beta-test an online technical testing system, which will soon be released to
the public.  Specifically, we need people of various skill levels to take
one or more timed, multiple-choice exams, including a Perl exam, and to
comment on/criticize the exam as a
whole, as well as on individual questions.

If you would like to partake, please reply with your First and Last name,
and we will set you up with an account.

There are currently over 50 exams in the RecruitSource database - if there
are any other skills that you would like to try against our exam system,
please let us know.

Thanks for your help,

RecruitSource Tech Team




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

Date: Thu, 23 Sep 1999 17:12:35 +0200
From: Espen Myrland <espen@nextel.no>
Subject: Re: proper 'my' usage
Message-Id: <37EA4362.49D3C7B4@nextel.no>

Marty Landman wrote:

> I'd like advice on the best way to use my variables.  I'm leaning
> towards having all my 'my' vbles as the first line in every routine
> like:
>
> sub foo    {
>     my ($yours, $mine, $ours);
>     ($yours,$mine,$ours) = ($a_global,$b_global,$c_global);
>     ....
> }
>
> but in the above example this seems repetitive if not silly.

my ($yours, $min, $ours) = (......??????



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

Date: Thu, 23 Sep 1999 11:43:22 -0400
From: Marty Landman <marty@catnmoose.com>
Subject: Re: proper 'my' usage
Message-Id: <37EA4A9A.E8FC1823@catnmoose.com>

Espen Myrland wrote:

> my ($yours, $min, $ours) = (......??????

Thanks. I thought I'd addressed that option a bit further down in my
original post where I present a 'sub bar' example.  The problem I'm
concerned about is having a consistent style vs. whether it's problematic
for efficiency reasons to use the my construct when first using the
variable.

e.g.

for(my $i=0;$i<10;$i++)    {...}

Is there anything *bad* about having the my construct occur within the
for loop above?  Would it be better to code:

my $i;
for($i=0;$i<10;$i++)    {...}

Marty

--
Cat 'n Moose Web Programming & Design http://www.catnmoose.com/
Perl - CGI Tutorials & Sample Pgms  http://www.catnmoose.com/thecgibin/




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

Date: Thu, 23 Sep 1999 15:49:41 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: proper 'my' usage
Message-Id: <p_rG3.5999$QJ.359040@typ11.nn.bcandid.com>

In article <37EA3DF3.49BC937B@catnmoose.com>,
Marty Landman  <marty@catnmoose.com> wrote:
>I'd like advice on the best way to use my variables.  I'm leaning
>towards having all my 'my' vbles as the first line in every routine

I don't like this; it sometimes moves them a significant distance from
where they're used, expanding their scope needlessly.  Reduce scope as
much as possible.

>sub foo    {
>    my ($yours, $mine, $ours);
>    ($yours,$mine,$ours) = ($a_global,$b_global,$c_global);
>    ....
>}
>
>but in the above example this seems repetitive if not silly.

In the above example, you should combine the two lines into one.

>I'm concerned specifically about producing an inefficiency when coding
>something like this:
>
>sub bar    {
>    my @me = @global_you;
>    my $she = $global_factor;
>    for(@me)    {
>        my $he = $_/$she;
>        ....
>    }
>}
>
>Is there a penalty to be paid by saying 'my $he' within the for loop in
>bar?  Or is this a reasonable way of doing my declarations?


#!/usr/bin/perl -w
use strict;
use Benchmark;
timethese(5000, {
	'null loop' => sub { my $i; for ($i=0; $i<1000; $i++) { } },
	'in loop' => sub { my $i; for ($i=0; $i<1000; $i++) { my $x = 37 } },
	'out of loop' => sub { 
		my $i; 
		my $x; for ($i=0; $i<1000; $i++) { $x = 37 } },
	});

Benchmark: timing 5000 iterations of in loop, null loop, out of loop...
   in loop: 66 wallclock secs (50.89 usr +  0.00 sys = 50.89 CPU)
 null loop: 32 wallclock secs (25.40 usr +  0.00 sys = 25.40 CPU)
out of loop: 59 wallclock secs (45.31 usr +  0.01 sys = 45.32 CPU)

OK.  So the variable assignment takes (45.31-25.40)/5000000 = .000 003
98 seconds, almost 4 microseconds; the additional 'my' takes
(50.89-45.31)/5000000 = .000 001 116 seconds, or a little over a
microsecond.  (These numbers are really probably only good to two sig
figs or so.)

So yes, there is a penalty, and the penalty is about 25% of the penalty
of assigning a number to a scalar variable, according to this
experiment.  It seems odd to me that it should be so small, but I
haven't hacked Perl's internals.

As a matter of habit, I always 'my' variables before I start a small
loop, for exactly this reason.  It is apparently a very silly reason.

There are other reasons you might want to my variables inside a small
loop -- for example, if you're taking references to them and storing
them in a data structure.
-- 
<kragen@pobox.com>       Kragen Sitaker     <http://www.pobox.com/~kragen/>
Thu Sep 23 1999
46 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>


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

Date: Thu, 23 Sep 1999 15:16:02 GMT
From: drew3966@my-deja.com
Subject: Substitution fails intermittently
Message-Id: <7sdg74$9op$1@nnrp1.deja.com>

I have a script which makes substitutions to HTML files using a regular
expression. I am running Windows NT (SP5). There are 118 input files.
For 70, the substitution works. For the other 38, there is no
substitution. It is file related. The files are all ASCII and all
read/write. I have tried with and without binmode and with and without
/s of /gis.

Brazil.htm works. Bulgaria.htm fails. I cut/paste 3 lines from
Brazil.htm into Bulgaria.htm. I cut/paste 3 lines from Bulgaria.htm into
Brazil.htm. Brazil.htm still works, proving the lines are good matches.
Bulgaria.htm fails, proving it is file related.

The code is included. For some files the code works and for other files
it fails.

Regular expression: s/(\D{2}(\d{4})(\d?9\d?[789]))/19$3\/$1/gi);

Open/read the file:
   open(HTMLFILE,"<$Dir"."$File") || ErrorOpen("$Dir"."$File", $!);
   $Bytes = 0;
   $Bytes = read(HTMLFILE, $Buffer, $HTML_MAX) ||
LogError("$Dir"."$File", $!);
print "$Dir . $File length ($Bytes)\n";
   close(HTMLFILE);

Substitution:
     $rc = ($Buffer =~ s/(\D{2}(\d{4})(\d?9\d?[789]))/19$3\/$1/gi);

Close/write the file:
     open(HTMLFILE,">$Dir"."$File") || ErrorOpen($Dir . $File, $!);
     $Bytes = length $Buffer;
     $Bytes = syswrite(HTMLFILE, $Buffer, $Bytes) || ErrorOpen($Dir .
$File, $!);
     close(HTMLFILE);

Any ideas?


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


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

Date: 23 Sep 1999 08:14:34 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: toLowercase??
Message-Id: <m16711wtgl.fsf@halfdome.holdit.com>

>>>>> "Codex" == Codex  <codex@bearclaw.bogus.net> writes:

Codex> Thomas Fischer <tfischer@deakin.edu.au> wrote:
>> How can I convert a mixedcase string to 100% lowercase with perl?

Codex> tr/[A-Z]/[a-z]/;

Is there any particular reason you are translating a left bracket to a
left bracket, and a right bracket to a right bracket?

No?

Then leave those brackets out!

	tr/A-Z/a-z/;

or just use the lc function:

	$_ = lc $_;

Aside: I curse System V for having mangled the *real* tr command
definition (from the One True Unix, V7).  I was happy for many years
typing "tr A-Z a-z", and then sysV decided that needed to be typed
'tr "[A-Z]" "[a-z]"'.  Yes, I know why (to allow POSIX charclasses),
but still.  Ugh.

$_ = pack "C*", 65..89; tr/A-Z/Just another Perl hacker,/; print;

-- 
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: Thu, 23 Sep 1999 08:11:35 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: toLowercase??
Message-Id: <MPG.1253e3032f27409e989fc4@nntp.hpl.hp.com>

In article <7MqG3.831$OH6.12941@news1.online.no> on Thu, 23 Sep 1999 
14:26:11 GMT, Codex <codex@bearclaw.bogus.net> says...
> Thomas Fischer <tfischer@deakin.edu.au> wrote:
> > How can I convert a mixedcase string to 100% lowercase with perl?
> 
> tr/[A-Z]/[a-z]/;

Why do you want to translate '[' to '[' and ']' to ']'?

It is perhaps worth noting again that while this approach is good and 
fast, it fails on non-[A-Z] upper-case letters if locales are used, 
whereas the lc() function (or \L in regex) would work.

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


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

Date: 23 Sep 1999 16:22:41 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: You should be admired
Message-Id: <37ea45c1_1@newsread3.dircon.co.uk>

Henry Penninkilampi <spamfree@metropolis.net.au> wrote:
>                                                       I responded by
> isolating her behavioural problem and delivered it to her on the end of a
> sharp tongue.  That had the desired effect - it shut her up and put her
> back in her place (for now).
> 

As I said just another barrack room social worker ...

/J\
-- 
"Pat was wondering if he could put his massive tool in my box" - Mrs
Doyle, Father Ted


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

Date: Thu, 23 Sep 1999 15:32:28 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: You should be admired
Message-Id: <gKrG3.5894$QJ.356926@typ11.nn.bcandid.com>

In article <spamfree-2409990030260001@d6.metropolis.net.au>,
Henry Penninkilampi <spamfree@metropolis.net.au> wrote:
>Are you of the opinion that I, for some reason, need to earn *your*
>respect?  Do you think yourself *that* important?  Hmmm...  Amusing
>notion.  I'll let that one go, I think, too easy...

I think myself representative.

>On this occasion, however, the *issue* had degraded to the point where
>mature adults were merely slinging vicious insults at each other, so I
>attempted to intervene and resolve the dispute in a neutral and diplomatic
>manner.  Abigail spat the dummy for some reason (maybe she was enjoying
>the argument?) and tried to have a go at me instead.  I responded by
>isolating her behavioural problem and delivered it to her on the end of a
>sharp tongue.  That had the desired effect - it shut her up and put her
>back in her place (for now).

I doubt it.  I think it more likely that he decided to ignore you.

>I don't like having to do that, and I've *never* done it in this forum
>before, but I thought enough damage was being done _to_the_group_ to
>warrant an intervention - so I did.

Done to the group?  Who are you, anyway, to say what is good for the
group and what is not?  You don't even know Abigail's a man.

>And now *you're* trying to have a go at me for 'standing up for what is
>right'???

No, for attacking Abigail for standing up for what is right.  Not that
he needs any defense from me.

>I understand your desire to stand up in defence of Abigail - I really do. 
>Under different circumstance, I would probably do the same.  But in this
>case, she was acting like a petulant child, and needed to be treated like
>one.  She knows it.  I know it.  Everyone who has been following the
>thread probably knows it.  If you can't see it, it's because you don't
>want to.

I don't think so.

>Your Honour has been served - you came to the defence of your friend.

I don't know Abigail well; I've never met him in person.  I wouldn't
presume to call him my friend.  In fact, sometimes I think he's
annoying, as I'm sure everyone here does.  But I think he was in the
right.

>I
>bear no grudge against you, Abigail, or anyone here.  As far as I'm
>concerned, this episode is over.  Why don't we all just retire to our
>respective quarters and spend our energies on something more productive?

That's what we were doing.  We were restating our community's values.
-- 
<kragen@pobox.com>       Kragen Sitaker     <http://www.pobox.com/~kragen/>
Thu Sep 23 1999
46 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>


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

Date: Thu, 23 Sep 1999 17:32:19 +0200
From: "Trond Michelsen" <mike@crusaders.no>
Subject: Re: You should be admired
Message-Id: <iKrG3.15$pn4.230@news1.online.no>


James W Corpening <jwc@acsu.buffalo.edu> wrote in message
news:37E8FC1F.D130A86F@acsu.buffalo.edu...
> Ya know, some of you illiterates are real idiots.  I write in perl,
and I use

Why are some people so eager to get killfiled?

--
Trond Michelsen





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

Date: Fri, 24 Sep 1999 01:14:34 +0930
From: spamfree@metropolis.net.au (Henry Penninkilampi)
Subject: Re: You should be admired
Message-Id: <spamfree-2409990114340001@d6.metropolis.net.au>

In article <37e9f830_1@newsread3.dircon.co.uk>, Jonathan Stowe
<gellyfish@gellyfish.com> wrote:

> Perhaps other groups dont have the same constant parade of
> 'Web Developers'[1], Script Kiddies, Warez d00dz, spammers,
> cheating students and sundry other ignorant losers and
> feckless scum that this group seems to attract.

'Ignorant losers and feckless scum' - I like that!

:^)


> I'm sure you would agree that if this group is to be a useful
> forum for  the genuine Perl question then we shouldnt just
> humor these people, for instance, by giving them answers in an
> unrelated language to a question that was not related to Perl
> in the first place.  Further I am sure you will agree that
> in humoring these people the situation will only be made worse.

I agree that it would be wrong to simply give them the answers because, as
you quite rightly say, they would just keep coming back and the situation
would get worse.

I see no reason, however, why we can't provide them with a pointer in the
right direction (and, if the answer happens to be known and trivial, that
in the bargain).

"That's a JavaScript question.  Try comp.lang.javascript" is, to me, far
superior to "I would call you an idiot, but that would insult a lot of
genuine idiots out there" (or words to that effect).


> How many times does this need to be said and how many times do answers
> be given, before it sinks in.

For me?  Once usually does the job.  I've never heard this point of view
before, so it's new to me.


> We are not talking about newbies here we
> are not talking about people straying we are talking about people who
> come here and expect every single question that they might have about
> any problem domain that Perl might be ever so tenuously connected to to
> be answered.  What we are talking about is that when these people are
> told they have asked the questions in the wrong place, however abrubtly
> or politely, we always get some barrack room social worker who starts
> jumping up and down and saying that perhaps we ought to have some old
> folks home for the people who actually have made some nett contribution
> to this group so that the newbies and the sundry losers referred to
> above can have comp.lang.perl.misc as their personal playroom.

Well put.  Very succinct.  I know understand the root of your frustration
- thank you.


> Why not raise a CFD if you think that you want to turn this group into a
> smoking pit by changing its charter to explicitly allow the things that
> people get upset about ?
> 
> Its always interesting that all the people who suggest we should balkanize
> comp.lang.perl.misc because they dont like people being nasty to losers
> never suggest that they will post a CFD themselves - it is always couched
> as "Has anyone ever considered CFDing ..." or its moral equivalent.

Nothing to do with a moral equivalent.  I phrased my question that way
(and others probably have for similar reasons) because I didn't want to go
over ground that had been well trodden before.  I didn't want to waste
*your* time.  Sorry for being considerate.


> I would refer you to the post with the subject line :
> 
>      How to find the right place to post (FAQ)
> 
> in the group news.announce.newusers
>
> For those (who seem to be in ascendence right now) who dont have access to
> this newsgroup because their news-server is improperly configured this
> is at:
> 
>  http://www.deja.com/getdoc.xp?AN=498432950&fmt=text

I just checked the 5 news servers which supply 50% of all news in
Australia and *none* of them carry the document you mentioned.  All carry
the newsgroup, but "How to find the right place to post (FAQ)" is nowhere
to be seen.  In fact, news.announce.newusers only carries an average of 3
messages.

Perhaps you should stop relying on a document that isn't available to half
of UseNet (assuming all the servers I couldn't check *do* carry that FAQ
and the numbers extrapolate evenly)?  And I hardly think
<http://www.deja.com/getdoc.xp?AN=498432950&fmt=text> is one of the
default bookmarks in Navigator or Explorer, so visibility from that angle
is near-zero as well.

Sounds, to me, like there is this wonderful document, which can lay this
problem to rest, but no-one reads it because no-one knows it even exists!

Hmmm...

I remember being sent a "Welcome" message when I first posted to this
group ages ago (was it this group?) which must have been sent by a script
which scans the group for articles from new email addresses.  If you think
it is important that folks read the "How to find the right place to post
(FAQ)", why don't we tweak that script to send out the FAQ as well?  That
way you can be sure that the FAQ has been shoved in front of every new
posters face at least once, and then they no longer have any excuses...

Just an idea.

Henry.


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

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


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