[17723] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5143 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Dec 18 18:10:48 2000

Date: Mon, 18 Dec 2000 15:10:20 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <977181020-v9-i5143@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Mon, 18 Dec 2000     Volume: 9 Number: 5143

Today's topics:
    Re: Language evolution C->Perl->C++->Java->Python (Is P <just_me@nowhere.com>
    Re: Language evolution C->Perl->C++->Java->Python (Is P <russ_jones@rac.ray.com>
        mod_perl install problem <johnson@bonaire.nmr.mgh.harvard.edu>
    Re: mod_perl install problem <randy@theoryx5.uwinnipeg.ca>
        My apologies everyone for multiple posts. msalerno@my-deja.com
        Named Pipe blocking problem solved (Gregory Spath)
    Re: newbie question - dbi:xbase <jeff@vpservices.com>
    Re: newbie question - dbi:xbase <kolisko@penguin.cz>
    Re: newsgroup statistics script in perl (Richard Zilavec)
    Re: One-Liner to Sum a Stack of Numbers? <anmcguire@my-deja.com>
    Re: One-Liner to Sum a Stack of Numbers? (Martien Verbruggen)
    Re: One-Liner to Sum a Stack of Numbers? <nospam@nospam.com>
        Please help - split question? <kmiller@2xtreme.net>
    Re: please helpme (Abigail)
    Re: RegEx: \s but not \n (Sean McAfee)
    Re: Sendmail script problems (Richard Zilavec)
        should subroutines do their own error checking? <jesse@uchicago.edu>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Mon, 18 Dec 2000 20:15:27 +0100
From: Just Me <just_me@nowhere.com>
Subject: Re: Language evolution C->Perl->C++->Java->Python (Is Python the   ULTIMATE oflanguages??)
Message-Id: <3A3E624F.DED472AD@nowhere.com>

Well, now I really wonder why people have to reinvent the wheel over and over
again. Smalltalk has been here since the 80's and has proven its value on many
serious projects but in the last couple of years or so I am seeing a flood of new
languages every year. It's like a tower of Babel. We all had VisualWorks Smalltalk
doing exactly the same thing as Java and Python are doing now already 10 years ago
and still these things are regarded as something new... I guess it's a matter of
taste, some people like a syntax like this and some people prefer something else.
But I for sure am not prepared to switch from my Smalltalk/ENVY IDE to some
primitive text editor and file based versioning tool just to be able to do some
Python (what kind of a name is this anyway?).

BTW: I guess what you were measuring there was the speed of printing the result and
not how fast the factorial is calculated since just doing 1000 iterations could
never take sooo long, or does it?

Chris Fedde wrote:

> In article <3A3C920C.35794C90@nowhere.com>,
> Just Me  <just_me@nowhere.com> wrote:
> >Try writing this in your favourite language:
> >
> >    1000 factorial
> >        -> a very large number which causes overflow if
> >            not evaluated in Smalltalk
> >
>
> Here is one in perl...
>
>     cat fact.pl
>     use Math::BigInt;
>
>     sub fact {
>         my $n = shift;
>         if ($n == 0){
>             return 1;
>         } else {
>             return $n * fact($n-1);
>         }
>     }
>
>     print fact(Math::BigInt->new($ARGV[0])), "\n";
>
> It's not very fast though:
>
>     real    0m10.433s
>     user    0m10.104s
>     sys     0m0.033s
>
> Ruby seems to be able to do it much faster...
>
> $ cat fact.rb
> def fact(n)
>     if n == 0
>         1
>     else
>         n * fact(n-1)
>     end
> end
>
> $ print fact(ARGV[0].to_i), "\n"
>
> time ruby fact.rb 1000
>
> real    0m0.129s
> user    0m0.086s
> sys     0m0.034s
>
> Ruby is very much like smalltalk with a procedural language verneer and
> many of the 'good things' from Perl.
>
> Both output what I suspect is the correct value...
>
> 4023872600770937735437024339230039857193748642107146325437999104299385123986290
> 2059204420848696940480047998861019719605863166687299480855890132382966994459099
> 7424504087073759918823627727188732519779505950995276120874975462497043601418278
> 0946464962910563938874378864873371191810458257836478499770124766328898359557354
> 3251318532395846307555740911426241747434934755342864657661166779739666882029120
> 7379143853719588249808126867838374559731746136085379534524221586593201928090878
> 2973084313928444032812315586110369768013573042161687476096758713483120254785893
> 2076716913244842623613141250878020800026168315102734182797770478463586817016436
> 5024153691398281264810213092761244896359928705114964975419909342221566832572080
> 8213331861168115536158365469840467089756029009505376164758477284218896796462449
> 4516076535340819890138544248798495995331910172335555660213945039973628075013783
> 7615307127761926849034352625200015888535147331611702103968175921510907788019393
> 1781141945452572238655414610628921879602238389714760885062768629671466746975629
> 1123408243920816015378088989396451826324367161676217916890977991190375403127462
> 2289988005195444414282012187361745992642956581746628302955570299024324153181617
> 2104658320367869061172601587835207515162842255402651704833042261439742869330616
> 9089796848259012545832716822645806652676995865268227280707578139185817888965220
> 8164348344825993266043367660176999612831860788386150279465955131156552036093988
> 1806121385586003014356945272242063446317974605946825731037900840244324384656572
> 4501440282188525247093519062092902313649327349756551395872055965422874977401141
> 3346962715422845862377387538230483865688976461927383814900140767310446640259899
> 4902222217659043399018860185665264850617997023561938970178600408118897299183110
> 2117122984590164192106888438712185564612496079872290851929681937238864261483965
> 7382291123125024186649353143970137428531926649875337218940694281434118520158014
> 1233448280150513996942901534830776445690990731524332782882698646027898643211390
> 8350621709500259738986355427719674282224875758676575234422020757363056949882508
> 7968928162753848863396909959826280956121450994871701244516461260379029309120889
> 0869420285106401821543994571568059418727489980942547421735824010636774045957417
> 8516082923013535808184009699637252423056085590370062427124341690900415369010593
> 3983835777939410970027753472000000000000000000000000000000000000000000000000000
> 0000000000000000000000000000000000000000000000000000000000000000000000000000000
> 0000000000000000000000000000000000000000000000000000000000000000000000000000000
> 0000000000000000000000000000000000000000
>
> chris
> --
>     This space intentionally left blank



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

Date: Mon, 18 Dec 2000 14:31:07 -0600
From: Russ Jones <russ_jones@rac.ray.com>
Subject: Re: Language evolution C->Perl->C++->Java->Python (Is Python the  ULTIMATE of  	languages??)
Message-Id: <3A3E740B.5413C28D@rac.ray.com>

Uri Guttman wrote:
> 
> flame bait. go the fuck away. you obviously know not from what you
> blather.
>

 

Sure were a lot of 'em, huh Uri?




-- 
Russ Jones - HP OpenView IT/Operatons support
Raytheon Aircraft Company, Wichita KS
russ_jones@rac.ray.com 316-676-0747

Quae narravi, nullo modo negabo. - Catullus


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

Date: 18 Dec 2000 19:41:58 GMT
From: Chris Johnson <johnson@bonaire.nmr.mgh.harvard.edu>
Subject: mod_perl install problem
Message-Id: <91lpa6$fgl$1@hpngsv01.mgh.harvard.edu>

     Hi all,

     If there is a better place to ask this please let me know and I
will use it.

     Trying to install mod_perl-1.24 on apache-1.3.14.  Tried both
with and without mod_ssl-2.7.1-1.3.14 in first.  Mod_perl always gives
the following

************* WARNING *************

  Apache Version 1.3.0 required, aborting...

************* WARNING *************

This is on a SunOS4 system.  Does anyone have a clue as to what might
be wrong?  I've successfully donethis before although not on a SunOS4
system.  Help appreciated.


-------------------------------------------------------------------------------
Chris Johnson               |Internet: johnson@nmr.mgh.harvard.edu
Systems Administrator       |Web:      http://www.nmr.mgh.harvard.edu/~johnson
NMR Center                  |Voice:    617.724.
Mass. General Hospital      |FAX:      617.726.7422
149 (2301) 13th Street      |Life stinks.  If you're very lucky, sometimes
Charletown, MA., 02129 USA  |it stinks a little less.  Me
-------------------------------------------------------------------------------


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

Date: 18 Dec 2000 21:39:40 GMT
From: Randy Kobes <randy@theoryx5.uwinnipeg.ca>
Subject: Re: mod_perl install problem
Message-Id: <91m06s$slo$1@canopus.cc.umanitoba.ca>

In comp.lang.perl.misc, 
  Chris Johnson <johnson@bonaire.nmr.mgh.harvard.edu> wrote:

>      Trying to install mod_perl-1.24 on apache-1.3.14.  Tried both
> with and without mod_ssl-2.7.1-1.3.14 in first.  Mod_perl always gives
> the following
> ************* WARNING *************
>   Apache Version 1.3.0 required, aborting...
> ************* WARNING *************

Try mod_perl-1.24_01.tar.gz from 
http://www.cpan.org/CPAN/authors/id/D/DO/DOUGM/.

best regards,
randy kobes


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

Date: Mon, 18 Dec 2000 19:41:18 GMT
From: msalerno@my-deja.com
Subject: My apologies everyone for multiple posts.
Message-Id: <91lp8t$6jh$1@nnrp1.deja.com>

I was posting the filehandle message and Deja gave me a few errors that
it didn't post.  So I tried again and got the same error.  I apologize
for the multiple posts, it was not what I had intended to do.

Matt


Sent via Deja.com
http://www.deja.com/


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

Date: Mon, 18 Dec 2000 22:51:00 -0000
From: gspath@freefall.homeip.net (Gregory Spath)
Subject: Named Pipe blocking problem solved
Message-Id: <slrn93t54l.di4.gspath@freefall.homeip.net>

Thanks for everyone's help.  I found a way to do what I want, and I don't have
to fork as many processes doing it this way either.

I discovered today that you can use select and bit-vectors, or more easily, the
IO::Select module to test for data ready in a filehandle.  Performing the
following stops hangups in my code due to FIFO blocks from happening: 

use IO::Select;

$select = IO::Select->new();
$select->add(*FILEHANDLE);
if (@ready = $select->can_read(0)){
	# safe to read from each filehandle in @ready (just FILEHANDLE in this case)
}


I'm doing this with a FIFO (named pipe) read successfully (ie, opened as "<
/named/pipe/file")

-- Greg

-- 
Gregory Spath              
gspath@freefall.homeip.net   http://freefall.homeip.net/
SCHeckler on IRC ----------> http://freefall.homeip.net/javairc/
Team YBR ------------------> http://www.yellowbreechesracing.org/


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

Date: Mon, 18 Dec 2000 13:07:18 -0800
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: newbie question - dbi:xbase
Message-Id: <3A3E7C86.13C92860@vpservices.com>

Michal Kolesar wrote:
> 
> when I tried run it i get error message:
> DBD::xbase initialisation failed: Can't locate object method "driver" via
> package
> "DBD::xbase" at d:/michal/programfiles/perl/site/lib/dbi.pm line 511.
> Perhaps the capitalisation of DBD 'xbase' isn't right. at noname1.pl line 8

Look at the last line of the error message: "Perhpas the capitalisation
of DBD 'xbase' insn't right."  What if, by some strange coincidence that
happened to be your problem and the driver's name was XBase instead of
xbase?  Wow imagine that, the error message means something!  What will
these programmers think of next?

-- 
Jeff


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

Date: Tue, 19 Dec 2000 01:45:05 +0100
From: "Michal Kolesar" <kolisko@penguin.cz>
Subject: Re: newbie question - dbi:xbase
Message-Id: <91m430$2vir$1@news.vol.cz>


"Jeff Zucker" <jeff@vpservices.com> wrote in message
news:3A3E7C86.13C92860@vpservices.com...
> Michal Kolesar wrote:
> >
> > when I tried run it i get error message:
> > DBD::xbase initialisation failed: Can't locate object method "driver"
via
> > package
> > "DBD::xbase" at d:/michal/programfiles/perl/site/lib/dbi.pm line 511.
> > Perhaps the capitalisation of DBD 'xbase' isn't right. at noname1.pl
line 8
>
> Look at the last line of the error message: "Perhpas the capitalisation
> of DBD 'xbase' insn't right."  What if, by some strange coincidence that
> happened to be your problem and the driver's name was XBase instead of
> xbase?  Wow imagine that, the error message means something!  What will
> these programmers think of next?

Thank You very much.
My english is not good and I dont thought that 'capitalisation' is a synonym
to case
sensitive....
And I am newbie to perl.. and I don't know, that perl is case sensitive
language..

sorry...
I change it to XBase and now is all OK!

>
> --
> Jeff




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

Date: Mon, 18 Dec 2000 19:30:37 GMT
From: rzilavec@tcn.net (Richard Zilavec)
Subject: Re: newsgroup statistics script in perl
Message-Id: <3a3e6491.756927@news.tcn.net>

On 15 Dec 2000 23:58:16 GMT, nova@moo.pl (Mariusz Drozdziel) wrote:

>	Does anybody has something for easy creating newsgroup's
>statictis? I want it in perl, becouse propably i will have to 
>change this, but i have no time to write something like this
>from scrath.... :-/

Try going to http://search.cpan.org and search for News... 


--
 Richard Zilavec
 rzilavec@tcn.net


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

Date: Mon, 18 Dec 2000 21:33:20 GMT
From: Andrew N McGuire <anmcguire@my-deja.com>
To: andrew.mcguire@walgreens.com
Subject: Re: One-Liner to Sum a Stack of Numbers?
Message-Id: <91lvr0$cm7$1@nnrp1.deja.com>

In article <slrn93rvmp.bel.abigail@tsathoggua.rlyeh.net>,
  abigail@foad.org wrote:
> Andrew N. McGuire (anmcguire@ce.mediaone.net) wrote on MMDCLXVI
September
> MCMXCIII in <URL:news:86hf42dx57.fsf@hawk.ce.mediaone.net>:
> <>
> <> >>>>> "A" == Abigail  <abigail@foad.org> writes:
> <>
> <> A> On Sat, 16 Dec 2000 01:20:06 GMT, SuperGumby
(tick.toff@spam.com) wrote
> <> A> ++ OK OK, having just commented in another post on the
proliferation of
> <> A> ++ oneliners,,, How can this be described as a oneliner ?
Theoretically it
> <> A> ++ seems to me any perl program can be written sans <cr> but
this thing ha
> <> A> ++ 'statement terminator' in the middle of it.
> <>
> <> A> Perl doesn't have statement terminator.
> <>
> <> [ snip ]
> <>
> <>   Sure it does, ';' is a statement terminator.
>
> Could you come with a reference (in the Camel III, or the standard
> documentation) for that?

Certainly, Camel III page 49.  (See index as well)

[anm@eagle ~] nroff -man /usr/local/man/man1/perlsyn.1 | grep terminat
     terminated with a semicolon, unless it is the final
     expression), and thus need an explicit termination if used
     modifier, just before the terminating semicolon (or block
     terminating the inner one.  And it's faster because Perl

> And furthermore, could you please explain:
>
>     $ perl -wce 'print "This is a statement with no terminator"'
>     -e syntax OK

  The perlsyn manpage explains if for me.

> How could the syntax be ok if Perl would have statement terminators?

  I never said that ';' is the only way to terminate a perl statement,
just A way.  The last statement in a block does not need to be
terminated, with a semicolon that is.

anm


--
$ENV{PAGER} = 'perl -wpe0';
system perldoc => '-t', '-F', $0;

=head1 Just Another Perl Hacker


Sent via Deja.com
http://www.deja.com/


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

Date: Mon, 18 Dec 2000 22:00:44 GMT
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: One-Liner to Sum a Stack of Numbers?
Message-Id: <slrn93t24a.j5f.mgjv@verbruggen.comdyn.com.au>

On Mon, 18 Dec 2000 10:09:15 GMT,
	SuperGumby <tick.toff@spam.com> wrote:
> seperator, terminator, schmirminator,,, this seems to be just a label.
> 
> before I go further: am I right ? from my newbie perspective ? that one
> could strip all whitespace from a perl script and expect it to run correctly
> ? Theoretically making all perl scripts "oneliners" (except those with here
> documents, I suppose, I'll probably learn of other exceptions as I walk the
> path).

You are wrong. Try it.

> and before I again get in trouble for "jeopardy" posting, please be aware:

Killfiled you at home.Now I'll do the same here. You've been told, and
yet you persist. You're a troll. Your fake email address makes that
clear as well, doesn't it? You do it on purpose.

Martien
-- 
Martien Verbruggen              | 
Interactive Media Division      | 42.6% of statistics is made up on the
Commercial Dynamics Pty. Ltd.   | spot.
NSW, Australia                  | 


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

Date: 18 Dec 2000 23:03:27 GMT
From: The WebDragon <nospam@nospam.com>
Subject: Re: One-Liner to Sum a Stack of Numbers?
Message-Id: <91m53v$ao7$0@216.155.33.105>

In article <fnl%5.23209$xW4.177588@news-server.bigpond.net.au>, 
"SuperGumby" <tick.toff@spam.com> wrote:

 | 
 | and before I again get in trouble for "jeopardy" posting, please be 
 | aware:
 | 
 | I do not do it to annoy people, I believe what I refer to as "top 
 | posting" is a much better alternative to "bottom posting", which is 
 | EVIL.

how can it be evil? 

Let me explain what top-posting promotes, which IS evil:

o it promotes people leaving in multiple .sig lines (waste of bandwidth)

o it promotes people NOT editing the previous post to remove extraneous 
content they are not replying to (waste of bandwidth)

o it promotes the impression that the poster didn't bother to even READ 
the post he/she is replying to, and generally the content of the 
top-posted material reflects that presumption. (extreme waste of 
bandwidth :)

o and last, but far from least, people don't read news from bottom to 
top, they read news from top to bottom (and by news I mean ANYTHING in 
print, period) (except for our oriental friends and some other foreign 
languages) 

to "follow up" is just that.. that's why they call it Jeopardy Quoting, 
because on the Game Show "Jeopardy" the answer comes before the 
question. and that, in a public forum, is truely evil considering the 
waste of bandwidth that generally follows such practices. 

If you don't like it, find somewhere else to post. 

You're not annoyed, you're just lazy. :P 
We want you to work a little, and THAT annoys you. =:P

-- 
send mail to mactech (at) webdragon (dot) net instead of the above address. 
this is to prevent spamming. e-mail reply-to's have been altered 
to prevent scan software from extracting my address for the purpose 
of spamming me, which I hate with a passion bordering on obsession.  


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

Date: Mon, 18 Dec 2000 21:42:37 GMT
From: "KMiller@2xtreme.net" <kmiller@2xtreme.net>
Subject: Please help - split question?
Message-Id: <hxv%5.105$OH2.20081@news-west.eli.net>

I'm trying to convert a postgres table listing into a hash.
I'm getting a set of blank elements from split.
I can't figure out where they're coming from.

The listing:
---- start of listing ---
Showing only tuples.
 submitter | char(3)   |
 filler1   | char(11)  |
 subdate   | char(4)   |
 filler2   | char(4)   |
 rectype   | char(1)   |
 subname   | char(33)  |
 claimcnt  | char(6)   |
 billval   | char(9)   |
 provcnt   | char(3)   |
 createdat | char(6)   |
 remcnt    | char(6)   |
 certstmt  | char(108) |
 flller3   | char(6)   |

---- end of listing ---

Some test code:

#!/usr/bin/perl -w

map { /\S/ && push @tablist,$_ } map { s'\| $''gm && /(.*)/ && $1 } qx{echo
'\\t \\d subcontrol'|psql omc};

$cnt=0;
for (@tablist) {
    print "tablist line ",$cnt,":",$tablist[$cnt],"\n";
    $cnt++;
}

#print out the would be key/value pairs
map { print "f:$f, t:$t\n";($f,$t)=split(/\|/,$_) } @tablist;

The output:

tablist line 0: submitter | char(3)
tablist line 1: filler1   | char(11)
tablist line 2: subdate   | char(4)
tablist line 3: filler2   | char(4)
tablist line 4: rectype   | char(1)
tablist line 5: subname   | char(33)
tablist line 6: claimcnt  | char(6)
tablist line 7: billval   | char(9)
tablist line 8: provcnt   | char(3)
tablist line 9: createdat | char(6)
tablist line 10: remcnt    | char(6)
tablist line 11: certstmt  | char(108)
tablist line 12: flller3   | char(6)
Use of uninitialized value in concatenation (.) at ./schema.pl line 11.
Use of uninitialized value in concatenation (.) at ./schema.pl line 11.
f:, t:
f: submitter , t: char(3)
f: filler1   , t: char(11)
f: subdate   , t: char(4)
f: filler2   , t: char(4)
f: rectype   , t: char(1)
f: subname   , t: char(33)
f: claimcnt  , t: char(6)
f: billval   , t: char(9)
f: provcnt   , t: char(3)
f: createdat , t: char(6)
f: remcnt    , t: char(6)
f: certstmt  , t: char(108)

I'm stumped.  Any help would be great.

-km





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

Date: 18 Dec 2000 19:32:35 GMT
From: abigail@foad.org (Abigail)
Subject: Re: please helpme
Message-Id: <slrn93spij.ltc.abigail@tsathoggua.rlyeh.net>

Arman (arman2@mixmail.com) wrote on MMDCLXVI September MCMXCIII in
<URL:news:CVr%5.103338$yO2.3036301@telenews.teleline.es>:
:) Hello,
:) 
:) I want to process a log file (750 Mbytes) with perl, but when I execute my
:) perl code it return the error "OUT OF MEMORY". While the execution of code I
:) detect one increment of memory used by the process. The perl process load
:) all log file into memory? Memory used by the process arrive to 450 Mbytes
:) when the error ocurs.
:) 
:) My code used is:
:) 
:) if (!open (FIN, $FicheroLog))
:)     { print "Error: No puedo abrir \"$FicheroLog\" para procesarlo\n";
:) exit; }

