[23995] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 6196 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Mar 1 11:05:52 2004

Date: Mon, 1 Mar 2004 08:05:07 -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, 1 Mar 2004     Volume: 10 Number: 6196

Today's topics:
    Re: finding common words (viv2k)
    Re: finding common words <noreply@gunnar.cc>
    Re: finding common words <tore@aursand.no>
    Re: Getting status/response codes in Perl (Ali)
        Global special variable alternative names (Elephant)
    Re: Global special variable alternative names <usenet@morrow.me.uk>
    Re: Help with Perl Expect. (Charles DeRykus)
        Newbie Need help with if statement <elpedro@mindspring.com>
    Re: Newbie Need help with if statement <usenet@morrow.me.uk>
    Re: Newbie Need help with if statement <ittyspam@yahoo.com>
    Re: Opening a unique dat file for each user chris-usenet@roaima.co.uk
    Re: Opening a unique dat file for each user <kuujinbo@hotmail.com>
        OS Version <Mark.Fenbers@noaa.gov>
    Re: OS Version <usenet@morrow.me.uk>
    Re: OS Version <josef.moellers@fujitsu-siemens.com>
    Re: OS Version <jurgenex@hotmail.com>
    Re: perl::api2 pdf problem... <matthew.garrish@sympatico.ca>
        Replacing a regex on a one line expression <olczyk2002@yahoo.com>
    Re: Replacing a regex on a one line expression <usenet@morrow.me.uk>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 1 Mar 2004 04:50:34 -0800
From: viv2k@hotmail.com (viv2k)
Subject: Re: finding common words
Message-Id: <6fd673b3.0403010450.74652ae8@posting.google.com>

Gunnar Hjalmarsson <noreply@gunnar.cc> wrote in message news:<c1id33$1iqib4$1@ID-184292.news.uni-berlin.de>...
> If you encounter problems, please feel welcome to ask for help here,
> but now we want to see code that you wrote.

Ok guys, I've got a slightly different requirement now. The lists I
have to compare have increased to 3 and I need to find out words that
appear in at least two of the lists. However, if a word appears in
only 2 list, I need to include it in my third list by giving it a
default value, like '0'.

Example: 
ListA      
Apple 4, Boy 3, Cat 5    
ListB
Apple 1.0, Baby 2.1, Cat 3.3  
ListC
Apple 99, Beef 100, Cow   101

Should give me as result:
ListA      ListB       ListC
Apple 4    Apple 1.0   Apple 99
Cat   5    Cat   3.3   Cat   0

Right now, my code looks like below but I don't know how to give this
default value. Any help is much appreciated.

my %ListA;
     open my $fh, '< ListA.txt' or die "Couldn't open ListA.txt $!";
     while (<$fh>) {
         for (split /,\s*/) {
             my ($key, $value) = split;
             $ListA{$key} = $value;
         }
     }
     close $fh;

 my %ListB;
     open my $fh, '< ListB.txt' or die "Couldn't open ListB.txt $!";
     while (<$fh>) {
         for (split /,\s*/) {
             my ($key, $value) = split;
             $ListB{$key} = $value;
         }
     }
     close $fh;

my %ListC;
     open my $fh, '< ListC.txt' or die "Couldn't open ListC.txt $!";
     while (<$fh>) {
         for (split /,\s*/) {
             my ($key, $value) = split;
             $ListC{$key} = $value;
         }
     }
     close $fh;


     for (keys %ListA) {
         delete $ListA{$_} unless exists $ListB{$_} || $ListC{$_} ;
     }
     for (keys %ListB) {
         delete $ListB{$_} unless exists $ListA{$_} || $ListC{$_};
     }
    for (keys %ListC) {
         delete $ListC{$_} unless exists $ListA{$_} || $ListB{$_};
     }

     print "ListA \n";
     print "$_\t$ListA{$_}\n" for sort keys %ListA;
     print "\n";
     print "ListB \n";
     print "$_\t$ListB{$_}\n" for sort keys %ListB;
     print "\n";
     print "ListC \n";
     print "$_\t$ListC{$_}\n" for sort keys %ListC;


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

