[22575] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 4796 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Mar 31 21:06:11 2003

Date: Mon, 31 Mar 2003 18:05:06 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Mon, 31 Mar 2003     Volume: 10 Number: 4796

Today's topics:
        -d following symbolic links <bmetcalf@nortelnetworks.com>
    Re: -d following symbolic links <uri@stemsystems.com>
    Re: -d following symbolic links <dmcbride@naboo.to.org.no.spam.for.me>
        Apache::Request is not good to me. <mt-news@gmx.net>
    Re: CGI.pm or roll-your-own? <tore@aursand.no>
    Re: CGI::ContactForm 1.03 - Feedback request <noreply@gunnar.cc>
    Re: CGI::ContactForm 1.03 - Feedback request <tore@aursand.no>
    Re: Cookie Question (Captain Zod)
    Re: Cookie Question (Malcolm Dew-Jones)
    Re: Cookie Question <jurgenex@hotmail.com>
    Re: Cookie Question <eric.schwartz@hp.com>
    Re: Does Perl can do everything you need in unix shell  <oldno7@comcast.net>
        Double bit-negation <acm2@ukc.ac.uk>
    Re: implicit vs explicit variable usage in loop w/ rang <eric-amick@comcast.net>
    Re: Loading STDOUT into a variable <jurgenex@hotmail.com>
    Re: modules using modules - shared objects <nwzmattXX@XXnetscape.net>
    Re: Replacing a string in a file (Triniman)
        split map avoid error message <stremitz@consultant.com>
    Re: split map avoid error message <uri@stemsystems.com>
    Re: split map avoid error message <stremitz@consultant.com>
    Re: webhosts that support perl well? <henq _ replace 0 by o <hvtijen@h0tmail.c0m>>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Mon, 31 Mar 2003 23:40:04 +0000 (UTC)
From: Brandon Metcalf <bmetcalf@nortelnetworks.com>
Subject: -d following symbolic links
Message-Id: <slrnb8hk4u.rff.bmetcalf@cash.rhiamet.com>


Is there anyway to tell the file test operators such as -d to not
follow symbolic links?  For example,


  $ ls -ld realdir dirlink
  lrwxrwxrwx    1 bmetcalf onmsdev         7 Mar 31 17:29 dirlink -> realdir/
  drwxr-xr-x    2 bmetcalf onmsdev      4096 Mar 31 17:28 realdir/
  $ cat jj
  print 'yep' if -d 'dirlink';
  $ perl -l jj
  yep


So, it in order to determine if something is a real directory and not
a symbolic link I would have to do something like


  (-d $somedir && ! -l $somedir)


Is there a better way to do this?


Thanks,
Brandon
-- 
There is only one corner of the universe you can be certain of
improving and that's your own self.
  --Aldous Huxley


------------------------------

Date: Mon, 31 Mar 2003 23:53:03 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: -d following symbolic links
Message-Id: <x7n0jbrt41.fsf@mail.sysarch.com>

>>>>> "BM" == Brandon Metcalf <bmetcalf@nortelnetworks.com> writes:

  BM> Is there anyway to tell the file test operators such as -d to not
  BM> follow symbolic links?  For example,

  BM> So, it in order to determine if something is a real directory and not
  BM> a symbolic link I would have to do something like

  BM>   (-d $somedir && ! -l $somedir)

the whole point of symlinks is that only -l and stat/lstat can tell the
difference. getting around that would be silly and prolly break lots of
stuff.

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: Tue, 01 Apr 2003 00:04:28 GMT
From: Darin McBride <dmcbride@naboo.to.org.no.spam.for.me>
Subject: Re: -d following symbolic links
Message-Id: <gI4ia.350955$na.27572737@news2.calgary.shaw.ca>

Brandon Metcalf wrote:

> 
> Is there anyway to tell the file test operators such as -d to not
> follow symbolic links?  For example,
> 
> 
>   $ ls -ld realdir dirlink
>   lrwxrwxrwx    1 bmetcalf onmsdev         7 Mar 31 17:29 dirlink ->
>   realdir/
>   drwxr-xr-x    2 bmetcalf onmsdev      4096 Mar 31 17:28 realdir/
>   $ cat jj
>   print 'yep' if -d 'dirlink';
>   $ perl -l jj
>   yep
> 
> 
> So, it in order to determine if something is a real directory and not
> a symbolic link I would have to do something like
> 
> 
>   (-d $somedir && ! -l $somedir)
> 
> 
> Is there a better way to do this?

