[18799] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 967 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed May 23 11:10:47 2001

Date: Wed, 23 May 2001 08: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)
Message-Id: <990630617-v10-i967@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Wed, 23 May 2001     Volume: 10 Number: 967

Today's topics:
    Re: module for combinatorics? (partitions etc) <skilchen@swissonline.ch>
    Re: module for combinatorics? (partitions etc) (Mark Jason Dominus)
    Re: module for combinatorics? (partitions etc) (Anno Siegel)
    Re: module for combinatorics? (partitions etc) (Dave Bailey)
    Re: Multiple Line printing <michael@proweb.net.au>
    Re: Multiple Line printing (Anno Siegel)
    Re: Multiple Line printing <vmurphy@Cisco.Com>
    Re: Multiple Line printing <peb@bms.umist.ac.uk>
    Re: Multiple Line printing <peb@bms.umist.ac.uk>
    Re: Multiple Line printing (Anno Siegel)
        Perl equivalent of a C/C++ operation <mriehl@home.com>
    Re: Perl, Oracle and cursors gnari@my-deja.com
    Re: Q: about combining lines of a call record file... <tnathan@midwayisland.net>
    Re: Q: about combining lines of a call record file... (Helgi Briem)
    Re: Redirecting STDERR to sendmail <mike@gatrell.org>
        regexp for triming domainnames (Patrick Erler)
    Re: regexp for triming domainnames <pne-news-20010523@newton.digitalspace.net>
    Re: regexp for triming domainnames <admin@the-piper.net>
    Re: regexp for triming domainnames (Rafael Garcia-Suarez)
    Re: regexp for triming domainnames <peb@bms.umist.ac.uk>
    Re: regexp for triming domainnames (Patrick Erler)
    Re: sorting a scrolling_list() <ren@tivoli.com>
    Re: This String Formation does not work properly, pleaz (Steven)
        VMSPerl v5.7.0 built for VMS_VAX / CGI.pm v2.72 error : <jac.oppers@philips.com>
    Re: VMSPerl v5.7.0 built for VMS_VAX / CGI.pm v2.72 err <dan@tuatha.sidhe.org>
    Re: Warning/Danger -- Don't use Perl for CGI (Randal L. Schwartz)
    Re: what does this mean? (Mark Jason Dominus)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Wed, 23 May 2001 15:12:41 +0200
From: "Samuel Kilchenmann" <skilchen@swissonline.ch>
Subject: Re: module for combinatorics? (partitions etc)
Message-Id: <9egd0q$2o9hi$1@ID-13368.news.dfncis.de>

"Anno Siegel" <anno4000@lublin.zrz.tu-berlin.de> schrieb im
Newsbeitrag news:9eg2rt$928$1@mamenchi.zrz.TU-Berlin.DE...
>
> A recursive approach suggests itself:  If the number of terms is
> less than 2, return (a list consisting of) the final sum.  If it
> is larger, select a possible summand $new between 1 and
> $final_sum - $num_terms.

between 1 and $final_sum - ($num_terms - 1)
(otherwise you exclude some possible solutions)