Date: Mon, 01 Mar 2004 15:07:01 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: finding common words
Message-Id: <c1vg90$1nb0io$1@ID-184292.news.uni-berlin.de>

viv2k wrote:
> Ok guys, I've got a slightly different requirement now. The lists I
> have to compare have increased to 3 and I need to find out words
> that appear in at least two of the lists. However, if a word
> appears in only 2 list, I need to include it in my third list by
> giving it a default value, like '0'.
> 
> Example:
> ListA
> Apple 4, Boy 3, Cat 5
> ListB
> Apple 1.0, Baby 2.1, Cat 3.3
> ListC
> Apple 99, Beef 100, Cow   101
> 
> Should give me as result:
> ListA      ListB       ListC
> Apple 4    Apple 1.0   Apple 99
> Cat   5    Cat   3.3   Cat   0
> 
> Right now, my code looks like below but I don't know how to give
> this default value. Any help is much appreciated.

Well, you need to somehow count the number of occurrences of each
word, right? Below find a suggestion that does just that.

> my %ListA;
>      open my $fh, '< ListA.txt' or die "Couldn't open ListA.txt $!";
>      while (<$fh>) {
>          for (split /,\s*/) {
>              my ($key, $value) = split;
>              $ListA{$key} = $value;
>          }
>      }
>      close $fh;
> 
>  my %ListB;
>      open my $fh, '< ListB.txt' or die "Couldn't open ListB.txt $!";
>      while (<$fh>) {
>          for (split /,\s*/) {
>              my ($key, $value) = split;
>              $ListB{$key} = $value;
>          }
>      }
>      close $fh;
> 
> my %ListC;
>      open my $fh, '< ListC.txt' or die "Couldn't open ListC.txt $!";
>      while (<$fh>) {
>          for (split /,\s*/) {
>              my ($key, $value) = split;
>              $ListC{$key} = $value;
>          }
>      }
>      close $fh;
> 
> 
>      for (keys %ListA) {
>          delete $ListA{$_} unless exists $ListB{$_} || $ListC{$_} ;
>      }
>      for (keys %ListB) {
>          delete $ListB{$_} unless exists $ListA{$_} || $ListC{$_};
>      }
>     for (keys %ListC) {
>          delete $ListC{$_} unless exists $ListA{$_} || $ListB{$_};
>      }

     my %count;
     $count{$_}++ for keys %ListA, keys %ListB, keys %ListC;

     for (keys %count) {
         if ($count{$_} > 1) {
             $ListA{$_} ||= 0;
             $ListB{$_} ||= 0;
             $ListC{$_} ||= 0;
         }
     }

> print "ListA \n";
> print "$_\t$ListA{$_}\n" for sort keys %ListA;
> print "\n";
> print "ListB \n";
> print "$_\t$ListB{$_}\n" for sort keys %ListB;
> print "\n";
> print "ListC \n";
> print "$_\t$ListC{$_}\n" for sort keys %ListC;

Even if this solution gets the job done, there are likely more
efficient ways to do it.

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



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

Date: Mon, 01 Mar 2004 16:41:51 +0100
From: Tore Aursand <tore@aursand.no>
Subject: Re: finding common words
Message-Id: <pan.2004.03.01.13.25.30.768608@aursand.no>

On Mon, 01 Mar 2004 04:50:34 -0800, viv2k wrote:
> Ok guys, I've got a slightly different requirement now. The lists I
> have to compare have increased to 3 and I need to find out words that
> appear in at least two of the lists. However, if a word appears in
> only 2 list, I need to include it in my third list by giving it a
> default value, like '0'.

The easiest solution is to keep track of how many lists each data entry is
represented in, ie. by doing something like while iterating through each
list:

