[13861] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1271 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Nov 3 18:15:38 1999

Date: Wed, 3 Nov 1999 15:15:22 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <941670922-v9-i1271@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Wed, 3 Nov 1999     Volume: 9 Number: 1271

Today's topics:
        proposed "??" operator causing ambiguous syntax (Bart Lateur)
    Re: proposed "??" operator causing ambiguous syntax <rootbeer@redcat.com>
        Real Gurus Please Help: eval behavior problem! If you k <dani@3dsite.com>
    Re: Real Gurus Please Help: eval behavior problem! If y <rootbeer@redcat.com>
        search/replace with variables (Scott Stark)
    Re: search/replace with variables (Bill Moseley)
    Re: search/replace with variables (Michael Budash)
    Re: Using Perl on an NT Platform <lloyd@cs.toronto.edu>
    Re: Using Perl on an NT Platform (Jan Dubois)
    Re: What does HAND mean? <jhelgesen@my-deja.com>
    Re: What does HAND mean? <scottlm@visi.com>
    Re: What does HAND mean? <rootbeer@redcat.com>
    Re: What does HAND mean? <link@nowhere.org>
    Re: Year 2000 date problem (Craig Berry)
    Re: Year 2000 date problem (Kragen Sitaker)
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Wed, 03 Nov 1999 21:04:34 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: proposed "??" operator causing ambiguous syntax
Message-Id: <38229c02.763402@news.skynet.be>

A while ago, I suggested that the proposed "??" operator would conflict
with existing Perl code, most notably the ?PATTERN? syntax ( "??" does
look like an empty pattern, however you look at it) but also with ?:.
Abigail dared me to find an example, and I couldn't at the time. I think
I have found an example now. Here it is, the expression:

	$x??$pat?-1:1

which can be either

	$x ?? ( $pat ? -1 : 1 )

or

	$x ? ( ?$pat? - 1 ) : 1

(parentheses added for clarity)

-- 
	Bart.


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

Date: Wed, 3 Nov 1999 14:49:59 -0800
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: proposed "??" operator causing ambiguous syntax
Message-Id: <Pine.GSO.4.10.9911031442011.29670-100000@user2.teleport.com>

On Wed, 3 Nov 1999, Bart Lateur wrote:

> 	$x??$pat?-1:1
> 
> which can be either
> 
> 	$x ?? ( $pat ? -1 : 1 )
> 
> or
> 
> 	$x ? ( ?$pat? - 1 ) : 1

Yes. Still, since you had to search and search to find this one example,
there's not much chance that any real-world program will suffer from this
ambiguity. Thus, if the _only_ argument against this operator were this
weak one, no one should have a problem with it.

Note: I am expressing neither pro nor con opinions about whether the
proposed operator would be useful. I'm commenting only upon the
potentially ambiguous syntax.

Having said that, I see that we don't complain that these are potentially
ambiguous if whitespace is removed:

    $fred =~ $barney;

    $fred = ~ $barney;

Requiring reasonable whitespace is, well, reasonable. 

Cheers!

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



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

Date: Wed, 03 Nov 1999 12:54:40 -0800
From: Daniele Colajacomo <dani@3dsite.com>
Subject: Real Gurus Please Help: eval behavior problem! If you know the debugger  this will freak you out!
Message-Id: <3820A110.614D1F40@3dsite.com>


I'm having very strange behavior from eval statements, which
I've narrowed down with the following extra code:

       
        my $trace3 = 0;
        my $trace4 = 0;
        eval("\%{\$this->{_co_attributes_}} = ( 'object_tables' => '1'
)");
        eval ("\$trace3 = \$this->{_co_attributes_}"); 
        $trace4 = $this->{_co_attributes_};

The basic problem is that $this->{_co_attributes_}{'object_tables'} does
not
seem to be recognized as defined outside of the eval. 

In theory, $trace3 and $trace4 should both have the same value after the
code
above is executed, right? Running it in the debugger:

 DB<97> x $trace3
