[16100] in Perl-Users-Digest
Perl-Users Digest, Issue: 3512 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jun 29 14:15:38 2000
Date: Thu, 29 Jun 2000 11:15:27 -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: <962302527-v9-i3512@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Thu, 29 Jun 2000 Volume: 9 Number: 3512
Today's topics:
program automation jinrai@my-deja.com
Re: program automation <Peter.Dintelmann@dresdner-bank.com>
Re: return values without sub <billy@arnis-bsl.com>
Re: return values without sub (Tad McClellan)
Re: Strange behaviour in upper case conversion (Tad McClellan)
Re: Strange behaviour in upper case conversion <flavell@mail.cern.ch>
Re: Strange behaviour in upper case conversion <care227@attglobal.net>
Re: Strange behaviour in upper case conversion (Abigail)
String Cat Confussion don_bryant@my-deja.com
Re: String Cat Confussion <samay1NOsaSPAM@hotmail.com.invalid>
Re: String Cat Confussion perl_monkey@my-deja.com
Re: String Cat Confussion <billy@arnis-bsl.com>
Re: String Cat Confussion <stephen.kloder@gtri.gatech.edu>
Syntax question qq| <stuartfox@nospam.hotmail.com>
Re: Syntax question qq| <datm@uswest.net>
Re: Syntax question qq| <stuartfox@nospam.hotmail.com>
Re: Syntax question qq| (Tad McClellan)
Testing for local vs. global groups <stephen_carpenter@hp.com>
Re: upload <yuanjieNOyuSPAM@netscape.net.invalid>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 29 Jun 2000 15:11:45 GMT
From: jinrai@my-deja.com
Subject: program automation
Message-Id: <8jfouu$ckk$1@nnrp1.deja.com>
does anybody know how to automate a program using perl to run at a
certain time, on a windows NT machine.
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Thu, 29 Jun 2000 17:42:37 +0200
From: "Dr. Peter Dintelmann" <Peter.Dintelmann@dresdner-bank.com>
Subject: Re: program automation
Message-Id: <8jfqnv$htu1@intranews.dresdnerbank.de>
Hi,
jinrai@my-deja.com schrieb in Nachricht <8jfouu$ckk$1@nnrp1.deja.com>...
>does anybody know how to automate a program using perl to run at a
>certain time, on a windows NT machine.
use the schedule service (activate it in control panel -> services).
Then use the at command or the more comfortable winat utility
from the resource kit to enter your job.
BTW: there is nothing perl specific here....
Best regards,
Peter Dintelmann
------------------------------
Date: Thu, 29 Jun 2000 14:57:29 GMT
From: Ilja Tabachnik <billy@arnis-bsl.com>
Subject: Re: return values without sub
Message-Id: <8jfo4d$bvo$1@nnrp1.deja.com>
In article <395B5D1D.6DEDAA44@inf.fu-berlin.de>,
Hinrich Boog <boog@inf.fu-berlin.de> wrote:
> Hi there,
>
> I've got a short question on returning values:
>
> I am calling a perl-script from a cshell-script.
>
> set var= "`scriptname arguments`"
>
> The question is: How do I define the value that is returned by the
> perl-script? If I use return, the compiler tells me, that I can't use
> return outside a subroutine. I just want to reuse a value, that I
> calculated in my script...
>
IMHO when you use set var=`script args` you capture script's
standard output into var.
So you do need to return your script's result as an exit value,
but instead simply print $return_value;
Hope this helps.
Ilja.
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Thu, 29 Jun 2000 10:18:36 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: return values without sub
Message-Id: <slrn8lmmls.3sc.tadmc@magna.metronet.com>
On Thu, 29 Jun 2000 16:28:45 +0200, Hinrich Boog <boog@inf.fu-berlin.de> wrote:
>Hi there,
>
>I've got a short question on returning values:
>
>I am calling a perl-script from a cshell-script.
^^^^^^^^^^^^^
If you are writing _programs_ with a language designed for
_interactive_ use, you should expect problems:
"Csh Programming Considered Harmful"
http://www.perl.com/pub/language/versus/csh.html
>set var= "`scriptname arguments`"
>
>The question is: How do I define the value that is returned by the
>perl-script? If I use return, the compiler tells me, that I can't use
>return outside a subroutine. I just want to reuse a value, that I
>calculated in my script...
perldoc -f exit
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Thu, 29 Jun 2000 10:14:06 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Strange behaviour in upper case conversion
Message-Id: <slrn8lmmde.3sc.tadmc@magna.metronet.com>
On Thu, 29 Jun 2000 10:30:45 -0400, Drew Simonis <care227@attglobal.net> wrote:
>Philip Lees wrote:
>>
>> Hi. I'm trying to learn something about regex use in Perl and I came
>> across a curious problem. I started with something simple:
>>
>> ($name = $name) =~ tr/[a-z]/[A-Z]/;
>
>Why are you using this ($name = $name) notation? You aren't making a
>modification of the lvalue, so its really not needed.
>
>$name =~ tr/[a-z]/[A-Z]/; # will work just as well.
But still spends cycles that do not change anything (for
the first and last characters in the lists).
>> This converts $name to upper case. Fine.
>>
>> Now suppose I want to make just the first letter upper case and leave
>> the rest as it is. From what I've read in perlop and perlre, the ^
>> operator should match just the first character of the string. So
>
>Wrong. The ^ matches the start of a line/string, which is really
>_before_ the first position. So this will match only at the start
>of a line/string. That is, for a normal regex. I don't see anything
>in perlre or perlop to specify that when using the tr/// operator ^
>has a different meaning.
Also Wrong :-)
What you don't see in perlop is any mention of regular
expressions in connection with tr///
:-)
>>
>> ($name = $name) =~ tr/^[a-z]/[A-Z]/;
>>
>
>But, from the perlop page we see that tr "Transliterates all
>occurrences of the characters found in the search list with
^^^^
>the corresponding character in the replacement list", so you
^^^^
No mention of regular expressions to be found...
>(disclaimer: I suck with regular expressions =)
That's OK, because we are talking about tr///, and there
are no regular expressions involved.
:-)
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Thu, 29 Jun 2000 17:13:05 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Strange behaviour in upper case conversion
Message-Id: <Pine.GHP.4.21.0006291707260.5746-100000@hpplus03.cern.ch>
On Thu, 29 Jun 2000, Tad McClellan wrote:
> >This converts $name to upper case. Fine.
[...]
> and so does
>
> $name =~ tr/a-z/A-Z/;
Not if you have accented letters in the string, it doesn't.
> Perl FAQ, part 4:
>
> "How do I capitalize all the words on one line?"
This has to be a subtle Perl-insider joke in the FAQ here:
| This has the strange effect of turning "C<don't do it>" into "C<Don'T
| Do It>". Sometimes you might want this, instead (Suggested by Brian
| Foy):
cheers
------------------------------
Date: Thu, 29 Jun 2000 11:38:21 -0400
From: Drew Simonis <care227@attglobal.net>
Subject: Re: Strange behaviour in upper case conversion
Message-Id: <395B6D6D.3FD01D75@attglobal.net>
Tad McClellan wrote:
> >
> >$name =~ tr/[a-z]/[A-Z]/; # will work just as well.
>
> But still spends cycles that do not change anything (for
> the first and last characters in the lists).
I didn't say it worked well, but just as well as the OPs =)
. o O (I don't think he'll buy that, but its worth a throw)
>
> Also Wrong :-)
>
> What you don't see in perlop is any mention of regular
> expressions in connection with tr///
>
As soon as I saw Ala's post explaining that, I knew the blunder I
had made. It was just too late for a cancel to have any hope of
saving my brusied and battered ego. And I was sure I was getting
better. =)
Forever a newb.
DS
------------------------------
Date: 29 Jun 2000 12:00:07 EDT
From: abigail@delanet.com (Abigail)
Subject: Re: Strange behaviour in upper case conversion
Message-Id: <slrn8lmtm2.ka1.abigail@alexandra.delanet.com>
Philip Lees (pjlees@ics.forthcomingevents.gr) wrote on MMCDXCIV September
MCMXCIII in <URL:news:395b077a.69690459@news.grnet.gr>:
"" Hi. I'm trying to learn something about regex use in Perl and I came
"" across a curious problem. I started with something simple:
""
"" ($name = $name) =~ tr/[a-z]/[A-Z]/;
""
"" This converts $name to upper case. Fine.
Well, only if you use the letters from the ASCII set. It won't do
accented letters, other letters from Unicode, and it will ignore
your locale as well. On top of that, why are you replacing '['
with '[', and ']' with ']'?
"" Now suppose I want to make just the first letter upper case and leave
"" the rest as it is. From what I've read in perlop and perlre, the ^
"" operator should match just the first character of the string. So
""
"" ($name = $name) =~ tr/^[a-z]/[A-Z]/;
""
"" should do the job. Right? Wrong. What it does is convert the whole
"" string to upper case _and_ bump each character up by one ASCII code,
"" thus 'foo' becomes 'GPP', etc. Can anyone explain this?
Why are you looking in perlre for explaination of tr///? tr does *not*
use regular expressions. tr changes strings on a character by character
basis. So, it turns '^' into a '[', a '[' into an 'A', 'a' into 'B', etc.
"" My aim is to find something that formats names in a consistent way
"" from user input, so that
""
"" fiRsTnAmE LaStNaME would become
""
"" Firstname LASTNAME.
""
"" The reason I'm doing it this way is because I work in a bilingual
"" environment and uc() and lc() don't work for the Greek character set,
"" (e.g. join( '',uc( substr( $first,0,1)), lc(substr($first,1)) works
"" in English, but not in Greek), whereas my first example works in both
"" languages (if I add the Greek character ranges, of course).
Then you have set your locale wrong. If your locale is set up right,
uc and lc should work.
"" Incidentally, my second attempt above, when modified to include Greek,
"" does the same as before, except that some Greek letters are bumped up
"" by one and others by two ASCII codes. Bizarre!
""
"" I'm sure this will seem quite simple to you gurus. All help
"" appreciated.
You should set up your locale correctly, and then use the answer from
the FAQ.
Abigail
--
sub _'_{$_'_=~s/$a/$_/}map{$$_=$Z++}Y,a..z,A..X;*{($_::_=sprintf+q=%X==>"$A$Y".
"$b$r$T$u")=~s~0~O~g;map+_::_,U=>T=>L=>$Z;$_::_}=*_;sub _{print+/.*::(.*)/s}
*_'_=*{chr($b*$e)};*__=*{chr(1<<$e)};
_::_(r(e(k(c(a(H(__(l(r(e(P(__(r(e(h(t(o(n(a(__(t(us(J())))))))))))))))))))))))
------------------------------
Date: Thu, 29 Jun 2000 16:01:49 GMT
From: don_bryant@my-deja.com
Subject: String Cat Confussion
Message-Id: <8jfrt0$f5v$1@nnrp1.deja.com>
Please consider the following:
my $string1="/export/home/";
my $string2="00-06-30";
my $new_path="";
$new_path= join $new_path, $string1, $string2, "/";
The value of $new_path will now be:
"/export/home/00-06-30" instead of
"/export/home/00-06-30/".
How do I append a trailing "/" to the string? I do realize that
$new_path= join $new_path, $string1, $string2, "/";
actually places the "/" in "/export... at the beginning of the string
instead of the end but I don't understand why? Any help would be
appreciated.
Don Bryant
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Thu, 29 Jun 2000 09:20:08 -0700
From: Samay <samay1NOsaSPAM@hotmail.com.invalid>
Subject: Re: String Cat Confussion
Message-Id: <018d7f80.68be94bc@usw-ex0104-033.remarq.com>
It works fine on my machine:
$ cat > s1.pl
#!/usr/local/bin/perl
my $string1="/export/home/";
my $string2="00-06-30";
my $new_path="";
$new_path= join $new_path, $string1, $string2, "/";
print $new_path,"\n";
$ perl s1.pl
/export/home/00-06-30/
-----------------------------------------------------------
Got questions? Get answers over the phone at Keen.com.
Up to 100 minutes free!
http://www.keen.com
------------------------------
Date: Thu, 29 Jun 2000 16:15:59 GMT
From: perl_monkey@my-deja.com
Subject: Re: String Cat Confussion
Message-Id: <8jfsnb$fqo$1@nnrp1.deja.com>
In article <8jfrt0$f5v$1@nnrp1.deja.com>,
don_bryant@my-deja.com wrote:
> Please consider the following:
>
> my $string1="/export/home/";
> my $string2="00-06-30";
> my $new_path="";
>
> $new_path= join $new_path, $string1, $string2, "/";
this is backasswards. This should be:
join "/", $newpath, $string1, $string2;
(what you're joining by comes first, then what you're joining together.)
> How do I append a trailing "/" to the string? I do realize that
> $new_path= join $new_path, $string1, $string2, "/";
Ah, this is something different. This will do the trick though:
$new_path = $new_path . $string1 . $string2 . "/";
The "." operator concatenates strings. so:
$foobar = "Hello " . "World!\n";
print $foobar;
Yields "Hello World!"
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Thu, 29 Jun 2000 16:28:22 GMT
From: Ilja Tabachnik <billy@arnis-bsl.com>
Subject: Re: String Cat Confussion
Message-Id: <8jftec$gkk$1@nnrp1.deja.com>
In article <8jfrt0$f5v$1@nnrp1.deja.com>,
don_bryant@my-deja.com wrote:
> Please consider the following:
>
> my $string1="/export/home/";
> my $string2="00-06-30";
> my $new_path="";
>
> $new_path= join $new_path, $string1, $string2, "/";
>
> The value of $new_path will now be:
> "/export/home/00-06-30" instead of
>
> "/export/home/00-06-30/".
>
> How do I append a trailing "/" to the string? I do realize that
> $new_path= join $new_path, $string1, $string2, "/";
>
> actually places the "/" in "/export... at the beginning of the string
> instead of the end but I don't understand why? Any help would be
> appreciated.
>
Strange, I just cut&pasted your code and run it,
$new_path becomes /export/home/00-06-30/ as expected
(perl 5.005_03 built for aix).
BTW using $new_path as a first arg to join()
seems a bit strange for me in this context.
Maybe more clear:
$new_path= join '', $string1, $string2, "/";
OK, it doesn't matter in your example.
Hope this helps.
Ilja.
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Thu, 29 Jun 2000 12:46:21 -0400
From: Stephen Kloder <stephen.kloder@gtri.gatech.edu>
Subject: Re: String Cat Confussion
Message-Id: <395B7D5D.8F862060@gtri.gatech.edu>
Samay wrote:
> It works fine on my machine:
>
> $ cat > s1.pl
> #!/usr/local/bin/perl
> my $string1="/export/home/";
> my $string2="00-06-30";
> my $new_path="";
> $new_path= join $new_path, $string1, $string2, "/";
> print $new_path,"\n";
>
> $ perl s1.pl
> /export/home/00-06-30/
>
That's because $new_path= join $new_path, $string1, $string2, "/"; has
the same effect as $new_path = $string1 . $string2 . "/"; which is what
was desired. Remember that the string used between list elements is the
first parameter.
------------------------------
Date: Thu, 29 Jun 2000 16:22:07 +0100
From: "Stuart Fox" <stuartfox@nospam.hotmail.com>
Subject: Syntax question qq|
Message-Id: <8jfpmo$6rs$1@supernews.com>
If anyone can decipher this for me, I'd be most grateful...
We've inherited a perl script which is a bit dodgy. There is some syntax
that we're not sure on. There is a line like this
$msg = qq|Invalid Login: Please re-enter your Username and Password.|;
What is the meaning of qq| ?
Cheers
Stu
------------------------------
Date: Thu, 29 Jun 2000 08:42:41 -0700
From: "Dan Brown" <datm@uswest.net>
Subject: Re: Syntax question qq|
Message-Id: <XUL65.99$bu1.156013@news.uswest.net>
Stuart Fox <stuartfox@nospam.hotmail.com> wrote in message
news:8jfpmo$6rs$1@supernews.com...
> If anyone can decipher this for me, I'd be most grateful...
>
> We've inherited a perl script which is a bit dodgy. There is some syntax
> that we're not sure on. There is a line like this
> $msg = qq|Invalid Login: Please re-enter your Username and Password.|;
>
> What is the meaning of qq| ?
>
> Cheers
>
> Stu
I'll give you a clue. The qq has to do with some type of quote. The | is a
delimiter.
Check out
perldoc -f qq
or even better
perldoc perlop
(This works on both Unix and in a DOS window if you have ActiveState
installed on the Windoze box).
Dan
------------------------------
Date: Thu, 29 Jun 2000 16:57:28 +0100
From: "Stuart Fox" <stuartfox@nospam.hotmail.com>
Subject: Re: Syntax question qq|
Message-Id: <8jfrp1$693$1@supernews.com>
"Dan Brown" <datm@uswest.net> wrote in message
news:XUL65.99$bu1.156013@news.uswest.net...
> Stuart Fox <stuartfox@nospam.hotmail.com> wrote in message
> news:8jfpmo$6rs$1@supernews.com...
> > If anyone can decipher this for me, I'd be most grateful...
> >
> > We've inherited a perl script which is a bit dodgy. There is some
syntax
> > that we're not sure on. There is a line like this
> > $msg = qq|Invalid Login: Please re-enter your Username and Password.|;
> >
> > What is the meaning of qq| ?
> >
> > Cheers
> >
> > Stu
>
> I'll give you a clue. The qq has to do with some type of quote. The | is
a
> delimiter.
>
> Check out
>
> perldoc -f qq
>
> or even better
>
> perldoc perlop
>
> (This works on both Unix and in a DOS window if you have ActiveState
> installed on the Windoze box).
>
Cheers. That's cleared that up.
------------------------------
Date: Thu, 29 Jun 2000 12:35:45 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Syntax question qq|
Message-Id: <slrn8lmun1.43k.tadmc@magna.metronet.com>
On Thu, 29 Jun 2000 16:22:07 +0100, Stuart Fox
<stuartfox@nospam.hotmail.com> wrote:
>If anyone can decipher this for me, I'd be most grateful...
perldoc perlop
See the "Quote and Quote-like Operators" section.
>We've inherited a perl script which is a bit dodgy. There is some syntax
>that we're not sure on. There is a line like this
> $msg = qq|Invalid Login: Please re-enter your Username and Password.|;
Equivalent to:
$msg = "Invalid Login: Please re-enter your Username and Password.";
It is an alternative way of quoting a string.
Which is indeed "dodgy", as the above is also equivalent to:
$msg = 'Invalid Login: Please re-enter your Username and Password.';
which means you do not have to scan the string looking for variables
when debugging.
So the undodgy (though unnecessarily obfuscated) way would have been:
$msg = q|Invalid Login: Please re-enter your Username and Password.|;
:-)
>What is the meaning of qq| ?
The same as "
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Thu, 29 Jun 2000 08:32:47 -0700
From: Stephen Carpenter <stephen_carpenter@hp.com>
Subject: Testing for local vs. global groups
Message-Id: <395B6C1F.43C387C7@hp.com>
Hello,
I am using ActiveState Perl build 522 on NT and Win2K. I would like
to know if anyone has found a simple way to test for local groups on the
PDC vs global groups. The reason I ask is because
Win32::NetAdmin::GroupGetMembers only works with global groups and
Win32::NetAdmin::LocalGroupGetMembers only works with local groups.
I can do something like the pseudocode below:
if (Win32::NetAdmin::GroupGetMembers) {
etc.
}
elseif {
Win32::NetAdmin::LocalGroupGetMembers
same etc. as above
}
else { errorstuff}
but I would prefer to do something like:
testfunction($code);
if $code = 1 is not a valid group name die
if $code = 2 is global
if $code = 3 is local
execute correct netadmin statement
execute etc.
------------------------------
Date: Thu, 29 Jun 2000 08:21:11 -0700
From: yuanj <yuanjieNOyuSPAM@netscape.net.invalid>
Subject: Re: upload
Message-Id: <01ec71a0.fd746d7d@usw-ex0102-014.remarq.com>
We all do. Now what?
-----------------------------------------------------------
Got questions? Get answers over the phone at Keen.com.
Up to 100 minutes free!
http://www.keen.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 3512
**************************************