> open my $fh, '< ListA.txt' or die "Couldn't open ListA.txt $!";
> while (<$fh>) {
>     for (split /,\s*/) {
>         my ($key, $value) = split;
>         $ListA{$key} = $value;

          $all{$key}++;

>     }
> }
> close $fh;

This way, you'll always know how many lists each '$key' is in (by looking
at its value).


-- 
Tore Aursand <tore@aursand.no>
"First, God created idiots. That was just for practice. Then He created
 school boards." -- Mark Twain


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

Date: 1 Mar 2004 03:31:09 -0800
From: AyCeeUK@hotmail.com (Ali)
Subject: Re: Getting status/response codes in Perl
Message-Id: <124e26f8.0403010331.5420f4e6@posting.google.com>

Thanks very much, that was extremely helpful.  I think I know what I have to do now!

Ali :o)

"gnari" <gnari@simnet.is> wrote in message news:<c1tfq0$4qh$1@news.simnet.is>...
> "Ali" <AyCeeUK@hotmail.com> wrote in message
> news:124e26f8.0402291130.390bf3eb@posting.google.com...
> 
> 
> > I've created a site and on one page I need to print certain
> > information out to a log file.  I've managed to get all the data that
> > is required except a 'HTTP response code'.  I've searched through
> > several books and websites and all I've come up with is that they are
> > also called status codes and I've found how to create a page that is
> > displayed when a certain status code is found but I can't find out how
> > to log the status of the page that was loaded.
> >
> > Does anyone know how to do this and am I right in saying that for the
> > page to have loaded correctly the code must be 200?
> >
> > I thought it might be stored as an environment variable like when
> > setting and retrieving cookies but I can't find any environment
> > variables associated with status codes.
> 
> not really a perl question, but in general the web server does decide
> what the status code is until the cgi script has finished, because if
> the said script should terminate with error, a status 500 is returned.
> 
> you must either
> a) assume there will be no error,and log code 200, preferably as the very
> last action your script does
> or
> b) retrieve the status code from the webservers log file and join that
> somehow with your logfile
> or
> c) your webserver may allow for your application to add information
> to the webserver logfile. (Apache+mod_perl, for example allows this)
> 
> gnari


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

Date: 1 Mar 2004 07:14:22 -0800
From: niall.macpherson@ntlworld.com (Elephant)
Subject: Global special variable alternative names
Message-Id: <eecd76f9.0403010714.13270ee3@posting.google.com>

Is there a 'use' directive I need to include in order to acess these ?

If I use 

$! 

in my code it runs fine, but if I use 

$ERRNO

(which I would prefer, for readability) I get 

H:\Perl Scripts>systest.pl
Global symbol "$ERRNO" requires explicit package name at H:\Perl
Scripts\systest
 .pl line 15.
Global symbol "$ERRNO" requires explicit package name at H:\Perl
Scripts\systest
 .pl line 18.
Execution of H:\Perl Scripts\systest.pl aborted due to compilation
errors.

It's not just $ERRNO I cannot access - none of the others (eg $PID,
$CHILD_ERROR) work either whereas the short versions ( $$, $? ) work
fine.

I am using Active Perl v5.6.1


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

Date: Mon, 1 Mar 2004 15:15:35 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: Global special variable alternative names
Message-Id: <c1vk2n$p3d$4@wisteria.csv.warwick.ac.uk>


niall.macpherson@ntlworld.com (Elephant) wrote:
> Is there a 'use' directive I need to include in order to acess these ?
> 
> If I use 
> 
> $! 
> 
> in my code it runs fine, but if I use 
> 
> $ERRNO
> 
> (which I would prefer, for readability) I get 

perldoc perlvar

Ben

-- 
Musica Dei donum optimi, trahit homines, trahit deos.    |
Musica truces molit animos, tristesque mentes erigit.    |   ben@morrow.me.uk
Musica vel ipsas arbores et horridas movet feras.        |


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

Date: Mon, 1 Mar 2004 09:21:19 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: Help with Perl Expect.
Message-Id: <Htw4nJ.LK2@news.boeing.com>

