[19703] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1898 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Oct 9 14:10:31 2001

Date: Tue, 9 Oct 2001 11:10:13 -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: <1002651012-v10-i1898@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Tue, 9 Oct 2001     Volume: 10 Number: 1898

Today's topics:
        spawning batch jobs async. <aort527@hotmail.com>
    Re: spawning batch jobs async. (Anno Siegel)
        Special Pattern Match (M.A. Oxby)
    Re: Special Pattern Match <JPFauvelle@Colt-Telecom.fr>
    Re: Special Pattern Match <Laocoon@eudoramail.com>
    Re: Special Pattern Match <Laocoon@eudoramail.com>
        symbolic references to built-in functions <rtrahan@monmouth.com>
    Re: symbolic references to built-in functions (Mark Jason Dominus)
    Re: symbolic references to built-in functions (Martien Verbruggen)
    Re: symbolic references to built-in functions <nospam-abuse@ilyaz.org>
    Re: symbolic references to built-in functions (Mark Jason Dominus)
    Re: Text::CSV with Special Chars? <jeff@vpservices.com>
        tr/A-Z/a-z/ vs lc() (Peter J. Acklam)
    Re: tr/A-Z/a-z/ vs lc() <Thomas@Baetzler.de>
    Re: tr/A-Z/a-z/ vs lc() <mjcarman@home.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Tue, 09 Oct 2001 10:25:13 -0500
From: alex <aort527@hotmail.com>
Subject: spawning batch jobs async.
Message-Id: <3BC316D9.B7D2780D@hotmail.com>

I need to start two separate dos batch jobs
from within perl.  These jobs should run
by themselves (async) without my perl
script having to wait until they finish.

Is it possible to do this and how???





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

Date: 9 Oct 2001 16:04:33 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: spawning batch jobs async.
Message-Id: <9pv76h$fba$2@mamenchi.zrz.TU-Berlin.DE>

According to alex  <aort527@hotmail.com>:
> I need to start two separate dos batch jobs
> from within perl.  These jobs should run
> by themselves (async) without my perl
> script having to wait until they finish.
> 
> Is it possible to do this and how???

It is even a FAQ: perldoc -q background

Anno


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

Date: Tue, 9 Oct 2001 15:41:00 GMT
From: JHM1MAO@leeds.ac.uk (M.A. Oxby)
Subject: Special Pattern Match
Message-Id: <GKy3Gr.HpH@leeds.ac.uk>

I might be asking a bit much here, but I need a special pattern 
match/substitution and I can't figure it out. I need to match a string that:

1. Is NOT surrounded by " " s
2. Begins with http:// or mailto:

No hurry, but a response would be nice sometime soon :)
Cheers!
- Martin

