[16248] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3660 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Jul 14 00:05:47 2000

Date: Thu, 13 Jul 2000 21:05:11 -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: <963547511-v9-i3660@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Thu, 13 Jul 2000     Volume: 9 Number: 3660

Today's topics:
        @ not piped in print << -> must escape as \@ <shanen@my-deja.com>
    Re: @ not piped in print << -> must escape as \@ (jason)
        [Perl] get email content from unix a/c <raymondchanth@my-deja.com>
    Re: Advanced Regexp Parsing HELP! Please (Keith Calvert Ivey)
    Re: ATTENTION PERL MACHOES!!!!!!!!!!!!!!!!!!! (Steven Smolinski)
    Re: Email Attachments in Perl (no modules) <peter.sundstrom@eds.com>
        file endings with regexps... sept00@my-deja.com
    Re: file endings with regexps... <wyzelli@yahoo.com>
    Re: file endings with regexps... <wyzelli@yahoo.com>
    Re: file endings with regexps... (jason)
        how to convert "1.2.3.10" to "01020310"? <woowk@my-deja.com>
    Re: how to convert "1.2.3.10" to "01020310"? (jason)
    Re: how to convert "1.2.3.10" to "01020310"? <tony_curtis32@yahoo.com>
    Re: New to perl, need help <aqumsieh@hyperchip.com>
    Re: New to perl, need help (Keith Calvert Ivey)
    Re: perl beautifier? (Ilya Zakharevich)
        perl prog to change UNIX password through CGI oct1pm@hotmail.com
    Re: perl prog to change UNIX password through CGI <taboo@doofa.net>
        Perl Rocks!(OT?) <Rage@matrix13.freeserve.co.uk>
    Re: perl-5.6.0: Bug with "not" operator? (=?iso-8859-1?q?H=E5kon?= Alstadheim)
        query string problem.... <cam@home.com>
    Re: reg expression not working. WHY??? <godzilla@stomp.stomp.tokyo>
        Timing a script <taboo@doofa.net>
    Re: Timing a script (jason)
    Re: Using variables in regexps (Keith Calvert Ivey)
    Re: Why $|++ instead of $|=1 ? (Gwyn Judd)
    Re: Why $|++ instead of $|=1 ? (jason)
    Re: Why $|++ instead of $|=1 ? <wyzelli@yahoo.com>
    Re: Why $|++ instead of $|=1 ? (jason)
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Fri, 14 Jul 2000 02:17:08 GMT
From: Shannon Jacobs <shanen@my-deja.com>
To: shanen@acm.org
Subject: @ not piped in print << -> must escape as \@
Message-Id: <8klt6o$fqi$1@nnrp1.deja.com>

Okay, I've spent at least an hour trying to understand this without
success. FAQs, newsgroups, camel, etc.

Situation: Static Web page designed with TopPage. Includes some email
references. Converted it to dynamic page by cutting it up with print <<
for the static parts, then use Perl in the gaps for the dynamic stuff.
(Mostly form options with time or data file contingencies.) Technique
is lazy and impatient, but @ from HTML source requires backslash. Why?
[Demanded by hubris?] Appears to be related to invocation via Web
server (Apache under AIX). However, probably similar problem disables
perldoc--error is "In string, @sys now must be written as \@sys at...."

Hypothesis: weird@.

--
Please contribute to my fund to stamp out spamnut disease!! Send $17.50
in small unmarked bills to...


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Fri, 14 Jul 2000 03:10:53 GMT
From: elephant@squirrelgroup.com (jason)
Subject: Re: @ not piped in print << -> must escape as \@
Message-Id: <MPG.13d9220abe14857c9896a2@news>

Shannon Jacobs wrote ..
>Okay, I've spent at least an hour trying to understand this without
>success. FAQs, newsgroups, camel, etc.
>
>Situation: Static Web page designed with TopPage. Includes some email
>references. Converted it to dynamic page by cutting it up with print <<
>for the static parts, then use Perl in the gaps for the dynamic stuff.
>(Mostly form options with time or data file contingencies.) Technique
>is lazy and impatient, but @ from HTML source requires backslash. Why?
>[Demanded by hubris?] Appears to be related to invocation via Web
>server (Apache under AIX). However, probably similar problem disables
>perldoc--error is "In string, @sys now must be written as \@sys at...."
>
>Hypothesis: weird@.

