[22792] in Perl-Users-Digest
Perl-Users Digest, Issue: 5013 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue May 20 14:10:49 2003
Date: Tue, 20 May 2003 11:10:17 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Tue, 20 May 2003 Volume: 10 Number: 5013
Today's topics:
Perl: Regex help request (deepak p)
Re: Perl: Regex help request <krahnj@acm.org>
Re: Perl: Regex help request <mbudash@sonic.net>
Re: PHP or Perl ? <kah@kahnews.cjb.net>
Re: PHP or Perl ? <zak@mighty.co.za>
Re: PHP or Perl ? <zak@mighty.co.za>
Re: removing a word using a regexp doesn't w =?ISO-8859 <bigj@kamelfreund.de>
string operation question <a@b.c>
Re: string operation question <nobull@mail.com>
Re: string operation question <krahnj@acm.org>
Re: Using Web services from Perl (Pierre-Philippe Ravier)
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 20 May 2003 10:00:18 -0700
From: deepak10000@hotmail.com (deepak p)
Subject: Perl: Regex help request
Message-Id: <9e77c6b2.0305200900.627cea11@posting.google.com>
Dear Colleagues,
I need to replace null values in a pipe separated data file with 0.
There is one record per line and my env is perl 5.61 on Solaris if
that matters.
The first line of the data line is shown below along with what I would
like to change it to.
before
Line 1|550|152|154|29|3|1|||||||
would like it to be changed to
Line 1|550|152|154|29|3|1|0|0|0|0|0|0|0
I'm reading line-by-line and a snippet of code is pasted below.
If anyone can show me how to apply the substitute command or do it any
other way to get the desired result, I would appreciate it greatly.
$File_In = "file.txt";
open (FILE_IN, $File_In) or die "Can't read $File_In: $!";
while (<FILE_IN2) {
chomp;
print "Dollar_under before is $_\n";
s/\|\|/\|0\|/g;
print "Dollar_under after is $_\n";
}
The above prints
Dollar_under before is Line 1|550|152|154|29|3|1|||||||
Dollar_under after is Line 1|550|152|154|29|3|1|0||0||0||
.
.
Similarly rest of the data lines are printed. As you can see, its
printing something different than what I want..hence, I'm not applying
the substitute command correctly. Thanks for help and sharing of
knowledge in advance.
Regards,
Deepak
------------------------------
Date: Tue, 20 May 2003 17:36:00 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: Perl: Regex help request
Message-Id: <3ECA6733.DA5F914E@acm.org>
deepak p wrote:
>
> I need to replace null values in a pipe separated data file with 0.
> There is one record per line and my env is perl 5.61 on Solaris if
> that matters.
>
> The first line of the data line is shown below along with what I would
> like to change it to.
>
> before
> Line 1|550|152|154|29|3|1|||||||
>
> would like it to be changed to
> Line 1|550|152|154|29|3|1|0|0|0|0|0|0|0
>
> I'm reading line-by-line and a snippet of code is pasted below.
> If anyone can show me how to apply the substitute command or do it any
> other way to get the desired result, I would appreciate it greatly.
>
> $File_In = "file.txt";
>
> open (FILE_IN, $File_In) or die "Can't read $File_In: $!";
>
> while (<FILE_IN2) {
> chomp;
> print "Dollar_under before is $_\n";
> s/\|\|/\|0\|/g;
> print "Dollar_under after is $_\n";
> }
>
> The above prints
> Dollar_under before is Line 1|550|152|154|29|3|1|||||||
> Dollar_under after is Line 1|550|152|154|29|3|1|0||0||0||
> .
> Similarly rest of the data lines are printed. As you can see, its
> printing something different than what I want..hence, I'm not applying
> the substitute command correctly. Thanks for help and sharing of
> knowledge in advance.
I can think of two ways to do it:
$_ = join '|', map $_ || 0, split /\|/, $_, -1;
s/(?<=\|)(?=\||$)/0/g;
John
--
use Perl;
program
fulfillment
------------------------------
Date: Tue, 20 May 2003 17:36:40 GMT
From: Michael Budash <mbudash@sonic.net>
Subject: Re: Perl: Regex help request
Message-Id: <mbudash-CF6391.10364020052003@typhoon.sonic.net>
In article <9e77c6b2.0305200900.627cea11@posting.google.com>,
deepak10000@hotmail.com (deepak p) wrote:
> Dear Colleagues,
>
> I need to replace null values in a pipe separated data file with 0.
> There is one record per line and my env is perl 5.61 on Solaris if
> that matters.
>
> The first line of the data line is shown below along with what I would
> like to change it to.
>
> before
> Line 1|550|152|154|29|3|1|||||||
>
> would like it to be changed to
> Line 1|550|152|154|29|3|1|0|0|0|0|0|0|0
>
> I'm reading line-by-line and a snippet of code is pasted below.
> If anyone can show me how to apply the substitute command or do it any
> other way to get the desired result, I would appreciate it greatly.
>
> $File_In = "file.txt";
>
> open (FILE_IN, $File_In) or die "Can't read $File_In: $!";
>
> while (<FILE_IN2) {
> chomp;
> print "Dollar_under before is $_\n";
> s/\|\|/\|0\|/g;
> print "Dollar_under after is $_\n";
> }
>
> The above prints
> Dollar_under before is Line 1|550|152|154|29|3|1|||||||
> Dollar_under after is Line 1|550|152|154|29|3|1|0||0||0||
> .
> .
> Similarly rest of the data lines are printed. As you can see, its
> printing something different than what I want..hence, I'm not applying
> the substitute command correctly. Thanks for help and sharing of
> knowledge in advance.
>
> Regards,
> Deepak
s/\|(?=(\||$))/\|0/g;
hth-
--
Michael Budash
------------------------------
Date: Tue, 20 May 2003 15:49:46 GMT
From: KAH <kah@kahnews.cjb.net>
Subject: Re: PHP or Perl ?
Message-Id: <Xns9381B5816C0F4kahatkahnewsdotcjbdo@193.213.112.21>
Isofarro <spamblock@spamdetector.co.uk> wrote in
news:574bab.ab1.ln@sidious.isolani.co.uk:
>> There is a slight bias towards PHP on webhosts perhaps. Most of them
>> however have at least both of them.
>
> That's a pity really - I don't see many established web hosts offering
> mod_perl. If that were available, I'd certainly opt for Perl rather
> than PHP, purely because its much easier to do big web applications
> and portal type applications with Perl.
>
> PHP is a bit of a nightmare when the application grows. At least with
> Perl the app can be broken down to a set of modules.
It only becomes a nightmare if you let it. If you put PHP's OO (it may be
rather simple in PHP4, but still works) and dynamic script inclusion to
use, you can get a very nice, easy to browse codebase. It's all in the
hands of the actual coder(s).
KAH
------------------------------
Date: Tue, 20 May 2003 17:50:31 +0200
From: Zak McGregor <zak@mighty.co.za>
Subject: Re: PHP or Perl ?
Message-Id: <badis6$2hl$1@ctb-nnrp2.saix.net>
On Sun, 18 May 2003 13:05:46 +0200, J.O. Aho <"J.O. Aho"
<user@example.net>> wrote:
[snip]
> I have seen people to start to use php-scripts in their crontab, to do a
> lot different jobs for them. PHP is quite useble outside the web too,
> even if it has been mainly developed for web use. Wouldn't surprise me
> if we would have an extention of PHP in a couple of years that will
> handle GUI and other stuff too.
I'm afraid that PHP shows its lack of maturity far too often for it to be a
genuinely useful language, even for pre-parsing html. IMHO it is going to
be much more worthwhile for the neophyte to take the time to learn perl
first. Once familiar with perl, try out PHP for a bit (IMHO it is easier
to move perl -> php than php -> perl, although the former would be
merely a temporary dabble, the latter a permanent shift) and then
code forever merrily in perl. Which is after all, the way god intended
;-)
Ciao
Zak
--
========================================================================
http://www.carfolio.com/ Searchable database of 10 000+ car specs
========================================================================
------------------------------
Date: Tue, 20 May 2003 17:59:33 +0200
From: Zak McGregor <zak@mighty.co.za>
Subject: Re: PHP or Perl ?
Message-Id: <badjd4$2o2$1@ctb-nnrp2.saix.net>
On Sun, 18 May 2003 19:39:55 +0200, spaghetti <"spaghetti"
<spaghetti@aspyre.net>> wrote:
[snip]
> <div id="errormessage"></div>
>
> In a code behind file I can do this:
>
> errormessage.InnerHTML = "There was a big problem and everyone is gonna
> die!"
>
> And it'll render this:
>
> <div id="errormessage">There was a big problem and everyone is gonna
> die!</div>
And if there is no errormessage? Does it leave the empty <div...></div>?
Without knowing anything more about how this implementation works, it
seems like there could also be complications in the way this
transformation occurs. But hey, if it floats your boat, feel free to
prioritise convenience over all else.
Ciao
Zak
--
========================================================================
http://www.carfolio.com/ Searchable database of 10 000+ car specs
========================================================================
------------------------------
Date: Tue, 20 May 2003 14:57:47 +0200
From: "Janek Schleicher" <bigj@kamelfreund.de>
Subject: Re: removing a word using a regexp doesn't w =?ISO-8859-1?Q?ork_with_the_characters_'=E5',_'=E4'_and_'=F6'?=
Message-Id: <pan.2003.05.20.12.57.44.46822@kamelfreund.de>
Leif Wessman wrote at Tue, 20 May 2003 06:45:19 -0700:
> $text = "det mandelträdet";
> $text =~ s/\bdet\b//ig;
>
> result : "mandelträ"
> expected: "mandelträdet"
>
> Why isn't å,ä and ö working. Is there a workaround?
perldoc perllocale is your answer on the long run.
But, of course, there's a workaround:
$text =~ s/(?<![\wÄÖÜäöü])det(?![\wÄÖÜäöü])/ig;
allthough it's neither nice nor easy to maintain
(and is still wrong with an ß or similar).
Greetings,
Janek
------------------------------
Date: Tue, 20 May 2003 18:07:19 +0200
From: ZZT <a@b.c>
Subject: string operation question
Message-Id: <badjrn$t88$1@news1.wdf.sap-ag.de>
Hello all,
I process the following datas:
-------------------- --------------- ------
xxx xxxxx xxxx0855 Online
xxxxxx xxxxxx xxxx0856 Online
The line with the "-"'s resp. the numbers of "-" can and have to be used
to process the following lines and to separarte each column (3 per
line). How can I do this simplest?
thanks & regards
------------------------------
Date: 20 May 2003 17:45:52 +0100
From: Brian McCauley <nobull@mail.com>
Subject: Re: string operation question
Message-Id: <u9znlhh8hr.fsf@wcl-l.bham.ac.uk>
ZZT <a@b.c> writes:
> I process the following datas:
>
> -------------------- --------------- ------
> xxx xxxxx xxxx0855 Online
> xxxxxx xxxxxx xxxx0856 Online
>
> The line with the "-"'s resp. the numbers of "-" can and have to be
> used to process the following lines and to separarte each column (3
> per line). How can I do this simplest?
That's an interesting question. And one I'd usually answer. But then
I remebered someting...
http://groups.google.com/groups?selm=slrnavcnhi.3lq.tadmc%40magna.augustmail.com
http://groups.google.com/groups?q=author%3Aa@b.c+group%3Acomp.lang.perl.*
Have you turned over a new leaf or are you planning to carry on as before?
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Tue, 20 May 2003 17:09:19 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: string operation question
Message-Id: <3ECA60E5.8EC2F9BF@acm.org>
ZZT wrote:
>
> I process the following datas:
>
> -------------------- --------------- ------
> xxx xxxxx xxxx0855 Online
> xxxxxx xxxxxx xxxx0856 Online
>
> The line with the "-"'s resp. the numbers of "-" can and have to be used
> to process the following lines and to separarte each column (3 per
> line). How can I do this simplest?
One way to do it:
my @lens;
while ( <DATA> ) {
next unless /\S/;
/^[ -]+$/ and @lens = map length, /-+/g and next;
my @fields = unpack join( '', map "A$_ x", @lens ), $_;
# do something with @fields
}
__DATA__
-------------------- --------------- ------
xxx xxxxx xxxx0855 Online
xxxxxx xxxxxx xxxx0856 Online
John
--
use Perl;
program
fulfillment
------------------------------
Date: 20 May 2003 08:44:48 -0700
From: ppravier@hotmail.com (Pierre-Philippe Ravier)
Subject: Re: Using Web services from Perl
Message-Id: <153eb4a6.0305200744.43be6bcd@posting.google.com>
sholden@flexal.cs.usyd.edu.au (Sam Holden) wrote in message news:<slrnbcfr6l.foq.sholden@flexal.cs.usyd.edu.au>...
> On 18 May 2003 13:18:32 -0700,
> Pierre-Philippe Ravier <ppravier@hotmail.com> wrote:
> > Hi,
> >
> > I would like to know how can I use Web-Services from Perl ? The
> > Web-Service exposes its functions with the SOAP protocol over HTTP.
> > I have seen in some messages here that some SOAP modules exist for
> > Perl, which makes me hope all these things are possible.
>
> If googling for "perl SOAP" didn't explain the answer to you, nothing
> I could write would.
Indeed. www.soaplite.com seems a very fine example of what I am looking for.
I don't know why I didn't find it in the first place, well that's fine now.
Impressive piece of software by the way.
Thanks and sorry for the dummy question.
------------------------------
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 5013
***************************************