0  HASH(0x8c9484)
   'object_tables' => 1

  DB<98> x $trace4
0  HASH(0x6fe738)
     empty hash


But then, the debugger sees $this->{_co_attributes_} perfectly, while 
the code itself seems to get its addresses mixed up (ie. executing
a "x if(defined($this->{_co_attributes_}{'objects_table'})) { print
"foo"; }"
works fine in the debugger (prints "foo") but the same line of code
fails when executed in the regular code, claiming that the element is
not
defined.

also if I execute, in the debugger:
 DB<99> x $trace4 = $this->{_co_attributes_};
0  HASH(0x8c9484)
   'object_tables' => 1

so $trace4 - if the same line is executed in the debugger, is set
correctly.

Any clues as to what may be wrong? I'm losing my mind since the debugger
seems
useless (everything seems to be working as it should). I'm at the limit
of
my knowledge of how perl works, I can't figure this one out!

Please help!
Thanks,
Daniele Colajacomo


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

Date: Wed, 3 Nov 1999 14:57:33 -0800
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Real Gurus Please Help: eval behavior problem! If you know the debugger  this will freak you out!
Message-Id: <Pine.GSO.4.10.9911031452370.29670-100000@user2.teleport.com>

On Wed, 3 Nov 1999, Daniele Colajacomo wrote:

> Subject : Re: Real Gurus Please Help: eval behavior problem! If you know
>	the debugger  this will freak you out!

Please check out this helpful information on choosing good subject
lines. It will be a big help to you in making it more likely that your
requests will be answered.

    http://www.perl.com/CPAN/authors/Dean_Roehrich/subjects.post

> I'm having very strange behavior from eval statements, which
> I've narrowed down with the following extra code:
> 
>        
>         my $trace3 = 0;
>         my $trace4 = 0;
>         eval("\%{\$this->{_co_attributes_}} = ( 'object_tables' => '1'
> )");
>         eval ("\$trace3 = \$this->{_co_attributes_}"); 

eval STRING is evil. Avoid avoid avoid. 

But if you must use it and it's giving you troubles, you should 

    Check $@

    Try printing the string before (or instead of) running the eval

Still, what you seem to be doing is trying to use (soft?) references. This
is not a task for the evil eval. See the perlref manpage.

Good luck!

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



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

Date: 3 Nov 1999 20:27:16 GMT
From: sstark@sirius.com (Scott Stark)
Subject: search/replace with variables
Message-Id: <7vq5r4$o011@webint.na.informix.com>

I've got a simple regex replacement using variables:

	$line=~s/$var1/$var2/;

I've found that if the value of $var1 contains a question mark, the replacement 
isn't done. For example:

 $var1 gets assigned the string:

  <a href="bmcmd7.html#109955">? command&#32;<br>?</a>";

 $var2 gets:

  ? command&#32;

Any idea why this is so? Is perl interpreting it as a metacharacter? The 
substitution works for all other lines in my file that don't contain a question 
mark.

thanks,
Scott Stark



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

Date: Wed, 3 Nov 1999 12:51:49 -0800
From: moseley@best.com (Bill Moseley)
Subject: Re: search/replace with variables
Message-Id: <MPG.128a4040d13df65d98983e@nntp1.ba.best.com>

Scott Stark (sstark@sirius.com) seems to say...
> I've got a simple regex replacement using variables:
> 
> 	$line=~s/$var1/$var2/;
> 
> I've found that if the value of $var1 contains a question mark, the replacement 
> isn't done. For example:

 	$line=~s/\Q$var1\E/$var2/;

-- 
Bill Moseley mailto:moseley@best.com
pls note the one line sig, not counting this one.


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

Date: Wed, 03 Nov 1999 13:11:43 -0800
From: mbudash@wcws.com (Michael Budash)
Subject: Re: search/replace with variables
Message-Id: <mbudash-0311991311430001@adsl-216-103-91-123.dsl.snfc21.pacbell.net>