Diagnosis: clown

Suggestion: read Perl docs before writing Perl code

Solution: perldoc perldata

>--
   ^...there needs to be a space there for these to be proper sigdashes

-- 
  jason -- elephant@squirrelgroup.com --


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

Date: Fri, 14 Jul 2000 02:14:38 GMT
From: Raymond <raymondchanth@my-deja.com>
Subject: [Perl] get email content from unix a/c
Message-Id: <8klt22$fha$1@nnrp1.deja.com>

Dear All,

I want to run a perl script if somebody send email to my email a/c:
username@myserver.com
and I want to get the subject, sender, content, datetime of the email,
then open a new ticket and insert the data into database. I know I can
add "\username,script.pl" to .forward in unix such that the script.pl
can be triggered when email is received. But how can I get the
information of that email from the perl script ? Thank you very much.


Regards,
Raymond


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Fri, 14 Jul 2000 01:45:10 GMT
From: kcivey@cpcug.org (Keith Calvert Ivey)
Subject: Re: Advanced Regexp Parsing HELP! Please
Message-Id: <39736e83.5813689@nntp.idsonline.com>

Nathan Wiger <nathan.wiger@west.sun.com> wrote:

>   (@val) = (m#\s+(?:"([^"]*)"|(\S+))\n?#g);  # split up val

You have two sets of capturing parentheses there.  That's where
your undefined array elements are coming from.  Either follow
this with

    @val = grep { defined } @val;

or use only one set:

    (@val) = (m#\s+("[^"]*"|\S+)#g);  # split up val

and then strip off the quotes:

    s/^"(.*)"$/$1/ for @val;

-- 
Keith C. Ivey <kcivey@cpcug.org>
Washington, DC


-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----==  Over 80,000 Newsgroups - 16 Different Servers! =-----


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

Date: Fri, 14 Jul 2000 03:06:09 GMT
From: sjs@yorku.ca (Steven Smolinski)
Subject: Re: ATTENTION PERL MACHOES!!!!!!!!!!!!!!!!!!!
Message-Id: <slrn8mt0te.gt.sjs@john.sympatico.ca>

Elaine -HFB- Ashton <elaine@chaos.wustl.edu> wrote:
>I don't come around here to wank my ego and I've got enough things as it
>is. 

No, you come here to berate other regular contributors, now and then
calling them chauvinists, or otherwise trying to lash stilts to your
equine.

>However, I do believe someone is, in fact, working on something of
>this nature [...a free script archive a la Matt's...] which will force 
>some of you to bitch about something else for a change maybe.

Perhaps this will, by extension, cure your affliction as well.  

Steve


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

Date: Fri, 14 Jul 2000 14:28:51 +1200
From: "Peter Sundstrom" <peter.sundstrom@eds.com>
Subject: Re: Email Attachments in Perl (no modules)
Message-Id: <8kltug$rle$1@hermes.nz.eds.com>


Dan Woods wrote in message <396E2774.9AD54F38@ucalgary.ca>...
>eryq@zeegee.com wrote:

>But what is the best way to attach files (text or binary) if you are
>not allowed to install Perl modules ?  There are lots of people using
>hosting companies that either don't allow, or don't want to install
>modules.

If you are allowed to upload a file, then you have permission to install
Perl modules.  The only place where you might have restrictions is if there
are any components that need to be compiled.

MIME::Lite now has updated documentation saying how to install it locally.






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

Date: Fri, 14 Jul 2000 02:30:44 GMT
From: sept00@my-deja.com
Subject: file endings with regexps...
Message-Id: <8klu0k$gbe$1@nnrp1.deja.com>

I'm trying to get a file ending out of a variable. Now I've been trying
to solve it with a regexp for about an hour (online documentation and
books as well) and I really can't get it to work, so this is what I've
got:

  $path = "/mitglied/sdfjnsdf.html";
  $ending = $path;

  @temp = split ('\.', $ending);
  $length = scalar @temp;

  $ending = @temp[$length - 1];

How can this be done in a simple regexp?!?

Thanks a bundle in advance,
Tom


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Fri, 14 Jul 2000 12:43:09 +0930
From: "Wyzelli" <wyzelli@yahoo.com>
Subject: Re: file endings with regexps...
Message-Id: <Jxvb5.8$oA.4283@vic.nntp.telstra.net>

<sept00@my-deja.com> wrote in message
news:8klu0k$gbe$1@nnrp1.deja.com...
> I'm trying to get a file ending out of a variable. Now I've been
trying
> to solve it with a regexp for about an hour (online documentation and
> books as well) and I really can't get it to work, so this is what I've
> got:
>
>   $path = "/mitglied/sdfjnsdf.html";
>   $ending = $path;
>
>   @temp = split ('\.', $ending);
>   $length = scalar @temp;
>
>   $ending = @temp[$length - 1];
>
> How can this be done in a simple regexp?!?
>
> Thanks a bundle in advance,
> Tom
>

Slightly confusing way to express the question, but I think you want :

#!/usr/bin/perl -w
use strict;

my $path = '/mitglied/sdfjnsdf.html';
if (my ($pathfile, $filetype) = ($path =~
*)\.(.*)/)){ 
 print "$pathfile\n$filetype";
}


Wyzelli





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

Date: Fri, 14 Jul 2000 12:51:11 +0930
From: "Wyzelli" <wyzelli@yahoo.com>
Subject: Re: file endings with regexps...
Message-Id: <fFvb5.9$oA.4192@vic.nntp.telstra.net>

Wyzelli <wyzelli@yahoo.com> wrote in message
news:Jxvb5.8$oA.4283@vic.nntp.telstra.net...
> <sept00@my-deja.com> wrote in message
> news:8klu0k$gbe$1@nnrp1.deja.com...
>
> #!/usr/bin/perl -w
> use strict;
>
> my $path = '/mitglied/sdfjnsdf.html';
> if (my ($pathfile, $filetype) = ($path =~
>
 .(.*)/)){ 
>  print "$pathfile\n$filetype";
> }
> 

So much for 'cut and paste'... missing a few characters there...

#!/usr/bin/perl -w
use strict;

my $path = '/mitglied/sdfjnsdf.html';
if (my ($pathfile, $filetype) = ($path =~ /(.*)\.(.*)/)){
 print "$pathfile\n$filetype";
}

That better come through properly or I will go and smack Bill.

Wyzelli





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

Date: Fri, 14 Jul 2000 03:32:54 GMT
From: elephant@squirrelgroup.com (jason)
Subject: Re: file endings with regexps...
Message-Id: <MPG.13d927341cb196049896a3@news>

sept00@my-deja.com wrote ..
>I'm trying to get a file ending out of a variable. Now I've been trying
>to solve it with a regexp for about an hour (online documentation and
>books as well) and I really can't get it to work, so this is what I've
>got:
>
>  $path = "/mitglied/sdfjnsdf.html";
>  $ending = $path;
>
>  @temp = split ('\.', $ending);
>  $length = scalar @temp;
>
>  $ending = @temp[$length - 1];
>
>How can this be done in a simple regexp?!?

no need to use a regex .. you know the character you're looking for .. 
and you want everything after the right-most one of them

this seems to be what you're trying to get (excuse me if I adjusted your 
input slightly)

  my $path = "/mitglied/sd.fjn.sdf.html";

  my $ending = substr $path, rindex( $path, '.') - length($path) +1;

-- 
  jason -- elephant@squirrelgroup.com --


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

Date: Fri, 14 Jul 2000 02:09:20 GMT
From: ethan <woowk@my-deja.com>
Subject: how to convert "1.2.3.10" to "01020310"?
Message-Id: <8klso6$fdr$1@nnrp1.deja.com>

Hi,
Hope there someone who can help me with this. I am new to PERL and am
facing the problem of convert a string of "2.1.3.14" format
to "02010314" format.
Do I have to use regression expression?

Thank for your help!!
Ethan.


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Fri, 14 Jul 2000 03:02:02 GMT
From: elephant@squirrelgroup.com (jason)
Subject: Re: how to convert "1.2.3.10" to "01020310"?
Message-Id: <MPG.13d91ffab5e70f259896a1@news>

ethan wrote ..
>Hope there someone who can help me with this. I am new to PERL and am
>facing the problem of convert a string of "2.1.3.14" format
>to "02010314" format.

  printf '%02d%02d%02d%02d' => split /\./ => '2.1.3.14';

more details in the docs

  perldoc -f sprintf
  perldoc -f printf


-- 
  jason -- elephant@squirrelgroup.com --


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

Date: 13 Jul 2000 22:55:57 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: how to convert "1.2.3.10" to "01020310"?
Message-Id: <8766q9uzzm.fsf@limey.hpcc.uh.edu>

>> On Fri, 14 Jul 2000 02:09:20 GMT,
>> ethan <woowk@my-deja.com> said:

> Hi, Hope there someone who can help me with this. I am
> new to PERL and am facing the problem of convert a
> string of "2.1.3.14" format to "02010314" format.  Do I
> have to use regression expression?

Do you mean a "regular expression"?

Try this:

    my $string = '2.1.3.14';
    my @bits = split /\./, $string;
    my $new_string = join '', map {sprintf '%02d' => $_} @bits;
    
    print "$new_string\n";

i.e. get the components separated by '.' (backslashed
because it is a regexp metacharacter), then format each
component, and join them all back to together with no
separator.

    perldoc -f sprintf
    perldoc -f split
    perldoc -f join
    perldoc -f map

And of course, TIMTOWTDI...

hth
t
-- 
"With $10,000, we'd be millionaires!"
                                           Homer Simpson


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

Date: Fri, 14 Jul 2000 01:52:41 GMT
From: Ala Qumsieh <aqumsieh@hyperchip.com>
Subject: Re: New to perl, need help
Message-Id: <7ak8epjx5g.fsf@merlin.hyperchip.com>


kcivey@cpcug.org (Keith Calvert Ivey) writes:

> Ala Qumsieh <aqumsieh@hyperchip.com> wrote:
> >Uri Guttman <uri@sysarch.com> writes:
> 
> >> it can be shortened a bit like this by removing the init code:
> >> perl -le '$n=shift;($f1,$f2)=($f2,$f1+$f2||1), print $f1 while --$n' 10
> >
> >If you don't care about warnings, then we can cheat a little:
> >
> >	perl -wle '($*,$^W)=($^W,$^W+$*),print$*for 0..pop' 10
> 
> Interesting use of $^W.  The ^W there must mean an actual
> control character rather than ^ followed by W (do all shells
> allow that?).  

No. It is actually a ^ followed by a W. The value of this depends on the
-w switch. It is 0 if we don't use -w and 1 if we do. I was implicitly
setting it to 1 via the -w switch.

>                Otherwise, it's one longer than the more obvious
> 
>  	perl -le '($*,$W)=($W,$*+$W||1),print$*for 0..pop' 10

True. This is one shorter, but I like setting $^W implicitly :)

