[28132] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 9496 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jul 18 18:05:36 2006

Date: Tue, 18 Jul 2006 15:05:05 -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, 18 Jul 2006     Volume: 10 Number: 9496

Today's topics:
        "Its fast as heck" shiriram krishnamurthi said scheme w <bootiack@yahoo.com>
    Re: "Its fast as heck" shiriram krishnamurthi said sche <1usa@llenroc.ude.invalid>
    Re: commenting configuration files <tzz@lifelogs.com>
    Re: Extract alternate patterns harsha.ramanagoudra@gmail.com
    Re: help me <benmorrow@tiscali.co.uk>
    Re: How get UTF-8 from urlencoded web form <jwkenne@attglobal.net>
    Re: How get UTF-8 from urlencoded web form <flavell@physics.gla.ac.uk>
        How to add variables to strings? <yusufm@gmail.com>
        How to add variables to strings? <yusufm@gmail.com>
    Re: How to add variables to strings? <yusufm@gmail.com>
    Re: How to add variables to strings? <mritty@gmail.com>
    Re: How to add variables to strings? <tzz@lifelogs.com>
    Re: How to add variables to strings? <mritty@gmail.com>
    Re: How to add variables to strings? <tzz@lifelogs.com>
    Re: How to add variables to strings? <mritty@gmail.com>
    Re: How to find which (if any) member of a list is in a tinnews@leary.csoft.net
    Re: How to find which (if any) member of a list is in a <DJStunks@gmail.com>
    Re: numeric sort on string like a123-3 <someone@example.com>
    Re: numeric sort on string like a123-3 <mritty@gmail.com>
    Re: numeric sort on string like a123-3 anno4000@radom.zrz.tu-berlin.de
    Re: numeric sort on string like a123-3 <uri@stemsystems.com>
    Re: numeric sort on string like a123-3 <tzz@lifelogs.com>
    Re: numeric sort on string like a123-3 <mritty@gmail.com>
    Re: numeric sort on string like a123-3 <tzz@lifelogs.com>
        Perlis.dll produces text/plain <dveuve@gmail.com>
    Re: start printing at the end of the previous line <glennj@ncf.ca>
    Re: start printing at the end of the previous line <weberw@adelphia.net>
        tuff problem of the day for linux <bootiack@yahoo.com>
    Re: tuff problem of the day for linux <trwww@sbcglobal.net>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 18 Jul 2006 13:55:15 -0700
From: "gavino" <bootiack@yahoo.com>
Subject: "Its fast as heck" shiriram krishnamurthi said scheme webserver 8-10x spped of apachemodeperl
Message-Id: <1153256115.363421.42520@m79g2000cwm.googlegroups.com>

"Its fast as heck" shiriram krishnamurthi said scheme webserver 8-10x
spped of apachemodeperl



Was he serious?  he said 8x as fast as apache for dynamic content but
then someone from audioence asked about apache mod perl and he said yes

quickly.

Can scheme kick that much butt? (as he says)


7:26 on this mpg "its fast as heck"
http://technetcast.ddj.com/tnc_play_stream.html?stream_id=3D644


Reply =BB



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

Date: Tue, 18 Jul 2006 21:26:16 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: "Its fast as heck" shiriram krishnamurthi said scheme webserver 8-10x spped of apachemodeperl
Message-Id: <Xns9804B17AAF2DCasu1cornelledu@127.0.0.1>

"gavino" <bootiack@yahoo.com> wrote in news:1153256115.363421.42520
@m79g2000cwm.googlegroups.com:

> "Its fast as heck" shiriram krishnamurthi said scheme webserver 8-10x
> spped of apachemodeperl

Do you have a point or do you just like going straight to killfiles?

Bye.

Sinan
-- 
A. Sinan Unur <1usa@llenroc.ude.invalid>
(remove .invalid and reverse each component for email address)

comp.lang.perl.misc guidelines on the WWW:
http://augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html



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

Date: Tue, 18 Jul 2006 16:51:04 -0400
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: commenting configuration files
Message-Id: <g697j2atz5z.fsf@CN1374059D0130.kendall.corp.akamai.com>

On 18 Jul 2006, nmrabinovich@gmail.com wrote:

> how do you properly comment a configuration file? I just finished
> writing a perl script and I used a configuration file to hold specific
> details that would change like a user id and names of files. I need to
> comment the configuration file but I am not absolutely positive how to
> go about that.

Sounds like you wrote your own config parser.  This is probably a bad
idea, unless you really need to, or the format is extremely simple.
Use a module like AppConfig or YAML, or a XML parser.  The most common
comment format in Unix land for *plain text* is to begin a line with
'#', but there are as many configuration formats as there are
programs.

With YAML/XML/etc. data formats, you can make the comment a part of
the configuration, so each data element has its own doc string.  It
depends on how far you want to go, which should be determined by how
many people will be using your code, and for how long :)

As Xho said, you have to help us help you further.

Ted


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

Date: 18 Jul 2006 11:28:29 -0700
From: harsha.ramanagoudra@gmail.com
Subject: Re: Extract alternate patterns
Message-Id: <1153247308.985392.26600@m73g2000cwd.googlegroups.com>


Gunnar Hjalmarsson wrote:

>>snip
> >
> >       if($transaction =~ /(addReq|modReq|subtractReq)+?.*?(addReq)?/){
> >         print "$1..$2\n";
> >       }
> >

>
> One idea:
>
>      /(addReq|modReq|subtractReq)(?:.*(?=addReq)|.*)(addReq)?/
>
> --
> Gunnar Hjalmarsson
> Email: http://www.gunnar.cc/cgi-bin/contact.pl

Thank you Gunnar. This works.



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

Date: Tue, 18 Jul 2006 18:24:58 +0100
From: Ben Morrow <benmorrow@tiscali.co.uk>
Subject: Re: help me
Message-Id: <a4ivo3-t3c.ln1@osiris.mauzo.dyndns.org>

Try a decent subject line, and try not posting the same question twice.

Quoth "jeni" <jenish.g@gmail.com>:
> suggest any online free docs for handling MS Word using Win32::OLE.
> no one documentation gives the different methods to access MSWord.
> pls help me

You need to read Word's documentation, which comes with Word. You will
have to convert the examples from VBA to Perl, but that's not difficult.

Ben

-- 
               We do not stop playing because we grow old; 
                  we grow old because we stop playing.
                         benmorrow@tiscali.co.uk


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

Date: Tue, 18 Jul 2006 14:30:47 -0400
From: "John W. Kennedy" <jwkenne@attglobal.net>
Subject: Re: How get UTF-8 from urlencoded web form
Message-Id: <KO9vg.1804$VD1.452@fe09.lga>

Alan J. Flavell wrote:
> That seems to me a very confuddling way of trying to convince oneself 
> that \n is always 0x0A - even though, on some platforms, your
> hypothetical 0x0A never really exists, other than in the mind.

And RAM, and in the chr and ord functions, and files written in binary, 
and in C extension code, and (compared to 0x0D0A) in offsets and lengths 
relative to substrings.

I forgot to consider EBCDIC; when I last worked on mainframes, the 
Unix-like features of MVS weren't there yet. The meaning of "\n" on Macs 
(in various languages) is in chaos, because of Darwin.

-- 
John W. Kennedy
"The blind rulers of Logres
Nourished the land on a fallacy of rational virtue."
   -- Charles Williams.  "Taliessin through Logres: Prelude"


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

Date: Tue, 18 Jul 2006 19:47:36 +0100
From: "Alan J. Flavell" <flavell@physics.gla.ac.uk>
Subject: Re: How get UTF-8 from urlencoded web form
Message-Id: <Pine.LNX.4.64.0607181938550.2723@ppepc20.ph.gla.ac.uk>

On Tue, 18 Jul 2006, John W. Kennedy wrote:

> Alan J. Flavell wrote:
> > That seems to me a very confuddling way of trying to convince 
> > oneself that \n is always 0x0A - even though, on some platforms, 
> > your hypothetical 0x0A never really exists, other than in the 
> > mind.
> 
> And RAM, and in the chr and ord functions, and files written in binary,

Except on the platforms where it isn't.  Which is what this discussion 
is about.

Has it never occurred to you to ask yourself why CGI.pm, for example, 
contains this comment:

# Define the CRLF sequence.  I can't use a simple "\r\n" because the meaning
# of "\n" is different on different OS's (sometimes it generates CRLF, sometimes LF
# and sometimes CR). 