In article <c1k057$9at@netnews.proxy.lucent.com>,
Franklin Lee <pengtaoli@hotmail.com> wrote:
>Hi all,
>
>Now I met problem when using Perl Expect.
>I want to get the return code for cmd.
>For example,
>df -k
>echo $?
>
>codes as below
>****************************************
>...
>exp->send("echo \$?\r");
>exp->expect($timeout, "echo \$?\r\n");
>exp->expect($timeout, "([0-9]+)\r\n");
>
>....
>****************************************
>
>But I can't use ([0-9]+ to match 0 or other number?
>
>So could you tell me the reason? or how should I do?
>

Would Net::Telnet be an alternative...

use Net::Telnet;
my $t = new Net::Telnet (...
$t->open(...
$t->login('acct', 'password');
my @output = $t->cmd('df -k;echo \$?=$?');
 ...

hth,
--
Charles DeRykus


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

Date: Mon, 1 Mar 2004 08:11:46 -0700
From: "Ed" <elpedro@mindspring.com>
Subject: Newbie Need help with if statement
Message-Id: <c1vjri$1nnle6$1@ID-201461.news.uni-berlin.de>

I need help with the if statement below. What I need instead of three if
statements is one if and two "or" or something similar. Pseudo code would be

if
$areacode is blank or
$exchange is blank or
$phone is blank
then
$er_phone = $er_message
$er_count = $er_count + 1

T.I.A.
Ed
----------------------------------------------------


        if ($areacode eq "") {
             $er_areacode = $er_message;
             $er_count = $er_count + 1
     }
        if ($exchange eq "") {
             $er_exchange = $er_message;
             $er_count = $er_count + 1
     }
        if ($phone eq "") {
             $er_phone = $er_message;
             $er_count = $er_count + 1
     }




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

Date: Mon, 1 Mar 2004 15:14:51 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: Newbie Need help with if statement
Message-Id: <c1vk1b$p3d$3@wisteria.csv.warwick.ac.uk>


"Ed" <elpedro@mindspring.com> wrote:
> I need help with the if statement below. What I need instead of three if
> statements is one if and two "or" or something similar. Pseudo code would be
> 
> if
> $areacode is blank or
> $exchange is blank or
> $phone is blank
> then
> $er_phone = $er_message
> $er_count = $er_count + 1

and... what did you try?

if ($areacode eq "" or
    $exchange eq "" or
    $phone eq ""
) {
    $er_phone = $er_message;
    $er_count++;
}

Read perldoc perlop before you post again.

Ben

-- 
Heracles: Vulture! Here's a titbit for you / A few dried molecules of the gall
   From the liver of a friend of yours. / Excuse the arrow but I have no spoon.
(Ted Hughes,        [ Heracles shoots Vulture with arrow. Vulture bursts into ]
 /Alcestis/)        [ flame, and falls out of sight. ]         ben@morrow.me.uk


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

Date: Mon, 1 Mar 2004 10:17:03 -0500
From: Paul Lalli <ittyspam@yahoo.com>
Subject: Re: Newbie Need help with if statement
Message-Id: <20040301101547.V27834@dishwasher.cs.rpi.edu>

On Mon, 1 Mar 2004, Ed wrote:

> Date: Mon, 1 Mar 2004 08:11:46 -0700
> From: Ed <elpedro@mindspring.com>
> Newsgroups: comp.lang.perl.misc
> Subject: Newbie Need help with if statement
>
> I need help with the if statement below. What I need instead of three if
> statements is one if and two "or" or something similar. Pseudo code would be
>
> if
> $areacode is blank or
> $exchange is blank or
> $phone is blank
> then
> $er_phone = $er_message
> $er_count = $er_count + 1
>
> T.I.A.
> Ed
> ----------------------------------------------------
>
>
>         if ($areacode eq "") {
>              $er_areacode = $er_message;
>              $er_count = $er_count + 1
>      }
>         if ($exchange eq "") {
>              $er_exchange = $er_message;
>              $er_count = $er_count + 1
>      }
>         if ($phone eq "") {
>              $er_phone = $er_message;
>              $er_count = $er_count + 1
>      }

You need to read perldoc perlop.  Look for the section on logical
operators.  The operator you probably want in this case is 'or':

if ($areacode eq '' or $exchange eq '' or $phone eq ''){
	$er_phone = $er_message;
	$er_count++;
}

Paul Lalli


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

Date: Mon, 1 Mar 2004 09:19:19 +0000
From: chris-usenet@roaima.co.uk
Subject: Re: Opening a unique dat file for each user
Message-Id: <npbbh1-spr.ln1@moldev.cmagroup.co.uk>

Regent <arthur0421@163.com> wrote:
> $root and $path are consants, the only variable is $uid, getting its 
> value in this way:

> use CGI qw(:standard);
> my $q = new CGI;
> my $uid = $q->param('uid');

> perlsec tells me that $uid is tainted

It also gives you examples of how to untaint a tainted value

> but how can I untaint it, if the received value is to be used,
> dynamically, as part of a filename?

Basically, you shouldn't be trusting the value of $uid, as it's been
supplied by the user. (Consider $uid = "../../../../../../../etc/mime-magic",
or maybe worse.)

You need to decide what the possible values of $uid should be, and ensure
you grab only those:

	my $uid = $q->param('uid');	# Tainted
	if ($uid =~ /^(\d{1,5})$/) {
	    $uid = $1 +0;		# Untainted in range 0..99999
	}
	else {
	    die "Bad data for uid: '$uid'";
	}

The RE requires an explicit match to between one and five digits, putting
the matching data (if any) into $1. If you wanted to ensure $uid was in
the range (e.g.) 100 to 65535, then you could extend the if clause to
something like this:

	if ($uid =~ /^(\d{1,5})$/ and $1 >= 100 and $1 < 65536) { ... }

Chris
-- 
@s=split(//,"Je,\nhn ersloak rcet thuarP");$k=$l=@s;for(;$k;$k--){$i=($i+1)%$l
until$s[$i];$c=$s[$i];print$c;undef$s[$i];$i=($i+(ord$c))%$l}


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

Date: Mon, 01 Mar 2004 18:28:13 +0900
From: ko <kuujinbo@hotmail.com>
Subject: Re: Opening a unique dat file for each user
Message-Id: <c1uvqd$gnv$1@pin3.tky.plala.or.jp>

Don't top-post. Look at how your post was re-arranged - it makes it 
easier for people to follow the thread...

Regent wrote:
> Dave Cross wrote:
> 
>>> open (F, ">> $root/$path/$uid.dat") or die "$!\n";
> 
>> How do the variables $root, $path and $uid get set? You probably need to
>> untaint one of those.
>>
>> See "perldoc perlsec" for more details.
>>
>> Dave...
 >
 > $root and $path are consants, the only variable is $uid, getting its
 > value in this way:
 >
 > use CGI qw(:standard);
 > my $q = new CGI;
 > my $uid = $q->param('uid');
 >
 > perlsec tells me that $uid is tainted; but how can I untaint it, if
 > the received value is to be used, dynamically, as part of a filename?

Did you just read the whole document, specifically the section 
'Laundering and Detecting Tainted Data'?

Create a regular expression and use the subpattern(s) from the match. 
But make *sure* that you use a regex that tests for what you consider 
*valid* values. For example, you could technically do something like:

# *don't* do this
$uid = $1 if $uid =~ /(.*)/;

And your program will run, assuming there aren't any other errors. But 
that defeats the purpose of using taint mode, since it matches 
everything. You need to make a *careful* decision on what values you 
feel are appropriate within the context of your application, and then 
apply the regex to $uid.

 > Thanks for the reply but I don't seem to get the knack...

And since you're doing CGI, re-read perlsec till you do 'get the knack'. 
That should have been step one in the process...

HTH - keith


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

Date: Mon, 01 Mar 2004 10:04:30 -0500
From: Mark J Fenbers <Mark.Fenbers@noaa.gov>
Subject: OS Version
Message-Id: <404350FE.322F5687@noaa.gov>

This is a multi-part message in MIME format.
--------------2137EC3F0F4989C541021159
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

$^O gives the O/S name, in my case : 'linux', but I want to run my Perl script
on RH 7.X and RH 9.x of Linux.  How can my script determine which version of the
O/S it is running on?

Mark

--------------2137EC3F0F4989C541021159
Content-Type: text/x-vcard; charset=us-ascii;
 name="Mark.Fenbers.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: Card for Mark J Fenbers
Content-Disposition: attachment;
 filename="Mark.Fenbers.vcf"

begin:vcard 
n:Fenbers;Mark
tel;work:937-383-0430
x-mozilla-html:TRUE
org:National Weather Service;Ohio River Forecast Center
adr:;;;;;;
version:2.1
email;internet:Mark.Fenbers@noaa.gov
title:Sr. HAS Meteorologist
fn:Mark J Fenbers
end:vcard

--------------2137EC3F0F4989C541021159--



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

Date: Mon, 1 Mar 2004 15:12:07 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: OS Version
Message-Id: <c1vjs7$p3d$2@wisteria.csv.warwick.ac.uk>


Mark J Fenbers <Mark.Fenbers@noaa.gov> wrote:
> 
> $^O gives the O/S name, in my case : 'linux', but I want to run my Perl script
> on RH 7.X and RH 9.x of Linux.  How can my script determine which version of the
> O/S it is running on?

my $osvers = `uname -r`;

will return the OS version (at least on Linux). Note that this is the
kernel version, not the DeadRat distribution version.

> [Attachment type=text/x-vcard, name=Mark.Fenbers.vcf]

DON'T do that.

Ben

-- 
don't get my sympathy hanging out the 15th floor. you've changed the locks 3
times, he still comes reeling though the door, and soon he'll get to you, teach
you how to get to purest hell. you do it to yourself and that's what really
hurts is you do it to yourself just you, you and noone else ** ben@morrow.me.uk


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

Date: Mon, 01 Mar 2004 16:26:31 +0100
From: Josef =?iso-8859-1?Q?M=F6llers?= <josef.moellers@fujitsu-siemens.com>
Subject: Re: OS Version
Message-Id: <40435627.E4E797C8@fujitsu-siemens.com>

Mark J Fenbers wrote:
> =

> $^O gives the O/S name, in my case : 'linux', but I want to run my Perl=
 script
> on RH 7.X and RH 9.x of Linux.  How can my script determine which versi=
on of the
> O/S it is running on?

RedHat (and SuSE, don't know about the others) have a file /etc/*release
which tells you the version of the installed distribution.
Not that the contents is anything standard.

Josef
-- =

Josef M=F6llers (Pinguinpfleger bei FSC)
	If failure had no penalty success would not be a prize
						-- T.  Pratchett


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

Date: Mon, 01 Mar 2004 15:27:18 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: OS Version
Message-Id: <qDI0c.16080$C65.11988@nwrddc01.gnilink.net>

Mark J Fenbers wrote:
> $^O gives the O/S name, in my case : 'linux', but I want to run my
> Perl script on RH 7.X and RH 9.x of Linux.  How can my script
> determine which version of the O/S it is running on?

But linux is the operating system, isn't it?
RHxyz is the distribution, and has little to do with the OS

jue




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

Date: Mon, 1 Mar 2004 08:40:44 -0500
From: "Matt Garrish" <matthew.garrish@sympatico.ca>
Subject: Re: perl::api2 pdf problem...
Message-Id: <r3H0c.5706$qA2.279690@news20.bellglobal.com>


"michael vernersen" <michael@webactor.dk> wrote in message
news:b1c145db.0402292348.1b807bd5@posting.google.com...
>
>   What i want was to post the question to the germany perl newsgroup just
in
>   case someone there has an answer.
>

Cross-posting questions is just as bad. If you want the message to go to
more than one group, include all the groups in one post so everyone can see
the replies.

As to your problem, I'm not sure how much luck you're going to have.
PDF::API2 (not the perl::api2 you have in your subject) is not a core
module, so I doubt many people here have used it. I also suspect from the
code you've posted that you haven't made much of an effort to solve the
problem yourself, either. If you're not willing to read the documentation
and/or experiment on your own, don't expect people here to do it for you.

Matt




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

Date: Mon, 01 Mar 2004 06:11:14 -0600
From: TLOlczyk <olczyk2002@yahoo.com>
Subject: Replacing a regex on a one line expression
Message-Id: <g796405g3779hvlgf853r5c9vvcqdn93vh@4ax.com>

In a makefile, I had the following line:
>> PERLINCDIR := $(shell perl -MConfig -e 'print "$$Config{archlib}/CORE"')
The problem came when I tried this in Windows.
Then the variable of PERLINCDIR is;
c:\dir1\dir2/CORE.
From error messages I guess the \ and / confuses the compiler.
So I want to replace all the \ with / ( something I do routinely in
Windows precisely for this reason ).
Obviously the regex operation to do this is:
s:\\:/:g
The question is how to use this regex op.
I tried:
>> PERLINCDIR := $(shell perl -MConfig -e ' "$$Config{archlib}/CORE"; print s:\\:/:g; ')
No go.
I've also tried 
>> PERLINCDIR := $(shell perl -MConfig -e ' my $tlo="$$Config{archlib}/CORE"; $tlo =~ s:\\:/:g; print $tlo')
the result is an error "near my lo".

I've tried s:\\\\:/:g
I've tried my \$tlo, my \\$tlo etc.
all with no luck. Suggestions?


The reply-to email address is olczyk2002@yahoo.com.
This is an address I ignore.
To reply via email, remove 2002 and change yahoo to
interaccess,

**
Thaddeus L. Olczyk, PhD

There is a difference between
*thinking* you know something,
and *knowing* you know something.


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

Date: Mon, 1 Mar 2004 15:06:57 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: Replacing a regex on a one line expression
Message-Id: <c1vjih$p3d$1@wisteria.csv.warwick.ac.uk>


olczyk2002@yahoo.com wrote:
> In a makefile, I had the following line:
> >> PERLINCDIR := $(shell perl -MConfig -e 'print "$$Config{archlib}/CORE"')
> The problem came when I tried this in Windows.
> Then the variable of PERLINCDIR is;
> c:\dir1\dir2/CORE.
> From error messages I guess the \ and / confuses the compiler.
> So I want to replace all the \ with / ( something I do routinely in
> Windows precisely for this reason ).
> Obviously the regex operation to do this is:
> s:\\:/:g
> The question is how to use this regex op.
> I tried:
> >> PERLINCDIR := $(shell perl -MConfig -e ' "$$Config{archlib}/CORE"; print
> >> s:\\:/:g; ')
> No go.
> I've also tried 
> >> PERLINCDIR := $(shell perl -MConfig -e ' my $tlo="$$Config{archlib}/CORE";
> >> $tlo =~ s:\\:/:g; print $tlo')
> the result is an error "near my lo".

So... make is removing $t. This is what make does... to escape the $,
use $$. Also, for a one-liner I would use $_ (untested: you may need
s:\\\\:; ignore line-wrapping):

PERLINCDIR := $(shell perl -MConfig -e'$$_="$$Config{archlib}/CORE"; 
                s:\\:/:g; print')

Ben

-- 
Musica Dei donum optimi, trahit homines, trahit deos.    |
Musica truces molit animos, tristesque mentes erigit.    |   ben@morrow.me.uk
Musica vel ipsas arbores et horridas movet feras.        |


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

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.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

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


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