[18914] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1082 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jun 7 09:10:39 2001

Date: Thu, 7 Jun 2001 06:10:16 -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: <991919416-v10-i1082@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Thu, 7 Jun 2001     Volume: 10 Number: 1082

Today's topics:
    Re: regular exp replacement question (Lan Xing)
    Re: regular exp replacement question (Bernard El-Hagin)
    Re: regular exp replacement question (Matt Williams)
    Re: regular exp replacement question (Bernard El-Hagin)
    Re: Required or executed? <der.prinz@gmx.net>
    Re: Required or executed? (Alan Barclay)
        Searching for a pattern starting from the end of a stri <there_is_no_business_like_showbusiness@_NO_SPAM_hotmail.com>
    Re: Searching for a pattern starting from the end of a  (Anno Siegel)
    Re: Searching for a pattern starting from the end of a  <krahnj@acm.org>
        Starting a background job <michel.wouterse@intec-delft.com>
    Re: Starting a background job <m.grimshaw@salford.ac.uk>
    Re: Starting a background job <gnarinn@hotmail.com>
        Sybase Interface in Perl <priyagirish@worldnet.att.net>
    Re: When renaming files is this agood idea to flock the <helpmeplese@helpmeplese.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 7 Jun 2001 02:05:19 -0700
From: lan_xing@hotmail.com (Lan Xing)
Subject: Re: regular exp replacement question
Message-Id: <2a6ee727.0106070105.1ff7671f@posting.google.com>

Hello there, this is my first posting to peoples' answer.. 
I hope I did not screw up...

Anyway, if you are saying that $x is a scalar varible but not a array, then
the code would be,

$x = "123, \"123,000,00\", 124";

        $x =~ s/"|,\b//g;

print ("\n\n$x");

Lan Xing
=>


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

Date: Thu, 7 Jun 2001 10:04:55 +0000 (UTC)
From: bernard.el-hagin@lido-tech.net (Bernard El-Hagin)
Subject: Re: regular exp replacement question
Message-Id: <slrn9hujnt.8e2.bernard.el-hagin@gdndev25.lido-tech>

On 7 Jun 2001 02:05:19 -0700, Lan Xing <lan_xing@hotmail.com> wrote:
>Hello there, this is my first posting to peoples' answer.. 
>I hope I did not screw up...
>
>Anyway, if you are saying that $x is a scalar varible but not a array, then
>the code would be,
>
>$x = "123, \"123,000,00\", 124";

Why not use single quotes or qq?

$x = '123, "123,000,00", 124';

or

$x = qq/123, "123,000,00", 124/;

>        $x =~ s/"|,\b//g;

What happens if "123,000,00" changes to "123, 000, 00"?

>print ("\n\n$x");

No need for ()'s:

print "\n\n$x";

Cheers,
Bernard
--
perl -l54e's yyw q q tvmrx "h\ywx ersxliv zivp legoiv"qiy;y #a-zA-Z#d-gu-z#
chefghijklmnopqrstuvwxyzcJab-def-uPwxyzc;s j j s u u s t t s r r s
ppevalpereeteueje'


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

Date: 7 Jun 2001 03:52:59 -0700
From: mwilliams@uk.ibm.com (Matt Williams)
Subject: Re: regular exp replacement question
Message-Id: <5f5140d2.0106070252.64e537fe@posting.google.com>

"keng" <keng@spinalfluid.com> wrote in message news:<9fn66j$hnu$1@coco.singnet.com.sg>...
> dear all,
> 
> suppose
> i have a $x = 123, "123,000,00", 124; taken from a csv file.
> how do i strip the double quotes and the commas in the double quotes
> and change it to 123, 12300000, 124
> 
> pls help
> thanks in advance


try this 
#! /usr/bin/perl -w


$x = '123, "123,000,00", 124';
print $x."\n\n";

