[22395] in Perl-Users-Digest
Perl-Users Digest, Issue: 4616 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Feb 24 18:05:55 2003
Date: Mon, 24 Feb 2003 15:05:11 -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 Mon, 24 Feb 2003 Volume: 10 Number: 4616
Today's topics:
Re: $SIG{__DIE__} and modules (Tom Scanlan)
Anyone using the new WBEM/CIM standard with Perl yet? (John Ramsden)
Re: Change a variable <porter96@lycos.com>
Re: Change a variable <tassilo.parseval@post.rwth-aachen.de>
Re: Change a variable <nobull@mail.com>
Re: Change a variable <mgjv@tradingpost.com.au>
Re: Change a variable <jeff@vpservices.com>
Re: Change a variable <tassilo.parseval@post.rwth-aachen.de>
Re: Checking something to see if it isn't there........ <steven.smolinski@sympatico.ca>
Re: Checking something to see if it isn't there........ <krahnj@acm.org>
Re: Checking something to see if it isn't there........ <spero126NOSPAM@yahoo.com>
editting photos on the fly <sdyck@engr.uvic.ca.spam>
Re: editting photos on the fly <ian@WINDOZEdigiserv.net>
Re: editting photos on the fly <REMOVEsdnCAPS@comcast.net>
Re: editting photos on the fly <perl-dvd@darklaser.com>
Re: extract string from another string <pdhze@yahoo.co>
Re: FAQ proposal: Why can't I compare two strings using <nobull@mail.com>
Re: Get Public IP Address of Linux Machine <eric.schwartz@hp.com>
Re: If statement chacking if a variable is something OR <REMOVEsdnCAPS@comcast.net>
Re: If statement chacking if a variable is something OR <daby55@NOSPAM.com>
Re: Just wanted to share this technique (and hear some <mpapec@yahoo.com>
Re: Just wanted to share this technique (and hear some <tassilo.parseval@post.rwth-aachen.de>
Re: Just wanted to share this technique (and hear some <goldbb2@earthlink.net>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 24 Feb 2003 09:41:28 -0800
From: tscanlan@they.gotdns.org (Tom Scanlan)
Subject: Re: $SIG{__DIE__} and modules
Message-Id: <2d66ece1.0302240941.43ad4e4e@posting.google.com>
"Dieter D'Hoker" <webmaster@neverseenbefore.com> wrote in message news:<b3a82g$1jlhca$1@ID-155251.news.dfncis.de>...
> I have this perl-gameserver ,
> now sometimes it craches and I want autorestart it then ,
> so I definded
>
> $SIG{__DIE__} = \&SigDIE;
>
> and in sub SigDIE there is code to restart it if it is an unknow error ,
> if $@ =~ some text I use in all MY die statements , it still dies ...
>
> problem is that sig die catches ALL die statement , also those in
> eval-blocks ,
> in my server I don't use eval blocks that much , and they are only used in a
> way i can write my onw die text ,
> so I can handle it in sub SigDie ,
> but how about the modules I use , is it safe to use this in combination with
> those modules ?
>
> use Config::IniFiles;
> use English;
> use IO::Select;
> use IO::Socket;
> use POSIX qw();
> use strict;
> use Time::HiRes;
>
> Or maybe there is a beter way to do this ?
just as you can define &SigDie to catch all your signals, just define
a catch-all:
sub SigDie{
if ($@ =~ /my own die error/){
...
} elsif ($@ =~ /my other die error/) {
# autorestart...?
...
} else {
# otherwise it is someone else's die..
print STDERR "from my die handler: $@\n";
exit 1;
# or, do a restart instead of an exit.
}
}
doing this should keep you safe unless the modules you use have their
own die handlers.
Also, keep trying to find out why your program is crashing. Save the
output of your program so that you can go back to find out where it
crashed. Once you fix the bug, you (hopefully) don't need to worry
about catching a die signal.
-Tom Scanlan
------------------------------
Date: 24 Feb 2003 10:26:28 -0800
From: john_ramsden@sagitta-ps.com (John Ramsden)
Subject: Anyone using the new WBEM/CIM standard with Perl yet?
Message-Id: <d27434e.0302241026.648dbe6f@posting.google.com>
I have written a Perl monitoring app that currently uses SNMP to
retrieve
information from various backup products, including Veritas and TSM,
and
have now been tasked with extending it to work with various types of
SAN
hardware, such as McDATA and Brocade.
The app is pretty robust on the whole; but the MIB structures it has
dealt with hitherto are fairly simple, and a potential future weak
spot
is my home-made protocol (if I can dignify the method by such a term)
that it uses to transmit data via TCP sockets between the its SNMP
NMSs
and its manager process[s] that write this data to the app's database.
But to cut a long story short, a new XML-based standard was finalized
in
Jan 2003 which interfaces with several information
gathering/monitoring protocols, including SNMP, and I gather several
SAN manufacturers already support it (having worked with draft
versions over the last year or so).
In short, it seems like CIM [See http://www.dmtf.org/] is the way
things
will definitely go, and overall it is much more flexible than SNMP,
added
to which the 'hand-rolled' data encoding complications I wish to avoid
in
my app would be avoided courtesy of HTTP.
So is anyone working with this, and if so what languages or modules
have
you found to be the most effective? I'd be very interested if anyone,
especially Perl gurus, is in a position to share their experience and
maybe suggest and answer one or two questions I probably don't know
I should be asking!
Cheers
John Ramsden (john_ramsden@sagitta-ps.com)
------------------------------
Date: Mon, 24 Feb 2003 12:16:00 -0800
From: "Steve" <porter96@lycos.com>
Subject: Re: Change a variable
Message-Id: <v5kon4b7vflte1@corp.supernews.com>
> Lt. wrote:
> > My apologies, I am very new to this.
>
jue wrote:
> I guess 'this' includes Usenet? :-{
> I just replied to exactly the same question of yours in the other NG.
>
> _DO_NOT_MULTIPOST_!
Sooo ... rather than be helpful you decided to be an jerk (I was going to
say asshole, but I guess that's excessive)? Good job jue, good job. This
isn't a grad school class or some place that people should be hesitant to
ask a question, in fear of sounding stupid or ignorant ... its just a
newsgroup.
Steve
------------------------------
Date: 24 Feb 2003 18:47:44 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@post.rwth-aachen.de>
Subject: Re: Change a variable
Message-Id: <b3dpcg$jan$1@nets3.rz.RWTH-Aachen.DE>
Also sprach Steve:
> jue wrote:
>> I guess 'this' includes Usenet? :-{
>> I just replied to exactly the same question of yours in the other NG.
>>
>> _DO_NOT_MULTIPOST_!
>
>
> Sooo ... rather than be helpful you decided to be an jerk (I was going to
> say asshole, but I guess that's excessive)? Good job jue, good job. This
> isn't a grad school class or some place that people should be hesitant to
> ask a question, in fear of sounding stupid or ignorant ... its just a
> newsgroup.
You don't have a clue, do you? Jürgen did not complain about the
question but rather about the fact that you multiposted the question to
several groups. I suggest you use a search engine to find out about the
difference of multipost and crosspost.
Of course, you may ask questions here but you are expected to have done
your homework before. Some basic knowledge about usenet conventions is
required.
Tassilo
--
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval
------------------------------
Date: 24 Feb 2003 18:49:01 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: Change a variable
Message-Id: <u9fzqdbjky.fsf@wcl-l.bham.ac.uk>
"Steve" <porter96@lycos.com> writes:
> > Lt. wrote:
> > > My apologies, I am very new to this.
> >
>
> jue wrote:
> > I guess 'this' includes Usenet? :-{
> > I just replied to exactly the same question of yours in the other NG.
> >
> > _DO_NOT_MULTIPOST_!
>
>
> Sooo ... rather than be helpful you decided to be an jerk?
No there is no evidence to support that.
> (I was going to say asshole, but I guess that's excessive)
You, on the other hand... (No I won't decend to name calling).
> This isn't [...] some place that people should be hesitant to ask a
> question, in fear of sounding stupid or ignorant
Yes it is.
> ... its just a newsgroup.
It is widely accepted in newsgroups, as in just about any other social
context you'll ever encounter in life, that you should hesitate on the
sidelines ("lurk") for a bit while you work out what the social norms
are. It is right, proper and nesessary that people who are tempted to
bypass this step _should_ be motivated not to do so by fear sounding
stupid or ignorant. (Indeed that's probably why we have evolved such
a fear).
Of course if you do something stupid or ignorant and nobody point this
out to you this means that everyone thinks you are too stupid to
learn. So if we were to follow your advice this would be a _less_
friendly and supportive place.
Being treated with contempt may not be pleasant but always bare in
mind that if people do not show you contempt when you earn it, it is
because they have decided you are _benieth_ contempt.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Tue, 25 Feb 2003 07:12:41 +1100
From: Martien Verbruggen <mgjv@tradingpost.com.au>
Subject: Re: Change a variable
Message-Id: <slrnb5kv5p.2fm.mgjv@martien.heliotrope.home>
On Mon, 24 Feb 2003 12:16:00 -0800,
Steve <porter96@lycos.com> wrote:
>> Lt. wrote:
>> > My apologies, I am very new to this.
>>
>
> jue wrote:
>> I guess 'this' includes Usenet? :-{
>> I just replied to exactly the same question of yours in the other NG.
>>
>> _DO_NOT_MULTIPOST_!
>
>
> Sooo ... rather than be helpful you decided to be an jerk (I was going to
No. He was trying to educate you. This reponse of yours probably means
that many people from now on won't see your posts anymore.
Congratulations.
*plonk*
Martien
--
| Yes; Windows is great for running &
Martien Verbruggen | developing viruses, for instance. It's also
| very popular, but then again, so is the
| common cold. -- Dave Hinz
------------------------------
Date: Mon, 24 Feb 2003 12:33:49 -0800
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: Change a variable
Message-Id: <3E5A81AD.7010106@vpservices.com>
Tassilo v. Parseval wrote:
> Also sprach Steve:
>
>
>>jue wrote:
>>
>>>I guess 'this' includes Usenet? :-{
>>>I just replied to exactly the same question of yours in the other NG.
>>>
>>>_DO_NOT_MULTIPOST_!
>>>
>>
>>Sooo ... rather than be helpful you decided to be an jerk
>>
>
> You don't have a clue, do you?
No he (Steve) doesn't have a clue, Jue was right to educate the OP about
multiposting, but Steve was not the OP, just someone who stuck his
nose in.
> but rather about the fact that you multiposted the question to
> several groups.
Look back at the thread, the OP was "Lt", not "Steve". The OP made a
fairly common mistake (bad, but not plonkable in and of itself, IMHO).
It was Steve's follow up that was plonk bait.
--
Jeff
------------------------------
Date: 24 Feb 2003 21:58:08 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@post.rwth-aachen.de>
Subject: Re: Change a variable
Message-Id: <b3e4hg$17u$1@nets3.rz.RWTH-Aachen.DE>
Also sprach Jeff Zucker:
> Tassilo v. Parseval wrote:
>
>> Also sprach Steve:
>>>Sooo ... rather than be helpful you decided to be an jerk
>>>
>>
>> You don't have a clue, do you?
>
>
> No he (Steve) doesn't have a clue, Jue was right to educate the OP about
> multiposting, but Steve was not the OP, just someone who stuck his
> nose in.
Oh, indeed, didn't realize that.
>> but rather about the fact that you multiposted the question to
>> several groups.
>
> Look back at the thread, the OP was "Lt", not "Steve". The OP made a
> fairly common mistake (bad, but not plonkable in and of itself, IMHO).
"Plonkable". :-)
> It was Steve's follow up that was plonk bait.
I am not actually a plonker. I think the keystroke this requires in my
newsreader is not worth it since these are usually people who enter the
scene only once (to deposit a bit of trolling) and never return.
Tassilo
--
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval
------------------------------
Date: Mon, 24 Feb 2003 16:24:17 GMT
From: Steven Smolinski <steven.smolinski@sympatico.ca>
Subject: Re: Checking something to see if it isn't there..........
Message-Id: <RGr6a.1206$VG.248054@news20.bellglobal.com>
Spero <spero126NOSPAM@yahoo.com> wrote:
> "Anno Siegel" <anno4000@lublin.zrz.tu-berlin.de> wrote:
>> Spero <spero126NOSPAM@yahoo.com> wrote in comp.lang.perl.misc:
>> >
>> > How can I successfully check if $ARGV[$#ARGV] has been entered and
>> > it is in the correct format?
>>
>> If anything is in @ARGV at all $ARGV[$#ARGV] (or, equivalently
>> $ARGV[-1]) will be its last element. So you could do this:
>>
>> die "Invalid operation" unless @ARGV;
>> my $operation = @ARGV[ -1];
>> # ...
I prefer (after Getopt::Std has removed the options from @ARGV):
my $operation = shift or die "No operator given";
> I was wondering if I could have more control over the error message and
> also return an exit status of 1 using the Anno's method?
>
> instead of "Invalid operation at line xx" I would like "No operation given"
> (i.e. I need to remove the "at line" bit)
perldoc -f die
If you put a newline at the end of the message, you don't get the "at
line xx..." message.
my $operation = shift or die "No operation given.\n";
> Also, I really need to prduce an exit status of 1 if the last argument isn't
> there,
Oh. The die() call exists with 255 (see perldoc -f die). If you need a
1, then you have to do it yourself (see perldoc -f warn):
my $operation = shift; # or = $ARGV[-1], whichever you use
unless ($operation) {
warn "No operation given.\n";
exit 1;
}
# ...
Steve
--
Steven Smolinski => http://arbiter.ca/
GnuPG Public Key => http://arbiter.ca/steves_public_key.txt
=> or email me with 'auto-key' in the subject.
Key Fingerprint => 08C8 6481 3A7B 2A1C 7C26 A5FC 1A1B 66AB F637 495D
------------------------------
Date: Mon, 24 Feb 2003 19:56:56 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: Checking something to see if it isn't there..........
Message-Id: <3E5A78F7.9B5A2F56@acm.org>
Spero wrote:
>
> "Anno Siegel" <anno4000@lublin.zrz.tu-berlin.de> wrote in message
> news:b3d7hi$fbb$1@mamenchi.zrz.TU-Berlin.DE...
> >
> > If anything is in @ARGV at all $ARGV[$#ARGV] (or, equivalently $ARGV[-1])
> > will be its last element. So you could do this:
> >
> > die "Invalid operation" unless @ARGV;
> > my $operation = @ARGV[ -1];
> > # ...
>
> This was the only solution I was able to implement.
>
> I was wondering if I could have more control over the error message and
> also return an exit status of 1 using the Anno's method?
>
> > die "Invalid operation" unless @ARGV;
> > my $operation = @ARGV[ -1];
> > # ...
>
> instead of "Invalid operation at line xx" I would like "No operation given"
> (i.e. I need to remove the "at line" bit)
>
> Also, I really need to prduce an exit status of 1 if the last argument isn't
> there,
my $operation = pop or do {
warn "No operation given\n";
exit 1;
};
John
--
use Perl;
program
fulfillment
------------------------------
Date: Mon, 24 Feb 2003 20:18:49 -0000
From: "Spero" <spero126NOSPAM@yahoo.com>
Subject: Re: Checking something to see if it isn't there..........
Message-Id: <b3duk9$59b$1@wisteria.csv.warwick.ac.uk>
"Steven Smolinski" <steven.smolinski@sympatico.ca> wrote in message
news:RGr6a.1206$VG.248054@news20.bellglobal.com...
> Spero <spero126NOSPAM@yahoo.com> wrote:
> > "Anno Siegel" <anno4000@lublin.zrz.tu-berlin.de> wrote:
> >> Spero <spero126NOSPAM@yahoo.com> wrote in comp.lang.perl.misc:
> >> >
> >> > How can I successfully check if $ARGV[$#ARGV] has been entered and
> >> > it is in the correct format?
> >>
> >> If anything is in @ARGV at all $ARGV[$#ARGV] (or, equivalently
> >> $ARGV[-1]) will be its last element. So you could do this:
> >>
> >> die "Invalid operation" unless @ARGV;
> >> my $operation = @ARGV[ -1];
> >> # ...
>
> I prefer (after Getopt::Std has removed the options from @ARGV):
>
> my $operation = shift or die "No operator given";
>
> > I was wondering if I could have more control over the error message and
> > also return an exit status of 1 using the Anno's method?
> >
> > instead of "Invalid operation at line xx" I would like "No operation
given"
> > (i.e. I need to remove the "at line" bit)
>
> perldoc -f die
>
> If you put a newline at the end of the message, you don't get the "at
> line xx..." message.
>
> my $operation = shift or die "No operation given.\n";
>
> > Also, I really need to prduce an exit status of 1 if the last argument
isn't
> > there,
>
> Oh. The die() call exists with 255 (see perldoc -f die). If you need a
> 1, then you have to do it yourself (see perldoc -f warn):
>
> my $operation = shift; # or = $ARGV[-1], whichever you use
>
> unless ($operation) {
> warn "No operation given.\n";
> exit 1;
> }
>
> # ...
>
> Steve
> --
> Steven Smolinski => http://arbiter.ca/
> GnuPG Public Key => http://arbiter.ca/steves_public_key.txt
> => or email me with 'auto-key' in the subject.
> Key Fingerprint => 08C8 6481 3A7B 2A1C 7C26 A5FC 1A1B 66AB F637 495D
Great, thanks Steve,
Spero
------------------------------
Date: Mon, 24 Feb 2003 09:06:47 -0800
From: Steve <sdyck@engr.uvic.ca.spam>
Subject: editting photos on the fly
Message-Id: <3E5A5127.29BC40E2@engr.uvic.ca.spam>
I am probably months behind on this one, but I recently was sent an
e-mail with a link where I enter my name and it shows up on a picture.
I tried completely random names to be sure it wasn't just a database of
millions of pictures.
So my question is, how do they do this?
the link was www.kicken.com. I'll warn you though. Your name will
appear on a sign that says "I love <your name>" which is in front of a
topless girl. be sure you are of legal age before going to the site.
any help would be appreciated.
Steve
------------------------------
Date: Mon, 24 Feb 2003 17:08:52 GMT
From: "Ian.H [dS]" <ian@WINDOZEdigiserv.net>
Subject: Re: editting photos on the fly
Message-Id: <sakk5v057pmu2m9tcmgaum430a844kj70f@4ax.com>
Keywords: Remove WINDOZE to reply
-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1
In a fit of excitement on Mon, 24 Feb 2003 09:06:47 -0800, Steve
<sdyck@engr.uvic.ca.spam> managed to scribble:
> I am probably months behind on this one, but I recently was sent an
> e-mail with a link where I enter my name and it shows up on a
> picture. I tried completely random names to be sure it wasn't just
> a database of millions of pictures.
>
> So my question is, how do they do this?
>
> the link was www.kicken.com. I'll warn you though. Your name will
> appear on a sign that says "I love <your name>" which is in front
> of a topless girl. be sure you are of legal age before going to
> the site.
>
> any help would be appreciated.
>
> Steve
More than likely using the GD library (www.boutell.com IIRC).
You can dynamically create an image from whatever image you like and
add text onto that image too (so the original "pic" is used as a
background and the text that appears over the top is just added as
another "layer" so to speak).
HTH.
Regards,
Ian
-----BEGIN xxx SIGNATURE-----
Version: PGP 8.0
iQA/AwUBPlpRoWfqtj251CDhEQJ7ugCfdLMidB5eizdlRVytgy9So8ZYjGQAn37I
qWFxsBkXa5TGAFeNT+WRfD/g
=w6QI
-----END PGP SIGNATURE-----
--
Ian.H [Design & Development]
digiServ Network - Web solutions
www.digiserv.net | irc.digiserv.net | forum.digiserv.net
Scripting, Web design, development & hosting.
------------------------------
Date: Mon, 24 Feb 2003 11:25:09 -0600
From: "Eric J. Roode" <REMOVEsdnCAPS@comcast.net>
Subject: Re: editting photos on the fly
Message-Id: <Xns932C7E5671ECCsdn.comcast@216.166.71.239>
-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1
Steve <sdyck@engr.uvic.ca.spam> wrote in news:3E5A5127.29BC40E2
@engr.uvic.ca.spam:
> I am probably months behind on this one, but I recently was sent an
> e-mail with a link where I enter my name and it shows up on a picture.
> I tried completely random names to be sure it wasn't just a database of
> millions of pictures.
>
> So my question is, how do they do this?
>
> the link was www.kicken.com. I'll warn you though. Your name will
> appear on a sign that says "I love <your name>" which is in front of a
> topless girl. be sure you are of legal age before going to the site.
>
> any help would be appreciated.
>
> Steve
Did you have a Perl question?
- --
Eric
print scalar reverse sort qw p ekca lre reh
ts uJ p, $/.r, map $_.$", qw e p h tona e;
-----BEGIN xxx SIGNATURE-----
Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com>
iQA/AwUBPlpVdGPeouIeTNHoEQKvAQCglThqG4HFJi5U3pa3jM0JLTb4Jh4AoJzC
3UMV9jT31EmMC97xNabqlH/P
=d4ox
-----END PGP SIGNATURE-----
------------------------------
Date: Mon, 24 Feb 2003 18:18:53 GMT
From: "David" <perl-dvd@darklaser.com>
Subject: Re: editting photos on the fly
Message-Id: <hmt6a.4$7g4.2662@news-west.eli.net>
"Steve" <sdyck@engr.uvic.ca.spam> wrote in message
news:3E5A5127.29BC40E2@engr.uvic.ca.spam...
> I am probably months behind on this one, but I recently was sent an
> e-mail with a link where I enter my name and it shows up on a picture.
> I tried completely random names to be sure it wasn't just a database
of
> millions of pictures.
>
> So my question is, how do they do this?
There is a perl module (you can get from cpan.org) called Image::Magick
. I dont know if thats what their using, but I know you can dynamicaly
put text on an image with that.
> the link was www.kicken.com. I'll warn you though. Your name will
> appear on a sign that says "I love <your name>" which is in front of a
> topless girl. be sure you are of legal age before going to the site.
Regards,
David
------------------------------
Date: Mon, 24 Feb 2003 20:48:58 GMT
From: piet <pdhze@yahoo.co>
Subject: Re: extract string from another string
Message-Id: <Usenet.jnnggnjo@localhost>
John W. Krahn wrote:
>
> piet wrote:
> >
> > $teststring = 'stuff 650 N other stuff'
> > another example of string 'stuff stuff stuff stuff 90 N'
Thank you all for your replies.
what it there were several (from 1 to 10) matches to extract?
example:
$teststring =' stuff 650 N other stuff 90N stuff"
Txs
Piet
------------------------------
Date: 24 Feb 2003 18:21:58 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: FAQ proposal: Why can't I compare two strings using == ?
Message-Id: <u9lm05bku1.fsf@wcl-l.bham.ac.uk>
"Jürgen Exner" <jurgenex@hotmail.com> writes:
> One of the most frequently asked questions is
> "Why can't I compare two strings using == ?"
>
> Suggested answer:
> The operator "==" compares the numerical values of its operands.
> Chances are you want to compare the textual values in which case you should
> use the operator "eq" instead. For further details please check "perldoc
> perlop".
But surely that's just a special case of the question which the answer
is "use diagnostics and then perl will tell you".
Unfortuately I can't think of a way to phrase the question.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: 24 Feb 2003 13:44:58 -0700
From: Eric Schwartz <eric.schwartz@hp.com>
Subject: Re: Get Public IP Address of Linux Machine
Message-Id: <eto1y1xz9v9.fsf@wormtongue.emschwar>
"Buck Turgidson" <jc_va@hotmail.com> writes:
> I found and modified a java program to do this. I thought I would share
> it to save the next guy the trouble.
This being comp.lang.perl.misc, let's try re-writing that 32-line java
program in Perl:
#!/usr/bin/perl
use warnings;
use strict;
use LWP::Simple;
my $status = get('http://192.168.1.1/Status.htm');
$status =~ /(IP Address.{60}/;
print $1,"\n";
(note: untested)
Only 8 lines, and I'd say it's a lot clearer about what it's doing.
Of course, it's trivially golf-able, but that's neither here nor
there.
-=Eric
--
Come to think of it, there are already a million monkeys on a million
typewriters, and Usenet is NOTHING like Shakespeare.
-- Blair Houghton.
------------------------------
Date: Mon, 24 Feb 2003 10:50:29 -0600
From: "Eric J. Roode" <REMOVEsdnCAPS@comcast.net>
Subject: Re: If statement chacking if a variable is something OR something else?
Message-Id: <Xns932C787672204sdn.comcast@216.166.71.239>
-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1
"Tassilo v. Parseval" <tassilo.parseval@post.rwth-aachen.de> wrote in
news:b3dc27$5bc$1@nets3.rz.RWTH-Aachen.DE:
> And even without warnings he'll quickly realize that something is
> severely rotten with his code. Have you ever heard of an "If" keyowrd
> in Perl? ;-)
Sure. I see people using it in c.l.p.m. ALL the time! :-)
- --
Eric
print scalar reverse sort qw p ekca lre reh
ts uJ p, $/.r, map $_.$", qw e p h tona e;
-----BEGIN xxx SIGNATURE-----
Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com>
iQA/AwUBPlpNVGPeouIeTNHoEQJbhgCdGtaFnm6vHAdLPbM0Ds1qXrRI8cMAoN2d
QVqrJXCVGWrcTlnAG/tpH5hL
=DbQP
-----END PGP SIGNATURE-----
------------------------------
Date: Mon, 24 Feb 2003 19:44:35 -0000
From: "Daby" <daby55@NOSPAM.com>
Subject: Re: If statement chacking if a variable is something OR something else?
Message-Id: <b3dsms$iqq$1@newsg1.svr.pol.co.uk>
Sorry for the bad reproduction of a code sample. The syntax wasn`t corrent
and I have not used "If". However I do wonder if I did actually use "="
instead of "==" by mistake.
I wil ensure that I use warnings (even though I thought I already was!) and
will have a play later to see if everything now works as I expect - it
should do.
"Tassilo v. Parseval" <tassilo.parseval@post.rwth-aachen.de> wrote in
message news:b3dc27$5bc$1@nets3.rz.RWTH-Aachen.DE...
> Also sprach Bernard El-Hagin:
>
> > Daby wrote:
> >
> >> Why does if and OR(||) not work as I expect?
> >>
> >> If $y = 1 && $x =2 # this will behaves as I expect checking if y is
> >> 1 AND x is 2
> >>
> >> yet
> >>
> >> If $y= 1 || $y=99 #this does not work as I expect
>
> [...]
>
> > You should enable warnings when developing Perl code. Run the above code
> > with warnings enabled and you'll find out what the problem is.
>
> And even without warnings he'll quickly realize that something is
> severely rotten with his code. Have you ever heard of an "If" keyowrd in
> Perl? ;-)
>
> Tassilo
> --
>
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
>
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
>
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval
---
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.456 / Virus Database: 256 - Release Date: 18/02/2003
------------------------------
Date: Mon, 24 Feb 2003 20:24:17 +0100
From: Matija Papec <mpapec@yahoo.com>
Subject: Re: Just wanted to share this technique (and hear some opinions about it)
Message-Id: <p9sk5v4rbonpjo2bgvrgpcked1skj1kq51@4ax.com>
X-Ftn-To: Michele Dondi
Michele Dondi <bik.mido@tiscalinet.it> wrote:
>>while ( my $f = <> ) {
>> chomp $f;
>> -e and print and last for map "$_$f", @pre;
>> }
>
>Since you always want to both C<print> an C<last> when -e, then you
>could use
>
> -e and print, last for map "$_$f", @pre;
^
Isn't last here a second argument to print? I did perldoc but I'm not sure
how to look at this. :)
--
Matija
------------------------------
Date: 24 Feb 2003 21:49:53 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@post.rwth-aachen.de>
Subject: Re: Just wanted to share this technique (and hear some opinions about it)
Message-Id: <b3e421$nm$1@nets3.rz.RWTH-Aachen.DE>
Also sprach Matija Papec:
> Michele Dondi <bik.mido@tiscalinet.it> wrote:
>> -e and print, last for map "$_$f", @pre;
> ^
>
> Isn't last here a second argument to print? I did perldoc but I'm not sure
> how to look at this. :)
Nope. If you wanted it to be the second argument to print(), you'd have
to pass the default of $_ explicitely:
print $_, last;
Not that "last" has any return value, though. Whenever there is
FUNCTION, SOMETHING;
FUNCTION is assumed to either have no argument or some implicit default
and SOMETHING is executed afterwards. It's not much different than
FUNCTION; SOMETHING;
only that it is one statement and can thus be subject to statement
modifiers such as postfixed if's, for's etc.
Tassilo
--
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval
------------------------------
Date: Mon, 24 Feb 2003 15:56:46 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Just wanted to share this technique (and hear some opinions about it)
Message-Id: <3E5A870E.C62AFE23@earthlink.net>
"John W. Krahn" wrote:
>
> Benjamin Goldberg wrote:
> >
> > "John W. Krahn" wrote:
> > [snip]
> > > > #!/usr/bin/perl -i.bak -lw
> > > > use strict;
> > > >
> > > > my @pre=map sprintf('../../pics/%02d/', $_), 3..10;
> > > >
> > > > my ($cnt,$f);
> > > > while ($f=<>) {
> > > > next if ++$cnt == @pre;
> > >
> > > The value of $cnt starts out at 0, then you increment here to 1,
> > > then at the end of the loop you set it to 0 again so at this point
> > > the value of $cnt will ALWAYS be 1
> >
> > You're not seeing the 'redo' later in the loop.
>
> Yes I saw it but I assumed (wrongly) that it wouldn't execute. :-)
>
> > The code you provided is *not* equivilant to his code, since it
> > never alters the order of items in the @pre array.
>
> No, I made a little mistake. However, after some testing, this is
> equilalent to the OP's code.
[snip code]
But you *still* aren't re-ordering the items in @pre!
The whole point of the OP posting this code was that files named in two
consecutive lines in his input file are usually (though not always) in
the same directory as each other.
By rearranging @pre so that, after finding the file, the directory it
was found in becomes the first element of @pre, the OP's code makes
finding the next file much faster.
Consider, for example, the situation when a dozen consecutive lines of
the input name files are in "../../pics/10/":
In the OP's code, the first of those lines would search through @pre
until it finds that directory, and the other eleven of those lines don't
need to do any searching, since $pre[0] will now be "../../pics/10/"...
thus, those other eleven lines are much faster than the first one.
In your code, however, all twelve lines result in a full search
through the entire @pre array.
--
$;=qq qJ,krleahciPhueerarsintoitq;sub __{0 &&
my$__;s ee substr$;,$,&&++$__%$,--,1,qq;;;ee;
$__>2&&&__}$,=22+$;=~y yiy y;__ while$;;print
------------------------------
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 4616
***************************************