[18981] in Perl-Users-Digest
Perl-Users Digest, Issue: 1176 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Jun 22 11:05:45 2001
Date: Fri, 22 Jun 2001 08:05:15 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <993222314-v10-i1176@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Fri, 22 Jun 2001 Volume: 10 Number: 1176
Today's topics:
Re: [PAM] validating users using PAM <jason@uklinux.net>
Re: [PAM] validating users using PAM <tschmelter@statesman.com>
Re: [PAM] validating users using PAM <jason@uklinux.net>
Re: BCD Binary Coded Decimal Problem!! (Anno Siegel)
File Positon <blnukem@hotmail.com>
Re: File Positon nobull@mail.com
Re: hash os hashes sorting <woltz@sewp.nasa.gov>
How do I use module if I don't have the permission to i (chih-chieh, Huang)
Re: How do I use module if I don't have the permission <djberge@uswest.com>
HOW-TO: Extract text from this output? <david.mohorn@home.com>
Re: http://stein.cshl.org/WWW/software/CGI/#dos <tschmelter@statesman.com>
Re: http://stein.cshl.org/WWW/software/CGI/#dos <cpryce@pryce.net>
Re: Install Perl on HP (Ralph)
Re: Install Perl on HP <pne-news-20010622@newton.digitalspace.net>
Re: Install Perl on HP <h.m.brand@hccnet.nl>
Re: Install Perl on HP <h.m.brand@hccnet.nl>
Interfacing Perl v5 with Vantive Dbase application <EKAdmin@Kodak.com>
Re: Is There Any Other Routine Like CHOP(); (Lars)
libwww in Standard Distro? (was: Re: Grabbing a web pag <tschmelter@statesman.com>
Module for reading a binary PGM file <andrew@mvt.ie>
one liner ... simple question <hafner-usenet@ze.tu-muenchen.de>
Re: Opening a Netscape Window using a Perl script <bart.lateur@skynet.be>
Re: Pattern matching with variables (Loki)
Re: Perl description <mjcarman@home.com>
Re: Perl to Oracle connectivity <kevin@vaildc.net>
Re: Perl to Oracle connectivity <brian@jankoNOnet.SPAMcom.INVALID>
Re: Perl Tutorials or E-Books <bart.lateur@skynet.be>
Re: Perl Tutorials or E-Books <peb@bms.umist.ac.uk>
Re: Reference-problem <pne-news-20010622@newton.digitalspace.net>
regular expression problem (Xtreme)
Re: regular expression problem (Peter J. Acklam)
Re: regular expression problem <laszlo.gerencser@portologic.com>
Re: Searchin for .sh (Helgi Briem)
Re: splice/Join and split!! <mjcarman@home.com>
Uninitialized Value from a Hash? <vprasad@americasm01.nt.com>
Re: Uninitialized Value from a Hash? <tschmelter@statesman.com>
Re: Which C compiler to use for modules? <bart.lateur@skynet.be>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 22 Jun 2001 12:11:03 +0100
From: Jason Clifford <jason@uklinux.net>
Subject: Re: [PAM] validating users using PAM
Message-Id: <Pine.LNX.4.30.0106221210190.17173-100000@s1.uklinux.net>
On Fri, 22 Jun 2001, Robin Aly wrote:
> how can I validate user/password pairs with PAM (linux). Do I need a module?
> Any Help?
Authen::PAM
I have not used it myself as the only scripts I need to authenticate
against the system for a CGI so I use mod_auth_pam for them.
Jason Clifford
------------------------------
Date: Fri, 22 Jun 2001 13:29:29 GMT
From: Tim Schmelter <tschmelter@statesman.com>
Subject: Re: [PAM] validating users using PAM
Message-Id: <3B334869.85D86B98@statesman.com>
Jason Clifford wrote:
> On Fri, 22 Jun 2001, Robin Aly wrote:
>
> > how can I validate user/password pairs with PAM (linux). Do I need a module?
> > Any Help?
>
> Authen::PAM
>
> I have not used it myself as the only scripts I need to authenticate
> against the system for a CGI so I use mod_auth_pam for them.
>
> Jason Clifford
I briefly tried to work with Authen::PAM on Linux, but I had trouble getting it to
recognize the userID I was trying to authenticate. Instead, it would only attempt
to authenticate the real user ID (e.g., the login ID, as opposed to the ID I was
"su"-ed to)!
I never had much opportunity to troubleshoot my situation, but I'd love to hear
from others who may have been able to solve similar problems.
--
Tim Schmelter
Public Key available from http://www.keyserver.net
CAD7 2ABB 05A4 2F00 4CAE 7D2F 127C 129A 7173 2951
------------------------------
Date: Fri, 22 Jun 2001 14:32:49 +0100
From: Jason Clifford <jason@uklinux.net>
Subject: Re: [PAM] validating users using PAM
Message-Id: <Pine.LNX.4.30.0106221432160.7098-100000@s1.uklinux.net>
On Fri, 22 Jun 2001, Tim Schmelter wrote:
> I briefly tried to work with Authen::PAM on Linux, but I had trouble getting it to
> recognize the userID I was trying to authenticate. Instead, it would only attempt
> to authenticate the real user ID (e.g., the login ID, as opposed to the ID I was
> "su"-ed to)!
There is something in the documentation about this. Cannot remember what
it is but the issue is specifically addressed.
Jason
------------------------------
Date: 22 Jun 2001 10:13:13 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: BCD Binary Coded Decimal Problem!!
Message-Id: <9gv5np$d68$2@mamenchi.zrz.TU-Berlin.DE>
According to Harry Yau <harry.yau@regaltronic.com>:
> Hi Folk:
> I am working on a project to calculate the average cost of
> products which is made of a lot of small parts. In order to find out
> the cost of a product, I have to find out the cost of all its parts.
> However, I am facing some problem with the the decimal
> pleace. The range of the parts values is about $0.00001 - $3.00. When
> I multiple these price with the quantity something
> around 0.001 -10, the result returned by the script will be
> inaccurated. Let say, I doing something like:
> $0.05126 * 2 = $0.10252
> supposingly, but the result will become something like
> 0.102519999999997986.
Yes, that's the reason behind the inaccuracies you get.
[snip]
For a straightforward solution, calculate your prices in some
unit ($0.00001?) so that all your numbers are integers. Rescale
and round them to two decimal places only for output.
There is also a module for financial calculations that presumably
addresses this problem. A CPAN search for 'financial' should
bring it up.
Anno
------------------------------
Date: Fri, 22 Jun 2001 10:31:30 GMT
From: "Blnukem" <blnukem@hotmail.com>
Subject: File Positon
Message-Id: <68FY6.43268$Lk1.4105440@news02.optonline.net>
Hi All
How do I always keep a value in a flat file that is always changing such as
a name at specific line number, Say at the end of the file or in the third
line?
------------------------------
Date: 22 Jun 2001 12:12:15 +0100
From: nobull@mail.com
Subject: Re: File Positon
Message-Id: <u9u2186a5s.fsf@wcl-l.bham.ac.uk>
"Blnukem" <blnukem@hotmail.com> writes:
> How do I always keep a value in a flat file that is always changing such as
> a name at specific line number, Say at the end of the file or in the third
> line?
I strongly suspect that you are asking FAQ: "How do I change one line
in a file/delete a line in a file/insert a line in the middle of a
file/append to the beginning of a file?"
You should _always_ check the FAQ before posting a question to a newsgroup.
If when you do this you find that you have a question that is
superficially similar to (but not the same as) a FAQ then it is
important to differentate your question from the FAQ it resembles when
you post.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Fri, 22 Jun 2001 10:24:35 -0400
From: woltz <woltz@sewp.nasa.gov>
To: Stefan Weiss <der.prinz@gmx.net>
Subject: Re: hash os hashes sorting
Message-Id: <3B335523.C897D109@sewp.nasa.gov>
Stefan,
Your reply to my problem is a most wonderful gift.
My eyes were opened and the sun now shines trough the dark clouds.
I was beginning to think there was no way to get what I wanted from the hash mess I had created, I
was trying to build a complicated solution , but alas you showed me the answer was simple.
I thank you and hope that one day I may return the favor,
-
KG
Stefan Weiss wrote:
> woltz <woltz@sewp.nasa.gov> wrote:
>
> > I'm perplexed on how to sort, or retrieve my data in a sorted
> > fashion from, a hash of hashes on a
> > value from the bottom hash.
> (structure snipped)
> > I want to print all items sorted on another_value.
>
> #/usr/bin/perl -w
> use strict;
>
> my $top_hash = {
> id1 => {
> some_key => "some_value3",
> anotherkey => "another_value3",
> },
> id2 => {
> some_key => "some_value1",
> anotherkey => "another_value1",
> },
> id3 => {
> some_key => "some_value2",
> anotherkey => "another_value2",
> },
> };
> foreach my $item (sort byval keys %$top_hash) {
> print qq[
> item $item:
> some_key: $top_hash->{$item}{some_key}
> anotherkey: $top_hash->{$item}{anotherkey}
> ];
> }
> sub byval {
> $top_hash->{$a}{anotherkey} cmp $top_hash->{$b}{anotherkey}
> }
>
> enjoy,
> stefan
------------------------------
Date: 22 Jun 2001 07:04:31 -0700
From: h155@ms37.hinet.net (chih-chieh, Huang)
Subject: How do I use module if I don't have the permission to install?
Message-Id: <a488b3e.0106220604.793c56bd@posting.google.com>
Dear All:
I don't have the permission to install the module I need on the server I use.
And, it's not possible the administrator will give me that permission.
If there any possibility that I can still use module which is not currently
installed?
Thanks for your help!
------------------------------
Date: Fri, 22 Jun 2001 09:16:02 -0500
From: "Mr. Sunray" <djberge@uswest.com>
Subject: Re: How do I use module if I don't have the permission to install?
Message-Id: <3B335322.83F45D27@uswest.com>
"chih-chieh, Huang" wrote:
> Dear All:
>
> I don't have the permission to install the module I need on the server I use.
> And, it's not possible the administrator will give me that permission.
>
> If there any possibility that I can still use module which is not currently
> installed?
>
> Thanks for your help!
It goes like this:
perl Makefile.PL LIB=$HOME/local/lib INSTALLMAN1DIR=$HOME/local/man/man1
INSTALLMAN3DIR=$HOME/local/man/man3
I include the man1 and man3 directories because I have personally experienced
installation failure when they weren't specified (no, they weren't just
warnings). No harm in doing it anyway.
Look at ExtUtils::MakeMaker for other available options.
Regards,
Mr. Sunray
------------------------------
Date: Fri, 22 Jun 2001 13:10:07 GMT
From: "David Mohorn" <david.mohorn@home.com>
Subject: HOW-TO: Extract text from this output?
Message-Id: <PsHY6.106465$qc.13118039@news1.rdc1.va.home.com>
I have the following output that I need to extract the word either "OPENED"
or "CLOSED" from the second column that says "Journaling". Can someone show
me an easy way to do it. My first thought it to read the file line-by-line
looking for a string match on the left column, then parsing the
information.... But I know Perl is more flexible than the lamer way of doing
it... Please advise.
The columns do line up, even though they look jagged below.
File /f0000sb/gbls/f0000sb.ubg
Region GLCOMMON
DSE> D -f
File /f0000sb/gbls/f0000sb.ubg
Region GLCOMMON
Access method BG Global Buffers
1024
Reserved Bytes 0 Block size (in bytes)
8192
Maximum record size 510 Starting VBN
49
Maximum key size 210 Total blocks
0x0000E10D
Null subscripts FALSE Free blocks
0x00004D69
Last Record Backup 0x0003BFEE Extension Count
1000
Last Database Bckup 0x28D8E451 Number of local maps
113
Last Bytestream Bckup 0x00000001 Lock space
0x00000064
In critical section 0x00000000 Timers pending
0
Cache freeze id 0x00000000 Flush timer
00:00:01:00
Freeze match 0x00000000 Flush trigger
889
Current transaction 0x28D8E642 No. of writes/flush
7
Create in progress FALSE Modified cache blocks
0
Reference count 1 Journaling
CLOSED <------------ This is the value I want!!!!!!!!!!
Before imaging FALSE Journal Allocation
10000
Journal Buffer Size 1024 Journal Extension
1000
Journal Yield Limit 0 Journal Sync IO
FALSE
Journal File: /journal/i0002pr/i0002pr_glcommon.mjl
Mutex Hard Spin Count 8 Mutex Sleep Spin Count
16
Mutex Spin Sleep Time 8192 KILLs in progress
0
Replication State CLOSED Region Seqno
0x0000000000000000
Resync Seqno 0x0000000000000000 Resync transaction
0x00000001
Wait Disk 0
DSE> quit
------------------------------
Date: Fri, 22 Jun 2001 13:20:30 GMT
From: Tim Schmelter <tschmelter@statesman.com>
Subject: Re: http://stein.cshl.org/WWW/software/CGI/#dos
Message-Id: <3B33464D.5B804AF2@statesman.com>
David Soming wrote:
> Using CGI.pm
> Is it actually possible to limit the size of posts in bytes to (any)
> non-negative integer?
> It seems no matter what the number specified here still allows posts of
> around 100+ characters
> I'm wanting to use this to limit posts to 30 characters for email addresses.
> Would CGI::POST_MAX be the solution or is 100K the minimum?
100K <> 100 characters. "K" = 1024, so a 100K POST = 102,400 bytes
> http://stein.cshl.org/WWW/software/CGI/#dos
> <QUOTE>$CGI::POST_MAX
> If set to a non-negative integer, this variable puts a ceiling on the size
> of POSTings, in bytes. If CGI.pm detects a POST that is greater than the
> ceiling, it will immediately exit with an error message. This value will
> affect both ordinary POSTs and multipart POSTs, meaning that it limits the
> maximum size of file uploads as well. You should set this to a reasonably
> high value, such as 1 megabyte.
> $CGI::POST_MAX=1024 * 100; # max 100K posts</QUOTE>
If "$CGI::POST_MAX = 1024 * 100;" is documented to mean "max 100K posts", and
we're calculating 100K to be 1024 * 100, it logically follows that you can set
the value to whatever byte size you wish, right? Whether it's practical depends
on your application; a size of 1 byte won't accomplish anything, because the
content-length of a post (actually, CGI.pm uses the environment variable
$ENV{CONTENT_LENGTH}) is always going to be longer than one byte in a
"param=value" POST. If you're setting the number to "30", and you're parameter
name is "data", then you probably have only 25 characters of data to work with:
"data=0123456789012345678901234"
Finally, be sure to return something to the browser if the upload is too large.
Check the CGI.pm docs again for how to test for this event.
--
Tim Schmelter
Public Key available from http://www.keyserver.net
CAD7 2ABB 05A4 2F00 4CAE 7D2F 127C 129A 7173 2951
------------------------------
Date: Fri, 22 Jun 2001 09:35:54 -0500
From: Chris <cpryce@pryce.net>
Subject: Re: http://stein.cshl.org/WWW/software/CGI/#dos
Message-Id: <B758C1FA.732D%cpryce@pryce.net>
in article tj52ovosmj4ufe@corp.supernews.co.uk, David Soming at
davsoming@lineone.net wrote on 06/21/2001 7:09 PM:
> I'm wanting to use this to limit posts to 30 characters for email addresses.
> Would CGI::POST_MAX be the solution or is 100K the minimum?
To limit an HTML field to a length, you should code it into the tag, as:
<input type='text' maxlength='30' name='email' size='15'/>
Size is the size of the field when displayed in the browser. Maxlength is
the maximum number of characters that a user can enter.
cp
------------------------------
Date: 22 Jun 2001 03:05:33 -0700
From: ralphwang@hotmail.com (Ralph)
Subject: Re: Install Perl on HP
Message-Id: <57999a2f.0106220205.4b487696@posting.google.com>
Philip Newton <pne-news-20010617@newton.digitalspace.net> wrote in message news:<1q4pit4so3hcel3lrlqgkhcvm3grej7uo1@4ax.com>...
> On 17 Jun 2001 04:18:07 -0700, ralphwang@hotmail.com (Ralph) wrote:
>
> > * I thougth "standardard" install is pretty simple,
> > just download the tar file, untar, then type the
> > following
> >
> > rm -f config.sh Policy.sh
> > sh Configure -de
> > make
> > make test
> > make install
>
> Basically, yes.
>
Thanks Philip, version I download is 5.6.1, where should I execute
above command ( i.e. if I untar the file and put it into directory
/tmp/perl, should I go to /tmp/perl before I execute above command
? )
Also, when I went to directory /tmp/perl, I didn't see config.sh and
Policy.sh, there are two config.sh under other directory ( i.e.
/tmp/perl/Porting and /tmp/perl/epoc ) but there is no Policy.sh,
is still matter to remove them ?
>
> Which one? The 4.036 that comes with HP-UX?
>
Version 4.0.1.8, there are resided at /opt/local/bin and /opt/local/lib/perl
, do i need to clean them up before I build the new version ? thanks
With my best regards,
Ralph
------------------------------
Date: Fri, 22 Jun 2001 13:10:33 +0200
From: Philip Newton <pne-news-20010622@newton.digitalspace.net>
Subject: Re: Install Perl on HP
Message-Id: <6u76jtgolhbea3cj9acrjsdhjs5g524jpr@4ax.com>
On 22 Jun 2001 03:05:33 -0700, ralphwang@hotmail.com (Ralph) wrote:
> Philip Newton <pne-news-20010617@newton.digitalspace.net> wrote in message news:<1q4pit4so3hcel3lrlqgkhcvm3grej7uo1@4ax.com>...
> > On 17 Jun 2001 04:18:07 -0700, ralphwang@hotmail.com (Ralph) wrote:
> >
> > > * I thougth "standardard" install is pretty simple,
> > > just download the tar file, untar, then type the
> > > following
> > >
> > > rm -f config.sh Policy.sh
> > > sh Configure -de
> > > make
> > > make test
> > > make install
> >
> > Basically, yes.
> >
> Thanks Philip, version I download is 5.6.1, where should I execute
> above command ( i.e. if I untar the file and put it into directory
> /tmp/perl, should I go to /tmp/perl before I execute above command
> ? )
Yes. Assuming /tmp/perl is the directory with files such as README,
INSTALL, Configure, and toke.c. THe top-level directory of the unpacked
tar file.
> Also, when I went to directory /tmp/perl, I didn't see config.sh and
> Policy.sh, there are two config.sh under other directory ( i.e.
> /tmp/perl/Porting and /tmp/perl/epoc ) but there is no Policy.sh,
> is still matter to remove them ?
Not really. (But the shell shouldn't complain if you use the -f option
when you remove them.) These are files that can be created by the
configuring and building process, so they should probably be deleted so
you don't use defaults from another time. But if they don't yet exist,
that's OK, too.
> > Which one? The 4.036 that comes with HP-UX?
> >
> Version 4.0.1.8, there are resided at /opt/local/bin and /opt/local/lib/perl
> , do i need to clean them up before I build the new version ? thanks
Probably not, as long as you don't install into /opt/local.
Cheers,
Philip
--
Philip Newton <nospam.newton@gmx.li>
Yes, that really is my address; no need to remove anything to reply.
If you're not part of the solution, you're part of the precipitate.
------------------------------
Date: Fri, 22 Jun 2001 13:48:31 +0200
From: "H. Merijn Brand" <h.m.brand@hccnet.nl>
To: comp.lang.perl.misc
Subject: Re: Install Perl on HP
Message-Id: <Xns90C88C7853115Merijn@192.0.1.90>
ralphwang@hotmail.com (Ralph) wrote in
news:57999a2f.0106220115.48cd0ab8@posting.google.com:
> garnerjr@ci.richmond.va.us (Jim Garner) wrote in message
> news:<9gtklh$qn4$1@bob.news.rcn.net>...
>> I can compile perl 5.6.1 on 11.0 (ANSI/C or gcc), but it dumps core on
What's your HPc version? If it's rather old, would you be able to upgrade?
>> the pwent test. From what I can gather, calling getpwent() at end of
>> file blows up every time. The problem doesn't happen when compiled on
>> 10.20. I've tried +DAportable. I've tried the source code from the HP
+DAportable is only for old processor architectures, and does not influence
cross-OS behaviour.
>> porting library. I've tried numerous combinations of flags, static
'Configure -des' *should* be enough. If you get core dumps, can you provide
stack traces? Do you use 64bit env's? Threading? Have you read README.hpux?
>> libs, dynamic loading, nothing gets rid of the problem. I'm a pretty
>> good programmer, but the source code has so many layers of abstraction
>> and ifdefs that I haven't been able to pin down where the error occurs.
>> Any suggestions would be appreciated. My one remaining 10.20 system
>> won't be around much longer.
FWIW, all stuff built on 10.20 will still run (including modules) on 11.00
Problems might start when extenting the perl functionality with new or
updated modules that use XS (like Tk). These cannot be added to a port that
was built on 10.20
>> >Philip Newton <pne-news-20010617@newton.digitalspace.net> wrote in
>> >news:1q4pit4so3hcel3lrlqgkhcvm3grej7uo1@4ax.com:
>> >>> * I have previous verion perl install on my system,
>> >>
>> >> Which one? The 4.036 that comes with HP-UX?
>> >
> No, mine is 4.0.1.8 ( i saw there is perls under /opt/local/bin and
> /opt/local/lib/perl ), is this version ok ?
Nah, waaaaayyy to old. (does 'rm -rf' sound like a good suggestion ;-)
--
H.Merijn Brand Amsterdam Perl Mongers (http://www.amsterdam.pm.org/)
using perl-5.6.1, 5.7.1 & 626 on HP-UX 10.20 & 11.00, AIX 4.2, AIX 4.3,
WinNT 4, Win2K pro & WinCE 2.11 often with Tk800.022 &/| DBD-Unify
ftp://ftp.funet.fi/pub/languages/perl/CPAN/authors/id/H/HM/HMBRAND/
------------------------------
Date: Fri, 22 Jun 2001 13:50:27 +0200
From: "H. Merijn Brand" <h.m.brand@hccnet.nl>
To: comp.lang.perl.misc
Subject: Re: Install Perl on HP
Message-Id: <Xns90C88CCC59B68Merijn@192.0.1.90>
ralphwang@hotmail.com (Ralph) wrote in
news:57999a2f.0106211911.37b12d30@posting.google.com:
>> > I can't reply if you use an address that doesn't exist.
>>
>> He did the same with me. Same result. He just ended up in my Killfile,
>> for I don't think this is the right way to deal with newsgroup replies.
>
> I am really sorry about the trouble I cause. The new yahoo e-mail
> account , I set up a couple weeks ago, I can login and send e-mail but I
> don't know there is problem to receive until Philip told me. I already
> check with yahoo about my mail account and I really apologized for the
> trouble I caused.
/un/-killed ;-)
--
H.Merijn Brand Amsterdam Perl Mongers (http://www.amsterdam.pm.org/)
using perl-5.6.1, 5.7.1 & 626 on HP-UX 10.20 & 11.00, AIX 4.2, AIX 4.3,
WinNT 4, Win2K pro & WinCE 2.11 often with Tk800.022 &/| DBD-Unify
ftp://ftp.funet.fi/pub/languages/perl/CPAN/authors/id/H/HM/HMBRAND/
------------------------------
Date: Fri, 22 Jun 2001 09:55:25 -0400
From: Admin <EKAdmin@Kodak.com>
Subject: Interfacing Perl v5 with Vantive Dbase application
Message-Id: <3B334E4D.37D784E7@Kodak.com>
I'm looking for clues as to where to get started or if it is possible to
use Perl to interface the problem-tracking database program Vantive
System. I happen to use an older version of Vantive (v6).
Any comments would be well received!
Brad Trail
Eastman Kodak Company
bradley.trail@kodak.com
------------------------------
Date: Fri, 22 Jun 2001 10:20:45 GMT
From: Lars.Plessmann@gmx.de (Lars)
Subject: Re: Is There Any Other Routine Like CHOP();
Message-Id: <3b331bed.269202@news.btx.dtag.de>
On Fri, 22 Jun 2001 11:29:20 +1000, Michael Walmsley
<michael_w@pacific.net.au> wrote:
>Why not use a regex to delete the \r\n chars at the end of the line ?
>
>Windows line terminator is \r\n whereas unix is \n.
>
>You can either pre-process the file with dos2nuix which will convert the
>line termination chars for you or use a regex of the form :
>
>while(<>) {
> s/\r\n$/\n/;
> print;
>}
>
>This loop will iterate over the file and replace occurences of \r\n with
>just a \n.
>
>to get rid of spaces, etc again use a regex :
>
>
>my $string = " \r\n \r\r This is a test! \n\r ";
>
>$string =~ s/^[\s\r\n]*(.*?)[\r\n\s]*$/$1/m;
>
>print "[$frank]\n";
>
>The above regex will strip \r\n\s chars from the beginning and end of
>the tring as long as that is all there is. It will also match lines
>ending in that only and also starting in tht only. perldoc perlre will
>give you all the gory details on perl regular expresions which are far
>more powerful than delphi trim functions. The reason perl doesn't have
>these kinds of functions is because of it's regular expression power.
>
>Michael.
>
>
>
>Line termination differences is always a pain between unix and windows.
>
>Lars wrote:
>
>> I hava a list of items written to a file in windows.
>> when I open this file on unix systems, there seem to be 2 wrappings
>> (\n\n) at the end.
>> I use the chop routine which deletes one of them, that should be for
>> the line brake, but now there seem to be another char!? when I output
>> the chopped string I can see an space char (#32) at the end!
>>
>> So now my question: is there any practical function to cut all special
>> characters (line brakes, spaces and so on) at the beginning and at the
>> end of my string?
>> Borland Delphi has such a routine, it's name is:
>> "function trim(s: string): string;"
>>
>> is there a similar function in perl available?
>> if not, how can I realize that!? 2xchop is not the result, because
>> some strings do not have strange characters at the and, and in this
>> case importent chars would be cut!
>>
>> thx in advance
>> Lars
>>
>
many thanks for you help!!!!
it works :)
------------------------------
Date: Fri, 22 Jun 2001 13:33:02 GMT
From: Tim Schmelter <tschmelter@statesman.com>
Subject: libwww in Standard Distro? (was: Re: Grabbing a web page?)
Message-Id: <3B33493E.17F6F6FA@statesman.com>
Rafael Garcia-Suarez wrote, in response to a query similar to countless
others:
> cmavroudis wrote in comp.lang.perl.misc:
> } What is the best way for me to grab the source of a web page and put
> } it into a single variable?
>
> Probably the LWP::Simple module. Grab libwww from CPAN to install it (if
> you don't have it already).
Which begs the question, "Why isn't libwww included as part of the standard
Perl distribution?" It seems like a tremendously useful and heavily used set
of utilities.
--
Tim Schmelter
Public Key available from http://www.keyserver.net
CAD7 2ABB 05A4 2F00 4CAE 7D2F 127C 129A 7173 2951
------------------------------
Date: Fri, 22 Jun 2001 14:08:47 +0100
From: "Andrew" <andrew@mvt.ie>
Subject: Module for reading a binary PGM file
Message-Id: <9gvg12$14p$1@kermit.esat.net>
Hi,
What I'm looking to do is to be able to read a binary .pgm file. Having
done this, I intend to do some processing and then export it to VRML as a 3D
landscape kind of thing using the VRML module.
My problem is that I'm not sure how to import the .pgm file. I've checked
CPAN and the only likely looking candidates (based on their brief
descriptions) were Image::Magick and Image::Imlib2. Image::Magick doesn't
seem to be accessible - not even the documentation, so I'm not even sure
that it would do the job. I've downloaded Image::Imlib2, but the
documentation strongly implies that it's meant to be used in a Unix
environment (I'm using ActiveState Perl 5.6.1 on Windows NT), and it also
relies on a development version of Imlib2 being installed.
Am I looking in the right place for this, or can someone point me towards a
module that allow me to do what I want?
Thanks,
Andrew
------------------------------
Date: 22 Jun 2001 16:21:31 +0200
From: Walter Hafner <hafner-usenet@ze.tu-muenchen.de>
Subject: one liner ... simple question
Message-Id: <srjwv64mw7o.fsf@w3proj1.ze.tu-muenchen.de>
Hello,
just a quick check to confirm that I'm on the right path. :-)
I want to convert a list to a hash, so that all the list values become
keys in the hash.
background: I want to do things like
if ($a{$x}) {...}
which I can't do with a list.
Currently I use:
map {$a{$_} = 1} @b;
with @b being the list and %a the generated hash.
Any other way of doing this? (Of course there ist - we're talking about
Perl here :-)
-Walter
------------------------------
Date: Fri, 22 Jun 2001 10:25:17 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Opening a Netscape Window using a Perl script
Message-Id: <m776jt407r90hiagv7qlfoq0njo3e8t7lq@4ax.com>
Scott Vetter wrote:
> In know in some other language, which I won't mention, can open
>another Netscape Window both with and without certain attributes. Can
>this also be done in Perl? And if so how?
You can open another window from within a CGI script, by specifying the
"target" attribute for a link. If you want to control the looks of that
window, you'll have to open it explicitly first, using a browser side
scripting language. If visitors have disabled client side scripting, you
can only rely on "target" opening a window. It's their choice.
--
Bart.
------------------------------
Date: 22 Jun 2001 04:16:21 -0700
From: si.cox@bbsrc.ac.uk (Loki)
Subject: Re: Pattern matching with variables
Message-Id: <7dfd76cc.0106220316.3cbe10d7@posting.google.com>
thanks everyone for the replies.
Should have realised about the \\ being required.
Doh!
------------------------------
Date: Fri, 22 Jun 2001 08:24:35 -0500
From: Michael Carman <mjcarman@home.com>
Subject: Re: Perl description
Message-Id: <3B334713.43280DEB@home.com>
Cristian Cespedes V wrote:
>
> i need some help, does any body know the answer of this questions?
[snip]
I think your teacher wanted you to do your own homework. You can start
your research at http://www.perl.com
-mjc
------------------------------
Date: Fri, 22 Jun 2001 06:28:14 -0400
From: Kevin Michael Vail <kevin@vaildc.net>
Subject: Re: Perl to Oracle connectivity
Message-Id: <220620010628148454%kevin@vaildc.net>
In article <iyBY6.39736$0e3.35611247@news1.rsm1.occa.home.com>, Brian
Janko <brian@jankoNOnet.SPAMcom.INVALID> wrote:
> Does anyone know about Perl to Oracle connectivity? Is it difficult to set
> up? Where might I find information about this topic?
You need DBI and Oracle::DBD, both of which should be available on
CPAN. The documentation in those files should get you started.
--
Kevin Michael Vail | a billion stars go spinning through the night,
kevin@vaildc.net | blazing high above your head.
. . . . . . . . . | But _in_ you is the presence that
. . . . . . . . . | will be, when all the stars are dead. (Rainer Maria Rilke)
------------------------------
Date: Fri, 22 Jun 2001 15:02:31 GMT
From: "Brian Janko" <brian@jankoNOnet.SPAMcom.INVALID>
Subject: Re: Perl to Oracle connectivity
Message-Id: <b6JY6.24982$iR2.2494676@bin1.nnrp.aus1.giganews.com>
Thanks! I appreciate your help.
-- Brian
"Kevin Michael Vail" <kevin@vaildc.net> wrote in message
news:220620010628148454%kevin@vaildc.net...
> In article <iyBY6.39736$0e3.35611247@news1.rsm1.occa.home.com>, Brian
> Janko <brian@jankoNOnet.SPAMcom.INVALID> wrote:
>
> > Does anyone know about Perl to Oracle connectivity? Is it difficult to
set
> > up? Where might I find information about this topic?
>
> You need DBI and Oracle::DBD, both of which should be available on
> CPAN. The documentation in those files should get you started.
>
> --
> Kevin Michael Vail | a billion stars go spinning through the night,
> kevin@vaildc.net | blazing high above your head.
> . . . . . . . . . | But _in_ you is the presence that
> . . . . . . . . . | will be, when all the stars are dead. (Rainer Maria
Rilke)
>
------------------------------
Date: Fri, 22 Jun 2001 10:30:51 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Perl Tutorials or E-Books
Message-Id: <0l76jtckeejnd1m4c0m56n8f3omliog2gu@4ax.com>
Paul Boardman wrote:
>> anyone know where i can find some perl tutorials or free e-books?
>
>funnily enough, a google search (http://www.google.com) found 211, 000
>pages with the words 'Perl' and 'tutorial' in them. I'm sure one of
>those would be just fine.
And here's a haystack. I'm sure you'll be able to find a few needles in
there.
--
Bart.
------------------------------
Date: Fri, 22 Jun 2001 13:07:38 +0100
From: Paul Boardman <peb@bms.umist.ac.uk>
Subject: Re: Perl Tutorials or E-Books
Message-Id: <3B33350A.D56FB21F@bms.umist.ac.uk>
Bart Lateur wrote:
>
> Paul Boardman wrote:
>
> >> anyone know where i can find some perl tutorials or free e-books?
> >
> >funnily enough, a google search (http://www.google.com) found 211, 000
> >pages with the words 'Perl' and 'tutorial' in them. I'm sure one of
> >those would be just fine.
>
> And here's a haystack. I'm sure you'll be able to find a few needles in
> there.
That's not really the case here though is it Bart?
The top hit for a google search using the keywords 'Perl' and 'tutorial'
was
http://www.comp.leeds.ac.uk/Perl/start.html
which covers all the basics.
Regards
Paul
------------------------------
Date: Fri, 22 Jun 2001 13:13:45 +0200
From: Philip Newton <pne-news-20010622@newton.digitalspace.net>
Subject: Re: Reference-problem
Message-Id: <kv96jtovi02ek5hb85db6srm02o2lve5q1@4ax.com>
On Fri, 22 Jun 2001 11:11:34 +0200, "Stefan Serena"
<sserena@freesurf.ch> wrote:
> Am I allowed to write 'schrieb im Newsbeitrag' (german) or does it have to
> be english...?
IMO, that's fine, as long as the name (and perhaps the email address) of
the person are included. Other people include more stuff such as date
and time and/or message ID, so there's no fixed format. But at least a
name is good. And even if you write "skrev i meddelande", people can
usually figure out it's an attribution line if it occurs before the
first quote.
(Oh, and as long as you don't use "schrieb in im Newsbeitrag", or
whatever that buggy German version of OE wrote.)
Cheers,
Philip
--
Philip Newton <nospam.newton@gmx.li>
Yes, that really is my address; no need to remove anything to reply.
If you're not part of the solution, you're part of the precipitate.
------------------------------
Date: 22 Jun 2001 07:11:28 -0700
From: lxl22@visto.com (Xtreme)
Subject: regular expression problem
Message-Id: <91ff860e.0106220611.4815b09@posting.google.com>
Hi,
A little re question:
Assuming I have a string of the form "a_b_b_c" in which I don't know
how many "b_" substrings it has, how can I, in one single s/// line
replace every b_ for a "x_"? My main problem is that I don't know how
to tell the re engine how to replace it the same number of times as it
occurred.
Thanks in advance,
Xtreme
------------------------------
Date: 22 Jun 2001 16:21:52 +0200
From: jacklam@math.uio.no (Peter J. Acklam)
Subject: Re: regular expression problem
Message-Id: <cxclmmk388v.fsf@masterblaster.uio.no>
lxl22@visto.com (Xtreme) wrote:
> Assuming I have a string of the form "a_b_b_c" in which I don't
> know how many "b_" substrings it has, how can I, in one single
> s/// line replace every b_ for a "x_"? My main problem is that
> I don't know how to tell the re engine how to replace it the
> same number of times as it occurred.
s/b_/x_/g;
Peter
--
#!/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: Fri, 22 Jun 2001 14:42:03 GMT
From: Laszlo Gerencser <laszlo.gerencser@portologic.com>
Subject: Re: regular expression problem
Message-Id: <3B33759B.FDD00A52@portologic.com>
s/b_/anything/g
--
Laszlo Gerencser
PortoLogic Ltd.
------------------------------
Date: Fri, 22 Jun 2001 12:56:33 GMT
From: helgi@NOSPAMdecode.is (Helgi Briem)
Subject: Re: Searchin for .sh
Message-Id: <3b33401e.2002555953@news.isholf.is>
On 21 Jun 2001 21:54:15 -0700, nmangalath@amcon.com.au (Naru
Mangalath) wrote:
>I am not an expert in Unix, least of all Perl and regular expressions.
>I have this probelm. I have a bin directory containing Bourne shell
>scripts. I want to search each of the scripts to search for other
>scripts (.sh) that it is calling. Finally I want to create a file like
>this:
>script calls
>====== =====
>script1.sh script5.sh
> script4.sh
>script2.sh script4.sh
> script1.sh
>scrpit3.sh
>
As Abigail, pointed out, the problem as stated is not
computable, but I think this solution will give you
roughly what you want, although I have played fast
and loose with your specs:
#!/usr/bin/perl -w
#Check for references to executables in text files
if (not @ARGV) { die "Usage:$0 file[s]\n"; }
my @filelist = glob ("@ARGV");
foreach $file (@filelist)
{
open IN, $file or die "Error opening $file:$!\n";
print "$file calls the following programs/scripts:\n";
while (<IN>)
{
my @words = split /\s+/,$_;
for (@words)
{
if (-x $_) { print "\t$_\n"; }
}
}
close IN;
}
------------------------------
Date: Fri, 22 Jun 2001 08:16:20 -0500
From: Michael Carman <mjcarman@home.com>
Subject: Re: splice/Join and split!!
Message-Id: <3B334524.AF0DAA4A@home.com>
"John W. Krahn" wrote:
>
> Michael Carman wrote:
> >
> > while (<IN>) {
> > if ($. == 6 .. $. == 9) {
> ^^^^^ ^^^^^^
> The "$. ==" part is superfluous.
>
> if ( 6 .. 9 ) {
Heh. The funny thing is that's the way I wanted to write it; the way
that felt "natural." Somehow I managed to convince myself that it wasn't
right and wrote that slightly awkward bit instead. Yet another example
of the beauty of Perl and it's amazing ability to DWIM.
-mjc
------------------------------
Date: Fri, 22 Jun 2001 08:41:02 -0400
From: "Prasad, Victor [FITZ:K500:EXCH]" <vprasad@americasm01.nt.com>
Subject: Uninitialized Value from a Hash?
Message-Id: <3B333CDE.A426EE7A@americasm01.nt.com>
Nobull - thank you very much for your help!
I realized my mistake later. I have implemented your changes. It
works! But there are some fields in the database I get data from that
are blank - how do make perl not give me an error when there is an
uninitialized error?
code now:
# get the list of parameter names
($field,$data) = each %rowhash;
while ($row = $sth->fetchrow_hashref)
{
push @cat, { %$row };
while ( my ($field,$data) = each %$row)
{
line 114-> print $cgi->p("$field = $data");
}
}
Ouput:
[Fri Jun 22 08:35:01 2001] miscv.cgi: Use of uninitialized value at
line 114. [Fri Jun 22 08:35:01 2001] : Use of uninitialized value at
line 114. [Fri Jun 22 08:35:01 2001] miscv.cgi: Use of uninitialized
value at line 114. [Fri Jun 22 08:35:01 2001] miscv.cgi: Use of
uninitialized value at line 114. [Fri Jun 22 08:35:01 2001] miscv.cgi:
Use of uninitialized value at line 114.
hier_update_rqd =
crit1_desc = valid region code based on values in table region
crit2_desc =
crit3_desc =
crit1 = 1
crit2 =
crit3 =
sign_off_desc = test
sign_off_type = B
global_id = xxxxxx
Any ideas?
Again - thanks!
V
nobull@mail.com wrote:
>
> You meant something like:
>
> my @cat;
> while (my $row = $sth->fetchrow_hashref)
> {
> push @cat, { %$row };
> while ( my ($field,$data) = each %$row)
> {
> print $cgi->p("$field = $data");
> }
> }
>
> --
> \\ ( )
> . _\\__[oo
> .__/ \\ /\@
> . l___\\
> # ll l\\
> ###LL LL\\
------------------------------
Date: Fri, 22 Jun 2001 14:02:11 GMT
From: Tim Schmelter <tschmelter@statesman.com>
Subject: Re: Uninitialized Value from a Hash?
Message-Id: <3B335014.FD1EF984@statesman.com>
"Prasad, Victor [FITZ:K500:EXCH]" wrote:
<snip>
> while ($row = $sth->fetchrow_hashref)
> {
>
> push @cat, { %$row };
>
> while ( my ($field,$data) = each %$row)
> {
> line 114-> print $cgi->p("$field = $data");
> }
> }
>
> Ouput:
>
> [Fri Jun 22 08:35:01 2001] miscv.cgi: Use of uninitialized value at
> line 114. [Fri Jun 22 08:35:01 2001] : Use of uninitialized value at
> line 114. [Fri Jun 22 08:35:01 2001] miscv.cgi: Use of uninitialized
> value at line 114. [Fri Jun 22 08:35:01 2001] miscv.cgi: Use of
> uninitialized value at line 114. [Fri Jun 22 08:35:01 2001] miscv.cgi:
> Use of uninitialized value at line 114.
<snip>
If you get an "unitialized value" error after you've
done an assignment, it's a safe bet the value is "undefined".
In this case, you're trying to interpolate an undefined variable
into a "print" statement.
Try
$data = defined $data ? $data : '';
So, you're probably asking: "If undefined variables have special
magic in the context of increments"
[tas@fozzie tas]$ perl -we 'use strict; my $i; print ++$i, "\n"'
1
"and explicit concatenations"
[tas@fozzie tas]$ perl -we 'use strict; my $s; $s.="Hey"; print "$s\n";'
Hey
"why wouldn't it do the same thing in an interpolated concatenation?"
[tas@fozzie tas]$ perl -we 'use strict; my $s; print "s=$s\n";'
Use of uninitialized value in concatenation (.) at -e line 1.
s=
Well, it seems like a natural DWIM behavior to me, too. However, turning
off "-w" will remove that error message, which means that the error message
is a "warning". In other words, the situation is something Perl is
helpfully trying to let you know about. "Do you *really* mean for this
variable to be empty. Wouldn't you rather be explicit about it?
The special magic for increments and explicit concatenations is helpful in
some situations like setting flags, but can still cause trouble:
[tas@fozzie tas]$ perl -we 'use strict; my $i; while ($i<3) { print "$i\n";
$i++; }'
Use of uninitialized value in numeric lt (<) at -e line 1.
Use of uninitialized value in concatenation (.) at -e line 1.
1
2
So, the magic is reserved for *assigning* a value to an undefined variable,
but not for *reading* the value.
--
Tim Schmelter
Public Key available from http://www.keyserver.net
CAD7 2ABB 05A4 2F00 4CAE 7D2F 127C 129A 7173 2951
------------------------------
Date: Fri, 22 Jun 2001 10:29:27 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Which C compiler to use for modules?
Message-Id: <gd76jt0fk66tl29ba9kokar9e31erqu13e@4ax.com>
Martin Vorlaender wrote:
>> Any module that does not use XS for extensions can just be copied and
>> pasted in your site/perl directory.
>
>Not quite. Makefile.PL may contain configuration procedures that won't
>be executed in that case (e.g. libnet).
Plus, if the module relies on AutoLoader and its accompanying AutoSplit,
the latter won't have run, which it normally would have to do at install
time. Thus, AutoLoad won't work.
--
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 1176
***************************************