$x =~ m/(\".*\")/ig;

$temp = $1;

print $temp."\n";
$temp =~ s/\"//ig;

print $temp."\n";
$temp =~ s/\,//ig;

print $temp."\n";
$x =~ s/\".*\"/$temp/ig;

print $x;


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

Date: Thu, 7 Jun 2001 10:56:40 +0000 (UTC)
From: bernard.el-hagin@lido-tech.net (Bernard El-Hagin)
Subject: Re: regular exp replacement question
Message-Id: <slrn9humov.8e2.bernard.el-hagin@gdndev25.lido-tech>

On 7 Jun 2001 03:52:59 -0700, Matt Williams <mwilliams@uk.ibm.com> wrote:
>"keng" <keng@spinalfluid.com> wrote in message news:<9fn66j$hnu$1@coco.singnet.com.sg>...
>> dear all,
>> 
>> suppose
>> i have a $x = 123, "123,000,00", 124; taken from a csv file.
>> how do i strip the double quotes and the commas in the double quotes
>> and change it to 123, 12300000, 124
>> 
>> pls help
>> thanks in advance
>
>
>try this 
>#! /usr/bin/perl -w
>
>
>$x = '123, "123,000,00", 124';
>print $x."\n\n";
>
>$x =~ m/(\".*\")/ig;

No need to escape ". And what's the i for?

And what happens if $x = '1, "123,000,00", 12, "12,44,566"'?

>$temp = $1;
>
>print $temp."\n";
>$temp =~ s/\"//ig;

Again, what's the i there for?

Cheers,
Bernard
--
perl -l54e's yyw q q tvmrx "h\ywx ersxliv zivp legoiv"qiy;y #a-zA-Z#d-gu-z#
chefghijklmnopqrstuvwxyzcJab-def-uPwxyzc;s j j s u u s t t s r r s
ppevalpereeteueje'


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

Date: Thu, 7 Jun 2001 11:23:58 +0200
From: "Stefan Weiss" <der.prinz@gmx.net>
Subject: Re: Required or executed?
Message-Id: <3b1f47ea$1@e-post.inode.at>

Samuel Kilchenmann <skilchen@swissonline.ch> wrote:

[was script required or executed directly]

> perldoc -f caller
 ...
> If you store this as Foo.pm and call perl Foo.pm it will execute the
> bar() function.
> If you use/require this Package in another script it will make the
> Foo::bar() function available but it won't call it.

Thanks Samuel. I hesitated to use caller, because I wanted to have
all the functions that would be repeated in every script in another
module, but passing (caller)[0] to one of the module functions did
the trick.

cheers,
stefan





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

Date: 7 Jun 2001 10:57:15 GMT
From: gorilla@elaine.furryape.com (Alan Barclay)
Subject: Re: Required or executed?
Message-Id: <991911435.45444@elaine.furryape.com>

In article <3b1ecdd9@news.nwlink.com>, Ivo Zdravkov <ivoz@starmail.com> wrote:
>this work, but the style is ... :(
>
>if ($PROGRAM_NAME ne the_script_name){
>    # requred
>}

If you want to do that, you should standardize the name.

If you run a script as ./script, $0 would contain "./script". Putting dot on
your path and Running the same script would give $0 as just "script". Your
test would fail on one of these, even though they are logically the same.

The FindBin module would be a simple way of doing this standardization.


>
>"Stefan Weiss" <der.prinz@gmx.net> wrote in message
>news:3b1eb8fa$1@e-post.inode.at...
>> Hi
>>
>> Is there a way to test if a script has been started either
>>
>>     - directly form a shell: ./script.pl
>>     - passed to perl as parameter: perl script.pl
>>     - called from some other script: system(), exec(), ...
>>
>> or
>>
>>     - require()d from inside a perl script?
>>
>>
>> I only need to seperate the first three from the last. I tried to
>> ckeck if STDIN/STDOUT were terminals, but that did not help.
>>
>>
>> thanks,
>> stefan
>>
>>
>>
>
>




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

Date: Thu, 7 Jun 2001 12:38:56 +0200
From: "Bob Rock" <there_is_no_business_like_showbusiness@_NO_SPAM_hotmail.com>
Subject: Searching for a pattern starting from the end of a string????
Message-Id: <gSIT6.1140$fi2.29693@news.cpqcorp.net>

Hello,
is there a way to have Perl start searching for a given pattern from the end
of a string instead of the beginning of the same? If so could someone make
an example of the syntax to be used?
Thank you.


Regards,
Bob Rock







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

Date: 7 Jun 2001 11:10:37 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Searching for a pattern starting from the end of a string????
Message-Id: <9fnnfd$9hr$1@mamenchi.zrz.TU-Berlin.DE>

According to Bob Rock <there_is_no_business_like_showbusiness@_NO_SPAM_hotmail.com>:
> Hello,
> is there a way to have Perl start searching for a given pattern from the end
> of a string instead of the beginning of the same?

No, not in general.  If you explain your problem in more detail,
it may turn out that there is a solution to what you want.  It may
use one or more of rindex(), reverse() or regex backtracking, or
other techniques.

Anno


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

Date: Thu, 07 Jun 2001 11:12:29 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: Searching for a pattern starting from the end of a string????
Message-Id: <3B1F619D.C820E71F@acm.org>

Bob Rock wrote:
> 
> Hello,
> is there a way to have Perl start searching for a given pattern from the end
> of a string instead of the beginning of the same? If so could someone make
> an example of the syntax to be used?

Have a look at this article:
http://www.perl.com/pub/2001/05/01/expressions.html?wwwrrr_20010515.txt


John
-- 
use Perl;
program
fulfillment


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

Date: Thu, 7 Jun 2001 11:19:38 +0200
From: "Michel" <michel.wouterse@intec-delft.com>
Subject: Starting a background job
Message-Id: <9fng1j$3q8$1@news.unitel.co.kr>

Hi Group,

I got a script taking input from a form and returning a thank you html to
the clients browser. Working just fine and like it's supposed to.
However, now I want to store the gathered information in a database, which
is also piece of cake on itself.
Problem is, I do not want my clients to wait for the database-update to
finish, neither do I want to lock the script....
What I would like to accomplish is this:

Client sends the form
My script opens a BACKGROUND script to write the data in the database, while
the main script returns the thank you page. The returning of the latter
would be first priority (making things surfer-friendlier)

What I do NOT want, is the "parent" script to wait for the "child" process
to finish. (obviously)
What I wouldn't want either is the child process to remain in memory after
it completes. (deuh)

Is there some modules I need to look at? Please point me in the right
direction, someone?

Thank you very very much,

Michel





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

Date: Thu, 07 Jun 2001 11:08:37 +0100
From: Mark Grimshaw <m.grimshaw@salford.ac.uk>
Subject: Re: Starting a background job
Message-Id: <3B1F52A5.4DD7880D@salford.ac.uk>



Michel wrote:
> 
> Hi Group,
> 
> I got a script taking input from a form and returning a thank you html to
> the clients browser. Working just fine and like it's supposed to.
> However, now I want to store the gathered information in a database, which
> is also piece of cake on itself.
> Problem is, I do not want my clients to wait for the database-update to
> finish, neither do I want to lock the script....
> What I would like to accomplish is this:
> 
> Client sends the form
> My script opens a BACKGROUND script to write the data in the database, while
> the main script returns the thank you page. The returning of the latter
> would be first priority (making things surfer-friendlier)
> 
> What I do NOT want, is the "parent" script to wait for the "child" process
> to finish. (obviously)
> What I wouldn't want either is the child process to remain in memory after
> it completes. (deuh)
> 
> Is there some modules I need to look at? Please point me in the right
> direction, someone?
> 
> Thank you very very much,
> 
> Michel

Why use separate scripts?  If you have
$| = 1;
at the top of your script, all your print (to browser) statements get
flushed more or less immediately.  You can send all your browser print
statments before you do any database operations and the clinet would
believe the script had finished before it really had.  However, how do
then inform the client an error has occurred in writing the db if such a
case happens?  Maybe send some data back immediately so the client is
not left wondering if something's happening and then the browser tail
data once the db operations have finished?


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

Date: Thu, 7 Jun 2001 09:58:13 +0000
From: gnari <gnarinn@hotmail.com>
Subject: Re: Starting a background job
Message-Id: <991907893.315439155790955.gnarinn@hotmail.com>

In article <3B1F52A5.4DD7880D@salford.ac.uk>,
Mark Grimshaw  <m.grimshaw@salford.ac.uk> wrote:
>
>
>Michel wrote:
>> 
>> Hi Group,
>> 
>> I got a script taking input from a form and returning a thank you html to
>> the clients browser. Working just fine and like it's supposed to.
>> However, now I want to store the gathered information in a database, which
>> is also piece of cake on itself.
>> Problem is, I do not want my clients to wait for the database-update to
>> finish, neither do I want to lock the script....
>> What I would like to accomplish is this:
>> 
>> Client sends the form
>> My script opens a BACKGROUND script to write the data in the database, while
>> the main script returns the thank you page. The returning of the latter
>> would be first priority (making things surfer-friendlier)
>> 
>> What I do NOT want, is the "parent" script to wait for the "child" process
>> to finish. (obviously)
>> What I wouldn't want either is the child process to remain in memory after
>> it completes. (deuh)
>> 
>> Is there some modules I need to look at? Please point me in the right
>> direction, someone?
>> 
>> Thank you very very much,
>> 
>> Michel
>
>Why use separate scripts?  If you have
>$| = 1;
>at the top of your script, all your print (to browser) statements get
>flushed more or less immediately.  You can send all your browser print
>statments before you do any database operations and the clinet would
>believe the script had finished before it really had.  

i would think this is webserver dependent. the server might want to wait
for the script to finish before sending data.
you might want to try to close(STDOUT) when you have done your
prints before you do your background stuff.


gnari



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

Date: Thu, 07 Jun 2001 11:24:17 GMT
From: "Girish Dar" <priyagirish@worldnet.att.net>
Subject: Sybase Interface in Perl
Message-Id: <BvJT6.65729$t12.5224712@bgtnsc05-news.ops.worldnet.att.net>

My understanding about the Sybase interface in Perl so far is as follows.
Please correct me if I'm wrong.

I think DB-Library routines are built to be used as Sybase interface in C
programs . But the Sybase interface for Perl is another version of
DB-Library which is called SybPerl and that is what is used in Perl
programs.It is also possible to create a customised version of SybPerl
libraries in C language .


- Girish




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

Date: Thu, 7 Jun 2001 08:35:15 -0400
From: "helpmeplease" <helpmeplese@helpmeplese.com>
Subject: Re: When renaming files is this agood idea to flock them ?
Message-Id: <9fnse4$64v$1@sshuraab-i-1.production.compuserve.com>

buggs <buggs-clpm@splashground.de> wrote in message
news:9fn0u6$4t8$01$1@news.t-online.com...
> helpmeplease wrote:
>
> > When renaming files is this a good idea to Flock them?
>
> Why would you want to flock them?
>
> Buggs

I thought this would be required

open (LABLE,"current.dat") || &Error("$state - ERROR");
flock(LABLE, 2);
rename("current.dat", "current.old" );
rename($new, "current.dat" );
flock(LABLE, 8);
close (LABLE);

to prevent someone saving  new info to the current.dat file the same moment
that i
want to edit and save changes to the current.dat file.




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

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


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