[23062] in Perl-Users-Digest
Perl-Users Digest, Issue: 5283 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jul 28 21:05:55 2003
Date: Mon, 28 Jul 2003 18:05:09 -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 Mon, 28 Jul 2003 Volume: 10 Number: 5283
Today's topics:
Re: Can anyone help with the following code <uri@stemsystems.com>
Re: Can anyone help with the following code <REMOVEsdnCAPS@comcast.net>
Re: Can anyone help with the following code <uri@stemsystems.com>
Re: Can anyone help with the following code (Tad McClellan)
Re: CGI.pm problem under Redhat Linux 9.0 (perl-5.8.0) <akopps+usenet@ocf.berkeley.edu>
Create electronic newsletters and email to all people i <dbcoordinator@cws.org.nz>
Re: Currying functions <dave@3dex.com>
Re: FTP in ASCII mode from UNIX to NT (Tad McClellan)
Re: GD.pm index table limitation <mgjv@tradingpost.com.au>
Re: How do you Call a Perl subroutine with a variable n <REMOVEsdnCAPS@comcast.net>
Re: How to do equivalent to Crypt:CBC of Perl in Oracle <r_reidy@comcast.net>
how to do sh's -e in perl? <jidanni@jidanni.org>
Re: how to do sh's -e in perl? <grazz@pobox.com>
Re: how to do sh's -e in perl? <pkent77tea@yahoo.com.tea>
Re: How to pick out words from a non-delimited string? (Julian Hsiao)
Re: IntrOOspection: ISO an object's methods set <ben.goldberg@hotpop.com>
Re: New to Perl <krahnj@acm.org>
Re: New to Perl <none@given.com>
Re: New to Perl (Tad McClellan)
Re: Perl compiler? error <jkeen@concentric.net>
Re: Perl training resources? <Bill_Fields@azb.uscourts.gov>
Re: UTF-8 module <pkent77tea@yahoo.com.tea>
Re: what is perl's no op operator? <pkent77tea@yahoo.com.tea>
Re: what is perl's no op operator? <usenet@expires082003.tinita.de>
Re: Win32 Ole <mikeflan@earthlink.net>
Re: <bwalton@rochester.rr.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 28 Jul 2003 22:12:32 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Can anyone help with the following code
Message-Id: <x7y8yis3lc.fsf@mail.sysarch.com>
fix your line wrap.
don't post long complete programs. reviewing 600 lines is real work.
if this is third party code, get the author to fix it. we don't repair
free and broken scripts.
otherwise the code has many problems (from a cursory scan).
it uses stuff like @fields[2] (which is actually correct in perl6! so
the author is thinking ahead there) which is wrong.
my $i = '';
odd way to initialize a counter.
while (<BIDFILE1>) {
$$itemcode_bidfile_contents[$i] = $_;
$i++;
}
obviously warnings and strict aren't enabled. that would barf on
warnings for converting a null string to 0
and why is that using a scalar to hold an array that is used only one
other place? blecch.
@itemcode_bidfile_contents = <BIDFILE1> ;
there is tons more to be redone in this pile of crap.
i suggest you burn it, get your money back if possible and hire a
programmer to create a proper script.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
------------------------------
Date: Mon, 28 Jul 2003 17:15:21 -0500
From: "Eric J. Roode" <REMOVEsdnCAPS@comcast.net>
Subject: Re: Can anyone help with the following code
Message-Id: <Xns93C6B9AE67856sdn.comcast@206.127.4.25>
-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1
aaron@covenantsolutions.co.uk (Aaron Brockhurst) wrote in
news:14fc5121.0307281358.3c655be4@posting.google.com:
> Hi
>
> I am trying to get the following code to work but am really struggling
> to find out why the sub routines getPreviousDetails and
> getPreviousEmail dont work. I am trying to use the script on a
> charity auction page. I've put the code below
>
> Can anyone provide any solutions
>
> Thanks in advance
> Aaron
For one thing, "don't work" is so vague as to be useless. What do you
expect to happen, and what is actually happening? If you go to a doctor
and say "I don't feel well", guess what? He's going to ask you what your
symptoms are. Please tell us your program's symptoms! :-)
Second, the 600 line script you posted is, I'm afraid, extremely poor code.
I am not surprised that it is broken :-/ Where did you get it? You may
want to avoid that source in the future.
- --
Eric
$_ = reverse sort qw p ekca lre Js reh ts
p, $/.r, map $_.$", qw e p h tona e; print
-----BEGIN xxx SIGNATURE-----
Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com>
iQA/AwUBPyWgbWPeouIeTNHoEQKZdACg9NUw1/6TO6BW0LJjT4g/w9mnsT4An3Is
flPpujQJP97jeZP14yUM6QjG
=pMtQ
-----END PGP SIGNATURE-----
------------------------------
Date: Mon, 28 Jul 2003 22:36:29 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Can anyone help with the following code
Message-Id: <x7smoqs2he.fsf@mail.sysarch.com>
>>>>> "EJR" == Eric J Roode <REMOVEsdnCAPS@comcast.net> writes:
EJR> Second, the 600 line script you posted is, I'm afraid, extremely
EJR> poor code. I am not surprised that it is broken :-/ Where did
EJR> you get it? You may want to avoid that source in the future.
he replied via email to my post (cc'ed to him) saying 'thanks for your
advice'.
i suspect he wrote it. bid scripts aren't generic enough to make it to
the script kiddie archives.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
------------------------------
Date: Mon, 28 Jul 2003 18:26:58 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Can anyone help with the following code
Message-Id: <slrnbibca2.23r.tadmc@magna.augustmail.com>
Aaron Brockhurst <aaron@covenantsolutions.co.uk> wrote:
> I am trying to get the following code to work but am really struggling
> to find out why the sub routines getPreviousDetails and
> getPreviousEmail dont work.
^^^^^^^^^
Beware of saying "doesn't work"
This is a "red flag" phrase. If you find yourself writing that,
pause and see if you can't describe what is not working without
saying "doesn't work". That is, describe how it is not what you
want.
> #!/usr/bin/perl
use warnings;
use strict;
Ask perl to help you
You can ask perl itself to help you find common programming mistakes
by doing two things: enable warnings (perldoc warnings) and enable
"strict"ures (perldoc strict).
You should not bother the hundreds/thousands of readers of the
newsgroup without first seeing if a machine can help you find your
problem. It is demeaning to be asked to do the work of a machine. It
will annoy the readers of your article.
> if (@fields[1]=~m/^$loginname$/) {
^
^
> sub getBidInfo {
>
> my ($itemcode)=@_[0];
^
^
You should always enable warnings when developing Perl code!
[snip 600 lines of code]
First make a short (less than 20-30 lines) and *complete* program
that illustrates the problem you are having. People should be able
to run your program by copy/pasting the code from your article. (You
will find that doing this step very often reveals your problem
directly. Leading to an answer much more quickly and reliably than
posting to Usenet.)
Somebody should write all of that advice down somewhere...
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Mon, 28 Jul 2003 23:30:57 +0000 (UTC)
From: Akop Pogosian <akopps+usenet@ocf.berkeley.edu>
Subject: Re: CGI.pm problem under Redhat Linux 9.0 (perl-5.8.0)
Message-Id: <bg4bnh$2mkj$1@agate.berkeley.edu>
marmot101 <marmot101@yahoo.com> wrote:
> Hi,
> I just installed Redhat Linux 9.0, which include perl-5.8.0. However, when I
> run a perl program begin with:
> use CGI /:standard/;
> System complains: Can not locate CGI.pm ...
> I went to perl directory: /usr/lib/perl5/5.8.0. There is no CGI.pm, but
> there is a CGI.pm.newcgi. What should I do? rename this CGI.pm.newcgi to
> CGI.pm? that sounds weird ...
> Anyone can give me some suggestion?
Possibly, RedHat has packaged CGI.pm as a separate rpm package, the
way they already do with other popular perl modules, and this package
has not been installed. Take a look at your install media to see if
there is an rpm package named Perl-CGI or similar.
--
Akop Pogosian
This space has been accidentally left blank.
------------------------------
Date: Tue, 29 Jul 2003 12:49:16 +1200
From: "DB Coordinator for CS" <dbcoordinator@cws.org.nz>
Subject: Create electronic newsletters and email to all people in an excel spreadsheet
Message-Id: <FujVa.95500$JA5.2100992@news.xtra.co.nz>
Hi Guys
We are using Windows platform and active perl in our organisation. We want
to create electronic newsletters(which embed images as well) and want to
mailout all the people whose email addresses are in an excel spreadsheet.
Can you give some advice about what modules/items we should use in Active
perl to create/mailout electronic newsletters?. How can we achieve this
task?. Are there any particular way to do this in active perl?. What
modules/sections of Active perl we should need?.Can you give some reference
or help?
Thank you
Jo
------------------------------
Date: Mon, 28 Jul 2003 23:55:44 GMT
From: "Dave Benjamin" <dave@3dex.com>
Subject: Re: Currying functions
Message-Id: <4KiVa.145217$o86.136733@news1.central.cox.net>
"Adrian Kubala" <adrian@sixfingeredman.net> wrote in message
news:Pine.LNX.4.44.0307281409080.11405-100000@gwen.sixfingeredman.net...
> On Mon, 28 Jul 2003, Dave Benjamin wrote:
> > other languages like Python and Java use a more OO (and efficient) way
> > of caching the pattern than using the method I described.
>
> Why do you say "more efficient" -- can't you implement partial application
> with a closure, and why should that less efficient than a full-blown
> object? I'd think it'd be more efficient since there's no dynamic
> dispatch.
All I was trying to say (and I didn't explain this very well) was that
partial application does no actual computation, so if you partially apply a
regex match function with a particular pattern (assuming pattern means a
string, not a compiled regex), the regex could potentially be recompiled for
each iteration. In other words, if you can do some number crunching before
you have all the arguments you want, you're better off writing a function
that does that computation and then returns a closure instead of currying.
Python and Java achieve their efficiency by doing something similar to
currying, but in object-oriented style. You compile your regular expression
into an object, and that object's "match" method (or similar) can then be
applied to a sequence without worrying about redundantly recompiling the
same regex. Perl's a bit different, because it treats regexes as literals,
and does caching behind the scenes. (Right? I'm guessing...)
Dave
------------------------------
Date: Mon, 28 Jul 2003 18:35:51 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: FTP in ASCII mode from UNIX to NT
Message-Id: <slrnbibcqn.23r.tadmc@magna.augustmail.com>
jiju <jmkuruvilla@yahoo.com> wrote:
> someone else also gave me a tip. `perl -p -i -e 's/\\n/\\r\\n/'
> $filename` to replace the newlines with carriage returns in DOS.
That code does *not* replace the newlines with carriage returns.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 29 Jul 2003 00:21:19 GMT
From: Martien Verbruggen <mgjv@tradingpost.com.au>
Subject: Re: GD.pm index table limitation
Message-Id: <slrnbibfg1.d0q.mgjv@verbruggen.comdyn.com.au>
On 28 Jul 2003 12:19:13 -0700,
julien <jullag@hotmail.com> wrote:
> Hi there,
> i have a problem with the GD module: I need to allocate a lot of
> colors (and very sharply defined) for one single image. Apparently,
> once the image index color table is full (i.e. approx 255 elements),
> all subsequently allocated colors will have the same rgb code as the
> last element (the 255th one), which looks obviously not exactly as i
> would like.
If you want more than 255 colours, you need to work with a true colour
image. Use GD::Image->trueColor(1) before creating your images, or you
need to create your images with GD::Image->newTrueColor(). You will
need a GD version 2.xx to be able to do this.
Note that a true colour image is not a paletted image, even though the
GD interface still looks like you're working with a colour palette. If
you do want to work with a paletted image with more than 255 colours,
you'll have to switch to Image::Magick.
Martien
--
|
Martien Verbruggen | I used to have a Heisenbergmobile. Every time
Trading Post Australia | I looked at the speedometer, I got lost.
|
------------------------------
Date: Mon, 28 Jul 2003 17:09:03 -0500
From: "Eric J. Roode" <REMOVEsdnCAPS@comcast.net>
Subject: Re: How do you Call a Perl subroutine with a variable name?
Message-Id: <Xns93C6B89CBAFB6sdn.comcast@206.127.4.25>
-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1
fred.illig@lmco.com (Fred) wrote in
news:8714513c.0307281029.66147c6a@posting.google.com:
> Anyone,
>
> I have a Perl module (*.pm).
> I have a subroutine declared - sub x($$$);
> I have the subroutine in the module - sub x($$$){<process the input
> variables and return two variables>};
Why the ($$$) prototype?
> In another subroutine in this module, I want to call this subroutine
> (x) via an array element - @array = (a,b,c,x,y,z);
> ($outvar1, $outvar2) = &$array[3]($invar1,$invar2,$invar3);
This syntax looks fine. You should probably drop the &, though.
> This is not working.
You should elaborate. "Not working" is so vague as to be useless.
> How do I make a call to a subroutine where the name of the subroutine
> to be called is being derived from an element in an array? We have a
> variable as the subroutine name that we want to use.
That's usually a Bad Idea. What are you really trying to do?
- --
Eric
$_ = reverse sort qw p ekca lre Js reh ts
p, $/.r, map $_.$", qw e p h tona e; print
-----BEGIN xxx SIGNATURE-----
Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com>
iQA/AwUBPyWe8mPeouIeTNHoEQKUhwCdEuk2hZTG6o/FIWxSHBjJgGQjYQQAoPfR
PLN5eSnq7dSg2UX9z235VGt6
=w+ru
-----END PGP SIGNATURE-----
------------------------------
Date: Mon, 28 Jul 2003 16:30:00 -0600
From: Ron Reidy <r_reidy@comcast.net>
Subject: Re: How to do equivalent to Crypt:CBC of Perl in Oracle pl/sql
Message-Id: <3F25A3E8.3050303@comcast.net>
Look on CPAN for extproc-perl. Install (or have your DBA install); enjoy.
nataraj wrote:
> I have been using PERL, Crypt::CBC for encryption and storing the
> encrypted password in Oracle database.
>
> Now I want to do the encryption/decryption inside PL/SQL.
>
> How to achieve the same?
>
> i.e.
> I should be able to decrypt in pl/sql, something which has been
> encrypted in perl and vice versa.
>
> Please suggest.
>
> Thanks in advance.
> Nataraj
>
> --
> Posted via http://dbforums.com
--
Ron Reidy
Oracle DBA
------------------------------
Date: Tue, 29 Jul 2003 05:33:21 +0800
From: Dan Jacobson <jidanni@jidanni.org>
Subject: how to do sh's -e in perl?
Message-Id: <87u196e3q6.fsf@jidanni.org>
I can get the shell's "set -u" protection in perl with "use strict",
but what about the shells' "set -e"? Must I everywhere add "or die"s
to chdirs etc., why can't I turn it on for the whole program with one
line at the top?
------------------------------
Date: Mon, 28 Jul 2003 23:49:35 GMT
From: Steve Grazzini <grazz@pobox.com>
Subject: Re: how to do sh's -e in perl?
Message-Id: <jEiVa.9079$cM6.7154@nwrdny01.gnilink.net>
Dan Jacobson <jidanni@jidanni.org> wrote:
> I can get the shell's "set -u" protection in perl with
> "use strict", but what about the shells' "set -e"?
% perldoc -f -e # :-)
> Must I everywhere add "or die"s to chdirs etc., why can't
> I turn it on for the whole program with one line at the top?
You can; quit whinging.
% perldoc Fatal
There are also 'FATAL' warnings, which might catch a few
of the unwrappable functions (like system() and print()).
% perldoc warnings
% perldoc perllexwarn
--
Steve
------------------------------
Date: Tue, 29 Jul 2003 00:54:13 +0100
From: pkent <pkent77tea@yahoo.com.tea>
Subject: Re: how to do sh's -e in perl?
Message-Id: <pkent77tea-7A543D.00541329072003@usenet.plus.net>
In article <87u196e3q6.fsf@jidanni.org>,
Dan Jacobson <jidanni@jidanni.org> wrote:
> I can get the shell's "set -u" protection in perl with "use strict",
> but what about the shells' "set -e"? Must I everywhere add "or die"s
> to chdirs etc., why can't I turn it on for the whole program with one
> line at the top?
The 'set -e' option exits from the shell if any invoked commands exit
with non-zero status. Perl isn't a shell, so it achieves some things by
direct system calls (e.g. the mkdir(2) system call) rather than by
invoking external executables (/bin/mkdir) like a shell would. That
said, the majority of external commands are going to be subprocesses in
perl -and- the shell (e.g. lynx, rsync, who) so they're the same in that
respect.
So, 'yes', you're right. If you want that specific kind of error
checking you have to ask for it yourself. Look into the 'system'
function built-in to perl.
For example, taking your chdir example, you might try to handle
exceptional conditions... you might say:
# some setup here...
if (-d $somewhere) {
print "Output dir exists\n";
} else {
die "Hey - $somewhere doesn't exist and I don't know what to do\n";
}
or maybe:
unless (-d $somewhere) {
require File::Path;
File::Path::mkpath($somewhere, 1, 0775);
}
and then the chdir()
depending on how you think the condition should be handled. Is the
condition exceptional, or is it likely to happen frequently? Do you want
to ask the user for confirmation before altering the filesystem? Can you
check for problems before doing any work (e.g. testing to see if files
exist already)
P
--
pkent 77 at yahoo dot, er... what's the last bit, oh yes, com
Remove the tea to reply
------------------------------
Date: 28 Jul 2003 15:19:15 -0700
From: madoka@novastar.com (Julian Hsiao)
Subject: Re: How to pick out words from a non-delimited string?
Message-Id: <159063bc.0307281419.4e14318c@posting.google.com>
"Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de> wrote:
> Also sprach Julian Hsiao:
>
>> I want to know if there's an algorithm that picks out the words
from a
>> string that doesn't delimit each words. For example, given
>> "helloworld" outputs "hello world". Ideally, it should also be
>> resistant to spelling errors.
>
> Such an algorithm could only be used as a preprocessors. The result
> would still need to be verified by a human. An approach would be to take
> a dictionary file and scan the text for any words that are in the
> dictionary. If a word has been found, surround it with spaces.
I've thought about that, except that this approach doesn't handle
errors gracefully. In the event that a search fails (most likely due
to spelling errors), this algorithm will either have to halt, or risk
parsing the rest of the string incorrectly.
As an example, if at the first syntax error, a C compiler halts, or
parses the rest of the code incorrectly, it wouldn't be very useful at
all. Of course, the latter still happens sometimes, but at least most
compilers stll parses *some* of the remaining code correctly.
So the algorithm needs to know when to "jump ahead" a few characters
in case of errors.
> Another, more general approach, would try to do the splitting based on
> morphological rules for a given language.
Can you please elaborate on what you mean? In my case, the string
will always be in English.
> But take the word "deallocate": the above dictionary approach could turn
> this into "deal locate".
I don't think this is a problem, since I will be using the algorithm
only as a preprocessor, as you've suggested.
Thanks.
Julian Hsiao
madoka@novastar.com
------------------------------
Date: Mon, 28 Jul 2003 18:10:10 -0400
From: Benjamin Goldberg <ben.goldberg@hotpop.com>
Subject: Re: IntrOOspection: ISO an object's methods set
Message-Id: <3F259F42.86944183@hotpop.com>
J Krugman wrote:
>
> I am aware of the UNIVERSAL::can method to determine whether an
> object can perform a particular method, but is there a way to get
> all the methods that an object can perform (including the inherited
> ones, of course)? I realize this question is complicated by
> AUTOLOAD, but I'd be happy if I could find all of an object's
> non-AUTOLOADed methods.
Well, would go something like this:
sub list_all_possible_methods {
my $class = ref $_[0] || $_[0];
my $subs = $_[1] || {};
# stash == symbol table hash.
my $stash = do { no strict 'refs'; \%{ $class . "::" } };
while( my ($name, $glob) = each %$stash ) {
next if $subs->{$name};
if( "GLOB" ne ref \$glob ) {
# if it's not really a glob object, then
# we have a sub prototype, but have neither
# a sub body, nor any package variable, nor
# a filehandle associated with this name.
# This is probably due to autoload.ix, produced
# by AutoSplitter.pm during install. Pretend
# that the sub exists.
$subs->{$name} = 1 if UNIVERSAL::can($class, "AUTOLOAD");
} elsif( defined *{$glob}{CODE} ) {
# if a CODE slot exists in the glob, then there's
# a method here!
$subs->{$name} = 1;
}
}
my $isa = $stash->{"ISA"};
return keys %$subs unless defined $isa and "GLOB" eq ref \$isa;
$isa = *{$isa}{ARRAY};
return keys %$subs unless $isa;
foreach my $parent (@$isa) {
list_all_possible_subs($parent, $subs);
}
return keys %$subs;
}
[untested]
> More generally, how does UNIVERSAL determine whether object $foo
> can 'fandango'? Does it simply run eval { $foo->fandango() } and
> then pick through the bloody aftermath in $@, or does it use a more
> civilized approach, such as looking up some suitable tables? If
> the latter is true, how can a program access these tables of methods
> directly?
It uses a more civilized approach, something like:
sub my_can {
my $class = ref $_[0] || $_[0];
my $method = $_[1];
my $namespace = $class . "::";
my $stash = do { no strict 'refs'; \%$namespace };
if( my $glob = $stash->{$method} ) {
if( "GLOB" eq ref \$glob ) {
return *{$glob}{CODE} if defined *{$glob}{CODE};
} else {
no strict 'refs';
return \&{ $namespace . $method };
}
}
my $isa = $stash->{"ISA"};
return unless $isa and "GLOB" eq ref \$isa;
$isa = *{$isa}{ARRAY};
return unless $isa;
foreach my $parent (@$isa) {
my $coderef = my_can( $parent, $method );
return $coderef if defined $coderef;
}
return;
}
[untested]
Except that caching is done to make it faster.
By the way... how do you expect that when you do $foo->fandango, perl
finds fandango in the first place, and why do you think it wouldn't be
able to re-use that code for $foo->can("fandango")?
--
$a=24;split//,240513;s/\B/ => /for@@=qw(ac ab bc ba cb ca
);{push(@b,$a),($a-=6)^=1 for 2..$a/6x--$|;print "$@[$a%6
]\n";((6<=($a-=6))?$a+=$_[$a%6]-$a%6:($a=pop @b))&&redo;}
------------------------------
Date: Mon, 28 Jul 2003 22:16:50 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: New to Perl
Message-Id: <3F25A113.37BFFF08@acm.org>
nos wrote:
>
> I am looking for a way to look into a file and determine the next
> number in a sequence that is not present within a range of numbers.
> Example:
> File 10000
> 10001
> 10003
> 10004
>
> I want it to find 10002 as the missing number. Any suggestions.
perl -lne'print for $last + 1 .. $_ - 1; $last = $_' yourfile
John
--
use Perl;
program
fulfillment
------------------------------
Date: Mon, 28 Jul 2003 22:50:35 GMT
From: "Mark" <none@given.com>
Subject: Re: New to Perl
Message-Id: <%MhVa.2299$Vt6.330@rwcrnsc52.ops.asp.att.net>
"nos" <nos41@hotmail.com> wrote in message
news:e06c9226.0307281241.56435230@posting.google.com...
> I am looking for a way to look into a file and determine the next
> number in a sequence that is not present within a range of numbers.
> Example:
> File 10000
> 10001
> 10003
> 10004
>
> I want it to find 10002 as the missing number. Any suggestions.
>
> Thanks,
> Nos
Well you could just subtract each number from the next. If the answer is
<> -1 your have a gap.
------------------------------
Date: Mon, 28 Jul 2003 18:32:39 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: New to Perl
Message-Id: <slrnbibckn.23r.tadmc@magna.augustmail.com>
nos <nos41@hotmail.com> wrote:
> Any suggestions.
I suggest putting the subject of your article in the Subject
of your article.
Your post was *not* about being new to Perl.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 28 Jul 2003 22:46:18 GMT
From: "James E Keenan" <jkeen@concentric.net>
Subject: Re: Perl compiler? error
Message-Id: <bg493q$be0@dispatch.concentric.net>
"Jeff 'japhy' Pinyan" <pinyaj@rpi.edu> wrote in message
news:Pine.SGI.3.96.1030728142203.44173A-100000@vcmr-64.server.rpi.edu...
> On 28 Jul 2003, James E Keenan wrote:
>
> >>
> >There's no compiler error here, but I think you may have a conceptual
> >error. The 'elsif' clause establishes a Boolean context, i.e., either
> >a 'true' or 'false' (in Perl's terms) is the only acceptable answer.
>
> You're not answering the question, though. The OP is curious why the
> error is said to stem from line 8, when the expression causing the error
> is on line 12. This is because of the way Perl compiles the if-else block
> internally.
>
True. I was posting from Google, so I had to guess as to whether other
responses had been written but not yet posted. My hunch was that someone
would have made the point you did (Brian did, albeit in less specific terms
than you), so I felt free to raise another point about the OP's code.
Thanks.
------------------------------
Date: Mon, 28 Jul 2003 17:09:30 -0700
From: "William Fields" <Bill_Fields@azb.uscourts.gov>
Subject: Re: Perl training resources?
Message-Id: <bg4dvr$s06$1@apollo.nyed.circ2.dcn>
> WF> MCSD - Microsoft Visual FoxPro
> WF> MCP - Win2k Pro
> WF> US Bankruptcy Court
>
> i take it that using the first two led to the last one?
>
> :-)
Funny guy. =P
If there are no local Perl training resources in the Phoenix, Arizona area,
could someone suggest alternate training methods (CBT, videos, hands on
books etc...)
Thanks again.
--
William Fields
MCSD - Microsoft Visual FoxPro
MCP - Win2k Pro
US Bankruptcy Court
Phoenix, AZ
The secret to creativity is knowing how to hide your sources.
- Albert Einstein
------------------------------
Date: Tue, 29 Jul 2003 00:28:59 +0100
From: pkent <pkent77tea@yahoo.com.tea>
Subject: Re: UTF-8 module
Message-Id: <pkent77tea-239C52.00285829072003@usenet.plus.net>
In article <Pine.LNX.4.53.0307280128350.22453@lxplus073.cern.ch>,
"Alan J. Flavell" <flavell@mail.cern.ch> wrote:
> On Mon, Jul 28, pkent inscribed on the eternal scroll:
> > Oh the fun we've had with perl5.6.1, XML::Parser, high-order characters,
> > web browsers and CGI.
>
> More so than with 5.8 ?
A-ha. A-hahaha. Ha hahahaha. F' knows, because our backward-looking
uninspiring overpriced underperforming hosting provider took several
decades to upgrade 5.00404 to perl5.6.1 on a subset of all the servers,
entirely independent of the way they failed to manage module versions
and upgrades across the set of machines they administer. Hence we have
laughed ourselves into merry pools of bitter tears at the very thought
of saying "Please install the latest stable copy of perl in all
environments" and restrain ourselves to the dizzying trailing edge of
Perl development where we can be a mere 2 years or so behind the times.
Perl 5.8? We _dreamed_ of having problems with perl 5.8. We had problems
with 5.6 and we liked it! We had to develop software in a shoebox in the
the middle of the road.
Still, mustn't grumble, it could be worse.
P
(smileys left as an exercise)
--
pkent 77 at yahoo dot, er... what's the last bit, oh yes, com
Remove the tea to reply
------------------------------
Date: Tue, 29 Jul 2003 00:30:48 +0100
From: pkent <pkent77tea@yahoo.com.tea>
Subject: Re: what is perl's no op operator?
Message-Id: <pkent77tea-AD7D7F.00304829072003@usenet.plus.net>
In article <87d6fvuq5v.fsf@jidanni.org>,
Dan Jacobson <jidanni@jidanni.org> wrote:
> In the shell, I can do echo $a; : echo $b; echo $c
> to turn off b with minimal disturbance to the one-liner.
> In perl, one can't get away with just adding a ": ":
> print $a; if(0){print $b}; print $c; #best I know
> Is there a way less disruptive to this one-liner?
You can also use 'if' as a 'statement modifier', which is where it goes
at the end of the statement, like:
print $foo if 0;
P
--
pkent 77 at yahoo dot, er... what's the last bit, oh yes, com
Remove the tea to reply
------------------------------
Date: 28 Jul 2003 23:36:43 GMT
From: Tina Mueller <usenet@expires082003.tinita.de>
Subject: Re: what is perl's no op operator?
Message-Id: <bg4c2b$kcj23$2@ID-24002.news.uni-berlin.de>
Dan Jacobson wrote:
> In the shell, I can do echo $a; : echo $b; echo $c
> to turn off b with minimal disturbance to the one-liner.
> In perl, one can't get away with just adding a ": ":
> print $a; if(0){print $b}; print $c; #best I know
> Is there a way less disruptive to this one-liner?
just for fun, maybe:
1?1:
like:
print $a; 1?1: print $b; print $c;
regards, tina
--
http://www.tinita.de/ \ enter__| |__the___ _ _ ___
http://Movies.tinita.de/ \ / _` / _ \/ _ \ '_(_-< of
http://www.perlquotes.de/ \ \ _,_\ __/\ __/_| /__/ perception
- my mail address expires end of august 2003 -
------------------------------
Date: Mon, 28 Jul 2003 23:44:23 GMT
From: Mike Flannigan <mikeflan@earthlink.net>
Subject: Re: Win32 Ole
Message-Id: <3F25B5E2.27BED79E@earthlink.net>
Mike Flannigan wrote:
> I got the following code from the examples on
> http://aspn.activestate.com//ASPN/Products/ActivePerl/site/lib/Win32/OLE.html#examples
>
> When I try to run it, it gives me:
> Can't find string terminator "Overload" anywhere before EOF at
> C:/Perl/lib/Win32/OLE.pm line 29.
> Compilation failed in require at excel.pl line 4.
> BEGIN failed--compilation aborted at excel.pl line 4.
>
> I see that OLE.pm has "Overload" on line 59 and line 65 and a few
> other places, but not anywhere near line 29. Any ideas why this is
> not working? I'm very new to modules, but have gotten some to
> work in the past.
>
> use strict;
> use warnings;
>
> use Win32::OLE;
> # use existing instance if Excel is already running
> eval {my $ex =
> Win32::OLE->GetActiveObject('Excel.Application')};
> die "Excel not installed" if $@;
> unless (defined my $ex) {
> $ex = Win32::OLE->new('Excel.Application', sub
> {$_[0]->Quit;})
> or die "Oops, cannot start Excel";
> }
> # get a new workbook
> my $book = my $ex->Workbooks->Add; #<<<<<<LINE 13
> # write to a particular cell
> my $sheet = $book->Worksheets(1);
> $sheet->Cells(1,1)->{Value} = "foo";
> # write a 2 rows by 3 columns range
> $sheet->Range("A8:C9")->{Value} = [[ undef, 'Xyzzy', 'Plugh' ],
> [ 42, 'Perl', 3.1415 ]];
>
> # print "XyzzyPerl"
> my $array = $sheet->Range("A8:C9")->{Value};
> for (@$array) {
> for (@$_) {
> print defined($_) ? "$_|" : "<undef>|";
> }
> print "\n";
> }
> # save and exit
> $book->SaveAs( 'test.xls' );
> undef $book;
> undef $ex;
>
> __END__
>
> Mike Flannigan
Got no responses. Maybe because:
1) Too hard - it hurts my brain
NOT LIKELY
2) This is a Windows thing, and I don't like Windows.
Besides, Win32 Ole often doesn't work as intended.
THIS IS PROBABLY THE CORRECT REASON
3) It's too easy to deal with.
PROBABLY NOT THE CASE.
4) Other
POSSIBLE
------------------------------
Date: Sat, 19 Jul 2003 01:59:56 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re:
Message-Id: <3F18A600.3040306@rochester.rr.com>
Ron wrote:
> Tried this code get a server 500 error.
>
> Anyone know what's wrong with it?
>
> if $DayName eq "Select a Day" or $RouteName eq "Select A Route") {
(---^
> dienice("Please use the back button on your browser to fill out the Day
> & Route fields.");
> }
...
> Ron
...
--
Bob Walton
------------------------------
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 5283
***************************************