That would send your error message to STDOUT, not STDERR, the usual place
for errors. Why not use die?

:) 
:) @bucle = ();
:) 
:) while (<FIN>)
:) {
:)     chomp;
:)     push (@bucle, $_);
:)     # At this point I process bucle
:)     @bucle = ();
:) }

Well, what's the point of that? Why not just process $_ instead of saving
$_ in an array and then processing the array?

:) 
:) close (FIN);
:) 
:) Where is the problem? Anyone have any idea to solve this problem? Wich is
:) the method to process the file line to line and decrease memory used?


Well, if this is all the code, I'd be surprised if it uses that much 
memory. But if for some reason you push $_ again on some array, and don't
clear that array, the memory usuage is obvious.

Please run the above code, with just the loop:

    while (<FIN>) {
	chomp;
	push @buckle, $_;
	@buckle = ()
    }

If the memory problem persists, you've found a bug in Perl. If you don't
have the memory problem then, the leak is in the code you omitted.

It's not nice to pose a problem in this group, but omit the code that is
the source of the problem. Always try to reduce your problem on a small
piece of code that exhibits the problem. This has several major advantages:

    * More often that not, by reducing the code, you find the problem
      by yourself. You've learned something, and you don't have to ask.
    * More people will look at your code instead of just skipping your
      post.
    * It's more likely people will give you a helpful answer instead of
      a 1000 "I don't know but you could try <something stupid>" and
      other people writing posts like this.


