[23571] in Perl-Users-Digest
Perl-Users Digest, Issue: 5778 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Nov 11 03:05:43 2003
Date: Tue, 11 Nov 2003 00:05:10 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Tue, 11 Nov 2003 Volume: 10 Number: 5778
Today's topics:
Re: dates (David Efflandt)
Re: globals and while <qumsieh@cim.mcgill.ca>
Re: installing perl <kingsman22004@yahoo.com>
Re: installing perl <kingsman22004@yahoo.com>
Re: Interaction between two strings (Hae Jin)
Re: Perl Newbie <usenet@dwall.fastmail.fm>
Re: print statement spanning multiple lines <bigiain@mightymedia.com.au>
Re: print statement spanning multiple lines <nobody@dev.null>
Re: print statement spanning multiple lines <kuujinbo@hotmail.com>
Re: print statement spanning multiple lines <jwillmore@remove.adelphia.net>
Re: print statement spanning multiple lines <nospam@bigpond.com>
Re: Problems with Sendmail <nobody@dev.null>
went to 5.8.1 and now I can't access object data dynami (Sophie Miron)
Re: went to 5.8.1 and now I can't access object data dy (Jay Tilton)
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 11 Nov 2003 02:05:32 +0000 (UTC)
From: efflandt@xnet.com (David Efflandt)
Subject: Re: dates
Message-Id: <slrnbr0gvc.4co.efflandt@typhoon.xnet.com>
On Mon, 10 Nov 2003 21:06:36 GMT, Uri Guttman <uri@stemsystems.com> wrote:
>>>>>> "GJ" == Glenn Jackman <xx087@freenet.carleton.ca> writes:
>
> GJ> Matt Oliverius <moliverius@w-link.net> wrote:
> >> $date = `date`;
> >>
> >> I get time in UTC format. How would I change the assignment above so that
> >> I can get time in Pacific Standard Time?
>
> GJ> $date = `env TZ=PST date`;
>
> why fork off a process (even if the OP did)?
>
> perl -le 'print scalar localtime'
> Mon Nov 10 16:00:47 2003
>
> perl -le '$ENV{TZ}="PST" ; print scalar localtime'
> Mon Nov 10 21:01:07 2003
Actually that should be $ENV{TZ}="PST8PDT" (or use 'tzselect' to determine
alternate TZ string, which for US Pacific coast would be
'America/Los_Angeles'. Also see 'strftime' in 'perldoc POSIX' for
formatted time including timezone.
--
David Efflandt - All spam ignored http://www.de-srv.com/
------------------------------
Date: Tue, 11 Nov 2003 06:14:57 GMT
From: "Ala Qumsieh" <qumsieh@cim.mcgill.ca>
Subject: Re: globals and while
Message-Id: <B7%rb.10279$IP4.1026@newssvr25.news.prodigy.com>
"Uri Guttman" <uri@stemsystems.com> wrote in message
news:x77k28101l.fsf@mail.sysarch.com...
> >>>>> "AQ" == Ala Qumsieh <xxala_qumsiehxx@xxyahooxx.com> writes:
>
> >> >>>>> "MP" == Matija Papec <perl@my-header.org> writes:
> >>
> MP> my $x = 3;
> MP> print "$y\n" while my $y = $x--;
>
> AQ> But I thought that the OP's code was symantically identical to the
> AQ> following:
>
> AQ> use strict;
> AQ> my $x = 3;
> AQ> while (my $y = $x--) {
> AQ> print "$y\n";
> AQ> }
>
> AQ> and this is perfectly fine. Why the difference in behaviour then?
>
> how are those the same? the OP's code was a single statement, yours is a
> while with a block. in the former, my $y means $y is not visible until
> the next statement. in your code $y is visible to the code in the block.
I never said they were the same, just that I thought they were semantically
(sic) identical. I guess I'm wrong, but I don't really understand why. You
say that in the OP's code, the $y is not visible until the next statement,
but that doesn't seem intuitive to me since the "body" of the while loop
(i.e the print statement) will not execute until after the condition
(setting my $y = $x--) has been tested, at which point $y has been defined
as a lexical variable. And since it's defined in the condition part of the
while loop, then it ought to be available in the body, just like my longer
version of the code. To me (and I have never designed a language, so please
excuse my ignorance), both versions of the code ought to behave the same way
(the OP's version has an "invisible block" if you will). But, I get the
feeling that this might break something.
Btw, is this related to the fact that in statements of the form "EXPR
foreach EXPR" you can only use $_ as your loop variable?
Now, I would immediately see why this is wrong:
do {
print "$y\n";
} while my $y = $x--;
since this will evaluate the body before the condition.
--Ala
------------------------------
Date: Tue, 11 Nov 2003 15:53:27 +1100
From: King <kingsman22004@yahoo.com>
Subject: Re: installing perl
Message-Id: <3FB06B47.3090401@yahoo.com>
>>Ben Morrow wrote:
> OK... you used Configure -d, so it took all default answers.
> Check for me: after running Configure, config.sh contains
> prefix='/usr/local'
> and
> installprefix='/usr/local'
> ?
Yes, both point to /user/local. BUT after I did the following steps.
I put back the symlink pointing to perl5.6.1:
rm /usr/bin/perl;
ln -s perl5.6.1 /usr/bin/perl
:/home/username/#/usr/bin/perl5.6.1
print 1\n;
1
Once things stabilized, I went back to perl-5.8.1 directory and start
over, but left out the -de
reboot into a new root shell, no kde or x environment.
:/home/username/#tar -zxvf stable.tar.gz
:/home/username/#cd perl-5.8.1
:/home/username/perl-5.8.1#rm -f config.sh Policy.sh
:/home/username/perl-5.8.1#sh Configure
accept all the defaults except
Directories to use for library searches? [/usr/local/lib /lib /usr/lib]
/usr/local/lib
make
...whole bunch of lines
libperl.a(pp.o): In function `Perl_pp_pow':
pp.o(.text+0x1e22): undefined reference to `pow'
libperl.a(pp.o): In function `Perl_pp_sin':
pp.o(.text+0x5b08): undefined reference to `sin'
libperl.a(pp.o): In function `Perl_pp_cos':
pp.o(.text+0x5c0c): undefined reference to `cos'
libperl.a(pp.o): In function `Perl_pp_exp':
pp.o(.text+0x5e0c): undefined reference to `exp'
libperl.a(pp.o): In function `Perl_pp_log':
pp.o(.text+0x5f4d): undefined reference to `log'
libperl.a(pp.o): In function `Perl_pp_sqrt':
pp.o(.text+0x60a3): undefined reference to `sqrt'
collect2: ld returned 1 exit status
make: *** [miniperl] Error 1
:/home/username/perl-5.8.1#
should I go with
make test
make install
what about this Error 1 thing?
thanks
------------------------------
Date: Tue, 11 Nov 2003 17:01:27 +1100
From: King <kingsman22004@yahoo.com>
Subject: Re: installing perl
Message-Id: <3FB07B37.8070209@yahoo.com>
>>Ben Morrow wrote:
> OK... you used Configure -d, so it took all default answers.
> Check for me: after running Configure, config.sh contains
> prefix='/usr/local'
> and
> installprefix='/usr/local'
> ?
Yes, both point to /user/local. BUT after I did the following steps.
I put back the symlink pointing to perl5.6.1:
rm /usr/bin/perl;
ln -s perl5.6.1 /usr/bin/perl
:/home/username/#/usr/bin/perl5.6.1
print 1\n;
1
Once things stabilized, I went back to perl-5.8.1 directory and start
over, but left out the -de
reboot into a new root shell, no kde or x environment.
:/home/username/#tar -zxvf stable.tar.gz
:/home/username/#cd perl-5.8.1
:/home/username/perl-5.8.1#rm -f config.sh Policy.sh
:/home/username/perl-5.8.1#sh Configure
accept all the defaults except
Directories to use for library searches? [/usr/local/lib /lib /usr/lib]
/usr/local/lib
make
...whole bunch of lines
libperl.a(pp.o): In function `Perl_pp_pow':
pp.o(.text+0x1e22): undefined reference to `pow'
libperl.a(pp.o): In function `Perl_pp_sin':
pp.o(.text+0x5b08): undefined reference to `sin'
libperl.a(pp.o): In function `Perl_pp_cos':
pp.o(.text+0x5c0c): undefined reference to `cos'
libperl.a(pp.o): In function `Perl_pp_exp':
pp.o(.text+0x5e0c): undefined reference to `exp'
libperl.a(pp.o): In function `Perl_pp_log':
pp.o(.text+0x5f4d): undefined reference to `log'
libperl.a(pp.o): In function `Perl_pp_sqrt':
pp.o(.text+0x60a3): undefined reference to `sqrt'
collect2: ld returned 1 exit status
make: *** [miniperl] Error 1
:/home/username/perl-5.8.1#
should I go with
make test
make install
what about this Error 1 thing?
thanks
------------------------------
Date: Mon, 10 Nov 2003 20:54:20 -0800
From: "Austin P. So (Hae Jin)" <haejin@ubc.ca>
Subject: Re: Interaction between two strings
Message-Id: <boppuc$8ji$1@nntp.itservices.ubc.ca>
Ewout wrote:
> Assume that the parameter value is ABCR. The regex should be such that
> for example a string like ABCC should give a match. But if the
> parameter value is XYZR, then the string XYZC should give a match. To
> summarize: the regex should take part of the pattern from another
> string that is supplied separately from the regex. Is there any way to
> achieve this?
I'm a crappy perl programmer, but I think I understand your problem
despite the fact that you are being very ambiguous about it.
You seem to be doing what many "bioinformaticians" have been trying to
do, which is compare two sequences and find patterns of similarity
between these two sequences....so you might want to look in the bioperl
module (www.bioperl.org).
If you do as you wish and "parameterize" it, you will have to find a
metric and a weighting method which makes it a hard problem...
Otherwise, you could do what I think you are thinking of doing, and you
could generate a set of wild card matches which you could use to regex.
There are obvious memory issues (x**n permutations of x characters of
length n), but one trick is rather than build an array or hash of
$patterns, you splice them all into one very big $pattern.
i.e. $pattern = "x1|x2|x3....|xn";
$string =~ /$pattern/;
Doing this is immensely faster than iterating through an array or the like:
i.e. foreach $pattern (@pattern){
$string =~ /$pattern/;
This was mentioned somewhere...Perl Cookbook? Or it may have been the
advanced book of Perl Programming...
Austin
------------------------------
Date: Tue, 11 Nov 2003 06:25:31 -0000
From: "David K. Wall" <usenet@dwall.fastmail.fm>
Subject: Re: Perl Newbie
Message-Id: <Xns9430E81BDA24dkwwashere@216.168.3.30>
Uri Guttman <uri@stemsystems.com> wrote:
>>>>>> "AK" == Andreas Kahari <ak+usenet@freeshell.org> writes:
>
> AK> In article <2cff8447.0311101601.55c8d72c@posting.google.com>, Harshit
K wrote:
> >> I am sorry if this is a repeated question, maybe I missed it out. I am
> >> a newbie to perl, so could you suggest some good books on perl.
>
> AK> http://www.perl.org/books.html
>
> and even better is the perl books site:
>
> books.perl.org
I didn't know that site existed. It seems like duplication of effort to have
a list on learn.perl.org and another (larger) one on books.perl.org. Are the
maintainers of the two sites coordinating their efforts? If not, I think
they should be....
--
David Wall
------------------------------
Date: Tue, 11 Nov 2003 13:11:07 +1100
From: Iain Chalmers <bigiain@mightymedia.com.au>
Subject: Re: print statement spanning multiple lines
Message-Id: <bigiain-545319.13110711112003@news.fu-berlin.de>
In article <ceXrb.6024$aT.23@news-server.bigpond.net.au>,
"Voitec" <voitec@zzzzzzzzz.com> wrote:
> Hi,
>
> St00pid question time:
there are no stupid questions, only stupid people ;-)
> How can I make a print statement span several lines without affecting the
> final formatting?
how about:
print "line 1",
"line 2",
"line 3";
or:
print "line 1".
"line 2".
"line 3";
or perhaps even:
print <<END;
line 1
line 2
line 3
END
big
--
'When I first met Katho, she had a meat cleaver in one hand and
half a sheep in the other. "Come in", she says, "Hammo's not here.
I hope you like meat.' Sharkey in aus.moto
------------------------------
Date: Tue, 11 Nov 2003 03:13:57 GMT
From: Andras Malatinszky <nobody@dev.null>
Subject: Re: print statement spanning multiple lines
Message-Id: <3fb053f1$1@bandit2.georgetown.edu>
Iain Chalmers wrote:
> In article <ceXrb.6024$aT.23@news-server.bigpond.net.au>,
> "Voitec" <voitec@zzzzzzzzz.com> wrote:
>
>
>>Hi,
>>
>>St00pid question time:
>
>
> there are no stupid questions, only stupid people ;-)
>
>
>>How can I make a print statement span several lines without affecting the
>>final formatting?
>
>
> how about:
>
> print "line 1",
> "line 2",
> "line 3";
>
> or:
>
> print "line 1".
> "line 2".
> "line 3";
>
> or perhaps even:
>
> print <<END;
> line 1
> line 2
> line 3
> END
But this is not equivalent to the previous two! Your third version prints
line1
line2
line3
while the other two print
line1line2line3
(which is apparently what the OP wants).
------------------------------
Date: Tue, 11 Nov 2003 12:02:26 +0900
From: ko <kuujinbo@hotmail.com>
Subject: Re: print statement spanning multiple lines
Message-Id: <bopjlp$frq$2@pin3.tky.plala.or.jp>
Iain Chalmers wrote:
> In article <ceXrb.6024$aT.23@news-server.bigpond.net.au>,
> "Voitec" <voitec@zzzzzzzzz.com> wrote:
[snip]
>>How can I make a print statement span several lines without affecting the
>>final formatting?
>
>
> how about:
>
> print "line 1",
> "line 2",
> "line 3";
>
> or:
>
> print "line 1".
> "line 2".
> "line 3";
Those two examples will just concatenate into one long string, not keep
the indenting like the OP wanted - unless you included variables with
indenting/whitespace :) Maybe something like this:
print "
line1
line2
line3
";
> or perhaps even:
>
> print <<END;
> line 1
> line 2
> line 3
> END
>
> big
>
Yes :)
To the OP - if you type
perldoc -q "here document"
from your shell, you'll the relevant details of how to correctly use a
'here' document (last example).
HTH - keith
------------------------------
Date: Tue, 11 Nov 2003 05:21:49 GMT
From: James Willmore <jwillmore@remove.adelphia.net>
Subject: Re: print statement spanning multiple lines
Message-Id: <20031111001920.0fa2cd98.jwillmore@remove.adelphia.net>
On Tue, 11 Nov 2003 01:48:56 GMT
"Voitec" <voitec@zzzzzzzzz.com> wrote:
> How can I make a print statement span several lines without
> affecting the final formatting?
perldoc -f format
perldoc perlform
HTH
--
Jim
Copyright notice: all code written by the author in this post is
released under the GPL. http://www.gnu.org/licenses/gpl.txt
for more information.
a fortune quote ...
Acid absorbs 47 times it's weight in excess Reality.
------------------------------
Date: Tue, 11 Nov 2003 15:35:14 +1000
From: Gregory Toomey <nospam@bigpond.com>
Subject: Re: print statement spanning multiple lines
Message-Id: <2282242.Zhszyqe4Nd@gregs-web-hosting-and-pickle-farming>
It was a dark and stormy night, and Voitec managed to scribble:
> Hi,
>
> St00pid question time:
> How can I make a print statement span several lines without affecting the
> final formatting?
>
The most obvious way us to use "\n" for newline
print "line a\nline b\n\nline c";
Try 'man printf' for a list of other options (C and Perl share some libraries).
gtoomey
------------------------------
Date: Tue, 11 Nov 2003 04:03:40 GMT
From: Andras Malatinszky <nobody@dev.null>
Subject: Re: Problems with Sendmail
Message-Id: <3fb05f99@bandit2.georgetown.edu>
Phantom_guitarist wrote:
> I am currently having problems creating a script to send an email from perl.
> I have got the script down to the bare minimum;
>
> #!/usr/bin/perl
> print "Content-type:text/html\n\n";
> &mail('myemail@myaddress.co.uk','myemail@myaddress.co.uk','Test
> Message','Test Message');
> print "<br>Mail Sent";
>
> sub mail
> {
> print "Preparing to send<br>";
> # first param is recipient
> # second is from
> # third is subject
> # fourth is message
> $mailprog = '/usr/sbin/sendmail';
> $recipient = $_[0];
> $from = $_[1];
> $subject = $_[2];
> $message = $_[3];
> print "To: $recipient\n<br>";
> print "From: $from\n<br>";
> print "Subject: $subject\n\n<br>";
> print $message;
> print "<br>";
>
> open(MAIL,'|$mailprog')|| &error("Cant locate mail program");
Here you are trying to send stuff to a program called $mailprog in the
directory your script is running in. You probably meant to put that in
double quotes.
> print MAIL "To: $recipient\n";
> print MAIL "From: $from\n";
> print MAIL "Subject: $subject\n\n";
> print MAIL $message;
> close (MAIL);
> }
> sub error
> {
> print "Content-type:text/html\n\n";
> print $_[0];
> exit;
Well, "error" is a fitting name for a script that produces a syntax
error. You need to close that curly.
>
>
> but for some reason this doesn't work. It doesn't display any messages and
> the script runs fine.
I find this difficult to believe...
[snip]
------------------------------
Date: 10 Nov 2003 18:46:28 -0800
From: groups@mironloeb.org (Sophie Miron)
Subject: went to 5.8.1 and now I can't access object data dynamically
Message-Id: <7f1a1d9f.0311101846.2b5f51b7@posting.google.com>
My web host just upgraded from 5.6 to 5.8.1 and a series of scripts
I'd written are no longer working.
I'm using Class::Struct qw(struct) in my object modules. A Schedule
object contains 6 Station objects (among other things). A Station
contains 4 CurrItem objects...
These are defined globally:
@days = ('tue', 'wed', 'thu', 'fri');
@stations = ('art', 'outside', 'puzzles', 'cooking', 'science',
'floater');
In many places I use the following type of loop to access the object
data:
foreach my $class ($AM, $PM) {
foreach my $station (@stations) {
foreach my $day (@days) {
print $class->$station->$day->parent() ; # for example
}}}
I'm now getting an error, cannot perform method XXX on an undefined
value.
Is there a way around this problem, or a better way to code it? I'm
thinking of putting in an extra level of indirection (putting the 6
Station objects in a hash in the struct definition and calling "new"
explicitly).
Is what I'm doing using symbolic references? (the books show that as
using a variable to access a method, here I'm wanting it to see the
variable as a string)
I checked the documentation on deprecations in 5.8 and didn't find
what's causing the problem.
Any help for this newbie would be much appreciated.
Sophie Miron
groups@mironloeb.org
------------------------------
Date: Tue, 11 Nov 2003 04:32:53 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: went to 5.8.1 and now I can't access object data dynamically
Message-Id: <3fb06302.1151092764@news.erols.com>
groups@mironloeb.org (Sophie Miron) wrote:
: My web host just upgraded from 5.6 to 5.8.1 and a series of scripts
: I'd written are no longer working.
:
: I'm using Class::Struct qw(struct) in my object modules. A Schedule
: object contains 6 Station objects (among other things). A Station
: contains 4 CurrItem objects...
[snip]
: foreach my $class ($AM, $PM) {
: foreach my $station (@stations) {
: foreach my $day (@days) {
: print $class->$station->$day->parent() ; # for example
: }}}
:
: I'm now getting an error, cannot perform method XXX on an undefined
: value.
So one of the methods is returning undef when you expect it to return an
object.
From the Class::Struct modification history,
Modified by Damian Conway, 2001-09-10, v0.62.
[...]
Also default initializes nested object attributes to
undef, rather than calling object constructor without
args
That's the most likely reason for your old code not to work
anymore--upgrading your Perl also upgraded your Class::Struct module,
and your code relies on Class::Struct to initialize nested objects.
I wonder what the reason was for making that change to Class::Struct.
: Is there a way around this problem, or a better way to code it?
Backpedal to an older Class::Struct version, or have your code
initialized the nested objects itself.
: Is what I'm doing using symbolic references?
Technically, yes, but Perl resolves method names symbolically anyway.
Pay no attention to that man behind the curtain.
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.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 V10 Issue 5778
***************************************