> Then find a partition of $final_sum - $new into
> $num_terms - 1 parts and add the selected summand to the list:
>
>     sub gen {
>         my ( $final_sum, $num_terms) = @_;
>         return $final_sum if $num_terms < 2;
>         my $new = 1 + int rand( $final_sum - $num_terms);

          my $new = 1 + int rand( $final_sum - $num_terms + 1);

Try repeated calls to gen(3, 2) to see the problem in your solution.

>         return gen( $final_sum - $new, --$num_terms), $new;
>     }
>
In this case i prefer the iterative implementation of this recursion
as in the simple loops proposed by C. Berry and E. Chang. Except that
i would use a backwards counting loop instead of the somewhat strange

 foreach $i (1..$num_terms-1) {
    $rand = int rand($final_sum - $total - $num_terms + $i) +1;

used by E. Chang, or

  while (@res < $n - 1) {
    my $max = $m - $n + @res + 1;

used by C. Berry

something like:

sub gen {
  my ($final_sum, $num_terms) = @_;
  my @result = ();
  for (my $i = $num_terms - 1; $i > 0; $i--) {
    my $val = 1 + int(rand($final_sum - $i));
    push(@result, $val);
    $final_sum -= $val;
  }
  push(@result, $final_sum);
  return @result;
}




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

Date: Wed, 23 May 2001 13:43:18 GMT
From: mjd@plover.com (Mark Jason Dominus)
Subject: Re: module for combinatorics? (partitions etc)
Message-Id: <3b0bbe68.5190$149@news.op.net>

In article <slrn9gmm2o.l37.dave@sydney.daveb.net>,
Dave Bailey <dave@sydney.daveb.net> wrote:
>>Second, subset-sum is a number problem, and efficient algorithms *do*
>>exist.  These algorithms are polynomial in the magnitude of the number
>>N; the reason subset-sum is NP-complete is not that the solution takes
>>a long time, but that it takes a long time *relative to the size of
>>the problem statement*, which is very brief.  
>
>I have never heard of this definition of NP-completeness (defining
>it in terms of the problem statement).  

Well, that is the only way I have ever heard it defined, so we seem to
be at an impasse.

>I thought an NP complete problem was one which could be solved in
>polynomial time only if you have a way to test an arbitrary number of
>candidate solutions simultaneously (i.e. a quantum computer).  What
>does that have to do with the size of the problem statement?

I'm really sorry about this, and I don't want to be rude, but I think
your idea of NP completeness is seriously confused, and I don't think
Usenet is the right place for me to try to explain it.  I suggest that
you read a book on computability theory.  Most texts will explain in
detail what the defintiion is and why.  I know the The Hopcroft and
Ullman one explains what NP-completeness is, or you could try
"Computers and Intractibility: A Guide to the Theory of
NP-Completeness" by Garey and Johnson, which is probably more
accessible.  It will also explain about pseudo-polynomial problems
like subset-sum.

-- 
@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: 23 May 2001 13:52:58 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: module for combinatorics? (partitions etc)
Message-Id: <9egfbq$jt3$1@mamenchi.zrz.TU-Berlin.DE>

According to Samuel Kilchenmann <skilchen@swissonline.ch>:
> "Anno Siegel" <anno4000@lublin.zrz.tu-berlin.de> schrieb im
> Newsbeitrag news:9eg2rt$928$1@mamenchi.zrz.TU-Berlin.DE...
> >
> > A recursive approach suggests itself:  If the number of terms is
> > less than 2, return (a list consisting of) the final sum.  If it
> > is larger, select a possible summand $new between 1 and
> > $final_sum - $num_terms.
> 
> between 1 and $final_sum - ($num_terms - 1)
> (otherwise you exclude some possible solutions)
> 
> > Then find a partition of $final_sum - $new into
> > $num_terms - 1 parts and add the selected summand to the list:
> >
> >     sub gen {
> >         my ( $final_sum, $num_terms) = @_;
> >         return $final_sum if $num_terms < 2;
> >         my $new = 1 + int rand( $final_sum - $num_terms);
> 
>           my $new = 1 + int rand( $final_sum - $num_terms + 1);
> 
> Try repeated calls to gen(3, 2) to see the problem in your solution.

Oh, right.  We only need to leave room for the *remaining* number of
terms.

> >         return gen( $final_sum - $new, --$num_terms), $new;
> >     }
> >
> In this case i prefer the iterative implementation of this recursion
> as in the simple loops proposed by C. Berry and E. Chang.

In a case like this, where a recursive solution has an advantage in
clarity (never mind that I got it wrong all the same :), I'd consider
the iterative variant an optional optimization.

It is strange to note that one of the most popular examples for
recursion is the computation of factorials, where the recursive
approach has no advantage at all.

[code examples snipped]

Anno


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

Date: 23 May 2001 14:53:06 GMT
From: dave@sydney.daveb.net (Dave Bailey)
Subject: Re: module for combinatorics? (partitions etc)
Message-Id: <slrn9gn9gd.mdp.dave@sydney.daveb.net>

On Wed, 23 May 2001 13:43:18 GMT, Mark Jason Dominus <mjd@plover.com> wrote:
>In article <slrn9gmm2o.l37.dave@sydney.daveb.net>,
>Dave Bailey <dave@sydney.daveb.net> wrote:
[...]
>>I thought an NP complete problem was one which could be solved in
>>polynomial time only if you have a way to test an arbitrary number of
>>candidate solutions simultaneously (i.e. a quantum computer).  What
>>does that have to do with the size of the problem statement?
>
>I'm really sorry about this, and I don't want to be rude, [...]

If you're sorry and you don't want to be rude, either answer my 
question or say nothing.  Something along the lines of "the size 
of the problem statement is the quantity in which the solution 
verifier's execution time is a polynomial" would have sufficed.  

--
Dave Bailey
davidb54@yahoo.com


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

Date: Wed, 23 May 2001 21:26:10 +0800
From: "Michael G" <michael@proweb.net.au>
Subject: Re: Multiple Line printing
Message-Id: <3b0bba25$0$25491$7f31c96c@news01.syd.optusnet.com.au>

open(FILE, "<file.txt");
@array = <FILE>;
close(FILE)
foreah $line (@array){
    if ($line =~ /search/) {
        print $line;
    }
}

"Gary" <grobitaille@mail.com> wrote in message
news:a2051d6.0105230401.5f5a46c7@posting.google.com...
> I need to parse a text file and when a pattern is matched I need to
> print that line and the next 6 lines. Can someone provide me with a
> perl solution
>
>
> Thanks




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

Date: 23 May 2001 14:03:44 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Multiple Line printing
Message-Id: <9egg00$jt3$2@mamenchi.zrz.TU-Berlin.DE>

According to Michael G <michael@proweb.net.au>:

Please don't just slap your reply on top of the preceding post.  It's
considered rude.

> open(FILE, "<file.txt");
> @array = <FILE>;
> close(FILE)

Why read the file into an array, and then process it line-wise?  This
"false idiom" is spreading like wildfire.  It is idiotic.

> foreah $line (@array){
>     if ($line =~ /search/) {
>         print $line;
>     }
> }

This doesn't compile, and if corrected, wouldn't do what the original
poster needs.  You forgot to print "the next 6 lines" as requested.

The code you posted sets a bad example and is useless.  Don't do
that.

Anno

[original posting left in jeopardy position]

> "Gary" <grobitaille@mail.com> wrote in message
> news:a2051d6.0105230401.5f5a46c7@posting.google.com...
> > I need to parse a text file and when a pattern is matched I need to
> > print that line and the next 6 lines. Can someone provide me with a
> > perl solution
> >
> >
> > Thanks
> 
> 




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

Date: 23 May 2001 10:15:57 -0400
From: Vinny Murphy <vmurphy@Cisco.Com>
Subject: Re: Multiple Line printing
Message-Id: <m31ypgb17m.fsf@vpnrel.cisco.com>

"Michael G" <michael@proweb.net.au> writes:

> open(FILE, "<file.txt");
> @array = <FILE>;
> close(FILE)
> foreah $line (@array){
>     if ($line =~ /search/) {
>         print $line;
>     }
> }
> 

I'm pretty sure this won't work since you spelled foreach incorrectly.
Also if implemented correctly, would just print out each matched line.

A better way would be to do:
#!/usr/bin/perl -w

use strict;
 
my $file        = shift @ARGV;
my $search_for  = shift @ARGV;
my $lines_below = 6;
 
my $to = -1;
open( IN, $file ) || die;
while(<IN>) {
   $to = $. + $lines_below if /$search_for/; 
   print "$. : $_" if $. <= $to;
}
close IN;

I remember last year, around August or September (maybe), Tom
Christiansen had given out a one-liner on this newsgroup doing something
like the above.  

HTH.


> "Gary" <grobitaille@mail.com> wrote in message
> news:a2051d6.0105230401.5f5a46c7@posting.google.com...
> > I need to parse a text file and when a pattern is matched I need to
> > print that line and the next 6 lines. Can someone provide me with a
> > perl solution
> >
> >
> > Thanks
> 
> 

-- 
Vinny


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

Date: Wed, 23 May 2001 14:20:48 +0100
From: Paul Boardman <peb@bms.umist.ac.uk>
Subject: Re: Multiple Line printing
Message-Id: <3B0BB930.C9014A52@bms.umist.ac.uk>

Gary wrote:
> 
> I need to parse a text file and when a pattern is matched I need to
> print that line and the next 6 lines. Can someone provide me with a
> perl solution
> 

you don't give an indication as to how much Perl you know.

I'm assuming you know the basics and that you just need a pointer to the
solution.

while(<FILE>){
	$flag = 1 if /some pattern/;
	$counter++ if $flag;
	print if $flag && $counter <= 6;
}

There's probably a more elegant way of doing this (It will probably get
posted too).

Paul


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

Date: Wed, 23 May 2001 15:37:39 +0100
From: Paul Boardman <peb@bms.umist.ac.uk>
Subject: Re: Multiple Line printing
Message-Id: <3B0BCB33.4BBC0938@bms.umist.ac.uk>

Michael G wrote:
> 
> open(FILE, "<file.txt");
> @array = <FILE>;
> close(FILE)
> foreah $line (@array){
>     if ($line =~ /search/) {
>         print $line;
>     }
> }

not quite what the OP asked for though is it?

Paul


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

Date: 23 May 2001 15:00:10 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Multiple Line printing
Message-Id: <9egj9q$ms0$1@mamenchi.zrz.TU-Berlin.DE>

According to Paul Boardman  <peb@bms.umist.ac.uk>:
> Gary wrote:
> > 
> > I need to parse a text file and when a pattern is matched I need to
> > print that line and the next 6 lines. Can someone provide me with a
> > perl solution
> > 
> 
> you don't give an indication as to how much Perl you know.
> 
> I'm assuming you know the basics and that you just need a pointer to the
> solution.
> 
> while(<FILE>){
> 	$flag = 1 if /some pattern/;
> 	$counter++ if $flag;
> 	print if $flag && $counter <= 6;
> }
> 
> There's probably a more elegant way of doing this (It will probably get
> posted too).