> which doesn't give any warnings.  Actually, why are you using
> $*?  With $- instead, you wouldn't get any warnings.

Well, you could use any non-special variable which will automatically
initialize to 0, but will still give a warning under -w. A better choice
would have been $[, perhaps.

--Ala



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

Date: Fri, 14 Jul 2000 02:18:27 GMT
From: kcivey@cpcug.org (Keith Calvert Ivey)
Subject: Re: New to perl, need help
Message-Id: <39787791.8132383@nntp.idsonline.com>

Ala Qumsieh <aqumsieh@hyperchip.com> wrote:
>kcivey@cpcug.org (Keith Calvert Ivey) writes:
>> Ala Qumsieh <aqumsieh@hyperchip.com> wrote:

>> >	perl -wle '($*,$^W)=($^W,$^W+$*),print$*for 0..pop' 10
>> 
>> Interesting use of $^W.  The ^W there must mean an actual
>> control character rather than ^ followed by W (do all shells
>> allow that?).  
>
>No. It is actually a ^ followed by a W. The value of this depends on the
>-w switch. It is 0 if we don't use -w and 1 if we do. I was implicitly
>setting it to 1 via the -w switch.

I understand that.  But the special variable for warnings can be
written with an actual control-W (\x17) as well as ^ followed by
W, and that saves a keystroke (assuming you can enter the
control character by just pressing control-W).

>>                Otherwise, it's one longer than the more obvious
>> 
>>  	perl -le '($*,$W)=($W,$*+$W||1),print$*for 0..pop' 10
>
>True. This is one shorter, but I like setting $^W implicitly :)
>
>> which doesn't give any warnings.  Actually, why are you using
>> $*?  With $- instead, you wouldn't get any warnings.
>
>Well, you could use any non-special variable which will automatically
>initialize to 0, but will still give a warning under -w. A better choice
>would have been $[, perhaps.

That's why I suggested $-, so that it *wouldn't* print any
warning, even though you were using -w.  Why do you want to
print a warning?

-- 
Keith C. Ivey <kcivey@cpcug.org>
Washington, DC


-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----==  Over 80,000 Newsgroups - 16 Different Servers! =-----


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

Date: 14 Jul 2000 02:14:52 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: perl beautifier?
Message-Id: <8klt2s$4p4$1@charm.magnus.acs.ohio-state.edu>

[A complimentary Cc of this posting was sent to Paul Taylor
<pap@sotonians.org.uk>],
who wrote in article <8enb5.89$Ki2.11009@nnrp4.clara.net>:
> > Having said that, I don't know of any standalone program, but Emacs has
> > cperl-mode (written by the illustrious Ilya, author of most of the Perl
> > regex code and much of the Perl debugger) that seems to do a decent job
> > of indenting.

> Misbehaves a little if you're a brace-on-its-own-line merchant.  It
> tabs the opening brace out too far.

> sub smashing
>     {
>       ... 
>     }

If you want a different indent style, set it.

BTW, CPerl has a converter-to-PostScript as well.

Ilya


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

Date: Fri, 14 Jul 2000 02:05:21 GMT
From: oct1pm@hotmail.com
Subject: perl prog to change UNIX password through CGI
Message-Id: <8klsgo$f5c$1@nnrp1.deja.com>

Hi,

I am trying to write a Perl CGI program so that when a user click 'reset
password' button through webpage, he can update his UNIX password.
One can type 'passwd' interactively to reset the password. Is there a
way I can reset it using something like "system("passwd")" in Perl/CGI ?

thanks for your info,

Andrew


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: 14 Jul 2000 00:41:58 +1000
From: "Kiel Stirling" <taboo@doofa.net>
Subject: Re: perl prog to change UNIX password through CGI
Message-Id: <396dd536$1_2@nexus.comcen.com.au>


oct1pm@hotmail.com wrote:
>Hi,>
>I am trying to write a Perl CGI program so that when a user click 'reset
>password' button through webpage, he can update his UNIX password.
>One can type 'passwd' interactively to reset the password. Is there a
>way I can reset it using something like "system("passwd")" in Perl/CGI ?
>
>thanks for your info,
>
>Andrew
>
>
>Sent via Deja.com http://www.deja.com/
>Before you buy.

Try looking at poppasswd or maybe if your running FreeBSD 
pw(8) which if your working on a localhost is more efficient.






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

Date: Fri, 14 Jul 2000 02:15:37 +0100
From: "Rage Matrix" <Rage@matrix13.freeserve.co.uk>
Subject: Perl Rocks!(OT?)
Message-Id: <8klpbq$5a9$1@news5.svr.pol.co.uk>

I don't know if this is off-topic for this NG, but I'm gonna say my thing
anyways. I have just started my new job at a local software company. I have
just graduated from university and didn't know anything about Perl at all. I
have, however, used Linux a fair bit and also had knowledge of C++, Java and
VB. This was my first interview and I got the job even though I made it
clear that I knew nothing about Perl. Working is MUCH better than
university. I get to code all day and I actually get paid for it. Its like
getting paid for your hobby. Awesome!

Anyway, I have come to the conclusion that Perl ROCKS! I don't see much
point in using it on a non-UNIX based machine, but the language integrated
so well with Linux and I LOVE it! I always considered UNIX OS's to be less
of a technology and more of an art form and Perl simply makes this art form
a richer experience.
I just wanted to tell the world that!
BTW, as I have never posted to this NG before, as I have only been working
at my first full-time job for two weeks, how many programmers here work
solely with Perl and do most of you use it primarily on UNIX/Linux systems
or Win32? How long did you code in Perl before you became quite proficent in
it? What are the job prospects of Perl programmers generally?
How important is in-depth knowledge of  UNIX regarding your proficieny in
Perl?
(Sorry for all the questions, but...) Is the mindset for Perl different from
OO languages like C++ and Java? i.e. Is there a different logic that helps
you solve Perl problems faster?
The motto that I have learnt so far is: Never assume anything. (This is
regarding bugs in Perl programs).

Sorry for the rant, but I'm very happy with working with Perl!!

Regards,

Jon.
BSc Computer Studies (Graduate! Wow, that's gonna take some getting used
to!)

--
Jonathan M Baker
Software Engineer, Semantico Ltd (www.semantico.com)
Tron Software: http://www.tronsoftware.freewire.co.uk
-=The views expressed by me are not necessarily those of Semantico=-




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

Date: 13 Jul 2000 20:45:22 -0400
From: hakon.alstadheim@oslo.mail.telia.com (=?iso-8859-1?q?H=E5kon?= Alstadheim)
Subject: Re: perl-5.6.0: Bug with "not" operator?
Message-Id: <m0g0pd1qvx.fsf@alstadhome.cyberglobe.net>

mike@excite.com () writes:
> Earlier, Rafael Garcia-Suarez <rgarciasuarez@free.fr> wrote:
> >I think this change was made to make constructs like
> >      not($a) || $b
> >more intuitive.
> 
> In that case, you should have used:
> 	! $a || $b
> or
> 	(not $a) || $b
> 
[...]
> The more I think about it, the less I like this change.

Precisely my thoughts. We need to find out the rationale behind
this. Fair enough that perl is a DWIM tool, but this ... words are
inadequate, somebody needs to write a deathmetal song about this if 
Rafael is correct in his guess about the rationale.


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

Date: Fri, 14 Jul 2000 01:41:07 GMT
From: "cam" <cam@home.com>
Subject: query string problem....
Message-Id: <Tcub5.10287$8u4.137828@news1.rdc1.bc.home.com>

Hi:

I'm newish to perl. I'm trying to retrieve the data from a query string.
Can't seem to dump the "id=" part in my perl script. Here's a simple example
to illustrate:


html file:
======
<a href="/cgi-bin/getlink.pl?id=0">ibm</a>
<a href="/cgi-bin/getlink.pl?id=1">apple</a>
<a href="/cgi-bin/getlink.pl?id=2">linux</a>

Perl File:
=======
#!/usr/bin/perl

print "Content-type: text/html\n\n";
use LWP::Simple;

$id = $ENV{'QUERY_STRING'};

@gothere = ();
$gothere[0]="ibm";
$gothere[1]="apple";
$gothere[2]="linux";

print "@gothere[$ENV{'QUERY_STRING'}]\n";


Problem is that this returns:
id=xxxx

what I want is simply the xxxx WITHOUT the id=     on it. any ideas??  Why
is it returning the id= part and how can I get rid of it?

Thanks!!!!

Cam




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

Date: Thu, 13 Jul 2000 19:00:09 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: reg expression not working. WHY???
Message-Id: <396E7429.70A205B3@stomp.stomp.tokyo>

Pasquale wrote:
 
> Can someone please help me "see the light" as to where the 
> problem is with this snippet of code?

(snip)

Only you can open your eyes and truly see the light.

I can help you see your problem first time you
run your program. Copy and paste this code into
your script as a replacement for this code snippet
you posted with your article.

Sound thinking and good logic both dictate you
make a visual comparison of your input data and
your data arrays. In this sense, perhaps you will
see the light, right off.

I've included some better error checking methods
for file opening and array creation than the usual
cargo cult crud people around here demand and 
command everyone use. Look it over; it is more 
logical than the ho-hum usual strict thinking
of Perl 5 Cargo Cultists.

If you still have a problem, equally sound 
thinking and good logic dictate you look close
at your read and parse routine; what is it 
passing through which may be invisible?

I am curious what relationship there is between
an address and a price along with being curious
why you need to change your input price.

This snippet has been exhaustively tested under
realistic internet working conditions and works
perfect. Do not respond with "This doesn't work."


Godzilla!



$address = $formdata{'address'};
$price = $formdata{'price'};

open(LOGFILE, "test.log");
@entries = <LOGFILE>;
close(LOGFILE);

if (!(@entries))
 { print "File Open And Array Creation Failed."; exit; }
else
 { chomp (@entries); }

foreach $line(@entries) 
 {
  print "Entries Line Is: $line \n";

  @cells = split(/::/, $line);

  if (!(@cells))
   { print "\n\nCells Array Creation Failed."; exit; }

  print "Cells 0 Is: $cells[0]\n",
        "Cells 1 Is: $cells[1]\n",
        "Cells 2 Is: $cells[2]\n",
        "Cells 3 Is: $cells[3]\n",
        "Address Is: $address\n\n";

  if ($address eq $cells[3]) 
   {
    $cells[0] = $price;
    last;
   }
 }

 print "Final Results Are:\n\n",
       "Cells 0 Is: $cells[0]\n",
       "Cells 1 Is: $cells[1]\n",
       "Cells 2 Is: $cells[2]\n",
       "Cells 3 Is: $cells[3]\n",
       "Address Is: $address\n",
       "Price Is:   $price";

exit;


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

Date: 14 Jul 2000 00:29:26 +1000
From: "Kiel Stirling " <taboo@doofa.net>
Subject: Timing a script
Message-Id: <396dd246$1_2@nexus.comcen.com.au>


Hi 
I am looking for a better way to time scripts than using 
the systems time cmd.

Any idea's on timing scripts?

Kiel Stirling 


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

Date: Fri, 14 Jul 2000 02:51:32 GMT
From: elephant@squirrelgroup.com (jason)
Subject: Re: Timing a script
Message-Id: <MPG.13d91d7df1ca1edd9896a0@news>

Kiel Stirling  wrote ..
>I am looking for a better way to time scripts than using 
>the systems time cmd.
>
>Any idea's on timing scripts?

  use Benchmark;

it's a standard module

  perldoc Benchmark

-- 
  jason -- elephant@squirrelgroup.com --


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

Date: Fri, 14 Jul 2000 01:31:31 GMT
From: kcivey@cpcug.org (Keith Calvert Ivey)
Subject: Re: Using variables in regexps
Message-Id: <39726c39.5227945@nntp.idsonline.com>

"Marc Schaefer" <marc.schaefer@warwick.ac.uk> wrote:

>However, if you only want to delete single characters, you should have
>a look at tr/// (also in perlop):
>
>	$charToStrip = '$';
>	$price = '$59.95';
>
>	$price =~ tr/$charToStrip//d;

That works by accident.  It's a good thing you didn't have any
of the characters 'c', 'h', 'a', 'r', 'T', 'o', 'S', 't', 'i',
or 'p' in the string you were processing.  There's no
interpolation within tr///.  You could do

        eval "\$price =~ tr/$charToStrip//d";

I suppose, but I think it's better to stick with s///;

-- 
Keith C. Ivey <kcivey@cpcug.org>
Washington, DC


-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----==  Over 80,000 Newsgroups - 16 Different Servers! =-----


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

Date: Fri, 14 Jul 2000 01:53:39 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: Why $|++ instead of $|=1 ?
Message-Id: <slrn8mssqj.19b.tjla@thislove.dyndns.org>

I was shocked! How could M.J.T. Guy <mjtg@cus.cam.ac.uk>
say such a terrible thing:
>Wyzelli <wyzelli@yahoo.com> wrote:
>>
>>As I have demonstrated previously, whilst calling $|++ repeatedly leaves
>>the state of $| 'high' (or 'unbuffered' if you wish, since any non zero
>>value = unbuffered), calling $|-- repeatedly can in certain
>>circumstances cause $| to switch between a zero and non-zero value which
>>can lead to misleading results.
>
>It's not "in certain circumstances"  -  it's in *all* circumstances.
>
>$| is magical and can only take values 0 or 1.    An attempt to set
>any nonzero value sets it to 1.

perl -we '$| = 0; $|--;$|++; print "\$| == $|";'
$| == 1

Ergo. using $|-- and $|++ is not safe as the fact that $| is magic means
that doing these things in equal (ie. balanced) numbers does not get you
back to where you started. This is a bad thing I think. You should
always use 'local'.

-- 
Gwyn Judd (tjla@guvfybir.qlaqaf.bet)
My return address is rot13'ed
Schlattwhapper, n.:
	The window shade that allows itself to be pulled down,
hesitates for a second, then snaps up in your face.
		-- Rich Hall, "Sniglets"


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

Date: Fri, 14 Jul 2000 02:10:14 GMT
From: elephant@squirrelgroup.com (jason)
Subject: Re: Why $|++ instead of $|=1 ?
Message-Id: <MPG.13d913ce7cbe40b98969e@news>

Gwyn Judd wrote ..
>I was shocked! How could M.J.T. Guy <mjtg@cus.cam.ac.uk>
>say such a terrible thing:
>>Wyzelli <wyzelli@yahoo.com> wrote:
>>>
>>>As I have demonstrated previously, whilst calling $|++ repeatedly leaves
>>>the state of $| 'high' (or 'unbuffered' if you wish, since any non zero
>>>value = unbuffered), calling $|-- repeatedly can in certain
>>>circumstances cause $| to switch between a zero and non-zero value which
>>>can lead to misleading results.
>>
>>It's not "in certain circumstances"  -  it's in *all* circumstances.
>>
>>$| is magical and can only take values 0 or 1.    An attempt to set
>>any nonzero value sets it to 1.
>
>perl -we '$| = 0; $|--;$|++; print "\$| == $|";'
>$| == 1
>
>Ergo. using $|-- and $|++ is not safe as the fact that $| is magic means
>that doing these things in equal (ie. balanced) numbers does not get you
>back to where you started. This is a bad thing I think. You should
>always use 'local'.

while I'm still against it's use from a clarity standpoint - it's magic 
means that there's no way that $|++ will result in anything other than 
$| == 1 .. therefore

  {
    local $|;
    $|++;
  }

is always going to work as desired .. I'd prefer to do it in one clear 
line though with a

  local $| = 1;

-- 
  jason -- elephant@squirrelgroup.com --


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

Date: Fri, 14 Jul 2000 11:51:48 +0930
From: "Wyzelli" <wyzelli@yahoo.com>
Subject: Re: Why $|++ instead of $|=1 ?
Message-Id: <HNub5.6$oA.3943@vic.nntp.telstra.net>

jason <elephant@squirrelgroup.com> wrote in message
news:MPG.13d913ce7cbe40b98969e@news...
> Gwyn Judd wrote ..
>
> while I'm still against it's use from a clarity standpoint - it's
magic
> means that there's no way that $|++ will result in anything other than
> $| == 1 .. therefore
>
>   {
>     local $|;
>     $|++;
>   }
>
> is always going to work as desired .. I'd prefer to do it in one clear
> line though with a
>
>   local $| = 1;
>

I think the point we are making is that $|-- does NOT always set to 0
which is the dangerous half of the equation.

Wyzelli




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

Date: Fri, 14 Jul 2000 02:50:11 GMT
From: elephant@squirrelgroup.com (jason)
Subject: Re: Why $|++ instead of $|=1 ?
Message-Id: <MPG.13d91d359d08eb9298969f@news>

Wyzelli wrote ..
>jason <elephant@squirrelgroup.com> wrote in message
>news:MPG.13d913ce7cbe40b98969e@news...
>>
>> while I'm still against it's use from a clarity standpoint - it's
>> magic means that there's no way that $|++ will result in anything
>> other than $| == 1 .. therefore
>>
>>   {
>>     local $|;
>>     $|++;
>>   }
>>
>> is always going to work as desired .. I'd prefer to do it in one clear
>> line though with a
>>
>>   local $| = 1;
>>
>
>I think the point we are making is that $|-- does NOT always set to 0
>which is the dangerous half of the equation.

I think that point is well made .. although I'm half expecting someone 
to propose using $|-- all the time for toggling buffering on and off

to be honest - in all the code examples where I've seen $|++ I've never 
seen $|--

one should remember that $| only affects the buffering of the currently 
selected filehandle - so it's effectively localised by a new select() .. 
eg.

  # code begins
  open FOO, ">bar";
  select FOO;

  $|++;

  print STDOUT "\$| with FOO selected: [$|]\n";

  select STDOUT;

  print "\$| with STDOUT selected: [$|]\n";

  select FOO;

  print STDOUT "\$| with FOO selected: [$|]\n";
  # code ends

the majority of examples that I've seen using $|++ involve the following 
familiar construct

  select( (select(FOO), $|++)[0]);

my point is simply that it's probably not as critical as the volume of 
discussion it's receiving here would imply .. but I still prefer the 
$|=1 WTDI

-- 
  jason -- elephant@squirrelgroup.com --


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

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


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