Abigail
-- 
perl -we '$@="\145\143\150\157\040\042\112\165\163\164\040\141\156\157\164".
             "\150\145\162\040\120\145\162\154\040\110\141\143\153\145\162".
             "\042\040\076\040\057\144\145\166\057\164\164\171";`$@`'


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

Date: Mon, 18 Dec 2000 20:05:24 GMT
From: mcafee@waits.facilities.med.umich.edu (Sean McAfee)
Subject: Re: RegEx: \s but not \n
Message-Id: <86u%5.11100$O5.298403@news.itd.umich.edu>

In article <91k7f9$rdd@netnews.hinet.net>,
John Lin <johnlin@chttl.com.tw> wrote:
>May I ask a further question?  I want to join lines as well as removing
>the prefixing and trailing spaces.  That is, for those strings
>    "abc\n   def"
>    "abc \n  def"
>    "abc   \ndef"
>    "abc\ndef"
>the results are all "abcdef".  But not for "abc def" because it contains no
>"\n".
>My code is

>    s/[^\S\n]*\n[^\S\n]*//;

>It works.  But I think there is still a lot of space for improvement, right?

Well, maybe a little.  How about:

s/(?=\s*?\n)\s+//;

-- 
Sean McAfee                                                mcafee@umich.edu
print eval eval eval eval eval eval eval eval eval eval eval eval eval eval
q!q@q#q$q%q^q&q*q-q=q+q|q~q:q? Just Another Perl Hacker ?:~|+=-*&^%$#@!


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