- Martin Oxby
Founder and Administrator
[http://www.resource-centre.net]
Web Resources, Free Email, Messaging and Programming Tutorials all under one roof!


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

Date: Tue, 09 Oct 2001 18:03:40 +0200
From: Jean-Philippe Fauvelle <JPFauvelle@Colt-Telecom.fr>
Subject: Re: Special Pattern Match
Message-Id: <hm76stc8sdrsgkan9q98tsvtaf21gte51v@4ax.com>

Le Tue, 9 Oct 2001 15:41:00 GMT, JHM1MAO@leeds.ac.uk (M.A. Oxby) écrit:

if ( $str =~ m#^(?:http://|mailto:)\S+$# ) {
	...
}

Jean-Philippe Fauvelle



>I might be asking a bit much here, but I need a special pattern 
>match/substitution and I can't figure it out. I need to match a string that:
>
>1. Is NOT surrounded by " " s
>2. Begins with http:// or mailto:
>
>No hurry, but a response would be nice sometime soon :)
>Cheers!
>- Martin
>
>- Martin Oxby
>Founder and Administrator
>[http://www.resource-centre.net]
>Web Resources, Free Email, Messaging and Programming Tutorials all under one roof!



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

Date: Tue, 9 Oct 2001 18:04:15 +0200
From: Laocoon <Laocoon@eudoramail.com>
Subject: Re: Special Pattern Match
Message-Id: <Xns9135B7D6ED7CCLaocooneudoramailcom@62.153.159.134>

JHM1MAO@leeds.ac.uk (M.A. Oxby) wrote in news:GKy3Gr.HpH@leeds.ac.uk:

> I might be asking a bit much here, but I need a special pattern 
> match/substitution and I can't figure it out. I need to match a string
> that: 
> 
> 1. Is NOT surrounded by " " s
> 2. Begins with http:// or mailto:
> 


$string =~ m#^[^"]*(?:http://|mailto:)[^"]+$#;

hope this helps u 



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

Date: Tue, 9 Oct 2001 18:05:44 +0200
From: Laocoon <Laocoon@eudoramail.com>
Subject: Re: Special Pattern Match
Message-Id: <Xns9135B816E65FBLaocooneudoramailcom@62.153.159.134>

Jean-Philippe Fauvelle <JPFauvelle@Colt-Telecom.fr> wrote in
news:hm76stc8sdrsgkan9q98tsvtaf21gte51v@4ax.com: 

> Le Tue, 9 Oct 2001 15:41:00 GMT, JHM1MAO@leeds.ac.uk (M.A. Oxby)
> écrit: 
> 
> if ( $str =~ m#^(?:http://|mailto:)\S+$# ) {


This does not make sure that its not surrounded by double quotes.


>      ...
> }
> 
> Jean-Philippe Fauvelle
> 
> 
> 
>>I might be asking a bit much here, but I need a special pattern 
>>match/substitution and I can't figure it out. I need to match a string
>>that: 
>>
>>1. Is NOT surrounded by " " s
>>2. Begins with http:// or mailto:
>>
>>No hurry, but a response would be nice sometime soon :)
>>Cheers!
>>- Martin
>>
>>- Martin Oxby
>>Founder and Administrator [http://www.resource-centre.net]
>>Web Resources, Free Email, Messaging and Programming Tutorials all
>>under one roof! 
> 



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

Date: Tue, 09 Oct 2001 09:32:35 -0700
From: Richard Trahan <rtrahan@monmouth.com>
Subject: symbolic references to built-in functions
Message-Id: <3BC326A3.2F88753C@monmouth.com>

How can I execute a built-in via symbolic reference?

The following won't work:

$c = "cos";
print &$c(2);

Perl thinks I'm trying to access main::cos. If I change
$c to "CORE::cos", that doesn't work either.

What am I doing wrong, or can't I do that?
(I have a workaround, using eval, but that's rather expensive.)


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

Date: Tue, 09 Oct 2001 13:37:40 GMT
From: mjd@plover.com (Mark Jason Dominus)
Subject: Re: symbolic references to built-in functions
Message-Id: <3bc2fda3.289d$87@news.op.net>

In article <3BC326A3.2F88753C@monmouth.com>,
Richard Trahan  <rtrahan@monmouth.com> wrote:
>How can I execute a built-in via symbolic reference?

Sorry, no can do.

You might try

        $c = sub { cos(shift) };
        print &$c(2);


>(I have a workaround, using eval, but that's rather expensive.)

Do you really know it is expensive?  Compared to what?



-- 
@P=split//,".URRUU\c8R";@d=split//,"\nrekcah xinU / lreP rehtona tsuJ";sub p{
@p{"r$p","u$p"}=(P,P);pipe"r$p","u$p";++$p;($q*=2)+=$f=!fork;map{$P=$P[$f^ord
($p{$_})&6];$p{$_}=/ ^$P/ix?$P:close$_}keys%p}p;p;p;p;p;map{$p{$_}=~/^[P.]/&&
close$_}%p;wait until$?;map{/^r/&&<$_>}%p;$_=$d[$q];sleep rand(2)if/\S/;print


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

Date: Wed, 10 Oct 2001 00:17:45 +1000
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: symbolic references to built-in functions
Message-Id: <slrn9s61o9.448.mgjv@martien.heliotrope.home>

On Tue, 09 Oct 2001 09:32:35 -0700,
	Richard Trahan <rtrahan@monmouth.com> wrote:
> How can I execute a built-in via symbolic reference?

Not possible.

> (I have a workaround, using eval, but that's rather expensive.)

I think that eval is your best shot, but it is hard to say, since you
don't actually tell us why you think you need to call builtins via a
symbolic reference.

Martien
-- 
Martien Verbruggen              | 
Interactive Media Division      | This matter is best disposed of from
Commercial Dynamics Pty. Ltd.   | a great height, over water.
NSW, Australia                  | 


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

Date: Tue, 9 Oct 2001 15:47:37 +0000 (UTC)
From: Ilya Zakharevich <nospam-abuse@ilyaz.org>
Subject: Re: symbolic references to built-in functions
Message-Id: <9pv66p$3et$1@agate.berkeley.edu>

[A complimentary Cc of this posting was sent to
Martien Verbruggen
<mgjv@tradingpost.com.au>], who wrote in article <slrn9s61o9.448.mgjv@martien.heliotrope.home>:
> On Tue, 09 Oct 2001 09:32:35 -0700,
> 	Richard Trahan <rtrahan@monmouth.com> wrote:
> > How can I execute a built-in via symbolic reference?
> 
> Not possible.

Correct.  But this is a bug.  Taking a reference as in \&CORE::cos
should be equivalent to

  sub CORE::CORE::cos (;$) { cos (@_ ? shift: $_) }
  \&CORE::CORE::cos

(similar to what Fatal.pm is doing).

Ilya


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

Date: Tue, 09 Oct 2001 16:14:18 GMT
From: mjd@plover.com (Mark Jason Dominus)
Subject: Re: symbolic references to built-in functions
Message-Id: <3bc32259.2d80$38@news.op.net>

In article <9pv66p$3et$1@agate.berkeley.edu>,
Ilya Zakharevich  <nospam-abuse@ilyaz.org> wrote:
>Correct.  But this is a bug.  Taking a reference as in \&CORE::cos
>should be equivalent to
>
>  sub CORE::CORE::cos (;$) { cos (@_ ? shift: $_) }
>  \&CORE::CORE::cos

This cannot be done reliably in all cases, since there is no
equivalent for \&CORE::print, \&CORE::tied, etc.
-- 
@P=split//,".URRUU\c8R";@d=split//,"\nrekcah xinU / lreP rehtona tsuJ";sub p{
@p{"r$p","u$p"}=(P,P);pipe"r$p","u$p";++$p;($q*=2)+=$f=!fork;map{$P=$P[$f^ord
($p{$_})&6];$p{$_}=/ ^$P/ix?$P:close$_}keys%p}p;p;p;p;p;map{$p{$_}=~/^[P.]/&&
close$_}%p;wait until$?;map{/^r/&&<$_>}%p;$_=$d[$q];sleep rand(2)if/\S/;print


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

Date: Tue, 09 Oct 2001 09:42:27 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: Text::CSV with Special Chars?
Message-Id: <3BC328F3.97C3B23D@vpservices.com>

Ted Smith wrote:
> 
> It seems that the $csv->combine() method will not work if your array
> has any special characters. For example, my test with a field as
> 'Vitória' will not work.use Text::CSV_XS;

  use Text::CSV_XS;
  my $csv = Text::CSV_XS->new;
  $csv->{binary}=1;
  my @cols = qw( foo bar "stuff" Vitória ) ;
  $csv->combine(@cols);
  print $csv->string;

> What alternatives are there?

  use AnyData::Format::CSV;
  my $csv = AnyData::Format::CSV->new;
  my @cols = qw( foo bar "stuff" Vitória );
  print $csv->write_fields(@cols);

Both methods print out: foo,bar,"""stuff""",Vitória and both could use
other escape characters, eols, field separators, or quote characters if
you supply them.

-- 
Jeff



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

Date: 09 Oct 2001 16:57:43 +0200
From: pjacklam@online.no (Peter J. Acklam)
Subject: tr/A-Z/a-z/ vs lc()
Message-Id: <y9mkamzl.fsf@online.no>

Is there any reason at all for using "tr/A-Z/a-z/" to convert to
lowercase in stead of using "lc()"?

Of course, the same goes for tr/a-z/A-Z/ vs uc().

(I know that tr/// can do much more than converting case, so the
question is not whether lc/uc generally can replace tr///.)

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: Tue, 09 Oct 2001 17:16:29 +0200
From: =?ISO-8859-1?Q?Thomas_B=E4tzler?= <Thomas@Baetzler.de>
Subject: Re: tr/A-Z/a-z/ vs lc()
Message-Id: <h056st49sn9n47et9h0j8as4bkpontun2d@4ax.com>

On 09 Oct 2001, pjacklam@online.no (Peter J. Acklam) wrote:

>Is there any reason at all for using "tr/A-Z/a-z/" to convert to
>lowercase in stead of using "lc()"?

The tr/// might be faster (YMMV), but lc/uc are locale aware - i.e. they
may do the Right Thing for non-ASCII text, depending on how your Perl
was compiled and how your locale is set up.

HTH,
-- 
use strict;my($i,$t,@r)=(0,'5 -.@BHJPT4acd6e2hk2lmn2o4r2s3tuz',map{ord}
split//,unpack('u*','L#`T&)QD5#0`#!!`#%1D)#08`#P05!!(3``$$"``#"0L&``('.
'"`P<!`````0$`'));$t=~s/(\d)(.)/$2x$1/eg;map{$t.=substr$t,$i,1,''while
$_--;$i++}@r;print"$t\n";# Thomas@Baetzler.de - http://baetzler.de/perl


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

Date: Tue, 09 Oct 2001 10:18:48 -0500
From: Michael Carman <mjcarman@home.com>
Subject: Re: tr/A-Z/a-z/ vs lc()
Message-Id: <3BC31558.F9459B40@home.com>

"Peter J. Acklam" wrote:
> 
> Is there any reason at all for using "tr/A-Z/a-z/" to convert to
> lowercase in stead of using "lc()"?

Potentially. Maybe you want to know how many letters were changed:

    $n = $string =~ tr/A-Z/a-z/;

On the other hand, lc() will respect the locale setting. tr/A-Z/a-z/ is
not a locale-portable method of converting a string to lowercase.

-mjc


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

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


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