and goes on to set $CRLF differently according to platform.

> I forgot to consider EBCDIC; 

I was under the impression that you claimed "on all systems".

> The meaning of "\n" on Macs (in various
> languages) is in chaos, because of Darwin.

But I was under the impression that you claimed "on all systems".

Apparently VMS is different again.

Wouldn't you be prepared to admit that you were mistaken, and to 
refer readers to perlport for more reliable information on this 
matter?

regards


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

Date: 18 Jul 2006 12:01:51 -0700
From: "yusuf" <yusufm@gmail.com>
Subject: How to add variables to strings?
Message-Id: <1153249311.082053.157710@75g2000cwc.googlegroups.com>

Hi,

I want to construct a SQL statement which consists of a string added to
some information stored in variables. But its not adding the text of
the variable to the first part of the string, just storing the value of
the variable:

$statement = "select * FROM logarama WHERE timestamp > ". $T[4]+1



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

Date: 18 Jul 2006 12:02:00 -0700
From: "yusuf" <yusufm@gmail.com>
Subject: How to add variables to strings?
Message-Id: <1153249320.581943.158450@75g2000cwc.googlegroups.com>

Hi,

I want to construct a SQL statement which consists of a string added to
some information stored in variables. But its not adding the text of
the variable to the first part of the string, just storing the value of
the variable:

$statement = "select * FROM logarama WHERE timestamp > ". $T[4]+1;



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

Date: 18 Jul 2006 12:03:18 -0700
From: "yusuf" <yusufm@gmail.com>
Subject: Re: How to add variables to strings?
Message-Id: <1153249398.319462.49600@i42g2000cwa.googlegroups.com>

Sorry about the multiple posts, the line is:

$statement = "select * FROM logarama WHERE timestamp > " . $T[4]+1;

yusuf wrote:
> Hi,
>
> I want to construct a SQL statement which consists of a string added to
> some information stored in variables. But its not adding the text of
> the variable to the first part of the string, just storing the value of
> the variable:
> 
> $statement = "select * FROM logarama WHERE timestamp > ". $T[4]+1;



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

Date: 18 Jul 2006 12:14:36 -0700
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: How to add variables to strings?
Message-Id: <1153250076.371284.146780@m79g2000cwm.googlegroups.com>

yusuf wrote:
> Hi,
>
> I want to construct a SQL statement which consists of a string added to
> some information stored in variables. But its not adding the text of
> the variable to the first part of the string, just storing the value of
> the variable:
>
> $statement = "select * FROM logarama WHERE timestamp > ". $T[4]+1

Running the above through -MO=Deparse,-p gives us:

$ perl -MO=Deparse,-p -e'$statement = "select * FROM logarama WHERE
timestamp > " . $T[4]+1;'
($statement = (('select * FROM logarama WHERE timestamp > ' . $T[4]) +
1));
-e syntax OK

As the above shows, . has a higher precedence than +.  So you are
contatenating $T[4] to the string literal, and then adding 1 to the
result.  Put parentheses around your addition expression:

$statement = "select * FROM logarama WHERE timestamp > " . ($T[4]+1);

Paul Lalli



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

Date: Tue, 18 Jul 2006 16:18:48 -0400
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: How to add variables to strings?
Message-Id: <g69fygyu0nr.fsf@CN1374059D0130.kendall.corp.akamai.com>

On 18 Jul 2006, yusufm@gmail.com wrote:

> Sorry about the multiple posts, the line is:
>
>> statement = "select * FROM logarama WHERE timestamp > " . $T[4]+1;
>
> yusuf wrote:
>> Hi,
>>
>> I want to construct a SQL statement which consists of a string added to
>> some information stored in variables. But its not adding the text of
>> the variable to the first part of the string, just storing the value of
>> the variable:
>>
>>> statement = "select * FROM logarama WHERE timestamp > ". $T[4]+1;

What did you expect?  What did you actually get?  Can you post some
actual code (what's above won't compile)?

Ted


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

Date: 18 Jul 2006 13:30:20 -0700
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: How to add variables to strings?
Message-Id: <1153254620.682402.178580@i42g2000cwa.googlegroups.com>