Well, it would work only once, wouldn't it.  Re-reading the original
post, that's probably all that was asked, but a more general solution
that starts another block of seven lines at each match wouldn't have
to be more complicated.

Anno


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

Date: Wed, 23 May 2001 14:31:56 GMT
From: "Mark Riehl" <mriehl@home.com>
Subject: Perl equivalent of a C/C++ operation
Message-Id: <wRPO6.128975$K5.12116208@news1.rdc1.nj.home.com>

All,

I'm kind of new to Perl but have done a lot of C/C++ network programming.
If you're using a TCP socket in C/C++, you need to build what looks like a
IP packet that contains different fields.  For example, the first 2 bytes
might be the packet type, the next four might be the packet size, and the
rest would be the payload.

I need to develop an application that uses a C++ client and a Perl server.
In C/C++, I can use a buffer and a pointer and build the packet in the
buffer.  I can walk down the buffer using a pointer, know where I am, and
then write the proper values in the proper locations.

What's the closest equivalent to this in Perl?  Would I need to use pack()?
Or, can I just use a scalar such as $buf, and just add the components to it?
Can anyone point me off to any samples?

Thanks for the help,
Mark




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

Date: 23 May 2001 13:13:53 GMT
From: gnari@my-deja.com
Subject: Re: Perl, Oracle and cursors
Message-Id: <9egd2h$5qd$1@news.netmar.com>