In general, it's a bit better to do this:

(! -l $somedir && -d _)

You can't do this the other way around, though.  This should be the tiniest 
bit more efficient.



------------------------------

Date: Tue, 01 Apr 2003 03:05:57 +0200
From: "matthias tarasiewicz" <mt-news@gmx.net>
Subject: Apache::Request is not good to me.
Message-Id: <pan.2003.04.01.01.05.55.511190@gmx.net>

the package "Apache-Request" seems to have some problems, i can't install it.
see the error output below, thanks so much for your help.
matthias

---

cpan> install Apache::Request
Running install for module Apache::Request
Running make for J/JI/JIMW/libapreq-1.1.tar.gz
  Is already unwrapped into directory /root/.cpan/build/libapreq-1.1
  Has already been processed within this session
Running make test
make[1]: Entering directory `/root/.cpan/build/libapreq-1.1/c'
make[1]: Leaving directory `/root/.cpan/build/libapreq-1.1/c'
make[1]: Entering directory `/root/.cpan/build/libapreq-1.1/Request'
make[1]: Leaving directory `/root/.cpan/build/libapreq-1.1/Request'
make[1]: Entering directory `/root/.cpan/build/libapreq-1.1/Cookie'
make[1]: Leaving directory `/root/.cpan/build/libapreq-1.1/Cookie'
t/httpd -f `pwd`/t/httpd.conf
[Tue Apr  1 03:04:57 2003] [warn] module config_log_module is already loaded, skipping
[Tue Apr  1 03:04:57 2003] [warn] module mime_module is already loaded, skipping
PERL_DL_NONLAZY=1 PORT=8228 /usr/bin/perl -Iblib/arch -Iblib/lib -I/usr/lib/perl/5.6.1 -I/usr/share/perl/5.6.1 -e 'use Test::Harness qw(&runtests $verbose); $verbose=0; runtests @ARGV;' t/*.t
t/cookie.....skipped
        all skipped: no reason given
t/inherit....FAILED test 1                                                   
        Failed 1/1 tests, 0.00% okay
t/request....FAILED tests 1-10                                               
        Failed 10/10 tests, 0.00% okay
Failed Test Stat Wstat Total Fail  Failed  List of Failed
-------------------------------------------------------------------------------
t/inherit.t                1    1 100.00%  1
t/request.t               10   10 100.00%  1-10
1 test skipped.
Failed 2/3 test scripts, 33.33% okay. 11/11 subtests failed, 0.00% okay.
make: *** [run_tests] Error 11
  /usr/bin/make test -- NOT OK
Running make install
  make test had returned bad status, won't install without force

cpan> install Apache::Request




------------------------------

Date: Tue, 01 Apr 2003 03:34:09 +0200
From: "Tore Aursand" <tore@aursand.no>
Subject: Re: CGI.pm or roll-your-own?
Message-Id: <pan.2003.03.31.23.20.18.298914@aursand.no>

On Mon, 31 Mar 2003 15:50:12 +0200, Gunnar Hjalmarsson wrote:
> You mentioned CGI.pm's implementation of limited protection against DoS
> attacks as an example [...]

Yes.  As an _example_.  But one doesn't have to think CGI.pm to make that
point valid; _all_ use of modules benefit from the same advantage.

> [...] where you don't need to edit the programs that use CGI in order to
> benefit from improvements of the module. When I checked it out, I found
> that this protection is *not* activated by default, but you must set one
> or two variables, either in the programs that use CGI, or in CGI.pm
> itself.

That's right, and there's a good reason to it, too, as explained in my
last message; what if developers _intentionally_ want the users of their
script to upload large files?

You're still missing the main point, though;  Imagine a server admin for a
web site where there are 100 different scripts running, using CGI.pm. What
does _he_ have to do to protect the _server_ from being DoS attacked?

Another example:  Isn't it easier for beginners to change a documented
variable in CGI.pm than trying to cope with the environment variables?

> In an effort to understand what you were saying, it struck me that you
> must have been talking about editing CGI.pm. And now you say that that's
> not what you were talking about...?

I'm not trying to deal with CGI.pm _only_, as you seem to miss the whole
point with modules in the first place.

That said, there is nothing wrong to install CGI.pm locally for a user and
change it in a way you'd like.  Or you can sub-class it.  Whatever.


-- 
Tore Aursand


------------------------------

Date: Tue, 01 Apr 2003 01:57:00 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: CGI::ContactForm 1.03 - Feedback request
Message-Id: <b6akoe$3chpr$1@ID-184292.news.dfncis.de>

Tore Aursand wrote:
> 3. Instead of 'sub htmlize' I would have used a module for that.
>    There are a few entitites modules at CPAN.

This is the subroutine:

     sub htmlize {
         my $value = shift;
         $value =~ s/&/&amp;/g;
         $value =~ s/"/&quot;/g;
         $value =~ s/</&lt;/g;
         $value =~ s/>/&gt;/g;
         $value
     }

I found that CGI.pm includes a function for it, so I simply replaced 
the above subroutine with the escapeHTML() function.

/ Gunnar

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl



------------------------------

Date: Tue, 01 Apr 2003 03:34:09 +0200
From: "Tore Aursand" <tore@aursand.no>
Subject: Re: CGI::ContactForm 1.03 - Feedback request
Message-Id: <pan.2003.03.31.23.27.22.869149@aursand.no>

On Mon, 31 Mar 2003 16:44:51 +0200, Gunnar Hjalmarsson wrote:
>> 1. Use CGI.pm wherever possible.  There are a few places where
>>    you ignore the superior CGI.pm. :)

> Hmm.. On *that* there are different views [...]

No.  A) You can use CGI.pm in a lot more places in your module.  B) The
use of CGI.pm is superior over your way of doing tings.

>> 2. Separate Perl code from "other";  I see there is room for
>>    separating HTML, text and configuration directives into separate
>>    files.

> I see your point with that. But do you really think that doing so is
> always an advantage, irrespective of the size of a program? This module
> is small.

Doesn't matter if your module is small, written in urdu or what.  If you
choose to standardize your module to use a template system from the
beginning of, you can be sure that your users know how to handle it when,
or if, the module grows bigger.

In addition;  As your module is today, you must most certainly be a Perl
programmer to change any of the text.  You don't want that.


-- 
Tore Aursand


------------------------------

Date: 31 Mar 2003 15:35:53 -0800
From: cptnzod@yahoo.com (Captain Zod)
Subject: Re: Cookie Question
Message-Id: <9433af5b.0303311535.ef7de9a@posting.google.com>

"Alan J. Flavell" <flavell@mail.cern.ch> wrote in message news:<Pine.LNX.4.53.0303312039030.2896@lxplus005.cern.ch>...
> On Mon, Mar 31, Captain Zod inscribed on the eternal scroll:
> 
> > I am writing a shopping cart program. The way I designed it is that
> > there is one central cgi script which gets called all the time and
> > depending on the parameter that is passed to this script different
> > part of the script gets executed.
> 
> Seems to be a perfectly normal way to organise a program in any
> programming language: I don't see how this would involve any
> specifically Perl-related problem?
> 
> > Now here is the problem:
> > If I print http header
>  ------------^^^^^^^^^^^
> 
> The response from a CGI process is a CGI response.  The similarity to
> HTTP headers is intentional, but can sometimes be confusing.  It's
> best to keep them apart IMHO, even if it sometimes seems pedantic.
> 
> > and other things, then I can no longer
> > manipulate the cookies. So what is one to do?
> 
> Blindingly obvious that you don't put out the CGI response header
> until you've decided what the CGI response header should be, no?

Well, since the main script does all the tasks. It must print
depending on the task. Then it waits for another user input. But if
one wants to manipulate the cookie in another part of the script then
its a problem. Because it has already printed way passed the header.

By the way where is a good forum for this type of question. Is this a
browser question or web server question or html?

> 
> > Is there a way to close
> > out the current http ( session is right word? ) and start out new so
> > that I can manipulate the cookies again?
> 
> No, there isn't.  If there were, it would be in the CGI specification
> for all to see.  There's no reason that you should need it, if you
> organise your program right.  And this _still_ has nothing Perl
> specific about it, so this is hardly the right place for the
> discussion.  Even if there's a very selective coverage of CGI topics
> in the Perl FAQ part 9 (look for the 5.8.0 version at least) which
> might help to put things in perspective.
> 
> good luck


------------------------------

Date: 31 Mar 2003 16:23:38 -0800
From: yf110@vtn1.victoria.tc.ca (Malcolm Dew-Jones)
Subject: Re: Cookie Question
Message-Id: <3e88dc0a@news.victoria.tc.ca>

Captain Zod (cptnzod@yahoo.com) wrote:

: Well, since the main script does all the tasks. It must print
: depending on the task. Then it waits for another user input. 

In a regular cgi script, that last sentence indicates a programmer
misunderstanding, which is the root cause of many bugs.

A cgi script does not wait for user input. 




------------------------------

Date: Tue, 01 Apr 2003 01:04:54 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Cookie Question
Message-Id: <WA5ia.18656$gp1.9538@nwrddc02.gnilink.net>

Captain Zod wrote:
> "Alan J. Flavell" <flavell@mail.cern.ch> wrote in message
> news:<Pine.LNX.4.53.0303312039030.2896@lxplus005.cern.ch>...
[...]
>> Blindingly obvious that you don't put out the CGI response header
>> until you've decided what the CGI response header should be, no?
>
> Well, since the main script does all the tasks. It must print
> depending on the task. Then it waits for another user input.

Doh!
CGI is stateless and a CGI program does not wait for user input.

> But if
> one wants to manipulate the cookie in another part of the script then
> its a problem. Because it has already printed way passed the header.

Indeed, it is a problem when trying to write CGI program without
understanding the basics of CGI.
Not that this would have anything to do with Perl.

> By the way where is a good forum for this type of question. Is this a
> browser question or web server question or html?

Yes (to all three of them).
Probably your best bet is to ask in a NG that deals with CGI first.

jue




------------------------------

Date: 31 Mar 2003 18:07:27 -0700
From: Eric Schwartz <eric.schwartz@hp.com>
Subject: Re: Cookie Question
Message-Id: <etobrzr6n5c.fsf@wormtongue.emschwar>

"Jürgen Exner" <jurgenex@hotmail.com> writes:
> Captain Zod wrote:
> > By the way where is a good forum for this type of question. Is this a
> > browser question or web server question or html?
> 
> Yes (to all three of them).
> Probably your best bet is to ask in a NG that deals with CGI first.

Which is, by the way, comp.infosystems.www.authoring.cgi.

-=Eric
-- 
Come to think of it, there are already a million monkeys on a million
typewriters, and Usenet is NOTHING like Shakespeare.
		-- Blair Houghton.


------------------------------

Date: Mon, 31 Mar 2003 18:44:18 -0500
From: "Rev. Don Kool" <oldno7@comcast.net>
Subject: Re: Does Perl can do everything you need in unix shell scripting?what about PHP?
Message-Id: <3E88D2D2.5060905@comcast.net>



"Michael Vilain " wrote:
> In article <3e88c538$0$66672$bed64819@news.gradwell.net>,
>  "Brendon Caligari" <bcaligari@fubar.fireforged.com> wrote:
> 
> 
>>"edu@rd c" <ecleofe7@yahoo.com> wrote in message
>>news:1e1c9a33.0303311430.2143c5e@posting.google.com...
>>
>>>hi Guys,
>>>        Need your advice.This could be helpfull for those newbie.I
>>>want to learn shell scripting.I just want to know that if you master
>>>the Perl you can overcome all the shell scripting needed in unix,on
>>>w/c you dont need to study those csh,bsh,bash and so on.But what about
>>>PHP,since they are just the same function with perl and this is much
>>>easier to learn?
>>>        Thanks in advanced.God Bless to all...
>>
>>I'd love to see unix init scrips written in php.
> 
> 
> Although the OP's post is "uninformed" more than trollish, I'll respond 
> to it.  Shell scripting is a useful skill.  Being able to code in perl 
> or php is fine, but you can't manage the system's startup and shutdown 
> environment with them.  Nor can you change or setup a global environment 
> for users as their shell (if they have one) isn't usually perl or php 
> but one of the usual suspects.
> 
> The most common shell to learn is the Borne shell.  bash is a super-set 
> of that but bash isn't the default shell for Solaris' root, which runs 
> the startup scripts (it's /sbin/sh and should NOT be changed unless you 
> know what you're doing otherwise subsequent posts about "I can't login 
> as root" will be met with "I told you so").

	So where did he say that he was using SOLARIS?

		Hope this helps,
			Don



-- 
***************************   Q: How many frenchmen does it take
* Rev. Don McDonald, SCNA *      to defend Paris?
* Baltimore, MD           *   A: No one knows, it's never been tried.
*************************** 
http://mywebpages.comcast.net/oldno7/TheFrench.mpg
Reluctant Yamaha YZF-R1 Owner



------------------------------

Date: Tue, 01 Apr 2003 01:06:04 +0100
From: Tony McNulty <acm2@ukc.ac.uk>
Subject: Double bit-negation
Message-Id: <oprmxbwepi2czp9w@news.ukc.ac.uk>

I was playing in a golf game recently (badly) and this is the first time I 
came across the use of doubly negating:

print~~grep$'==eval'+$_%$&%[$_/=$&]'x14,"@ARGV"=~/ .* /..$`

This was one of the winning solutions, but i have no idea why they do it 
with that ~~

Can anyone explain the point of it to me?

Cheers,

Tony
--------------------------------------
web:   http://mercutio.digitalrice.com
email: mercutio at digitalrice dot com
--------------------------------------


------------------------------

Date: Mon, 31 Mar 2003 20:45:25 -0500
From: Eric Amick <eric-amick@comcast.net>
Subject: Re: implicit vs explicit variable usage in loop w/ range regexp
Message-Id: <emrh8v8na94p3krjlnqa83o9gc22n2utqm@4ax.com>

On 29 Mar 2003 09:38:13 -0800, stimonyhall@netscape.net (Upstart) wrote:

>yf110@vtn1.victoria.tc.ca (Malcolm Dew-Jones) wrote in message news:<3e84b6e6@news.victoria.tc.ca>...
>
>> This line does not do what you think it does. My added brackets show what
>> it is doing. 
>> 
>>          if ( ($line =~ /^BEGIN:/) ... (/^END:/) ) {
>
>wow. this is not clear to me for the documentation. any manpage i should be reading?

perlop shows the binding operators have higher precedence than the range
operators.

-- 
Eric Amick
Columbia, MD


------------------------------

Date: Tue, 01 Apr 2003 01:11:20 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Loading STDOUT into a variable
Message-Id: <YG5ia.18675$gp1.5239@nwrddc02.gnilink.net>

Stephan Bour wrote:
> I need to parse the output of the ifconfig shell command
> (system("ifconfig");) for the current IP address.

Why don't you just read the man page for the functions you are using?
    perldoc -f system
and the answer to your question is right there in the third paragraph

jue




------------------------------

Date: Tue, 01 Apr 2003 01:36:43 GMT
From: Matt <nwzmattXX@XXnetscape.net>
Subject: Re: modules using modules - shared objects
Message-Id: <uvfxzdmmt.fsf@XXnetscape.net>

"Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de> writes:

> Subject: Re: modules using modules - shared objects
> 
> The subject is a little misleading. When I hear "shared object" I think
> of .so files (the Linux equivalent of a dll). 
> 
> Also sprach Matt:
> 
> > I have been playing around with writing a module. I was suprised to
> > find that I can use a module from within my module, and return an
> > object ref from the other module with all of its methods.
<code snipped>
> > Ok, now obviously I am able to use all of the methods exported from
> > DBI in my script. How/why is this. I have not been able to find
> > documentation that has completely made me understand how this
> > works. 
> 
> Not quite. You are calling methods on the object previously returned. An
> object is something that combines data, a namespace and a couple of
> functions (methods in this context). There is no exporting involved
> really. When you do:
> 
>     $obj->method(@args);
> 
> perl finds out the class to which $obj belongs and does roughly this:
> 
>     CLASS_OF_OBJ::method($obj, @args);
> 
> Of course, what perl does is more complicated especially when
> inheritance etc. is involved.
> 

Thanks Tassilo. I'm starting to get a handle on it. I've been reading
up on inheritance a little. What I want to do now is to (bless? tie?)
an object of my class to a DBI object. In other words, just extend the
methods of the DBI object to include some custom methods. I've tried
various things, but I'm not sure what I'm doing and nothing is
working. Can you(or anyone else) give me an example of how this might
be possible, or point me in the direction of one.

> > Also, as you see, I declare both the $dbh variable in the
> > module and in the script with my(). In the script, I am getting the
> > object ref from the return value of a function in my module, so they
> > are both pointing to the same object, right? And when I call
> > selectSomething(), it is using this same object right?
> 
> Yes, you are. What you have (unknowingly perhaps) created here is a sort
> of closure: A function that "closes over" attached data ($dbh in this
> case) so that it always has access to this variable later.
<snip>

I guess I already knew that, but for some reason it was confusing
me. Thanks for clearing it up.

Matt 
-- 
Remove the X's to reply directly.


------------------------------

Date: 31 Mar 2003 16:06:10 -0800
From: jason.alphonse@alum.dartmouth.org (Triniman)
Subject: Re: Replacing a string in a file
Message-Id: <3b7960ec.0303311606.7b66cdb2@posting.google.com>

Stephan Bour <sbour@niaid.nih.gov> wrote in message news:<BAADF7A8.6B8C%sbour@niaid.nih.gov>...
> I'm having difficulties understanding file manipulation and I hope someone
> can help me.
> I'm trying to modify the text inside a hostfile and change the
> DNSSERVER=-NO- entry to DNSSERVER=-YES-.
> The code below works fine when I provide the string but I get a bunch of
> errors when I try to do the same thing on a copy of the hostfile itself.
> Could someone point me in the right direction as to how to load a file to
> modify it and have it saved with the new entry? Should I load the entire
> file in an array or use a while statement looking at each line one by one?
> I'm using the +< operator when opening the file, is this correct?
> 
> #!usr/bin/perl
> 
> $text = "Find the line DNSSERVER=-NO- and change it to DNSSERVER=-YES-";
> print "text is: $text\n";
> while ($text =~ s/DNSSERVER=-NO-/DNSSERVER=-YES-/){
> print "The string is now $text\n";
> }


If I had to do this, for simple substitutions there's a neat trick
from the command line thus:

perl -pi -e 's/DNSSERVER=-NO-/DNSSERVER=-YES-/sg' thefile.txt

You can look into the perl command line parameters to get the exact
details on this, but basically it is quick and it works, and it can be
stuck into a shell
script too.

-Jason Alphonse


------------------------------

Date: Mon, 31 Mar 2003 19:00:15 -0500
From: Alexander Stremitzer <stremitz@consultant.com>
Subject: split map avoid error message
Message-Id: <3E88D68F.3010307@consultant.com>

My program splits a tab separated record in individual fields and 
removes any trailing spaces from each field. Whenever a record is too 
short, I experience an error message. I would prefer not to get an error 
message and have an empty field rather than an undefined field. The last 
data line contains a TAB but no middle name.

Any help is welcome. In the actual program the list of fields is much 
longer.

pds:/db0_d/_alex/uphs/pmc> cat zzz
#!/usr/local/bin/perl -w

use Text::ParseWords;
use strict;
use warnings;

while (<DATA>) {
        chomp;
        my @ris_list = map { s/\s+$//; $_ } quotewords ('\t', 0, $_);
        my ($ris_pat_last,$ris_pat_first,$ris_pat_middle) = @ris_list;
        print "$ris_pat_last|$ris_pat_first|$ris_pat_middle\n";
}

__DATA__
RODGERS FRED    P
DAVIS   HAL
pds:/db0_d/_alex/uphs/pmc> zzz
RODGERS|FRED|P
Use of uninitialized value in substitution (s///) at zzz line 9, <DATA> 
line 2.
Use of uninitialized value in concatenation (.) or string at zzz line 
11, <DATA>
 line 2.
DAVIS|HAL|

Thanks,
Alex

-- 
All man's miseries derive from not being able to sit quietly in a room alone. (Pascal)




------------------------------

Date: Tue, 01 Apr 2003 00:10:15 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: split map avoid error message
Message-Id: <x7fzp3rsbc.fsf@mail.sysarch.com>

>>>>> "AS" == Alexander Stremitzer <stremitz@consultant.com> writes:

  AS> My program splits a tab separated record in individual fields and
  AS> removes any trailing spaces from each field. Whenever a record is too
  AS> short, I experience an error message. I would prefer not to get an
  AS> error message and have an empty field rather than an undefined
  AS> field. The last data line contains a TAB but no middle name.

  AS>         my @ris_list = map { s/\s+$//; $_ } quotewords ('\t', 0, $_);

simple, make sure $_ has at least a null string in there. and i would do
this in two lines. modifying $_ inside map is not the clearest code. map
is best used to generate new lists and foreach is best used to modify
existing lists.

         my @ris_list = map { $_ || '' } quotewords ('\t', 0, $_);
	 s/\s+$// for @ris_lists ;

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, 31 Mar 2003 19:50:44 -0500
From: Alexander Stremitzer <stremitz@consultant.com>
Subject: Re: split map avoid error message
Message-Id: <3E88E264.60605@consultant.com>


--------------010001070000020201030203
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit


Uri Guttman wrote:

>>>>>>"AS" == Alexander Stremitzer <stremitz@consultant.com> writes:
>>>>>>            
>>>>>>
>
>  AS> My program splits a tab separated record in individual fields and
>  AS> removes any trailing spaces from each field. Whenever a record is too
>  AS> short, I experience an error message. I would prefer not to get an
>  AS> error message and have an empty field rather than an undefined
>  AS> field. The last data line contains a TAB but no middle name.
>
>  AS>         my @ris_list = map { s/\s+$//; $_ } quotewords ('\t', 0, $_);
>
>simple, make sure $_ has at least a null string in there. and i would do
>this in two lines. modifying $_ inside map is not the clearest code. map
>is best used to generate new lists and foreach is best used to modify
>existing lists.
>
>         my @ris_list = map { $_ || '' } quotewords ('\t', 0, $_);
>
Thank you for your quick replay. It works great, except when one of the 
fields contains the value '0'. It is then replaced by a blank field. Any 
suggestions ?

>	 s/\s+$// for @ris_lists ;
>
>uri
>
>  
>
Alex

-- 
All man's miseries derive from not being able to sit quietly in a room alone. (Pascal)



--------------010001070000020201030203
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1">
  <title></title>
</head>
<body>
<br>
Uri Guttman wrote:<br>
<blockquote type="cite" cite="midx7fzp3rsbc.fsf@mail.sysarch.com">
  <blockquote type="cite">
    <blockquote type="cite">
      <blockquote type="cite">
        <blockquote type="cite">
          <blockquote type="cite">
            <pre wrap="">"AS" == Alexander Stremitzer <a class="moz-txt-link-rfc2396E" href="mailto:stremitz@consultant.com">&lt;stremitz@consultant.com&gt;</a> writes:
            </pre>
          </blockquote>
        </blockquote>
      </blockquote>
    </blockquote>
  </blockquote>
  <pre wrap=""><!---->
  AS&gt; My program splits a tab separated record in individual fields and
  AS&gt; removes any trailing spaces from each field. Whenever a record is too
  AS&gt; short, I experience an error message. I would prefer not to get an
  AS&gt; error message and have an empty field rather than an undefined
  AS&gt; field. The last data line contains a TAB but no middle name.

  AS&gt;         my @ris_list = map { s/\s+$//; $_ } quotewords ('\t', 0, $_);

simple, make sure $_ has at least a null string in there. and i would do
this in two lines. modifying $_ inside map is not the clearest code. map
is best used to generate new lists and foreach is best used to modify
existing lists.

         my @ris_list = map { $_ || '' } quotewords ('\t', 0, $_);</pre>
</blockquote>
Thank you for your quick replay. It works great, except when one of the fields
contains the value '0'. It is then replaced by a blank field. Any suggestions
?<br>
<blockquote type="cite" cite="midx7fzp3rsbc.fsf@mail.sysarch.com">
  <pre wrap="">
	 s/\s+$// for @ris_lists ;

uri

  </pre>
</blockquote>
Alex<br>
<pre class="moz-signature" cols="$mailwrapcol">-- 
All man's miseries derive from not being able to sit quietly in a room alone. (Pascal)</pre>
<br>
</body>
</html>

--------------010001070000020201030203--




------------------------------

Date: Tue, 1 Apr 2003 01:36:49 +0200
From: "henq" <henq _ replace 0 by o <hvtijen@h0tmail.c0m>>
Subject: Re: webhosts that support perl well?
Message-Id: <3e88d09a$0$139$1b62eedf@news.wanadoo.nl>

www.digitalspace.net   (happy customer)


>
> anyway, if anyone has a couple hosts they like to use, that support
> custom perl scripts in user cgi-bin, and hopefully other common
> features like .htaccess for specific password protection, please post
> their URL so I can go check them out....
>
> mucho gracias,

de nada


> D


~h




------------------------------

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 4796
***************************************


home help back first fref pref prev next nref lref last post