Ted Zlatanov wrote:
> On 18 Jul 2006, yusufm@gmail.com wrote:
>
>>> statement = "select * FROM logarama WHERE timestamp > ". $T[4]+1;
>
> What did you expect?  What did you actually get?  Can you post some
> actual code (what's above won't compile)?

The above compiles just fine if you don't chop off the OP's beginning
dollar-sign:
$ perl -c -e'$statement = "select * FROM logarama WHERE timestamp > " .
$T[4]+1;'
-e syntax OK

Please make sure your newsreader isn't assuming that $ means "beginning
of a quoted line"

Paul Lalli



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

Date: Tue, 18 Jul 2006 17:02:16 -0400
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: How to add variables to strings?
Message-Id: <g69y7uqsk2v.fsf@CN1374059D0130.kendall.corp.akamai.com>

On 18 Jul 2006, mritty@gmail.com wrote:

Ted Zlatanov wrote: > On 18 Jul 2006, yusufm@gmail.com wrote: >
>>>> statement = "select * FROM logarama WHERE timestamp > ". $T[4]+1;
>>
>> What did you expect?  What did you actually get?  Can you post some
>> actual code (what's above won't compile)?
>
> The above compiles just fine if you don't chop off the OP's beginning
> dollar-sign:
> $ perl -c -e'$statement = "select * FROM logarama WHERE timestamp > " .
> $T[4]+1;'
> -e syntax OK

You're right.  Gnus cut it off because I hit Enter too fast when it
asked if $ was a quote char.

In any case, the code is incomplete and my original questions are
valid, minus "won't compile."  Who knows what $T holds, and what the
OP expects.

> Please make sure your newsreader isn't assuming that $ means "beginning
> of a quoted line"

Thanks.

Ted


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

Date: 18 Jul 2006 14:15:09 -0700
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: How to add variables to strings?
Message-Id: <1153257309.202574.144090@m79g2000cwm.googlegroups.com>

Ted Zlatanov wrote:
> In any case, the code is incomplete and my original questions are
> valid, minus "won't compile."  Who knows what $T holds, and what the
> OP expects.

I disagree.  I think the OP was plenty clear in his original post:
>>I want to construct a SQL statement which consists of a string added to
>>some information stored in variables. But its not adding the text of
>>the variable to the first part of the string, just storing the value of
>>the variable:
>>
>>$statement = "select * FROM logarama WHERE timestamp > ". $T[4]+1

The value of $T is irrelevant, since the code does not use $T.  The
value of @T is also irrelevant, as the question is about why the value
of $T[4] plus 1 does not get added to the string.  The OP said exactly
what he expected: "adding the text of the variable to the first part of
the string".  (The form of the request leads me to believe the OP is
not a native English-speaker, which more than excuses (to me)
grammatical errors).  Anyone who runs the code sees what happens
instead - $statement gets the value of 1.

There are a multitude of un-clear posts in this newsgroup.  I do not
believe this was one of them.

Paul Lalli



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

Date: 18 Jul 2006 20:09:38 GMT
From: tinnews@leary.csoft.net
Subject: Re: How to find which (if any) member of a list is in a given line of text
Message-Id: <44bd4002$0$782$bed64819@news.gradwell.net>