In article <9eg4pp$2eu$1@news.netmar.com>, <gnari@my-deja.com> quoted
the whole article <ae46436e.0105210807.3228eddb@posting.google.com>
when he thought he had snipped it.

sorry about that

gnari


 -----  Posted via NewsOne.Net: Free (anonymous) Usenet News via the Web  -----
  http://newsone.net/ -- Free reading and anonymous posting to 60,000+ groups
   NewsOne.Net prohibits users from posting spam.  If this or other posts
made through NewsOne.Net violate posting guidelines, email abuse@newsone.net


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

Date: Wed, 23 May 2001 02:54:30 -0600
From: Todd Nathan <tnathan@midwayisland.net>
Subject: Re: Q: about combining lines of a call record file...
Message-Id: <B730D6E6.26A6%tnathan@midwayisland.net>

Oh, I should have figured that someone in the Perl community would do the
RTFM thing, being offline from the Perl community for 5+ years now I kinda
forgot why I left it in the first place.  Thanks for the not so sutle
refresher
course on how to be an asshole and get someone really disinterested in
something quickly ;'P  You are a class act.

\t

on 5/23/01 7:28 AM, Joe Golfer at name@domain.com wrote:

> How about buying a book on Perl and reading it?
> 
> In article <B730C91D.2697%tnathan@midwayisland.net>, you say...
>> Hi,
>> 
>> How would i write a Perl script to combine the lines of a Call Record
>> into one line...?  Thanks, and you are welcome to get a hold of me
>> directly, I really appreciate your help!!!
>> 
>> \t
>> 
>> Sample of call record data follows...
>> 
>> CR 16178: CallType  1 04-MAY-2001 Disc-202
>> Seize 13:59:16 Ans 13:59:27 Disc 13:59:38 TS   0
>> A Party:    MOBILE (11) 8084213370     Serial ed8283c4
>> 0013(51: 2)     13:59:16[ 1]--13:59:38[ 1]
>> B Party:    MOBILE (11) 8084213400     Serial fc097b20
>> 0012(51: 1)     13:59:19[ 2]--13:59:38[ 1]
>> 
>> CR 16194: CallType  1 04-MAY-2001 Disc-202
>> Seize 13:59:26 Ans 13:59:34 Disc 13:59:43 TS   0
>> A Party:    MOBILE (11) 8084213456     Serial e0da83ea
>> 0024(51:11)     13:59:26[ 1]--13:59:43[ 1]
>> B Party:    MOBILE (11) 8084213386     Serial 874a563a
>> 0021(51: 8)     13:59:28[ 2]--13:59:43[ 1]
>> 
>> CR 16162: CallType  1 04-MAY-2001 Disc-203
>> Seize 13:59:12 Ans 13:59:53 Disc 13:59:53 TS  36
>> A Party:    MOBILE (11) 8084213373     Serial 7713298a
>> 0023(51:10)     13:59:12[ 1]--13:59:53[ 1]
>> B Party:      PSTN (31) 9337
>> 1091(36: 2)     13:59:14[ 4]--13:59:53[ 1]
>> 
>> 
>> 
>> 
> 
> 



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

