[24697] in Perl-Users-Digest
Perl-Users Digest, Issue: 6854 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Aug 11 09:06:20 2004
Date: Wed, 11 Aug 2004 06:05:14 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Wed, 11 Aug 2004 Volume: 10 Number: 6854
Today's topics:
Re: "defined $r_libs->{$name} " triggers warning "Use o <leo2002chen@hotmail.com>
"Undefined subroutine &main:: called." from nowhere?? <smurf@smurf.noris.de>
Re: "Undefined subroutine &main:: called." from nowhere <smurf@smurf.noris.de>
Re: [OT] Perl Developers Needed for Open-Source ATC! (Aquila Deus)
Re: [OT] Perl Developers Needed for Open-Source ATC! (Peter J. Acklam)
Are you my mother? (was Re: Statistics...) (Greg Bacon)
Re: Expression Problem 510046470588-0001@t-online.de
fdqn and hostname conflict (Adrian Rafferty)
Re: fdqn and hostname conflict <odyniec-usenet@odyniec.net>
Re: join on space instead of comma (David Combs)
Re: join on space instead of comma <tassilo.von.parseval@rwth-aachen.de>
Re: Joining 2 strings <ebohlman@omsdev.com>
Re: News::Scan question (Greg Bacon)
Re: partially matching a regexp <andrewpalmer@email.com>
Re: passing param('something') through a function <richard@zync.co.uk>
Perl PDF modules - help please <GeoffW@wordsmith.demon.co.uk>
Re: Perl PDF modules - help please <noreply@gunnar.cc>
Re: pos and capture (Anno Siegel)
Re: Reading next line, finding missing number in sequen <matthew.garrish@sympatico.ca>
Re: Reading next line, finding missing number in sequen <abodeman@yahoo.com>
Re: Reading next line, finding missing number in sequen <tadmc@augustmail.com>
Re: Reading next line, finding missing number in sequen <andrewpalmer@email.com>
Re: Reading next line, finding missing number in sequen (Anno Siegel)
Re: split inconsistency- why? <yechie.labay@ericsson.com>
Re: Statistics for comp.lang.perl.misc <matthew.garrish@sympatico.ca>
Re: Statistics for comp.lang.perl.misc <bernard.el-haginDODGE_THIS@lido-tech.net>
Re: Statistics for comp.lang.perl.misc <mr@sandman.net>
Validating email addresses (Arthur)
Re: Validating email addresses <ceo@nospam.on.net>
Re: Validating email addresses <jurgenex@hotmail.com>
Re: Validating email addresses (Arthur)
Re: Validating email addresses (Arthur)
Re: Validating email addresses <noreply@gunnar.cc>
Re: Validating email addresses <nobull@mail.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 11 Aug 2004 15:00:35 +0800
From: "Liang" <leo2002chen@hotmail.com>
Subject: Re: "defined $r_libs->{$name} " triggers warning "Use of uninitialized value"
Message-Id: <cfcgdh$pk4$1@newshost.mot.com>
"Joe Smith" <Joe.Smith@inwap.com> wrote in message
news:86GRc.231703$IQ4.70113@attbi_s02...
> Liang wrote:
>
> > Would u please help to check the script, and let me know the reason?
Thanks
> > in advance.
>
> Your script works with perl-5.8.3 after changing one line to
Thanks Joe. You're right. It works on 5.6.0 as well. The problem occuses on
5.001.
> my $r_sect = $r_libs->{$name};
> by removing the extraneous % sign.
>
> Try with other versions of perl, and post your problem to
> comp.lang.perl.misc not comp.lang.perl .
> -Joe
------------------------------
Date: Wed, 11 Aug 2004 13:45:41 +0200
From: Matthias Urlichs <smurf@smurf.noris.de>
Subject: "Undefined subroutine &main:: called." from nowhere??
Message-Id: <pan.2004.08.11.11.45.40.921471@smurf.noris.de>
This happens when my program ends:
$ perl -d tools/dbdiff [..arguments..]
[... set break on last line of tools/dbdiff ...]
[... c ...]
[... various regular no-error program output ...]
main::(tools/dbdiff:449): print STDERR "Exiting\n";
DB<2> s
Exiting
Undefined subroutine &main:: called.
END failed--call queue aborted at tools/dbdiff line 1.
Dbase::CODE(0x8633f44)(/opt/ess/pp01/src/datenbank/dbperl/Dbase.pm:859):
859: print STDERR "PreEnd1\n";
OK. Needless to say, line 1 contains of "#!/usr/bin/perl" and nothing else.
So which *CENSORED* unsinglesteppable part of Perl decided to do this??
$ perl -v
This is perl, v5.8.4 built for i386-linux-thread-multi
Any help on where to dig further would be appreciated.
--
Matthias Urlichs
------------------------------
Date: Wed, 11 Aug 2004 14:29:39 +0200
From: Matthias Urlichs <smurf@smurf.noris.de>
Subject: Re: "Undefined subroutine &main:: called." from nowhere??
Message-Id: <pan.2004.08.11.12.29.39.836822@smurf.noris.de>
Addendum:
> Exiting
... and it stops here (endless loop, non-interruptible) when I do this
with PERLDB_OPTS="NonStop AutoTrace".
Time to recompile with debugging support. With my luck the problem will
then go away.
------------------------------
Date: 10 Aug 2004 18:48:09 -0700
From: aquila_deus@yahoo.co.uk (Aquila Deus)
Subject: Re: [OT] Perl Developers Needed for Open-Source ATC!
Message-Id: <c5cfac8f.0408101748.21fcfe6f@posting.google.com>
pjacklam@online.no (Peter J. Acklam) wrote in message news:<wu06oo00.fsf@online.no>...
> aquila_deus@yahoo.co.uk (Aquila Deus) wrote:
>
> > The project MrATC (Air Traffic Control) needs more Perl developers.
> > We've done some discussion and begin to code and write doc, but
> > there are only 2 developers now (and one is a perl noob - me).
>
> Remember to take the year 10000 problem into account, because
> unless you find a whole lot of full-time programmers that will
> join you, it will take you several thousand years to get it done.
>
> Just a tip.
>
> Peter
> (System administrator/developer, Oslo ATC, Norway)
Ummmm... You're right. That's what we worry about too.
------------------------------
Date: 11 Aug 2004 08:34:01 +0200
From: pjacklam@online.no (Peter J. Acklam)
Subject: Re: [OT] Perl Developers Needed for Open-Source ATC!
Message-Id: <llgmmbdy.fsf@online.no>
aquila_deus@yahoo.co.uk (Aquila Deus) wrote:
> pjacklam@online.no (Peter J. Acklam) wrote:
>
> > aquila_deus@yahoo.co.uk (Aquila Deus) wrote:
> >
> > > The project MrATC (Air Traffic Control) needs more Perl developers.
> > > We've done some discussion and begin to code and write doc, but
> > > there are only 2 developers now (and one is a perl noob - me).
> >
> > Remember to take the year 10000 problem into account, because
> > unless you find a whole lot of full-time programmers that will
> > join you, it will take you several thousand years to get it done.
>
> Ummmm... You're right. That's what we worry about too.
It would be fun to see an ATC system written in Perl, but I really
think you should spend your time on something else. The size and
complexity of ATC software is so large you have minimal chance at
succeeding.
Peter
(System administrator/developer, Oslo ATC, Norway)
--
#!/local/bin/perl5 -wp -*- mode: cperl; coding: iso-8859-1; -*-
# matlab comment stripper (strips comments from Matlab m-files)
s/^((?:(?:[])}\w.]'+|[^'%])+|'[^'\n]*(?:''[^'\n]*)*')*).*/$1/x;
------------------------------
Date: Wed, 11 Aug 2004 11:53:19 -0000
From: gbacon@hiwaay.net (Greg Bacon)
Subject: Are you my mother? (was Re: Statistics...)
Message-Id: <10hk25f5mqrtp61@corp.supernews.com>
In article <_CeSc.20342$Mq1.956850@news20.bellglobal.com>,
Matt Garrish <matthew.garrish@sympatico.ca> wrote:
: [...]
:
: If it's any help, Dr. Seuss wrote a book about a baby bird like you.
: It's called "Are you my mother?". I highly recommend it!
My son liked that book when he was younger! I can remember reading it
to him, and knowing the story from having heard it many times, he'd
jump ahead -- very funny to hear a two-year-old's attempt at a
matter-of-fact tone -- to say, "No, I am a dog" or "No, I am a cow."
Yes, great book!
Greg
--
The more corrupt the state, the more numerous the laws.
-- Tacitus
------------------------------
Date: 10 Aug 2004 23:37:39 +0200
From: 510046470588-0001@t-online.de
Subject: Re: Expression Problem
Message-Id: <87wu06isik.fsf@debian.i-did-not-set--mail-host-address--so-shoot-me>
"gnari" <gnari@simnet.is> writes:
>
> please do not do this unless you trust the input 100% to
> be in the format described.
>
> malicious input (or a mistake) can result in arbitrary code
> execution. (think rm -R /)
use the Safe module judiciously
Klaus Schilling
------------------------------
Date: 10 Aug 2004 19:02:44 -0700
From: aj_rafferty@yahoo.com (Adrian Rafferty)
Subject: fdqn and hostname conflict
Message-Id: <bbacd4ca.0408101802.42c46905@posting.google.com>
Hi,
i'm trying a dummy perl script on solaris ....
# cat test
#!/bin/perl -w
use Sys::Hostname;
my $hostname = hostname();
print "Hostname = $hostname\n";
#
the problem that i have is that some of the hosts have an
/etc/nodename
= to the fqdn , others have the none fqdn nodename
root@gdwtest.au.thenational.com: # cat /etc/nodename
gdwtest.au.thenational.com
root@gdwtest.au.thenational.com: # ./test
Hostname = gdwtest.au.thenational.com
root@gdwtest.au.thenational.com: #
i.e ..
n144110@webjump2: $ ./test
Hostname = webjump2
n144110@webjump2: $
How can i change the output of the script to be "gdwtest"
i.e. the first field of the fqdn ??
I have tried ...
root@gdwtest.au.thenational.com: # hostname | perl -lne 'print
((gethostbyname $_)[0])'
gdwtest
root@gdwtest.au.thenational.com: #
which returns the correct o/p , but i'm not sure how to integrate it
with the
original perl script.
the correct o/p is also displayed in the host without the fqdn ...
n144110@webjump2: $ hostname | perl -lne 'print ((gethostbyname
$_)[0])'
webjump2
n144110@webjump2: $
which returns the correct o/p , but i'm not sure how to integrate it
with the
original perl script.
Any help greatly appreciated,
Regards Adrian
------------------------------
Date: Wed, 11 Aug 2004 11:51:05 +0200
From: Michal Wojciechowski <odyniec-usenet@odyniec.net>
Subject: Re: fdqn and hostname conflict
Message-Id: <87vffq57g6.fsf@orion.odyniec.net>
aj_rafferty@yahoo.com (Adrian Rafferty) writes:
[...]
> How can i change the output of the script to be "gdwtest"
> i.e. the first field of the fqdn ??
You can use a regular expression to discard the part of FQDN that
begins with a dot, leaving just the base hostname.
$hostname =~ s/\..*$//;
Regards,
--
Michal Wojciechowski : for(<>){/\s/,$l{$m=$`}=$'}$_ : 10 PRINT "Yet another"
odyniec()odyniec;net : =$l{$c},/O\s/?$c=$'-1:y/"//d : 20 PRINT "Perl hacker"
http://odyniec.net : ,/T\s/?print$':0while$c++<$m : 30 GOTO 10
------------------------------
Date: Wed, 11 Aug 2004 06:03:09 +0000 (UTC)
From: dkcombs@panix.com (David Combs)
Subject: Re: join on space instead of comma
Message-Id: <cfccqt$if5$1@reader1.panix.com>
THANK YOU!
Now, finally, I have some *real* motivation to (finally) go
learn unpack, so I can *understand* all those tricks.
Any way you two can convince someone (O'Reilly?) to come
up with a "wild hacks with perl" book, and put out a
call for donated hacks to include in it?
Thanks again;
David
------------------------------
Date: Wed, 11 Aug 2004 10:00:41 +0200
From: "Tassilo v. Parseval" <tassilo.von.parseval@rwth-aachen.de>
Subject: Re: join on space instead of comma
Message-Id: <2nu21bF4ou37U1@uni-berlin.de>
Also sprach David Combs:
> Now, finally, I have some *real* motivation to (finally) go
> learn unpack, so I can *understand* all those tricks.
>
> Any way you two can convince someone (O'Reilly?) to come
> up with a "wild hacks with perl" book, and put out a
> call for donated hacks to include in it?
I am not sure that a book with such a title would do Perl's already
quite infamous reputation much good. :-)
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: 11 Aug 2004 05:26:39 GMT
From: Eric Bohlman <ebohlman@omsdev.com>
Subject: Re: Joining 2 strings
Message-Id: <Xns95425560CC0Aebohlmanomsdevcom@130.133.1.4>
selena_kid@yahoo.com (Sim) wrote in
news:82bbfd98.0408101451.69866dfa@posting.google.com:
> I managed to solve the problem! It is very similar to the solution Jue
> posted. Here's how it goes. I wish to thank everyone who has thought
> through this problem. My MSN is jjsimz@hotmail.com. I am a college
> Physics student, and if you have any physics question, I might be of a
> little help. =)
>
>
> #!/usr/bin/perl
> use strict;
You want 'use warnings;' here as well.
>
> open (FILE, 'sample.out') or die "could not open 'sample.out'!!! ";
> open (OUTPUTFILE, '>>output.out') or die "could not open
> 'output.out'!!! ";
Error messages for files should say *why* the file couldn't be opened;
stick a $! in both messages.
> while (<FILE>) {
> s/^\s*((.*\S)?)\s*$/$1/; #removes spaces before and after the
> string
The FAQ recommends doing this in two substitutions (neither of which
requires capturing) rather than one; it's usually faster.
> print (OUTPUTFILE $_, ' ');
> if ($. % 3 == 0) {print (OUTPUTFILE "\n")}
> }
> close FILE;
> close OUTPUTFILE;
------------------------------
Date: Wed, 11 Aug 2004 11:37:59 -0000
From: gbacon@hiwaay.net (Greg Bacon)
Subject: Re: News::Scan question
Message-Id: <10hk18nsjdbn227@corp.supernews.com>
In article <mr-4952B3.23463110082004@individual.net>,
Sandman <mr@sandman.net> wrote:
: In article <i38Sc.19983$Jp6.17178@newsread3.news.atl.earthlink.net>,
: "Bill Segraves" <segraves_f13@mindspring.com> wrote:
:
: > Surely, you're aware of Google. OTOH, if you were, you would have
: > found examples of how the author uses New::Scan, e.g.,
: >
: > http://search.cpan.org/src/GBACON/News-Scan-0.53/eg/
:
: Yes, I've read through all of therse example scripts, but they seem to
: all be based on batch-processing a feed file from a usenet server, not
: something I can call upon at will on any given set of data.
:
: Or am I missing something?
When I generate traffic reports, I call the nntpget program and then
scan the spool I've created, so in that sense, it's code I "can call
upon at will on any given set of data."
Well, the any given set of data part makes me squint, but we seem to
be talking about the same thing.
Let's take a step back: what are you trying to do? If I understand
your intent better, maybe I can offer useful suggestions.
Greg
--
The ground of liberty is to be gained by inches, and we must be
contented to secure what we can get from time to time and eternally
press forward for what is yet to get.
-- Thomas Jefferson
------------------------------
Date: Tue, 10 Aug 2004 23:52:50 -0500
From: "Andrew Palmer" <andrewpalmer@email.com>
Subject: Re: partially matching a regexp
Message-Id: <RzhSc.4428$5s3.3170@fe40.usenetserver.com>
"Andrew Palmer" <andrewpalmer@email.com> wrote in message
news:HpCQc.3093$zc1.2205@fe40.usenetserver.com...
>
> "Thomas Koenig" <Thomas.Koenig@online.de> wrote in message
> news:cettfn$4o9$1@meiner.onlinehome.de...
> > Assume I have a regexp, /^(hello)|(goodbye)$/ for example.
> >
> > I want to see wether a particular string matches part of that
> > particular regexp, so "", "h", "he", "hel", "hell", "hello", "g",
> > "go", "goo" "good", "goodb", "goodby" and "goodbye" would be ok,
> > and anything else wouldn't.
> >
> > I could hand-craft this example easily enough, but it grows
> > tedious and error-prone for more general regular expressions,
> > and automation would be much preferred.
> >
> > Ideas?
>
> Something like:
>
> if(test($input,"hello") || test($input,"goodbye"))
> {
> # stuff
> }
>
> sub test
> {
> my($s1,$s2)=@_;
> for my $len(0..length($s2))
> {
> return 1 if(substr($s2,0,$len) eq $s1);
> }
> return 0;
> }
>
Clearly the above code is retarded. The equivalent using index() is simply:
if(index("hello",$input)==0 || index("goodbye",$input)==0)
{
# stuff
}
The regex tokenizing modules seem unnecessary for the example you posted. Is
your actual test significantly more complicated?
------------------------------
Date: Wed, 11 Aug 2004 11:24:12 +0100
From: "Richard Gration" <richard@zync.co.uk>
Subject: Re: passing param('something') through a function
Message-Id: <cfcs4b$lo3$1@news.freedom2surf.net>
In article <C9cSc.10570$nx2.8410@newsread2.news.atl.earthlink.net>, "Bill
Segraves" <segraves_f13@mindspring.com> wrote:
> "steve_f" <me@example.com> wrote in message
> news:r8fih0hh10m31icsvvr837cb645eu8dkdk@4ax.com...
>> can CGI.pm use both POST and GET together?
> Yes. See the documentation, "MIXING POST AND URL PARAMETERS" --
And if you want a little giggle, search CGI.pm for the word 'cake' ;-)
R
------------------------------
Date: Wed, 11 Aug 2004 13:31:56 +0100
From: Geoff Wilkins <GeoffW@wordsmith.demon.co.uk>
Subject: Perl PDF modules - help please
Message-Id: <hzEsfRF8GhGBFwZB@wordsmith.demon.co.uk>
Hi all.
I'm trying to write a script which will insert text into a PDF template
file and output a new PDF file.
I can do this with PDF:Reuse - but I have to specify the co-ordinates
for where the text should appear. What I want, instead, is to be able
to replace "place-holders" in the template file with the text.
Can any one suggest a Perl PDF module which will help with this? Or any
other way of doing it?
--
Best wishes,
Geoff Wilkins
GeoffW@wordsmith.demon.co.uk
------------------------------
Date: Wed, 11 Aug 2004 14:36:13 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Perl PDF modules - help please
Message-Id: <2nui85F4th3dU1@uni-berlin.de>
Geoff Wilkins wrote:
> Hi all.
Do not multi-post!
http://www.uwasa.fi/~ts/http/crospost.html
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: 11 Aug 2004 11:16:11 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: pos and capture
Message-Id: <cfcv5r$f17$1@mamenchi.zrz.TU-Berlin.DE>
UToronto News <l.heisler@utoronto.ca> wrote in comp.lang.perl.misc:
>
> I have a question about capturing information from a regular expression
> match
>
> when i run
...without strictures and warnings, it seems.
> $string="the rain in spain falls mainly on the plain";
> $searchpattern=".ain";
>
> while ($string=~m/$searchpattern/g)
> {
> $position=pos($string)-length($search);
^^^^^^^
There is no variable "$search". "strict" would have told you so.
Also, the length of the search pattern is generally not the same
as the length of the match. Use the @- array for the beginning
of a match.
> print "position=$position\n";
> pos($string)=$position+1;
This is an error. pos( $string) points already one character past
the match. Incrementing it further may miss some.
> }
>
> -- this searches for all occurences of $search in $string, and prints out
> the starting position of each
> position=8
> position=17
> position=28
> position=43
Have you checked that? Your positions are too large by 4:
print "position=$-[ 0]\n" while $string =~ /$searchpattern/g;
position=4
position=13
position=24
position=39
Your question about pos() after a match in list context has been answered.
Anno
------------------------------
Date: Tue, 10 Aug 2004 21:45:25 -0400
From: "Matt Garrish" <matthew.garrish@sympatico.ca>
Subject: Re: Reading next line, finding missing number in sequence
Message-Id: <QSeSc.20363$Mq1.964246@news20.bellglobal.com>
"Matt Garrish" <matthew.garrish@sympatico.ca> wrote in message
news:h7dSc.20263$Mq1.923325@news20.bellglobal.com...
>
>
> for (($num - ($num - $cnt)) .. ($num - 1)) {
>
That, of course, would be the long way of writing:
for ($cnt .. ($num -1)) {
I was trying something else and never looked twice at it when I switched
gears... : )
Matt
------------------------------
Date: Tue, 10 Aug 2004 21:27:54 -0500
From: "Brian Kell" <abodeman@yahoo.com>
Subject: Re: Reading next line, finding missing number in sequence
Message-Id: <opscjqgswiz772u5@ultramarine.unl.edu>
On Tue, 10 Aug 2004 19:46:26 -0400, Matt Garrish
<matthew.garrish@sympatico.ca> wrote:
>> while (<FILE>) {
>> $currline = $_;
>> $nxtline=$currline++ ;
>> if ($_ != $nxtline) {
>> print MISSING "Missing occurrence is $_ \n";
>> }
>> }
>>
>
> In the above, you assign the value of the line to $currline, then add 1
> and
> assign it to $nxtline. You then test whether the value on the input line
> equals the number you just incremented? This should fail for *all* cases
> (i.e., 1+1 != 1, 2+1 != 2, etc.).:
Not quite; $nxtline will get the value of $currline before the increment.
So it will *succeed* for all cases.
Brian
--
($a='%Q$yW0se3%qhggfIi')=~s,([f-y]),qq;"\\c$1";,ege,@l=unpack'a5a5a*',$a;for$i(
@l){$$i.=sprintf"%lx",$_ for
unpack'C*',$i;push@n,$$i;}$"=',',$_="\c`",$p=eval"
pack'VVN',@n",@b=unpack'C12',$p;$m=4054314,$a=96;(++$a,$m>>=1)&1?s@$@chr$a-!($a
%6-4)*32@e:$;while$m;@z=split m
&&;for$j(@b){print$z[$j&15|($j>>=4,0)]for+z,j;}
------------------------------
Date: Tue, 10 Aug 2004 23:40:21 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Reading next line, finding missing number in sequence
Message-Id: <slrnchj8pl.58t.tadmc@magna.augustmail.com>
Pea <taralish@yahoo.com> wrote:
> text file of numbers, one on each line and just need a script that
> will find the missing number.
> open (FILE, "FILE.txt");
You should always, yes *always*, test the return value from open():
open (FILE, 'FILE.txt') or die "coult not open 'FILE.txt' $!";
> Any ideas?
Does it have to work when there is more than one number in a row omitted?
If not, then:
---------------------------------------
#!/usr/bin/perl
use warnings;
use strict;
for ( my $prev=<DATA>; my $num = <DATA>; $prev = $num) {
print $prev+1, " is missing\n" if $num != $prev+1;
}
__DATA__
1
2
3
5
---------------------------------------
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Wed, 11 Aug 2004 00:18:05 -0500
From: "Andrew Palmer" <andrewpalmer@email.com>
Subject: Re: Reading next line, finding missing number in sequence
Message-Id: <wXhSc.4429$5s3.1975@fe40.usenetserver.com>
"Brian Kell" <abodeman@yahoo.com> wrote in message
news:opscjh0fq0z772u5@pc0938...
> On Tue, 10 Aug 2004 16:14:50 -0700, Jim Gibson <jgibson@mail.arc.nasa.gov>
> wrote:
>
> > my $expected = 1;
> > while(<FILE>) {
> > if( $_ != $expected ) {
> > print MISSING "Missing ...";
> > }
> > $expected = $_ + 1;
> > }
>
> But consider this file:
>
> 1
> 2
> 3
> 5
> 6
> 7
> 9
> 10
>
> This script will print:
>
> Missing 4...
> Missing 5...
> Missing 6...
> Missing 7...
> Missing 8...
>
Hmm... I get only:
Missing 4
Missing 8
which is correct, isn't it?
> (Assuming, of course, that you modified it to print the missing number.)
I modified it thus:
my $expected = 1;
while(<DATA>) {
if( $_ != $expected ) {
print "Missing $expected\n";
}
$expected = $_ + 1;
}
__DATA__
1
2
3
5
6
7
9
10
>
> Brian
>
> -----
>
>
($a='%Q$yW0se3%qhggfIi')=~s,([f-y]),qq;"\\c$1";,ege,@l=unpack'a5a5a*',$a;for
$i(
> @l){$$i.=sprintf"%lx",$_ for
> unpack'C*',$i;push@n,$$i;}$"=',',$_="\c`",$p=eval"
>
pack'VVN',@n",@b=unpack'C12',$p;$m=4054314,$a=96;(++$a,$m>>=1)&1?s@$@chr$a-!
($a
> %6-4)*32@e:$;while$m;@z=split m
> &&;for$j(@b){print$z[$j&15|($j>>=4,0)]for+z,j;}
------------------------------
Date: 11 Aug 2004 10:41:53 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Reading next line, finding missing number in sequence
Message-Id: <cfct5h$dqt$1@mamenchi.zrz.TU-Berlin.DE>
Pea <taralish@yahoo.com> wrote in comp.lang.perl.misc:
> Hello,
> I know this has been discussed before and I've tried some of the
> solutions too. But I've been unsuccessful so far. I have a simple
> text file of numbers, one on each line and just need a script that
> will find the missing number. Example of file:
> 1
> 2
> 3
> 5
>
> My script:
>
> open (FILE, "FILE.txt");
> open (MISSING, ">Missing.txt");
>
> while (<FILE>) {
> $currline = $_;
> $nxtline=$currline++ ;
> if ($_ != $nxtline) {
> print MISSING "Missing occurrence is $_ \n";
> }
> }
>
> close FILE;
> close MISSING;
my @data = <FILE>;
my @missing = 0 .. $data[ -1];
@missing[ @data] = ();
print "@{[ grep defined, @missing]}\n";
That reports 0 as missing too, but that's easy to correct. A variant
delivers the missing elements without intervening undef's:
my @data = <FILE>;
my @missing = 0 .. $data[ -1];
splice @missing, $_, 1 for reverse @data;
print "@missing\n";
Anno
------------------------------
Date: Wed, 11 Aug 2004 11:44:02 +0300
From: "Yechie Labay" <yechie.labay@ericsson.com>
Subject: Re: split inconsistency- why?
Message-Id: <cfcm8i$2mc$1@aken.eed.ericsson.se>
guys, cut the bullshit off, if you dont wan to use Perl, dont, just dont nag
the others who do... it looks like your understanding in design in general
very poor, remember, having write some scripts does not make you designer...
"Peter Hickman" <peter@semantico.com> wrote in message
news:4118f748$0$13089$afc38c87@news.easynet.co.uk...
> Sara wrote:
> > Everybody is happy. But
> >
> > split /,/,'cat,mouse,eel,fish,,,';
> >
> > yields
> > 0 'cat'
> > 1 'mouse'
> > 2 'eel'
> > 3 'fish'
> >
> > Huh? Where did the trailing items go?
>
> If you had read the documentation as you have claimed then why are you
asking
> where the trailing items went? You would know, are you trolling?
>
> > I work around this inconsistency by adding in "placeholders" like:
> >
> > s/,,/,#,/g; s/,,/,#,/g;
> >
> > then do the split,then remove the #'s. What a treat. Thanks Larry!
>
> Larry created Perl just to piss you off.
>
> > But I can't help but wonder- what programming advantage does this
> > offer and why was split designed to ignore some split candidates such
> > as these trailing items? And why only omit trailing items, and not
> > leading? Was there some presumption made about leading ones being more
> > meaningful than trailing? Very odd presumption if so!
>
> Because if you are processing several lines from comma separated file for
> example then trailing blank cells are of no interest but the leading blank
cells
> are because they help line up data with the previous line. Gosh that was
hard.
>
> > To the programmer, it would be easier to make split consistent, and in
> > those cases when the programmer doesn't want empty trailing items he
> > can easily prepare the scalar to get rid of them:
>
> If most people require 'keep the leading, lose the trailing' then it would
be
> better if this were the default behaviour rather than everyone having to
write
> two lines of code where they could write one. Only academics think the
> programmer should be a slave to the language, Larry likes to make the
language
> work for the programmer.
>
> By the way you are the first 'programmer' (I give you the benefit of the
doubt
> here) that has had issue with the behaviour of split. They rest of us find
it
> very useful.
>
> > Perl is pretty much self-consistent, in fact this is one of very few
> > cases I've encountered which lacks consistency. I'd be interested
> > though in hearing the arguments on why this was a beneficial language
> > design choice?
>
> It is realy realy useful. Boy are you going to have fun with OOPerl.
------------------------------
Date: Tue, 10 Aug 2004 21:28:32 -0400
From: "Matt Garrish" <matthew.garrish@sympatico.ca>
Subject: Re: Statistics for comp.lang.perl.misc
Message-Id: <_CeSc.20342$Mq1.956850@news20.bellglobal.com>
"Sandman" <mr@sandman.net> wrote in message
news:mr-8DC25B.23512010082004@individual.net...
> In article <Yg5Sc.39$EQ5.37@nwrddc03.gnilink.net>,
> "Jürgen Exner" <jurgenex@hotmail.com> wrote:
>
> > >> Then the Subject header should say something about News::Scan.
> > >
> > > My original post, the one I wanted Greg to view, did exactly that.
> >
> > It did not. And it still says "Statistics for comp.lang.perl.misc" and
> > nothing about News::Scan.
>
> As does yours.
>
> > >> Please help us keep threads threaded, don't put things unrelated to
> > >> the Subject into the thread.
> > >
> > > I replied to a post, I didn't create the thread.
> >
> > You replied with a request that had nothing to do with the statistics
for
> > comp.lang.perl.misc.
>
> What are you replying to, and what does that have to do with the
statistics of
> cpl.misc? Surely you're not expected to be held at any other standard than
the
> one you're trying to push on others?
>
You're getting ridiculed because you seem to think that an automated
statistic generator is a person. Live with it and move on. It's what you get
for talking to the ether like it's a person.
If it's any help, Dr. Seuss wrote a book about a baby bird like you. It's
called "Are you my mother?". I highly recommend it!
Matt
------------------------------
Date: Wed, 11 Aug 2004 09:22:05 +0200
From: "Bernard El-Hagin" <bernard.el-haginDODGE_THIS@lido-tech.net>
Subject: Re: Statistics for comp.lang.perl.misc
Message-Id: <Xns95425FBFF148elhber1lidotechnet@62.89.127.66>
Sandman <mr@sandman.net> wrote:
[...]
> Look, go troll someone else - I'm here only for the perl
> discussion.
Well, at least you have a sense of humour. Unfortunately, "stupid, but
funny" won't keep you out of many killfiles. See ya, Chuckles.
--
Cheers,
Bernard
------------------------------
Date: Wed, 11 Aug 2004 12:35:56 +0200
From: Sandman <mr@sandman.net>
Subject: Re: Statistics for comp.lang.perl.misc
Message-Id: <mr-A231F6.12355611082004@individual.net>
In article <_CeSc.20342$Mq1.956850@news20.bellglobal.com>, "Matt
Garrish" <matthew.garrish@sympatico.ca> wrote:
>>>>> Please help us keep threads threaded, don't put things unrelated
>>>>> to the Subject into the thread.
>>>>
>>>> I replied to a post, I didn't create the thread.
>>>
>>> You replied with a request that had nothing to do with the
>>> statistics for comp.lang.perl.misc.
>>
>> What are you replying to, and what does that have to do with the
>> statistics of cpl.misc? Surely you're not expected to be held at any
>> other standard than the one you're trying to push on others?
>
> You're getting ridiculed because you seem to think that an automated
> statistic generator is a person.
So basically, I'm being trolled for no reason at all since I don't think that
at all. The automated poster does have Gregs name on it, and most people here
surely highlights replies to their own posts?
> Live with it and move on. It's what
> you get for talking to the ether like it's a person.
Ironically, Greg answered - color you surprised. :-D
> If it's any help, Dr. Seuss wrote a book about a baby bird like you.
> It's called "Are you my mother?". I highly recommend it!
*yawn* Don't you have a schoolyard to hang out in instead of trolling this
group?
--
Sandman[.net]
------------------------------
Date: 10 Aug 2004 20:26:16 -0700
From: amerar@iwc.net (Arthur)
Subject: Validating email addresses
Message-Id: <8b622eae.0408101926.73f3e20e@posting.google.com>
Hi All,
I'm using that Perl module: Mail::RFC822::Address qw(valid).
I am not getting any of the expected results at all. First off, the
perl code compiles, so that means it found Mail::RFC822::Address.
When I ran the test:
if (valid("me@mail.com")) {
print "That's a valid address\n";
}
It printed nothing. However, if I reversed the condition:
if (! valid("me@mail.com")) {
print "That's a valid address\n";
}
What gives, or am I stupid and I'm missing something? The real script
uses a variable for the email address, but why does the above not
work??
Thanks,
Arthur
------------------------------
Date: Wed, 11 Aug 2004 03:33:32 GMT
From: ChrisO <ceo@nospam.on.net>
Subject: Re: Validating email addresses
Message-Id: <gsgSc.730$fl6.305@newssvr15.news.prodigy.com>
Arthur wrote:
> Hi All,
>
> I'm using that Perl module: Mail::RFC822::Address qw(valid).
>
> I am not getting any of the expected results at all. First off, the
> perl code compiles, so that means it found Mail::RFC822::Address.
>
> When I ran the test:
>
> if (valid("me@mail.com")) {
> print "That's a valid address\n";
> }
>
> It printed nothing. However, if I reversed the condition:
>
> if (! valid("me@mail.com")) {
> print "That's a valid address\n";
> }
>
> What gives, or am I stupid and I'm missing something? The real script
> uses a variable for the email address, but why does the above not
> work??
I'm not familiar with the module, but "me@mail.com" needs to be
"me\@mail.com" in the above example. Since you didn't take the time to
cut and paste your exact script (or the relevant section), it's anyone's
guess what your real problem could be.
-ceo
------------------------------
Date: Wed, 11 Aug 2004 05:23:21 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Validating email addresses
Message-Id: <d3iSc.26899$114.18434@nwrddc02.gnilink.net>
Arthur wrote:
> Hi All,
>
> I'm using that Perl module: Mail::RFC822::Address qw(valid).
>
> I am not getting any of the expected results at all. First off, the
> perl code compiles, so that means it found Mail::RFC822::Address.
>
> When I ran the test:
>
> if (valid("me@mail.com")) {
You elected to have perl interpolate the array @mail.
Somehow I doubt this is really what you want.
Use single quotes if you don't want Perl to interpolate @mail.
BTW: if you would have enabled warnings then perl would have told you
(unless you actually do have an array named @mail).
jue
------------------------------
Date: 11 Aug 2004 04:29:43 -0700
From: amerar@iwc.net (Arthur)
Subject: Re: Validating email addresses
Message-Id: <8b622eae.0408110329.13d0c8f3@posting.google.com>
Well, the actual code looks like this:
if (valid($new_email)) {
$invalid = "N";
} else {
$invalid = "Y";
$inv++;
}
That's pretty simply.......it should work right??? It does not
though. I've tried single and double quotes......no luck.....
Arthur
"Jürgen Exner" <jurgenex@hotmail.com> wrote in message news:<d3iSc.26899$114.18434@nwrddc02.gnilink.net>...
> Arthur wrote:
> > Hi All,
> >
> > I'm using that Perl module: Mail::RFC822::Address qw(valid).
> >
> > I am not getting any of the expected results at all. First off, the
> > perl code compiles, so that means it found Mail::RFC822::Address.
> >
> > When I ran the test:
> >
> > if (valid("me@mail.com")) {
>
> You elected to have perl interpolate the array @mail.
> Somehow I doubt this is really what you want.
>
> Use single quotes if you don't want Perl to interpolate @mail.
>
> BTW: if you would have enabled warnings then perl would have told you
> (unless you actually do have an array named @mail).
>
> jue
------------------------------
Date: 11 Aug 2004 04:42:37 -0700
From: amerar@iwc.net (Arthur)
Subject: Re: Validating email addresses
Message-Id: <8b622eae.0408110342.12c0056c@posting.google.com>
Even stranger, if the list of addresses I send all have an @ sign,
then everything is flagged as valid, even if I have other symbols in
the address, such as # or ( or *.
But if and only if I omit the @ sign is it marked invalid..........
Does this thing even work under Red Hat, what is the issue?
Arthur
"Jürgen Exner" <jurgenex@hotmail.com> wrote in message news:<d3iSc.26899$114.18434@nwrddc02.gnilink.net>...
> Arthur wrote:
> > Hi All,
> >
> > I'm using that Perl module: Mail::RFC822::Address qw(valid).
> >
> > I am not getting any of the expected results at all. First off, the
> > perl code compiles, so that means it found Mail::RFC822::Address.
> >
> > When I ran the test:
> >
> > if (valid("me@mail.com")) {
>
> You elected to have perl interpolate the array @mail.
> Somehow I doubt this is really what you want.
>
> Use single quotes if you don't want Perl to interpolate @mail.
>
> BTW: if you would have enabled warnings then perl would have told you
> (unless you actually do have an array named @mail).
>
> jue
------------------------------
Date: Wed, 11 Aug 2004 14:00:58 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Validating email addresses
Message-Id: <2nug61F4o7n7U1@uni-berlin.de>
Arthur wrote:
> Well, the actual code looks like this:
>
> if (valid($new_email)) {
> $invalid = "N";
> } else {
> $invalid = "Y";
> $inv++;
> }
>
> That's pretty simply.......it should work right??? It does not
> though. I've tried single and double quotes......no luck.....
Please post a short but *complete* program that illustrates your
observation.
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Wed, 11 Aug 2004 13:16:28 +0100
From: Brian McCauley <nobull@mail.com>
Subject: Re: Validating email addresses
Message-Id: <cfd2f8$fjn$1@sun3.bham.ac.uk>
Arthur top-posts:
[ top-posting corrected - please don't top-post, it is rude ]
>
> "Jürgen Exner" <jurgenex@hotmail.com> wrote in message news:<d3iSc.26899$114.18434@nwrddc02.gnilink.net>...
>
>>Arthur wrote:
>>>I'm using that Perl module: Mail::RFC822::Address qw(valid).
>>>
>>>I am not getting any of the expected results at all. First off, the
>>>perl code compiles, so that means it found Mail::RFC822::Address.
>>>
>>>When I ran the test:
>>>
>>> if (valid("me@mail.com")) {
>>
>>You elected to have perl interpolate the array @mail.
>
> Well, the actual code looks like this:
If you post something other than actual code then you should expect to
get comments on what you posted and not the actual code that we can't see.
> if (valid($new_email)) {
> $invalid = "N";
> } else {
> $invalid = "Y";
> $inv++;
> }
>
> That's pretty simply.......it should work right???
Err... how would you know? What's in $new_mail ? What ends up in $invalid?
> It does not though.
"It does not work" is a red flag phrase. When ever you find yourself
saying "it does not work" you should stop and go back and try to find a
better way to express yourself.
Please post a minimal but complete script that fails to work as you
would expect.
------------------------------
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.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
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 6854
***************************************