[22032] in Perl-Users-Digest
Perl-Users Digest, Issue: 4254 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Dec 12 11:06:10 2002
Date: Thu, 12 Dec 2002 08:05:10 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Thu, 12 Dec 2002 Volume: 10 Number: 4254
Today's topics:
Re: A formating problem (Tad McClellan)
Books for Beginners (James Foster)
Re: Books for Beginners <wsegrave@mindspring.com>
Re: Books for Beginners <GPatnude@adelphia.net>
Re: Books for Beginners (Helgi Briem)
Re: Books for Beginners (Tad McClellan)
Re: CGI page comments <GPatnude@adelphia.net>
Choosing a From: address (Re: Regex that would match em (Tad McClellan)
Compile Perl module in Binary Library <philippe_heitzmann@crediteurop.lu>
configuring CPAN problem <cheechew@hotmail.com>
Re: Downloading images from web pages using perl. (Kawaii)
Re: Help with reg.exp. (Rune)
Re: Help with reg.exp. (Tad McClellan)
just-some-times debugging? <noemail@nowhere.net>
Most Useful Win32 Utility (Phil Hibbs)
Re: Newbie question (Helgi Briem)
Re: Output Lines of 70 Characters <wsegrave@mindspring.com>
Re: Output Lines of 70 Characters <wsegrave@mindspring.com>
Re: Passing an object to another object <dl19@le.academicplace.intheuk>
Portable Open <sunil_franklin@hotmail.com>
Re: repost : Read return value from a sql script using <sunil_franklin@hotmail.com>
Re: Simplify split and s/// statement <garry@ifr.zvolve.net>
Re: Simplify split and s/// statement (Anno Siegel)
Re: Simplify split and s/// statement <mgjv@tradingpost.com.au>
Sorting large hex numbers <tim@deadgoodsolutions.spam-me-and-die.com>
Re: Sorting large hex numbers (Anno Siegel)
Re: Tk module <dave@dave.org.uk>
Re: Tk module (Tad McClellan)
Re: Tk module (Yang xiao)
Re: what perl calls is the challenge <os7man@attbi.com>
Re: what perl calls is the challenge (Helgi Briem)
Re: what perl calls is the challenge (Tad McClellan)
Re: Why doesn't my array grow? (Tad McClellan)
Re: Why doesn't my array grow? <bart.lateur@pandora.be>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 12 Dec 2002 09:25:09 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: A formating problem
Message-Id: <slrnavhail.2tb.tadmc@magna.augustmail.com>
Benjamin Goldberg <goldbb2@earthlink.net> wrote:
> Tad McClellan wrote:
>> Jan Fure wrote:
> [snip]
>> > while (<@data1>) {
>>
>> You're using an awfully strange looking filehandle in the input
>> operator...
>
> No, he's using an awfully strange looking filename-spec to glob().
Doh! I should have recognized that.
> The above is equivilant to:
>
> while( glob("@data1") ) {
>
> This joins the elements of @data1 on $" and passes it to glob(). It
> gets parsed into a filename-specifyer; since none of the elements of
> @data1 contain "{" or "}", this means that it merely gets split on
> whitespace into tokens. Since none of those tokens contains '*' or '?',
> they simply get returned unchanged, regardless of whether or not they
> match anything in the filesystem.
>
> In other words, for his particular data, it's merely an expensive way of
> saying:
>
>> foreach ( @data1 ) {
No, that way doesn't do the "split on whitespace" thing, which is
why making that change fixed the problem.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 12 Dec 2002 05:05:12 -0800
From: idmercury@yahoo.co.uk (James Foster)
Subject: Books for Beginners
Message-Id: <b4d37d82.0212120505.5c14a972@posting.google.com>
Does anyone know of a good book to start learning Perl programming
from. I have previous experience of C++ but I want a good book that
explanins the basics and fundimentals of Perl, right from the
beginning. Any suggestions?
Thank you.
HAND :-)
------------------------------
Date: Thu, 12 Dec 2002 07:16:49 -0600
From: "William Alexander Segraves" <wsegrave@mindspring.com>
Subject: Re: Books for Beginners
Message-Id: <ata2k9$suv$2@slb5.atl.mindspring.net>
"James Foster" <idmercury@yahoo.co.uk> wrote in message
news:b4d37d82.0212120505.5c14a972@posting.google.com...
> Does anyone know of a good book to start learning Perl programming
> from. I have previous experience of C++ but I want a good book that
> explanins the basics and fundimentals of Perl, right from the
> beginning. Any suggestions?
1. Learning Perl (LP, aka Llama Book)
2. Programming Perl (PP, aka Camel Book)
latest editions available from www.ora.com and, possibly, your local
bookstore. Books-A-Million has recently had LP2 and LP3 on its closeout
shelves at less than half price, as well as The Perl CD Bookshelf, v. 2.0,
which includes several Perl titles on CDROM and a hard copy of Perl in a
Nutshell, for less than one fourth of the original price.
Cheers.
Bill Segraves
Bill Segraves
------------------------------
Date: Thu, 12 Dec 2002 15:47:57 GMT
From: "codeWarrior" <GPatnude@adelphia.net>
Subject: Re: Books for Beginners
Message-Id: <Nc2K9.23346$VA5.1887725@news1.news.adelphia.net>
"William Alexander Segraves" <wsegrave@mindspring.com> wrote in message
news:ata2k9$suv$2@slb5.atl.mindspring.net...
> "James Foster" <idmercury@yahoo.co.uk> wrote in message
> news:b4d37d82.0212120505.5c14a972@posting.google.com...
> > Does anyone know of a good book to start learning Perl programming
> > from. I have previous experience of C++ but I want a good book that
> > explanins the basics and fundimentals of Perl, right from the
> > beginning. Any suggestions?
>
> 1. Learning Perl (LP, aka Llama Book)
> 2. Programming Perl (PP, aka Camel Book)
>
> latest editions available from www.ora.com and, possibly, your local
> bookstore. Books-A-Million has recently had LP2 and LP3 on its closeout
> shelves at less than half price, as well as The Perl CD Bookshelf, v. 2.0,
> which includes several Perl titles on CDROM and a hard copy of Perl in a
> Nutshell, for less than one fourth of the original price.
>
> Cheers.
>
> Bill Segraves
>
> Bill Segraves
>
>
Perl In a Nutshell -- O'Reilly ISBN 1-56592-286-7 -- Hardcopy comes with
the Perl CD bookshelf mentioned above....
I use the Perl CD Bookshelf -- It's all HTML so I set up a local web
server -- Basically put a COMPLETE set of on-line documentation on your
PC...
GP
------------------------------
Date: Thu, 12 Dec 2002 15:54:53 GMT
From: helgi@decode.is (Helgi Briem)
Subject: Re: Books for Beginners
Message-Id: <3df8b113.675913883@news.cis.dfn.de>
On Thu, 12 Dec 2002 15:47:57 GMT, "codeWarrior"
<GPatnude@adelphia.net> wrote:
>I use the Perl CD Bookshelf -- It's all HTML so I set up a local web
>server -- Basically put a COMPLETE set of on-line documentation on your
>PC...
Much as I like the Perl CD Bookshelf, I would like to
point out that there is already a complete set of on-line
documentation on your PC that comes with every Perl
installation.
--
Regards, Helgi Briem
helgi AT decode DOT is
A: Top posting
Q: What is the most irritating thing on Usenet?
- "Gordon" on apihna
------------------------------
Date: Thu, 12 Dec 2002 09:57:53 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Books for Beginners
Message-Id: <slrnavhcg1.2tb.tadmc@magna.augustmail.com>
James Foster <idmercury@yahoo.co.uk> wrote:
> Does anyone know of a good book to start learning Perl programming
> from. I have previous experience of C++ but I want a good book that
> explanins the basics and fundimentals of Perl, right from the
> beginning. Any suggestions?
"Learning Perl", 3rd edition.
Order it by clicking on the link at:
http://www.stonehenge.com/books/
and you'll get a 30% discount, and Randal will get a kickback too.
Disclaimer: I work for Randal, but I recommended his book
even before joining Stonehenge.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Thu, 12 Dec 2002 16:03:46 GMT
From: "codeWarrior" <GPatnude@adelphia.net>
Subject: Re: CGI page comments
Message-Id: <Cr2K9.23353$VA5.1891855@news1.news.adelphia.net>
"stephen" <terraxFILTER@rogers.com> wrote in message
news:at8ntq$11r3lm$1@ID-96300.news.dfncis.de...
> Without SSI, modperl, or frames, is there a good way to add a comments
board
> to the bottom of a webpage?
>
> Basically I have a website (ridecanada.com) that provides profiles of
winter
> resorts. At the bottom of the resort profile pages I would like visitors
to
> be able to add comments about the resort.
>
> The only thing I've been able to think of is to have a script that takes
an
> html filename as a parameter then writes an output html file by copying
the
> passed file then appending the comment board. I'm not entirely happy with
> this solution.
>
> Any ideas?
>
> Thanks,
> Stephen
>
>
You might look into using a Wiki script for your message board...
------------------------------
Date: Thu, 12 Dec 2002 07:57:42 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Choosing a From: address (Re: Regex that would match email address format)
Message-Id: <slrnavh5em.2ke.tadmc@magna.augustmail.com>
Brian Wakem <no@email.com> wrote:
You might consider choosing a less common faux address, it took
me a while to figure out why your article was scored so low. :-)
Message-ID: <KgCj6.437223$U46.12848308@news1.sttls1.wa.home.com>
From: "Frank Miller" <no@email.com>
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Thu, 12 Dec 2002 15:28:51 +0100
From: "Philippe Heitzmann" <philippe_heitzmann@crediteurop.lu>
Subject: Compile Perl module in Binary Library
Message-Id: <3df89d23_2@news.vo.lu>
HI,
How can I compile my perl module in Binary library, and to use it after
in perl script.
Thanks
------------------------------
Date: Thu, 12 Dec 2002 20:57:38 +0800
From: "cheechew" <cheechew@hotmail.com>
Subject: configuring CPAN problem
Message-Id: <ata0jq$csg$1@mawar.singnet.com.sg>
When I try to configure CPAN, it give me this error message.
Can't locate object method "new" via package "Net::FTP::I" at
/usr/lib/perl5/5.6.0/i386-linux/IO/Socket.pm line 162, <STDIN> line 24.
What do you think the most likey problem?
------------------------------
Date: 12 Dec 2002 06:13:10 -0800
From: kawaii@networkduels.com (Kawaii)
Subject: Re: Downloading images from web pages using perl.
Message-Id: <186949a0.0212120613.248aa7bc@posting.google.com>
kawaii@networkduels.com (Kawaii) wrote in message news:<186949a0.0212111440.4df7ed8a@posting.google.com>...
> Hello everyone.
> I am trying to get or request Images from web pages and often I find
> the program
> putting html source code into a .jpg or .gif file. (with the name of
> the image)
>
> I have tried,
>
> use LWP::Simple;
> $image = get ("ftp://images.cosplay.com/data/566/1dsc02111.jpg");
> open (FILEHANDLE, ">image.jpg");
> binmode FILEHANDLE; ## With or without this, does nothing to help.
> print FILEHANDLE $image;
> close (FILEHANDLE);
>
> (this is on a unix machine, solaris)
>
>
> I've tried the mirror option within lwp, which returns a 0 byte file.
> I've tried the Request option, which is basicly another get done by
> another module.
> If you simply paste the URL listed above, You get the image all by
> itself.
> (The image is an example, but not a bad image just the same.)
>
> Can anyone, in a few lines of perl code, get the above image to
> actually download and save into the specified file. Alot of the images
> I am trying to aqcuire are in php or ez board's, but again, I simply
> need to insert the above url into a browser and voila. Just the raw
> image.
>
> Any help would be great.
> (Please do not suggest wget)
ACK!!!
I am sorry folks, the code pasted to the screen was a last attempt
that was not intended to work.
the ftp:// should of been http:// such as the following...
> use LWP::Simple;
> $image = get ("http://images.cosplay.com/data/566/1dsc02111.jpg");
> open (FILEHANDLE, ">image.jpg");
> binmode FILEHANDLE; ## With or without this, does nothing to help.
> print FILEHANDLE $image;
> close (FILEHANDLE);
>
I am simply trying to grab the image via html/http/url...
------------------------------
Date: 12 Dec 2002 04:44:07 -0800
From: hoplah@hotmail.com (Rune)
Subject: Re: Help with reg.exp.
Message-Id: <6b0f1981.0212120444.708f40fa@posting.google.com>
Help again,
My script just evolved. Now I need to support an extend string that
looks like this:
C[CCNNNNNNNNNNN]
C= Char
N= Number
The former solution looked like this:
@list = $line =~ m{ ( [A-Z]{2}\d{11} ) }gx;
How can I support the special characters in the string? I tried like
this, but it didn't return anything:
@list = $line =~ m{ ( [A-Z]{1}\[[A-Z]{2}\]\d{11} ) }gx;
Could someone please help and explain me how to do it correctly?
Thanks,
Rune
gilgames@aol.coma (Gilgames) wrote in message news:<20021125083248.11546.00000071@mb-fg.aol.com>...
> <<
>
> My problem is now that there can be multible instances of the
> substring within the string, but my code only gets the first instance.
> Does anyone know how to extend the code to grep all the instances of
> the substring into an array so that $number would be @number
> containing one instance per element?
> >>
>
> put the g parameter to the end, and run it in a loop which builds up an array.
------------------------------
Date: Thu, 12 Dec 2002 08:14:31 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Help with reg.exp.
Message-Id: <slrnavh6e7.2ke.tadmc@magna.augustmail.com>
Rune <hoplah@hotmail.com> wrote:
> Now I need to support an extend string that
> looks like this:
>
> C[CCNNNNNNNNNNN]
>
> C= Char
> N= Number
> How can I support the special characters in the string? I tried like
> this, but it didn't return anything:
>
> @list = $line =~ m{ ( [A-Z]{1}\[[A-Z]{2}\]\d{11} ) }gx;
>
> Could someone please help and explain me how to do it correctly?
Your pattern requires the digits _following_ the ]
m{ ( [A-Z]\[[A-Z]{2}\d{11}\] ) }gx;
[snip upside-down quoted text, please don't do that]
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 12 Dec 2002 13:29:55 GMT
From: nobody <noemail@nowhere.net>
Subject: just-some-times debugging?
Message-Id: <Xns92E25713646C6abccbaabc@129.250.170.82>
I have Perl scripts running Perl scripts running more Perl scripts.
Say, A runs B which runs C.
I'd like to use environment vars (PERL5OPT etc.) so that when B is
run, it's started in the debugger (ptkdb). But I don't want A and C to
run in the debugger.
I don't want to change source for any of the programs. They're
embedded in bash scripts, so that includes changing the initial perl
command used to start A.
Any ideas? Maybe some sort of tiny custom "debugger", which could
check the program name, and either invoke the real debugger or
just run the script? Or maybe it would be better to redefine the
perl command, to first do some checking then run perl with the
correct params.
Is any of this available off the shelf?
Thanks for your help.
------------------------------
Date: 12 Dec 2002 04:41:01 -0800
From: gg@snark.freeserve.co.uk (Phil Hibbs)
Subject: Most Useful Win32 Utility
Message-Id: <a9ec249e.0212120441.738d5769@posting.google.com>
I present an idea for anyone that uses Win32.
One of Perl's most useful features, in my experience, is it's ability
to read from and write to the Win32 clipboard. A selection of small
scripts, with keyboard shortcuts in the Start menu, have proven
invaluable to me. For example, the following .CMD file will convert
the clipboard to plain text:
@rem = '--*-Perl-*--
@echo off
perl -x "%~dpnx0" %*
goto endofperl
@rem ';
#!perl
#line 8
use strict;
use warnings;
use Win32::Clipboard;
my $CLIP = Win32::Clipboard();
if ($CLIP->IsFiles()) {
$CLIP->Set($CLIP->GetFiles);
} else {
$CLIP->Set($CLIP->GetText);
}
__END__
:endofperl
Copying text from one Word document to another can be really messy -
the clipboard carries with it all of the style, paragraph, character
and table attributes with it. Copying a column from a table and
converting it to paragraph text can be done with the "Convert => Table
to text" menu option, but if you're doing it many times, it gets
really annoying. With this script bound to a keypress, all you haev to
do is copy, hit the key (I use Ctrl-Shift-Equals), and paste.
Comparing files? The Compare Documents dialog pops up, and you have to
navigate your way around the directory structure to find the file.
With this Perl script, you can have an Explorer window already open,
just select the file and Copy it, then hit the key, and Paste into the
File dialog.
Many other text manipulation techniques can be made easier to use with
this system - rather than getting the text from <STDIN>, get it from
and write it back to the clipboard. Useful for telnet, 3270, or other
terminal emulator, or just for transforming text that you have in a
file. Select, copy, transform, paste.
I use %~dpnx because this is more reliable in WinNT and Win2K, but for
Win9X you will need to adjust the perl invocation to something like
this:
perl -x -S "%0" %1 %2 %3 %4 %5 %6 %7 %8 %9
and your .BAT file will have to be the first match in the PATH.
Phil Hibbs.
------------------------------
Date: Thu, 12 Dec 2002 11:25:03 GMT
From: helgi@decode.is (Helgi Briem)
Subject: Re: Newbie question
Message-Id: <3df871a1.659670506@news.cis.dfn.de>
On Wed, 11 Dec 2002 14:04:23 GMT, "TBN" <ihave@noemail.com>
wrote:
>"Jay Tilton" <tiltonj@erols.com> wrote in message
>news:3df6ceca.27824714@news.erols.com...
>> "TBN" <ihave@noemail.com> wrote:
>>
>> : Subject: Newbie question
>>
>> You cannot be so new that you do not recognize the value of a
>> good subject line, and that the one you chose there is worthless.
>>
>I'll try to do better, but I did get a good answer so it couldn't have been
>completely worthless.
No, but it will be worthless to any future newbie who
searches google for help on the same subject.
It is however, very useful, to the myriad of usenet users
who filter newsgroup articles by subject and therefore
never read yours.
--
Regards, Helgi Briem
helgi AT decode DOT is
A: Top posting
Q: What is the most irritating thing on Usenet?
- "Gordon" on apihna
------------------------------
Date: Thu, 12 Dec 2002 05:15:55 -0600
From: "William Alexander Segraves" <wsegrave@mindspring.com>
Subject: Re: Output Lines of 70 Characters
Message-Id: <at9r8m$ua5$1@slb0.atl.mindspring.net>
"Jürgen Exner" <jurgenex@hotmail.com> wrote in message
news:AxUJ9.2202$m8.331@nwrddc01.gnilink.net...
> William Alexander Segraves wrote:
> > I don't know, off hand; but I'm certainly willing to learn something
> > new. I just didn't know how to write simultaneously to a file and
> > STDOUT.
>
> Please see the FAQ "How do I print to more than one file at once?"
> (STDIN is just another file handle)
Well, then. I'm glad I didn't *ask*, or it would have been in violation of
the posting guidelines. ;-)
Thanks, Jue.
Cheers.
Bill Segraves
------------------------------
Date: Thu, 12 Dec 2002 06:43:39 -0600
From: "William Alexander Segraves" <wsegrave@mindspring.com>
Subject: Re: Output Lines of 70 Characters
Message-Id: <ata2k7$suv$1@slb5.atl.mindspring.net>
"Tad McClellan" <tadmc@augustmail.com> wrote in message
news:slrnavfer8.2do.tadmc@magna.augustmail.com...
> William Alexander Segraves <wsegrave@mindspring.com> wrote:
>
> > You should be able to do this with built-in formatting ( format)
> > capabilities of Perl
<snip>
> Is there a problem with using
>
> write;
> or
> write STDOUT;
>
> ??
Thanks for the nudge, Tad. I hope the OP sees this as a much shorter way.
I'm not certain this shortened version would be easier for the OP to
understand; but thanks to *your* hint, I was able to reduce my example to
the following:
#!perl -w
# usage - perl textcvt_to_70char_v8.pl < text_in.txt > text_out.txt
use strict;
while(<>){write}
format =
^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
$_
^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<~~
$_
.
Note that I've moved ~~ to the end of the second picture line to eliminate
the earlier problem with spaces at the beginnings of the picture lines.
Cheers.
Bill Segraves
------------------------------
Date: Thu, 12 Dec 2002 14:49:28 +0000
From: Dela Lovecraft <dl19@le.academicplace.intheuk>
Subject: Re: Passing an object to another object
Message-Id: <ata7l3$okt9$1@rook.le.ac.uk>
Malte,
> That's right. Maybe tempObject is a bad name, but if it fits your mind
> thats ok.
That's all it is in this instance....
>> $self->{OBJECT} = $tempObject;
>> $self->{WHO} = $tempObject->{NAME}; #Or use a function:
>
>
> You should use a method. _NEVER_ access the underlying structure of a
> foreign object directly. Whether, you should ever access your own
> structure outside of accessor methods is a different matter.
I usually do, but I threw this in to illustrate what it was I am trying
to do. In the actual example of code I am using, I do use a construct
such as the one I gave:
>> # $self->{WHO} = $tempObject->getName();
> We don't know tempObject's type. Perl is not Java/C#/strictly typed. You
> have to tell us. Does getName() exist and does it return a defined value?
getName certainly would exist in this example (otherwise I wouldn't use
it!). In the example I have given, we know what is passed to an instance
of Object2 (an instance of Object1), so I think it would be fair to
assume that tempObject is an instance of Object1. You may think
differently.... I don't need to worry about other users in this case - I
am the only one who will be using this.
Dela
------------------------------
Date: Thu, 12 Dec 2002 21:14:40 +0530
From: "Sunil" <sunil_franklin@hotmail.com>
Subject: Portable Open
Message-Id: <Sc2K9.3$cw5.99@news.oracle.com>
All,
http://www.perldoc.com/perl5.6.1/pod/perlipc.html
says :-
"The open2() and open3() functions are unlikely to work anywhere except on a
Unix system or some other one purporting to be POSIX compliant."
http://www.perldoc.com/perl5.6.1/pod/perlport.html
says :-
"don't directly access the system in code meant to be portable. That means,
no system, exec, fork, pipe, ``, qx//, open with a |"
Later in the same doc under " functions that are either completely
unimplemented or else have been implemented differently on various
platforms"
says :-
open FILEHANDLE,EXPR
open FILEHANDLE
The | variants are supported only if ToolServer is installed. (Mac OS)
open to |- and -| are unsupported. (Mac OS, Win32, RISC OS)
Opening a process does not automatically flush output handles on some
platforms. (SunOS, Solaris, HP-UX)
-------------
perlport.html does not mention open2 and open3 as having any problems, it
lists only open with a pipe. perlipc.html says that open2 and open3 are not
portable.
Is my understanding correct. (I dont know what a POSIX compliant OS is)
So, which open do I use when I want to write portable code?
Thanks,
Sunil.
------------------------------
Date: Thu, 12 Dec 2002 21:15:31 +0530
From: "Sunil" <sunil_franklin@hotmail.com>
Subject: Re: repost : Read return value from a sql script using piped open
Message-Id: <hd2K9.4$cw5.94@news.oracle.com>
> > close SQLP or die "cannot close in doScript";
> >
> > print "Status is :" . ($? >> 8);
>
> As you have observed, the above will always either die or print
> "Status is :0".
>
> > Your suggestions please.
>
> I suggest you read: perldoc -f close
>
> Pay particular attension to what is said about the return value of the
> close() function the paragraph that starts "If the file handle came
> from a piped open..."
>
Thanks !
That solved my problem.
------------------------------
Date: Thu, 12 Dec 2002 11:32:11 -0000
From: Garry Williams <garry@ifr.zvolve.net>
Subject: Re: Simplify split and s/// statement
Message-Id: <slrnavgstq.fh.garry@zfw.zvolve.net>
On Thu, 12 Dec 2002 04:23:57 GMT, Martien Verbruggen
<mgjv@tradingpost.com.au> wrote:
> On Wed, 11 Dec 2002 17:33:04 -0500,
> Alexander Stremitzer <stremitz@consultant.com> wrote:
>> I am using the following code segment in my program. The code does what
>> it is supposed to do. However, it looks somewhat cludgy.
>> Is there a way to simplify the statement below ? The goal is to remove
>> the trailing white space from all fields.
>>
>> my ($pat_name,$pat_id,$birth_date,$accnbr,$study_date) = split (/\|/,
>> $PDS_LINE);
>
> Just to add another possibility:
>
> my ($pat_name,$pat_id,$birth_date,$accnbr,$study_date) =
> map { s/\s+$// } split (/\|/, $PDS_LINE);
>
> I like map for the readability of the code.
Maybe it contributes readability, but it doesn't do what you intend.
:-)
--
Garry Williams
------------------------------
Date: 12 Dec 2002 11:48:00 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Simplify split and s/// statement
Message-Id: <at9t1g$398$1@mamenchi.zrz.TU-Berlin.DE>
According to Garry Williams <garry@zvolve.com>:
> On Thu, 12 Dec 2002 04:23:57 GMT, Martien Verbruggen
> <mgjv@tradingpost.com.au> wrote:
> > On Wed, 11 Dec 2002 17:33:04 -0500,
> > Alexander Stremitzer <stremitz@consultant.com> wrote:
> >> I am using the following code segment in my program. The code does what
> >> it is supposed to do. However, it looks somewhat cludgy.
> >> Is there a way to simplify the statement below ? The goal is to remove
> >> the trailing white space from all fields.
> >>
> >> my ($pat_name,$pat_id,$birth_date,$accnbr,$study_date) = split (/\|/,
> >> $PDS_LINE);
> >
> > Just to add another possibility:
> >
> > my ($pat_name,$pat_id,$birth_date,$accnbr,$study_date) =
> > map { s/\s+$// } split (/\|/, $PDS_LINE);
> >
> > I like map for the readability of the code.
>
> Maybe it contributes readability, but it doesn't do what you intend.
> :-)
It is easily fixed (as you know), using "map { s/\s+$/; $_} ...", but
the correction takes away some of the gained readability.
Anno
------------------------------
Date: Thu, 12 Dec 2002 23:40:41 +1100
From: Martien Verbruggen <mgjv@tradingpost.com.au>
Subject: Re: Simplify split and s/// statement
Message-Id: <slrnavh0u9.aid.mgjv@martien.heliotrope.home>
On Thu, 12 Dec 2002 11:32:11 -0000,
Garry Williams <garry@ifr.zvolve.net> wrote:
> On Thu, 12 Dec 2002 04:23:57 GMT, Martien Verbruggen
><mgjv@tradingpost.com.au> wrote:
>> On Wed, 11 Dec 2002 17:33:04 -0500,
>> Alexander Stremitzer <stremitz@consultant.com> wrote:
>>> I am using the following code segment in my program. The code does what
>>> it is supposed to do. However, it looks somewhat cludgy.
>>> Is there a way to simplify the statement below ? The goal is to remove
>>> the trailing white space from all fields.
>>>
>>> my ($pat_name,$pat_id,$birth_date,$accnbr,$study_date) = split (/\|/,
>>> $PDS_LINE);
>>
>> Just to add another possibility:
>>
>> my ($pat_name,$pat_id,$birth_date,$accnbr,$study_date) =
>> map { s/\s+$// } split (/\|/, $PDS_LINE);
>>
>> I like map for the readability of the code.
>
> Maybe it contributes readability, but it doesn't do what you intend.
>:-)
Oops.
my ($pat_name,$pat_id,$birth_date,$accnbr,$study_date) =
map { s/\s+$//; $_ } split (/\|/, $PDS_LINE);
Martien
--
|
Martien Verbruggen |
| In a world without fences, who needs Gates?
|
------------------------------
Date: Thu, 12 Dec 2002 11:39:37 -0000
From: "tim" <tim@deadgoodsolutions.spam-me-and-die.com>
Subject: Sorting large hex numbers
Message-Id: <1039693319.78162.0@doris.uk.clara.net>
Is there a module or method of handling large hex numbers? I want to sort
them into largest first order, it works fine for number of 8 characters or
below, but anything above I get error messages:
Hexadecimal number > 0xffffffff non-portable at test.pl line 3.
Integer overflow in hexadecimal number at test 3.
#!/usr/bin/perl -w
@array=("3E1D302EDFDFDFDF", "3E1D", "4E1D302ECCCC6666",
"4E1D302ECCCC6667","4E1D302DCCCC6666", "3E");
my @array= sort { hex($b) <=> hex($a) } @array;
foreach (@array) {
print "$_\n";
}
p.s. I sent this to the wrong groups first, so apollogies for multi-posting!
------------------------------
Date: 12 Dec 2002 11:52:50 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Sorting large hex numbers
Message-Id: <at9tai$398$2@mamenchi.zrz.TU-Berlin.DE>
According to tim <tim@deadgoodsolutions.spam-me-and-die.com>:
> Is there a module or method of handling large hex numbers? I want to sort
> them into largest first order, it works fine for number of 8 characters or
> below, but anything above I get error messages:
> Hexadecimal number > 0xffffffff non-portable at test.pl line 3.
> Integer overflow in hexadecimal number at test 3.
>
> #!/usr/bin/perl -w
> @array=("3E1D302EDFDFDFDF", "3E1D", "4E1D302ECCCC6666",
> "4E1D302ECCCC6667","4E1D302DCCCC6666", "3E");
> my @array= sort { hex($b) <=> hex($a) } @array;
> foreach (@array) {
> print "$_\n";
> }
>
> p.s. I sent this to the wrong groups first, so apollogies for multi-posting!
Math::BigInt is one solution. Math::Bigint->new( '0xffff...') doesn't
have any limitations.
Anno
------------------------------
Date: Thu, 12 Dec 2002 11:56:53 +0000
From: "Dave Cross" <dave@dave.org.uk>
Subject: Re: Tk module
Message-Id: <pan.2002.12.12.11.56.53.210928@dave.org.uk>
On Thu, 12 Dec 2002 06:47:10 +0000, Lois wrote:
> Hi all,
>
> Please advise which file to download in order to use the Tk module. I
> went to CPAN and found at least a dozens of related files.
<http://search.cpan.org/dist/Tk/>
Dave...
--
.sig missing...
------------------------------
Date: Thu, 12 Dec 2002 08:02:57 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Tk module
Message-Id: <slrnavh5oh.2ke.tadmc@magna.augustmail.com>
Dave Cross <dave@dave.org.uk> wrote:
> On Thu, 12 Dec 2002 06:47:10 +0000, Lois wrote:
>> Please advise which file to download in order to use the Tk module. I
>> went to CPAN and found at least a dozens of related files.
>
><http://search.cpan.org/dist/Tk/>
Tk has its own newsgroup too: comp.lang.perl.tk.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 12 Dec 2002 06:36:31 -0800
From: yang2002_99@yahoo.com (Yang xiao)
Subject: Re: Tk module
Message-Id: <55c6e631.0212120636.740f9e28@posting.google.com>
"Lois" <lois@hotmail.com> wrote in message news:<OhWJ9.119088$pN3.8766@sccrnsc03>...
> Hi all,
>
> Please advise which file to download in order to use the Tk module. I
> went to CPAN and found at least a dozens of related files.
>
>
> Thanks,
> lois
perl -MCPAN -e shell
CPAN>install Tk
Yang
------------------------------
Date: Thu, 12 Dec 2002 13:59:51 GMT
From: Eric Osman <os7man@attbi.com>
Subject: Re: what perl calls is the challenge
Message-Id: <3DF8969E.5B2C018E@attbi.com>
In my case, although I'm doing my perl learning
on windows 98, in the ACTUAL situations, I'll be
coding for whatever web server the person I'm helping is
actually on.
So, I assume (correct me if I'm wrong), that the
web server will sometimes be unix, sometimes be
windows, and occasionally be other things ?
Toward this end, I have the following
questions:
o Is it easy to tell indigoperl to use
a cygwin window instead of a dos window ?
I'm pretty sure that with the appropriate
cygwin installation, things like unix "sendmail"
are available.
o In the general case, when coding for various
web servers, how do I find out what tidbits
(like "sendmail") exist on that server, and
what kind of server it is.
o Speaking of doing email from perl, which of
these do you think are useful, which are
bad, and do you have others to suggest:
- sendmail
- blat
- Sender.pm
Also, which ones tend to be available on
both unix and windows servers ?
As for all those book edits, please send them to the
author or the publisher. They are very useful.
/Eric
------------------------------
Date: Thu, 12 Dec 2002 14:34:37 GMT
From: helgi@decode.is (Helgi Briem)
Subject: Re: what perl calls is the challenge
Message-Id: <3df89cb3.670697332@news.cis.dfn.de>
On Thu, 12 Dec 2002 13:59:51 GMT, Eric Osman
<os7man@attbi.com> wrote:
>In my case, although I'm doing my perl learning
>on windows 98, in the ACTUAL situations, I'll be
>coding for whatever web server the person I'm helping is
>actually on.
Probably applies to most people, at least those who
code for web servers.
>So, I assume (correct me if I'm wrong), that the
>web server will sometimes be unix, sometimes be
>windows, and occasionally be other things ?
Hmm. Generally, what people call "web servers"
are pieces of software. The most common by far
is apache, which can run under PC, mac, Unix or
whatever. Another common one is IIS, which only
runs on Windows machines.
>Toward this end, I have the following
>questions:
>
>o Is it easy to tell indigoperl to use
> a cygwin window instead of a dos window ?
> I'm pretty sure that with the appropriate
> cygwin installation, things like unix "sendmail"
> are available.
A window?? Perl doesn't use "windows". You
can tell it to use whatever application you like
as long as you give it the correct path.
Instead of using sendmail, why don't you use
one of the myriad of perl modules that allowes
you to send e-mail without using an external
application.
>o In the general case, when coding for various
> web servers, how do I find out what tidbits
> (like "sendmail") exist on that server, and
> what kind of server it is.
my $sendmail = '/usr/bin/sendmail';
if (not -x $sendmail) { #do something else }
>o Speaking of doing email from perl, which of
> these do you think are useful, which are
> bad, and do you have others to suggest:
No idea. I use MIME::Lite;
--
Regards, Helgi Briem
helgi AT decode DOT is
A: Top posting
Q: What is the most irritating thing on Usenet?
- "Gordon" on apihna
------------------------------
Date: Thu, 12 Dec 2002 09:48:15 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: what perl calls is the challenge
Message-Id: <slrnavhbtv.2tb.tadmc@magna.augustmail.com>
Eric Osman <os7man@attbi.com> wrote:
[ you should quote a little bit of context when referring to
something that was said earlier.
]
> In my case, although I'm doing my perl learning
> on windows 98, in the ACTUAL situations, I'll be
> coding for whatever web server the person I'm helping is
> actually on.
>
> So, I assume (correct me if I'm wrong), that the
> web server will sometimes be unix, sometimes be
> windows, and occasionally be other things ?
You are wrong.
A web server is not an operating system, so it cannot "be unix".
The web server will sometimes be running under (or "on") unix,
sometimes under windows, or Macs, or VMS, or ...
> Toward this end, I have the following
> questions:
>
> o Is it easy to tell indigoperl to use
> a cygwin window instead of a dos window ?
I dunno. I don't do Windows.
> I'm pretty sure that with the appropriate
> cygwin installation, things like unix "sendmail"
> are available.
Another, perhaps better, alternative is to install Linux
or FreeBSD with dual boot.
> o In the general case, when coding for various
> web servers, how do I find out what tidbits
> (like "sendmail") exist on that server, and
> what kind of server it is.
You should do your dead level best to code without system
dependencies, then your question will become moot. :-)
Do things in "native Perl" whenever possible.
> o Speaking of doing email from perl
Use a module rather than an external program.
> As for all those book edits, please send them to the
> author or the publisher.
I am a Consulting Editor for a competing publisher (Manning),
so I don't want to help them (for free). :-)
> They are very useful.
I am available for hire to do book reviews, or for individual
help similar to what I give away for free here.
Sybex could hire me, if it doesn't violate my NDA. :-)
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Thu, 12 Dec 2002 08:08:57 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Why doesn't my array grow?
Message-Id: <slrnavh63p.2ke.tadmc@magna.augustmail.com>
Bob Stutes <bstutes@eskimo.com> wrote:
> Uri Guttman wrote:
>>>>>>>"BS" == Bob Stutes <bstutes@eskimo.com> writes:
> [ .. snip ..]
>
> Dude .. you get yer jollies stepping on people?
Dude .. you get yer jollies leading people on wild goose chases?
If you post broken code here, it is likely to be corrected.
If you don't like being corrected, then the best approach is
to not post broken code.
*plonk*
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Thu, 12 Dec 2002 15:26:19 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: Why doesn't my array grow?
Message-Id: <4cahvugul3bknmqkf7sjqn1h75aa7c54kb@4ax.com>
Rob Richardson wrote:
>No thanks to Tad. I put "use strict" and "use warnings" in. I ran my
>program through my local Apache server. Internet Explorer locked up.
>I ran it from an MS-DOS command prompt, and I got a couple hundred
>errors saying "Global symbol "$logname" requires explicit
>package name at index.cgi line 21.". I got nothing talking about an
>invalid use of "currentIndex".
The threshold for using "use strict" is that now you *have* to declare
all variables, or use fully qualified names. That is precisely what
these couple of hundred complaints are about. You need to fix them
first. Once you're shtough all that, what will be left is a compalint
about the bareword "currentIndex".
You can bypass the above requirement by allowing undeclared variables:
use strict;
no strict 'vars';
Now you'll only see non variable name related complaints.
--
Bart.
------------------------------
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 4254
***************************************