Date: Wed, 23 May 2001 14:17:00 GMT
From: helgi@NOSPAMdecode.is (Helgi Briem)
Subject: Re: Q: about combining lines of a call record file...
Message-Id: <3b0bc639.3710207646@news.isholf.is>

On Wed, 23 May 2001 02:54:30 -0600, Todd Nathan
<tnathan@midwayisland.net> wrote:

>Oh, I should have figured that someone in the Perl community would do the
>RTFM thing, being offline from the Perl community for 5+ years now I kinda
>forgot why I left it in the first place.  Thanks for the not so sutle
>refresher
>course on how to be an asshole and get someone really disinterested in
>something quickly ;'P  You are a class act.
>
Don't let the door hit your ass on the way out.

Regards,
Helgi Briem



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

Date: Wed, 23 May 2001 15:15:19 +0100
From: "M" <mike@gatrell.org>
Subject: Re: Redirecting STDERR to sendmail
Message-Id: <9egglp$glg$1@taliesin.netcom.net.uk>

On Tue, 22 May 2001 18:41:24 +0100, "Unknown" <nobull@mail.com> wrote:

<snip>
> BTW: You never use $date.

why not??

M
-- 
Don't vote... you'll only encourage them.


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

Date: Wed, 23 May 2001 15:10:08 +0200
From: perler@yahoo.com (Patrick Erler)
Subject: regexp for triming domainnames
Message-Id: <Xns90AA9A4D08A55fuyyehcesyrdx@62.153.159.134>

hello!

i have a regexp problem which is rather tricky, at least for me:

i would like to strip from a domainname:

    	www.test.com

or

    	foo.bar.test.com

everything but "test".

i think the easiest way to do it is in 2 steps:

first step

s/everything after the last . and the .//

    	so that we have foo.bar.test or www.test

second step

s/everything to the last . and the last .//

but i just get a smoking head her when i try to create the regexp.. 

maybe someone can help?

thanks in advance,


PAT


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

Date: Wed, 23 May 2001 15:49:17 +0200
From: Philip Newton <pne-news-20010523@newton.digitalspace.net>
Subject: Re: regexp for triming domainnames
Message-Id: <thfngtof851kideophvfbtspttuarclmm9@4ax.com>