Ted Zlatanov <tzz@lifelogs.com> wrote:
> On 18 Jul 2006, tinnews@leary.csoft.net wrote:
> 
> > Are there any cleaner/quicker ways of doing the following:-
> >
> > @fs = ("string1", "string2", "string3", "string4");
> >
> > foreach $f (@fs)
> > {
> >       if (index ($line, $f)
> >       {
> >           # do something useful
> >       }
> > }
> >
> > Sorry if the syntax isn't quite right but I'm sure the idea is fairly
> > clear.  The strings to search for (@fs) are read from a file once only
> > and are essentially constant, they can be in an array or a hash or
> > whatever is most efficient.
> >
> > The line to search comes from standard input and is the 'variable'
> > in the problem.
> >
> > So I'm receiving lines of text and I want to do something whenever
> > one of my 'constant' strings is found in that line.    
> 
> You can also make a complicated regex (you need to qr// and then join)
> to match, then study() it and maybe it will be a little faster, but
> this way is probably easiest.  Just put a last() inside your if()
> block to skip any tests you don't need to make (if that's the right
> logic).
> 
> If the search strings have commonalities, you can search for that, and
> skip lines that don't contain it.  I doubt it's worth the effort.
> Generally, go for the simplest solution unless it's slow :)
> 
OK, thanks, I just wanted to be sure I wasn't missing something glaringly
obvious.

-- 
Chris Green


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

Date: 18 Jul 2006 14:55:46 -0700
From: "DJ Stunks" <DJStunks@gmail.com>
Subject: Re: How to find which (if any) member of a list is in a given line of text
Message-Id: <1153259746.879385.93000@75g2000cwc.googlegroups.com>

Ted Zlatanov wrote:
> On 18 Jul 2006, tinnews@leary.csoft.net wrote:
>
> > Are there any cleaner/quicker ways of doing the following:-
> >
> > @fs = ("string1", "string2", "string3", "string4");
> >
> > foreach $f (@fs)
> > {
> > 	if (index ($line, $f)
> > 	{
> > 	    # do something useful
> > 	}
> > }
> >
> > Sorry if the syntax isn't quite right but I'm sure the idea is fairly
> > clear.  The strings to search for (@fs) are read from a file once only
> > and are essentially constant, they can be in an array or a hash or
> > whatever is most efficient.
> >
> > The line to search comes from standard input and is the 'variable'
> > in the problem.
> >
> > So I'm receiving lines of text and I want to do something whenever
> > one of my 'constant' strings is found in that line.
>
> You can also make a complicated regex (you need to qr// and then join)
> to match,

you can use Regex::Presuf to form a regex from a list of strings which
generally matches faster than simply or'ing everything together...

might help.  might not.

-jp



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

Date: Tue, 18 Jul 2006 18:08:05 GMT
From: "John W. Krahn" <someone@example.com>
Subject: Re: numeric sort on string like a123-3
Message-Id: <9s9vg.111474$I61.85513@clgrps13>

filippo wrote:
> 
> I have string lilke these
> 
> a12-1
> b1-3
> b123-2
> c12
> c12-1
> 
> axxx-y
> 
> a is a letter
> xxx is a number 1-120
> y is a number 1-3
> 
> I want to sort by xxx, is it possible?

my @sorted = map  $_->[ 1 ],
             sort { $a->[ 0 ] <=> $b->[ 0 ] }
             map  { /(\d+)/, $_ }
             qw/ a12-1 b1-3 b123-2 c12 c12-1 /;



John
-- 
use Perl;
program
fulfillment


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

Date: 18 Jul 2006 11:09:15 -0700
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: numeric sort on string like a123-3
Message-Id: <1153246155.259060.94280@i42g2000cwa.googlegroups.com>

filippo wrote:
> I have string lilke these
>
> a12-1
> b1-3
> b123-2
> c12
> c12-1
>
> axxx-y
>
> a is a letter
> xxx is a number 1-120
> y is a number 1-3
>
> I want to sort by xxx, is it possible?

Sure it is.  In your sort subroutine, compare the xxx parts of the
string, rather than the strings themselves:

my @sorted = sort {
   my ($a_num) = $a =~ /^[a-z](\d+)/;
   my ($b_num) = $b =~ /^[a-z](\d+)/;
   return $a_num <=> $b_num;
}  @strings;

Or, to make this more efficient, use a Schwartzian Transform, so you
only have to do the pattern match once on each element:

my @sorted = map { $_->[0] }
sort { $a->[1] <=> $b->[1] }
map { [$_, /^[a-z](\d+)/ ] } @strings;

(Note that both of these will leave a12-1, c12, and c12-1 in a random
order in Perl 5.6 and lower, and in the same order as they were in the
original list in Perl 5.8 and higher.  Altering the sort to take the
second number and/or the beginning letter into account is left as an
excercise to the OP. :-) )

Paul Lalli



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

Date: 18 Jul 2006 18:15:01 GMT
From: anno4000@radom.zrz.tu-berlin.de
Subject: Re: numeric sort on string like a123-3
Message-Id: <4i4mp5F2599lU1@news.dfncis.de>

filippo <filippo2991@virgilio.it> wrote in comp.lang.perl.misc:
> Hi,
> I have string lilke these
> 
> a12-1
> b1-3
> b123-2
> c12
> c12-1
> 
> axxx-y
> 
> a is a letter
> xxx is a number 1-120
> y is a number 1-3
> 
> I want to sort by xxx, is it possible?

Sure.  Your xxx is the first group of digits in each list element, so
the match

    /(\d+)/

will capture them.  So this should sort them:

    sort {
       my ( $n_a) = $a =~ /(\d+)/;
       my ( $n_b) = $a =~ /(\d+)/;
       $n_a <=> $n_b;
   } @list;

This supposes that all list elements have at least one group of
integers.

It also does unnecessary work since the numeric part is extracted
from each element every time, often multiple times for the same
element.  A Schwartz transform eliminates the overhead:

    map $_->[ 0],
        sort { $a->[ 1] <=> $b->[ 1] }
        map [ $_, /(\d+)/],
        @list;

(Code untested)

Anno


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

Date: Tue, 18 Jul 2006 15:17:17 -0400
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: numeric sort on string like a123-3
Message-Id: <x7zmf6vi2q.fsf@mail.sysarch.com>

>>>>> "JWK" == John W Krahn <someone@example.com> writes:

  JWK> my @sorted = map  $_->[ 1 ],
  JWK>              sort { $a->[ 0 ] <=> $b->[ 0 ] }
  JWK>              map  { /(\d+)/, $_ }

you forgot to return an anon array from that map:

		map  { [ /(\d+)/, $_ ] }

and since that is a simple expression you can lose the {} (but add a ,)

		map  [ /(\d+)/, $_ ],

  JWK>              qw/ a12-1 b1-3 b123-2 c12 c12-1 /;


i figure you know that but typoed.

this is one reason i recommend sort::maker for even simple sorts as you
don't have to worry about map issues and [0] vs [1] and such. you can
even have it return the source it generates and paste that into your
code so you are not dependent on the module being around.

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org


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

Date: Tue, 18 Jul 2006 16:45:50 -0400
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: numeric sort on string like a123-3
Message-Id: <g69bqrmtzep.fsf@CN1374059D0130.kendall.corp.akamai.com>

On 18 Jul 2006, someone@example.com wrote:

filippo wrote: >
>> I have string lilke these
>>
>> a12-1
>> b1-3
>> b123-2
>> c12
>> c12-1
>>
>> axxx-y
>>
>> a is a letter
>> xxx is a number 1-120
>> y is a number 1-3
>>
>> I want to sort by xxx, is it possible?
>
> my @sorted = map  $_->[ 1 ],
> sort { $a->[ 0 ] <=> $b->[ 0 ] }
> map  { /(\d+)/, $_ }
> qw/ a12-1 b1-3 b123-2 c12 c12-1 /;

An alternate, using split:

my @sorted = map { $_->[0] . $_->[1] } 
             sort {$a->[1] <=> $b->[1] } 
             map { [split("", $_, 2)] } 
             qw/ a12-1 b1-3 b123-2 c12 c12-1 /;

avoids regexes but it's not exciting otherwise :)

Ted



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

Date: 18 Jul 2006 13:50:27 -0700
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: numeric sort on string like a123-3
Message-Id: <1153255827.131620.81660@s13g2000cwa.googlegroups.com>

Ted Zlatanov wrote:

> An alternate, using split:
>
> my @sorted = map { $_->[0] . $_->[1] }
>              sort {$a->[1] <=> $b->[1] }
>              map { [split("", $_, 2)] }
>              qw/ a12-1 b1-3 b123-2 c12 c12-1 /;
>
> avoids regexes but it's not exciting otherwise :)

It also causes "is not numeric" warnings all over the place.

Paul Lalli



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

Date: Tue, 18 Jul 2006 16:59:06 -0400
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: numeric sort on string like a123-3
Message-Id: <g693bcytysl.fsf@CN1374059D0130.kendall.corp.akamai.com>

On 18 Jul 2006, mritty@gmail.com wrote:

Ted Zlatanov wrote:
>
>> An alternate, using split:
>>
>> my @sorted = map { $_->[0] . $_->[1] }
>> sort {$a->[1] <=> $b->[1] }
>> map { [split("", $_, 2)] }
>> qw/ a12-1 b1-3 b123-2 c12 c12-1 /;
>>
>> avoids regexes but it's not exciting otherwise :)
>
> It also causes "is not numeric" warnings all over the place.

Warnings?  Who programs with -w on? :)

It does teach something about Perl regardless: a string that begins
with a number will be interpreted as that number despite the warning
in a numeric context.  That can be useful in many places.  Take it as
a fun example, not production code.

Ted


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

Date: 18 Jul 2006 13:39:51 -0700
From: "David" <dveuve@gmail.com>
Subject: Perlis.dll produces text/plain
Message-Id: <1153255191.275224.66850@h48g2000cwc.googlegroups.com>

We run a help desk perl web app that drags its feet a bit. (I estimate
that when doing our slowest operation, it loads perl, then compiles and
runs something like 20,000 lines of code, but it's probably well above
that. I only wrote ~2000 of those lines.) I was trying to configure
perlis.dll to hopefully improve performance, after fine tuning the code
about as much as my novice skill can.

My problem, though, is that it produces results in text/plain. The html
renders in IE, with the "Content-type: text/html\n\n" printed up at the
top of the page, and does not render at all in Firefox. When I
configure IIS 6 (Windows 2003) to run perl.exe, it renders as it
should.

Does anyone have any ideas? The only thing I was able to find via
google or groups was a mention of this exact problem, followed by an
non-helpful solution.

Thank you.



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

Date: 18 Jul 2006 18:05:45 GMT
From: Glenn Jackman <glennj@ncf.ca>
Subject: Re: start printing at the end of the previous line
Message-Id: <slrnebq8np.m92.glennj@smeagol.ncf.ca>

At 2006-07-18 12:50PM, weberw@adelphia.net <weberw@adelphia.net> wrote:
>  Thanks David,    It still prints everything on one line.  Can you take
>  a look at my code...
[...]

That's how browsers render multiple whitespace in HTML.

>  print header,
>  	start_html($title),
>  	h1($title);

print "<pre>";

>  find ( {
>    wanted => \&wanted}, 'C:/Documents and
>  Settings/whatever/Desktop/test');
>  
>  printf "\nThere are %d files in %d directories.\n",
>  $file_count,
>  $dir_count;

print "</pre>";

[...]
>  print end_hmtl;


-- 
Glenn Jackman
Ulterior Designer


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

Date: 18 Jul 2006 14:07:03 -0700
From: "weberw@adelphia.net" <weberw@adelphia.net>
Subject: Re: start printing at the end of the previous line
Message-Id: <1153256823.048620.51670@i42g2000cwa.googlegroups.com>

Hi Glen-you have been really helpful!  How do you incorporate the print
' ' x line with a hyperlink?  It works fine when it is not a hyperlink
for example

print "<pre>";
print ' ' x ($directorylen-5), $_;
print "</pre>";

but print ' ' x ($directorylen), <a
href=\"$File::Find::name\">$_</a>\n"; has a syntax error.  How would I
incorporate my hyplerlink tags into the print ' ' x line?

Also, not clear what you meant by [....].



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

Date: 18 Jul 2006 14:05:16 -0700
From: "gavino" <bootiack@yahoo.com>
Subject: tuff problem of the day for linux
Message-Id: <1153256716.393937.155030@s13g2000cwa.googlegroups.com>

30 servers with veritas backup client
task
1 add 1 line to config file
2 restart backup client
3 do for all 30 servers over ssh
4 do in a script without having to goto each server and login



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

Date: Tue, 18 Jul 2006 21:27:45 GMT
From: "Todd W" <trwww@sbcglobal.net>
Subject: Re: tuff problem of the day for linux
Message-Id: <lncvg.123536$H71.26941@newssvr13.news.prodigy.com>


"gavino" <bootiack@yahoo.com> wrote in message 
news:1153256716.393937.155030@s13g2000cwa.googlegroups.com...
> 30 servers with veritas backup client
> task
> 1 add 1 line to config file
> 2 restart backup client
> 3 do for all 30 servers over ssh
> 4 do in a script without having to goto each server and login
>

1. Write a subroutine that does [task] to one computer
2. Put names of all machines in an array
3. loop over array and call sub for each element

To put the thread on topic, search CPAN for SSH

Todd W.




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

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


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