Date: Mon, 18 Dec 2000 19:39:34 GMT
From: rzilavec@tcn.net (Richard Zilavec)
Subject: Re: Sendmail script problems
Message-Id: <3a3e6752.1462236@news.tcn.net>

On Mon, 18 Dec 2000 12:03:51 +0100, willem veenhoven
<willem@veenhoven.com> wrote:
>
>> $email = 'mikelin6@home.com';
>
>There must be something wrong with you, Mr. Lin. As many people
>including myself already told you in the .perl group you have to escape
>the '@' in the email. But you just do not listen to all the advice you
>got, and now start to ask the same stupid questions in this group ..

The above code is fine and would only require an escape if it was
surrounded by double quotes.


--
 Richard Zilavec
 rzilavec@tcn.net


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

Date: Mon, 18 Dec 2000 16:48:47 -0600
From: Jesse James Jensen <jesse@uchicago.edu>
Subject: should subroutines do their own error checking?
Message-Id: <3A3E944F.B2B3CD0B@uchicago.edu>

What do you all think?

Say I want to call a subroutine and pass it some variables.  If a
particular one of these variables is empty, I don't want the subroutine
to work its magic.  This check, however, is tangential to the
subroutine; i.e., based on other, more important conditions, I would
want to run the subroutine.  Should I check in the main program and not
run the subroutine, or should I leave the check to the subroutine to
figure out?  Is there a general consenus on this?



Option 1
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
sub increment {
    my ($foo, $bar)  =  @_;

    if ($bar eq "") { return $foo };      # shouldn't happen, but could
    
    $foo++;                               # program usually does this
    return $foo;
}
if ($maincondition = true) {
    &increment( $foo, $bar );
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


Option 2
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
sub increment {
    my ($foo)  =  shift;
    
    $foo++;
    return $foo;
}
if ( ($maincondition = true) and ($bar ne "") ) {
    &increment( $foo );
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


thanks,
jjj

-- 
Jesse James Jensen
jesse@uchicago.edu
http://www.flywheel.org/


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

Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 16 Sep 99)
Message-Id: <null>


Administrivia:

The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

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 V9 Issue 5143
**************************************


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