On Wed, 23 May 2001 15:10:08 +0200, perler@yahoo.com (Patrick Erler)
wrote:

> i think the easiest way to do it is in 2 steps:

Yes, probably. At least if you want to use a regexp.

> s/everything after the last . and the .//

Easier if you express it as "a . and all the non-.'s that follow it
until the end of the string":

    s/\.[^.]+\z//;

> s/everything to the last . and the last .//

    s/.+\.//;

Since the .+ is greedy, the \. will match the last dot in the string,
not the first one.

Replace + with * if you want; however, I assume that you don't have host
names that begin or end with a dot.

Another way would be to use split: split on dots and retrieve the
next-to-last component:

    $host = (split /\./, $domain)[-2];
    # or, alternatively,
    $host = (reverse split /\./, $domain, 3)[1];

This even works on things like "example.com" (that is, host names which
only have two components). The second example does not split more often
than necessary, but since most host names in practice probably do not
have more than four or five components, and very many have only three
components anyway, the extra cost for the reverse probably does not
offset the gain from less splitting.

Cheers,
Philip
-- 
Philip Newton <nospam.newton@gmx.li>
Yes, that really is my address; no need to remove anything to reply.
If you're not part of the solution, you're part of the precipitate.


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

Date: Wed, 23 May 2001 15:52:53 +0200
From: "Tom Klinger" <admin@the-piper.net>
Subject: Re: regexp for triming domainnames
Message-Id: <3b0bc1d3@news.i-one.at>


"Patrick Erler" <perler@yahoo.com> wrote in message
news:Xns90AA9A4D08A55fuyyehcesyrdx@62.153.159.134...
> hello!
>
> i have a regexp problem which is rather tricky, at least for me:
>
> i would like to strip from a domainname:
>
>     www.test.com
>
> or
>
>     foo.bar.test.com
>
> everything but "test".
>
If you don't mind about things like www.university.ac.at for example you
could use this:

#!/usr/bin/perl
$domain=$ARGV[0];
$domain =~ s/^.+\.(.+)\.((\w+){2,3})$/$1/;
print "Domainname: $domain\n";
exit;

Tried to also a solution for the mentioned case above, but sorry, maybe an
other may have a clue, I'm already in a hurry ...

hth, Tom




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

Date: 23 May 2001 13:50:44 GMT
From: rgarciasuarez@free.fr (Rafael Garcia-Suarez)
Subject: Re: regexp for triming domainnames
Message-Id: <slrn9gng0j.k1i.rgarciasuarez@rafael.kazibao.net>

Patrick Erler wrote in comp.lang.perl.misc:
} hello!
} 
} i have a regexp problem which is rather tricky, at least for me:
} 
} i would like to strip from a domainname:
} 
}     	www.test.com
} 
} or
} 
}     	foo.bar.test.com
} 
} everything but "test".

$string =~ s/^(.*)\.([a-zA-Z0-9-]+)\.[a-zA-Z0-9-]+$/$2/
  or die "$string has not the right format\n";

-- 
Rafael Garcia-Suarez / http://rgarciasuarez.free.fr/


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

Date: Wed, 23 May 2001 15:41:17 +0100
From: Paul Boardman <peb@bms.umist.ac.uk>
Subject: Re: regexp for triming domainnames
Message-Id: <3B0BCC0D.ED454093@bms.umist.ac.uk>

Patrick Erler wrote:
> 
> hello!
> 
> i have a regexp problem which is rather tricky, at least for me:
> 
> i would like to strip from a domainname:
> 
>         www.test.com
> 
> or
> 
>         foo.bar.test.com
> 
> everything but "test".
<snip>

how about 

$domainname = "www.test.com";
$result = (split/\./)[-2];


this works on foo.bar.test.com as well.

HTH

Paul


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

Date: Wed, 23 May 2001 16:42:31 +0200
From: perler@yahoo.com (Patrick Erler)
Subject: Re: regexp for triming domainnames
Message-Id: <Xns90AAA9F6526Dfuyyehcesyrdx@62.153.159.134>

Philip Newton <pne-news-20010523@newton.digitalspace.net> wrote in 
news:thfngtof851kideophvfbtspttuarclmm9@4ax.com:

>     $host = (split /\./, $domain)[-2];
>     # or, alternatively,
>     $host = (reverse split /\./, $domain, 3)[1];
this is the perfect solution! (i forgot to mention that i want to catch 
example.com too)

thanks for you quick replies!


PAT


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

Date: 22 May 2001 15:30:19 -0500
From: Ren Maddox <ren@tivoli.com>
Subject: Re: sorting a scrolling_list()
Message-Id: <m3ititcejo.fsf@dhcp9-172.support.tivoli.com>

On Tue, 22 May 2001, wjohnson@roger.ecn.purdue.edu wrote:

> 
> I'm doing some CGI stuff with a syntax like
> 
> my $q=new CGI;
> 
> print $q->scrolling_list(
>     -name => "myname",
>     -values => \%hashref,
>     -size => 1);
> 
> 
> And when I look at the scrolling_list on the form, the visible
> labels are being printed according to however they get hashed in the
> hash table.  The only way I know of specifying an order is by using
> an array reference instead of a hash reference, but then I lose the
> functionality of having a different internal representation of the
> data.
> 
> Is there a way to force the scrolling_list to display in a specified
> order and/or a sorted order?

From "perldoc CGI":

  print $query->scrolling_list(-name=>'list_name',
                               -values=>['eenie','meenie','minie','moe'],
                               -default=>['eenie','moe'],
                               -size=>5,
                               -multiple=>'true',
                               -labels=>\%labels);

So the answer is, pass an array ref for "-values" that is in the order
you want, and pass the hash for "-labels".

-- 
Ren Maddox
ren@tivoli.com


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

Date: 23 May 2001 07:42:17 -0700
From: steve.busiello@gs.com (Steven)
Subject: Re: This String Formation does not work properly, pleaze help!
Message-Id: <fa45b871.0105230642.3e0718fc@posting.google.com>

Take a look at this:
#---------CODE----------
$money = 1000000.23233;
($dollar,$cents) = split(/\./,$money);
$new = reverse($dollar);
$new =~ s/([0-9]{3})/$1\,/g;
$money = reverse($new).".$cents";
print "$money\n";
#---------CODE----------

hope this helps
-Steven


Lars.Plessmann@gmx.de (Lars) wrote in message news:<3b0af4ae.12124850@news.btx.dtag.de>...
> Heres my routine, that makes mistakes if you use big numbers >= 1000.
> It works only with little numbers up to 999 I think. Where's the
> problem?
> I think it's the rounding part. How can I improve it? I don't want
> 232.333333 or something like that. Only 2 digts after the dot.
> 
> sub MoneyFormat
> {
>  # currency format adding commas for easy read
>  my $buf=0;
>  local $_ = shift;
>  1 while s/^([-+]?\d+)(\d{3})/$1,$2/;
>  
>  # rounding the currency
>  $_=sprintf("%.02f", $_); 
> 
>  # Change dots to comma and comma to dots (German form)
>  tr/,./.,/;  
> 
>  return $_;
> }


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

Date: Wed, 23 May 2001 15:53:45 +0200
From: Jac.m.a.m.Oppers <jac.oppers@philips.com>
Subject: VMSPerl v5.7.0 built for VMS_VAX / CGI.pm v2.72 error : "CGI open of tmpfile: file specification syntax error".
Message-Id: <x7QLO1tTyJQ==XKxBAdVbp5cEvSx@4ax.com>


Hi,

VMSPerl v5.7.0 built for VMS_VAX gives the following error in CGI.pm
v2.72 when I try to run the standard "File Upload Example" using the
relative old OpenVMS V5.5-2H4 with DEC C v5.2-003 and USO HTTPDServer
2.0-A :

Software error:
CGI open of tmpfile: file specification syntax error.

Btw. most scripts are working, but not the standard "File Upload
Example". 

I added these two lines at the hardcoded location for file upload in
CGI.pm v2.72 :
$TempFile::TMPDIRECTORY = 'dka300:[httpd]';
$OS='VMS';
but that does not make the error message go away :-)

The error occurs inside CGI.pm, more specifically within this piece of
code :