In article <7vq5r4$o011@webint.na.informix.com>, sstark@sirius.com (Scott
Stark) wrote:

> I've got a simple regex replacement using variables:
> 
>         $line=~s/$var1/$var2/;
> 
> I've found that if the value of $var1 contains a question mark, the
replacement 
> isn't done. For example:
> 
>  $var1 gets assigned the string:
> 
>   <a href="bmcmd7.html#109955">? command&#32;<br>?</a>";
> 
>  $var2 gets:
> 
>   ? command&#32;
> 
> Any idea why this is so? Is perl interpreting it as a metacharacter?

yes. this was just discussed today. try:

$line=~s/\Q$var1/$var2/;

hth-
-- 
Michael Budash ~~~~~~~~~~ mbudash@wcws.com


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

Date: Wed, 3 Nov 1999 19:43:23 GMT
From: Lloyd Smith <lloyd@cs.toronto.edu>
To: patelni101480@my-deja.com
Subject: Re: Using Perl on an NT Platform
Message-Id: <3820905B.C5036E0@cs.toronto.edu>

patelni101480@my-deja.com wrote:
> 
> But when I try to use it, it gives me all the different shutdown
> options, it won't actually shutdown the machine.  I can shutdown my own
> local computer, but I can't shutdown other computers on a network.
> Anyone have any suggestions???

As I recall, the shutdown syntax takes a netbios machine name as an 
argument: 

  shutdown \\machinename

you need to escape the backslashes: 

  system ("shutdown \\\\machinename");

HTH,
lloyd


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

Date: Wed, 03 Nov 1999 21:51:21 +0100
From: jand@activestate.com (Jan Dubois)
Subject: Re: Using Perl on an NT Platform
Message-Id: <38239d00.3496708@news3.ibm.net>

[mailed & posted]

patelni101480@my-deja.com wrote:

>I am trying to get Perl to use the NT command called shutdown.  This
>command allows me to shutdown other computers on a network.  In Perl I
>know there is a command called system, that would let me use shutdown.
>But when I try to use it, it gives me all the different shutdown
>options, it won't actually shutdown the machine.  I can shutdown my own
>local computer, but I can't shutdown other computers on a network.
>Anyone have any suggestions???

Show us some code!  Did you forget to double backslashes inside "" strings?

Do you know that the Win32 module contains a Win32::InitiateSystemShutdown
function?  Read about it in `perldoc Win32`:

Win32::InitiateSystemShutdown(MACHINE, MESSAGE, TIMEOUT, FORCECLOSE, REBOOT)
        [EXT] Shutsdown the specified MACHINE, notifying users with
        the supplied MESSAGE, within the specified TIMEOUT interval.
        Forces closing of all documents without prompting the user
        if FORCECLOSE is true, and reboots the machine if REBOOT is
        true. This function works only on WinNT.

Don't forget the "use Win32;" statement should you choose to try this
function.

-Jan


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

Date: Wed, 03 Nov 1999 20:29:00 GMT
From: BlastMaster <jhelgesen@my-deja.com>
Subject: Re: What does HAND mean?
Message-Id: <7vq5u5$cs1$1@nnrp1.deja.com>


> Helping Another Newbie, Damn.

"Handled Adeptly, Nobody Died."


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


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

Date: Wed, 03 Nov 1999 14:57:57 -0600
From: Scott McGerik <scottlm@visi.com>
Subject: Re: What does HAND mean?
Message-Id: <3820A1D5.36B4348A@visi.com>

Abigail wrote:

> Scott McGerik (scottlm@visi.com) wrote on MMCCLV September MCMXCIII in
> <URL:news:3820676B.93BC6880@visi.com>:
> && Abigail wrote:
> &&
> && > HTH. HAND.
> &&
> && What does HAND mean? I am not familiar with it.
> 
> It's the piece of meat that connects your fingers to your wrist.