# choose a relatively unpredictable tmpfile sequence number
my $seqno = unpack("%16C*",join('',localtime,values %ENV));
for (my $cnt=10;$cnt>0;$cnt--) {
next unless $tmpfile = new TempFile($seqno);
$tmp = $tmpfile->as_string;
last if defined($filehandle =  
        Fh->new($filename,$tmp,$PRIVATE_TEMPFILES));
$seqno += int rand(100);
}
die "CGI open of tmpfile: $!\n" unless $filehandle;

I noticed by setting the $set verify option within wwwexec.com of the
OSU HTTPDServer v2.0-A that the pid of the server process differs from
$seqno, and that outside the perl interpreter the USO HTTPDServer
2.0-A software already creates and deletes a tempfile containing the
correct content : that's probably why other upload scripts not using
perl, but HTML or Javascript do work. The OSU HTTPDServer 2.0-A tries
to cooperate with the perl interpreter within wwwexec.com by giving
the name of the temporary file to perl (take a look at netserver.log):

$  perl WWW_ROOT:[BIN]FILE_UPLOAD.PL "POST" "HTTP/1.1" >net_link: <
sys$scratch:perlcgi_00001395.tmp
[Wed May 23 14:57:48 2001] www_root:[bin]file_upload.pl: CGI open of
tmpfile: file specification syntax error
%SYSTEM-F-NOLOGNAM, no logical name match

Here I find the same error message as within the browser. In this case
the pid of the server process is equal to 1395 and $seqno equals
35221. Not compatible at all as parts of the same temporary filename
:-)  

Anyone any ideas ? Did I forget to read some parts of the
documentation of perl v5.7.0 or the OSU HTTPDServer v2.0-A ?
Suggestions are most welcome.

Best regards,
Jac.
jac.oppers@philips.com (replaces jac@natlab.research.philips.com)
j.m.a.m.oppers@(hccnet|hetnet|chello).nl



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

Date: Wed, 23 May 2001 14:43:51 GMT
From: Dan Sugalski <dan@tuatha.sidhe.org>
Subject: Re: VMSPerl v5.7.0 built for VMS_VAX / CGI.pm v2.72 error : "CGI open of tmpfile: file specification syntax error".
Message-Id: <H0QO6.21521$v5.1745402@news1.rdc1.ct.home.com>

Jac.m.a.m.Oppers <jac.oppers@philips.com> wrote:

> Hi,

> VMSPerl v5.7.0 built for VMS_VAX gives the following error in CGI.pm
> v2.72 when I try to run the standard "File Upload Example" using the
> relative old OpenVMS V5.5-2H4 with DEC C v5.2-003 and USO HTTPDServer
> 2.0-A :

5.7.0 is a development version of perl, and it has a number of oddities
and bugs. (Hence the development label :)  Don't use it in production.
Instead, grab perl 5.6.1, which should work OK.

You might potentially run into problems, given that VMS 5.5 is positively
antique, and Dec C 5.2 isn't that much newer. If it gives you a problem,
grab perl 5.005_03 instead and use that. It's a little older, but I know
that it builds properly with VMS 5.5/Dec C 5.2.

					Dan


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

Date: 23 May 2001 07:28:12 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Warning/Danger -- Don't use Perl for CGI
Message-Id: <m14rucjg1v.fsf@halfdome.holdit.com>

>>>>> "W" == W K <bill.kemp@wire2.com> writes:

W> They are saying don't have pErL* in a cgi-bin directory, as in
W> "/usr/local/apache/cgi-bin/perl"
W> Rather than having it somewhere like
W> "/usr/bin/perl"

W> Does anyone use the first variant anyway?

Originally, yes.  After TC released "latro", no. :)

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!


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

Date: Wed, 23 May 2001 13:31:09 GMT
From: mjd@plover.com (Mark Jason Dominus)
Subject: Re: what does this mean?
Message-Id: <3b0bbb9b.510b$1c3@news.op.net>

In article <slrn9gmu2s.91g.vek@pharmnl.ohout.pharmapartners.nl>,
Villy Kruse <vek@pharmnl.ohout.pharmapartners.nl> wrote:
>I wonder: why do a web search if the documentation and manuals are all
>installed locally?

Why post to usenet if the manuals are all installed locally?

-- 
@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: 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 967
**************************************


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