Hmmm, I believe Jonathan Stowe gets the award for that answer.
However, I was not asking what a hand was. I was asking what HAND
meant. A different question entirely. Sometimes, some people try to
hard to be witty....

Scott.


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

Date: Wed, 3 Nov 1999 14:32:08 -0800
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: What does HAND mean?
Message-Id: <Pine.GSO.4.10.9911031431430.29670-100000@user2.teleport.com>

On Wed, 3 Nov 1999, Scott McGerik wrote:

> However, I was not asking what a hand was. I was asking what HAND
> meant. A different question entirely. Sometimes, some people try to
> hard to be witty....

 ....that they're only half-witty.

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



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

Date: Wed, 03 Nov 1999 22:59:52 GMT
From: "ling" <link@nowhere.org>
Subject: Re: What does HAND mean?
Message-Id: <I73U3.34961$Jp4.55931@news20.bellglobal.com>

Hack as none did.

kieu




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

Date: Wed, 03 Nov 1999 21:49:39 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Year 2000 date problem
Message-Id: <s21bfjog24218@corp.supernews.com>

ofuuzo (ofuuzo@ub.uit.no) wrote:
: I  have the following perl date/time script:
: 
: @months = ('Jan','Feb','Mar','Apr','May','Jun',
:    'Jul','Aug','Sept','Oct','Nov','Dec');
: @days = ('Sun','Mon','Tue','Wed','Thur','Fri','Sat');

No -w?  No 'use strict'?  Sheer masochism.  Let the language help you;
nobody will think you less macho or anything.

For future ref, the above can be more legibly written

  @months = qw(Jan Feb Mar Apr May Jun Jul Aug Sept Oct Nov Dec);
  @days   = qw(Sun Mon Tue Wed Thur Fri Sat);

By the way, is it intentional that September and Thursday don't follow the
3-character-abbreviation patten?  Looks weird to me.

Also, note that strftime (perldoc POSIX) is a much easier way to format
dates nicely.

: ($sec,$min,$hour,$mday,$mon,$year,$wday) =
: (localtime(time))[0,1,2,3,4,5,6];

Noting that 'time' is the default argument of time, and using a subrange
to do the list slice, we derive the more concise

  ($sec, $min, $hour, $mday, $mon, $year, $wday) = (localtime)[0..6];

: if ($year > "96") {
:  $yd = "19$year";
: }
: else {
:  $yd = "20$year";
: }

Ow. :(  You have read the manual (in this case, perldoc -f localtime),
right?  I mean, who would start using a tool without understanding it?

: When I set the year in my computer to 1999,  the exact day, month  and
: year will be printed. But when I set the year in my computer to 2000,
: the year changes to 19100 instead of 2000.
: What is wrong with the above script. I need help.

I don't know; it seems to be doing precisely what you told it to do.  For
all values returned in the year field from localtime which are greater
than 96 (why the string-ish quoting on that, by the way?), you prepend the
string '19'.  So, when the year gets the value it is defined in the doc
(which you have of course read, as mentioned above) to have in the year
2000, that value is tacked onto the end of '19', just as your script says
should happen.

Did you want something different?  If so, why did you code it as you have?

-- 
   |   Craig Berry - cberry@cinenet.net
 --*--  http://www.cinenet.net/users/cberry/home.html
   |   "They do not preach that their God will rouse them
      a little before the nuts work loose." - Kipling


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

Date: Wed, 03 Nov 1999 22:43:35 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: Year 2000 date problem
Message-Id: <rU2U3.25585$23.1330878@typ11.nn.bcandid.com>

In article <s21bfjog24218@corp.supernews.com>,
Craig Berry <cberry@cinenet.net> wrote:
> I mean, who would start using a tool without understanding it?

I have never understood a tool without using it first.  I do, however,
generally read the manual.
-- 
<kragen@pobox.com>       Kragen Sitaker     <http://www.pobox.com/~kragen/>
Tue Nov 02 1999
6 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>


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

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


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