[18616] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 784 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Apr 27 18:11:08 2001

Date: Fri, 27 Apr 2001 15:10:20 -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: <988409420-v10-i784@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Fri, 27 Apr 2001     Volume: 10 Number: 784

Today's topics:
        Image representation of a binary string <goldbb2@earthlink.net>
    Re: Is there a neater way to code this? (in) <tom@timanfaya.freeserve.co.uk>
    Re: Levels of perl programming (Tad McClellan)
    Re: Levels of perl programming <sthomas@ws5120.nc.fnc.fujitsu.com>
        Mail Program <b_many2k@yahoo.com>
    Re: Mail Program <webmaster@webdragon.unmunge.net>
    Re: Mail Program <Jonathan.L.Ericson@jpl.nasa.gov>
    Re: Mail Program <Jonathan.L.Ericson@jpl.nasa.gov>
    Re: Please help <goldbb2@earthlink.net>
    Re: Problem in Netscape with CGI Headers (Tad McClellan)
    Re: Problem in Netscape with CGI Headers <flavell@mail.cern.ch>
    Re: Problem in Netscape with CGI Headers (Si Ballenger)
    Re: Question on variable substitution (Tad McClellan)
    Re: Question on variable substitution (Tad McClellan)
    Re: regex for quoted lists (Anno Siegel)
    Re: regex for quoted lists nobull@mail.com
    Re: regex for quoted lists <cybertoast@mindless.com>
    Re: Regular expression for zip code <sharding@ccbill.com>
    Re: Regular expression for zip code <xris@dont.send.spam>
    Re: Regular expression for zip code (Anno Siegel)
    Re: Regular expression for zip code <ren@tivoli.com>
    Re: Regular expression for zip code <xris@dont.send.spam>
    Re: Regular expression for zip code <sharding@ccbill.com>
    Re: So what do YOU use Perl for? <mingram@atreus-systems.com>
    Re: split and array problem <ren@tivoli.com>
        Strange string -> num conversion <jll63@easynet.be>
    Re: Strange string -> num conversion (Anno Siegel)
    Re: Strange string -> num conversion <jll63@easynet.be>
    Re: Strange string -> num conversion (Anno Siegel)
    Re: Strange string -> num conversion <jll63@easynet.be>
    Re: Things I'm just not getting in Perl (Abigail)
        WI Performance Hit w/ Hash || Array v Scalar? (Ameen Dausha)
    Re: WI Performance Hit w/ Hash || Array v Scalar? <Jonathan.L.Ericson@jpl.nasa.gov>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Fri, 27 Apr 2001 20:33:51 GMT
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Image representation of a binary string
Message-Id: <3AE9D8D9.DA92AC79@earthlink.net>

It came up in sci.crypt that one might want to create an image which
represents [the hash of] a binary string, as a sort of visual
fingerprint.  Someone posted the URL
http://www.horde.net/~jwm/software/hex/ which does that, *but* the perl
glue used doesn't want to download (the server is trying to run the
script when one tries to dl it), and furthermore, the program first
generates the md5hash with one program, makes the picture (as a ppm)
with another, then converts to jpg, and stores that as a file (to
eventually be cleaned up, I suppose).  It would be much better to have a
perl cgi which did all the steps in one program, and returned the image
directly (ie, using content-type: image/whatever).

A smart version would even test if there's an if-modified-since field in
the http request header, and respond that the image is good if it's more
recent than the file modification date of the cgi script (so caches will
work right -- there are so many cgis which stupidly always regenerate
data no matter what, even if it's not needed).

-- 
Sometimes the journey *is* its own reward--but not when you're trying to
get to the bathroom in time.


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

Date: Fri, 27 Apr 2001 19:08:57 +0100
From: "Tom Lachecki" <tom@timanfaya.freeserve.co.uk>
Subject: Re: Is there a neater way to code this? (in)
Message-Id: <9cccog$hng$1@newsg3.svr.pol.co.uk>

| Important Perl style suggestion:  Never name anything you don't have to.
:)

*l* Good one :)

-Tom




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

Date: Fri, 27 Apr 2001 12:58:05 -0400
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Levels of perl programming
Message-Id: <slrn9ej98t.4av.tadmc@tadmc26.august.net>

Samuel Thomas <sthomas@ws5120.nc.fnc.fujitsu.com> wrote:
>I feel like and idiot for not being able to find this but
>can anyone point me to the document that lists 7 or so 
>levels of perl skill and how to tell which one you are?


"Seven Levels of Perl Mastery":


   http://larc.ee.nthu.edu.tw/~cfwu/perl/japh.txt

   http://prometheus.frii.com/~gnat/yapc/2000-stages/


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: 27 Apr 2001 14:36:56 -0400
From: Samuel Thomas <sthomas@ws5120.nc.fnc.fujitsu.com>
Subject: Re: Levels of perl programming
Message-Id: <tl6hezayyt3.fsf@ws5120.nc.fnc.fujitsu.com>

tadmc@augustmail.com (Tad McClellan) writes:

> "Seven Levels of Perl Mastery":
> 
> 
>    http://larc.ee.nthu.edu.tw/~cfwu/perl/japh.txt
> 
>    http://prometheus.frii.com/~gnat/yapc/2000-stages/
Thanks a bunch,

 ...only a few more things to do before i hit expert :)

-- 
                /\
Sam Thomas     /  \     "hello, sailor"
Ext 1161      /	** \    Nothing happens here.
	     /______\


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

Date: Fri, 27 Apr 2001 19:38:21 GMT
From: "Brent Reynolds" <b_many2k@yahoo.com>
Subject: Mail Program
Message-Id: <NUjG6.17119$q51.171313@news1.gvcl1.bc.home.com>

This is a multi-part message in MIME format.

------=_NextPart_000_001C_01C0CF16.EFBAC9C0
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

How can I find the path to the mail program on my server?

------=_NextPart_000_001C_01C0CF16.EFBAC9C0
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 5.50.4611.1300" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>How can I find the path to&nbsp;the =
mail program on=20
my server?</FONT></DIV></BODY></HTML>

------=_NextPart_000_001C_01C0CF16.EFBAC9C0--



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

Date: 27 Apr 2001 20:51:52 GMT
From: "Scott R. Godin" <webmaster@webdragon.unmunge.net>
Subject: Re: Mail Program
Message-Id: <9ccm58$l96$0@216.155.33.86>

In article <NUjG6.17119$q51.171313@news1.gvcl1.bc.home.com>,
 "Brent Reynolds" <b_many2k@yahoo.com> wrote:

 | How can I find the path to the mail program on my server?

ls -l `which sendmail`
ls -l `where sendmail`

-- 
unmunge e-mail here:
#!perl -w
print map {chr(ord($_)-3)} split //, "zhepdvwhuCzhegudjrq1qhw"; 
# ( damn spammers. *shakes fist* take a hint. =:P )


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

Date: 27 Apr 2001 20:23:56 +0000
From: Jon Ericson <Jonathan.L.Ericson@jpl.nasa.gov>
Subject: Re: Mail Program
Message-Id: <86hezagkgz.fsf@jon_ericson.jpl.nasa.gov>

"Brent Reynolds" <b_many2k@yahoo.com> writes:

> How can I find the path to the mail program on my server?

Ask your System Administrator?  This is *off-topic* for a *perl*
newsgroup, however.

Jon


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

Date: 27 Apr 2001 21:27:49 +0000
From: Jon Ericson <Jonathan.L.Ericson@jpl.nasa.gov>
Subject: Re: Mail Program
Message-Id: <86oftidodm.fsf@jon_ericson.jpl.nasa.gov>

"Scott R. Godin" <webmaster@webdragon.unmunge.net> writes:

> In article <NUjG6.17119$q51.171313@news1.gvcl1.bc.home.com>,
>  "Brent Reynolds" <b_many2k@yahoo.com> wrote:
> 
>  | How can I find the path to the mail program on my server?
> 
> ls -l `which sendmail`
> ls -l `where sendmail`

  C:\>ls -l `which sendmail`
  The name specified is not recognized as an
  internal or external command, operable program or batch file.

  C:\>cygwin

  $ ls -l `where sendmail`
  bash: where: command not found

  $ ls -l `which sendmail`
  bash: which: command not found

  $ type sendmail
  bash: type: sendmail: not found

  $ type ssmtp
  ssmtp is hashed (/usr/bin/ssmtp)

Jon


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

Date: Fri, 27 Apr 2001 21:16:32 GMT
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Please help
Message-Id: <3AE9E2DE.ABED3770@earthlink.net>

Wyzelli wrote:
> 
> "John W. Krahn" <krahnj@acm.org> wrote in message
> news:3AE68065.EA1EF698@acm.org...
> >
> >$ perl -e 'print map { $_ % 10 ? "$_, " : "tenth\n" } ( 101 .. 150 )'
> > 101, 102, 103, 104, 105, 106, 107, 108, 109, tenth
> > 111, 112, 113, 114, 115, 116, 117, 118, 119, tenth
> > 121, 122, 123, 124, 125, 126, 127, 128, 129, tenth
> > 131, 132, 133, 134, 135, 136, 137, 138, 139, tenth
> > 141, 142, 143, 144, 145, 146, 147, 148, 149, tenth
> 
> According to the specs::
> 
> Create another Perl file named a1-q3.pl that contains: (6 marks)
> a numerical array containing the numbers from 101 to 150
> create and execute a function (or "subroutine") which will replace every
> tenth item in the array with the word "tenth"
> print the entire array on screen with 10 items printed per line and each
> item separated with a comma and a space (", ")
> 
> No file created -1 mark of 1
> No Numerical Array -1 mark of  1
> No function (or "subroutine") created -2 marks of  2
> Prints screen properly, but is not printing an array (as it does not
> exist) -1 of  2
> 
> Scores 1/6  :(
> 
> Geez I'm a hard task master... LOL <grin>
> 
> Wyzelli

Actually...
perl -e 'print map { $_ % 10 ? "$_, " : "tenth\n" } ( 101 .. 150 )'
You have an anonymous sub here ^^^, and you have an array here ^^^.
And the result of map is also an array.
So you actually only get 5/6, with the one point off for not having it
in a file.

The following file:
#!/usr/local/bin/env perl
print map { $_ % 10 ? "$_, " : "tenth\n" } ( 101 .. 150 );
__END__

Will satisfy all of the requirements.  Now, if there were a requirement
that the arrays and sub not be anonymous, then you'd have points off for
this.

Hmm, thinking on it a bit more, I think that the {} stuff is actually a
block, not a sub... but if you changed it to:

#!/usr/local/bin/env perl
print map sub { $_ % 10 ? "$_, " : "tenth\n" }, ( 101 .. 150 );
__END__

You'd be ok.

-- 
Sometimes the journey *is* its own reward--but not when you're trying to
get to the bathroom in time.


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

Date: Fri, 27 Apr 2001 12:11:17 -0400
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Problem in Netscape with CGI Headers
Message-Id: <slrn9ej6h5.4av.tadmc@tadmc26.august.net>


[ Newsgroups repaired ]


Alan J. Flavell <flavell@mail.cern.ch> wrote:

>2. You've crossposted it to a group which anyone who's bothered to
>read this group for a while knows is officially obsolete.


No need for much savvy at all, as I don't think that newsgroup
has *ever* existed.


   Newsgroups: comp.lang.perl.misc,comp.perl.lang
                                        ^^^^^^^^^  transposed...


 ... which is how the article got past my scorefile.


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Fri, 27 Apr 2001 20:43:23 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Problem in Netscape with CGI Headers
Message-Id: <Pine.LNX.4.30.0104272038470.25751-100000@lxplus003.cern.ch>

On Fri, 27 Apr 2001, Tad McClellan wrote:

> [ Newsgroups repaired ]

Woops...

> >2. You've crossposted it to a group which anyone who's bothered to
> >read this group for a while knows is officially obsolete.

[..]

>    Newsgroups: comp.lang.perl.misc,comp.perl.lang
>                                         ^^^^^^^^^  transposed...

Again, sorry, and thanks for picking up the discrepancy.

Well, the hon Usenaut then responded immediately by enlisting for
my killfile - but I wouldn't want other readers to remain confused!

cheers



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

Date: Fri, 27 Apr 2001 19:46:51 GMT
From: shb@vnet.net (Si Ballenger)
Subject: Re: Problem in Netscape with CGI Headers
Message-Id: <3ae9cbb9.496312936@166.82.1.9>

On Fri, 27 Apr 2001 16:34:42 GMT, ros@elcalamar.com (David Pardo)
wrote:

>Never mind. Won't bother you anymore
>
>David

Just look at the bright side. You gave Alan and Tad another
opportunity to publically stroke each others puds. They always
turn up in the same threads..., wonder why???  ;-)


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

Date: Fri, 27 Apr 2001 12:16:54 -0400
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Question on variable substitution
Message-Id: <slrn9ej6rm.4av.tadmc@tadmc26.august.net>

Dieter Faulbaum <faulbaum@alder.bessy.de> wrote:
>
>this is an excerpt from a perl file, which doesn't do what I want.
                                                       ^^^^^^^^^^^

I am pressing my forehead against the monitor to sense what you want...

 ...

 ... it isn't coming through.


Sorry.


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Fri, 27 Apr 2001 12:19:14 -0400
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Question on variable substitution
Message-Id: <slrn9ej702.4av.tadmc@tadmc26.august.net>

Dieter Faulbaum <faulbaum@alder.bessy.de> wrote:
>
>this is an excerpt from a perl file


No it isn't.


>my To = "$2";


That is not Perl code, so it cannot have come from a perl file.


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: 27 Apr 2001 18:05:08 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: regex for quoted lists
Message-Id: <9cccck$d1f$4@mamenchi.zrz.TU-Berlin.DE>

According to sundar  <cybertoast@mindless.com>:
> I'm a little stumped on a seemingly simple regex.
> 
> I've got a string, for instance:
>     $string = "and one, 'very, font, face, verdana', much, 'something, else'";
> 
> I need to break the string out into a list, based on the delimiter - in this
> case comma.  The problem is that the string may contain "quoted lists", as in
> the stuff between the 's above.

What you have there is a common data format called CSV (comma
separated values).  The FAQ answers your question,
perldoc -q 'delimited string' takes you there.  Also check CPAN
for CSV.

[Obligatory remark on how you are supposed to check the FAQ before posting
suppressed, because this item is particularly well hidden]

Anno


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

Date: 27 Apr 2001 19:43:13 +0100
From: nobull@mail.com
Subject: Re: regex for quoted lists
Message-Id: <u966fqgp4u.fsf@wcl-l.bham.ac.uk>

sundar <cybertoast@mindless.com> writes:

> I know that it's probably something that's very simple that I'm
> missing,

The FAQ.  This exact question appears in it.

> but 2 hours of messing with this has got me nowhere.

Whereas 5 minuites consulting the FAQ would have got you the answer
instantly.

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: Fri, 27 Apr 2001 14:53:47 -0500
From: sundar <cybertoast@mindless.com>
Subject: Re: regex for quoted lists
Message-Id: <3AE9CE4B.8E02586A@mindless.com>

Seems some days I just lose my mind :-)  I had looked through the FAQ's but
could not find the specific section after 15 minutes (wish that 5 minutes were
enough!), and figured that I must just work through this on my own.

But thanks for the redirection, all cynicism notwithstanding.

nobull@mail.com wrote:
> 
> sundar <cybertoast@mindless.com> writes:
> 
> > I know that it's probably something that's very simple that I'm
> > missing,
> 
> The FAQ.  This exact question appears in it.
> 
> > but 2 hours of messing with this has got me nowhere.
> 
> Whereas 5 minuites consulting the FAQ would have got you the answer
> instantly.
> 
> --
>      \\   ( )
>   .  _\\__[oo
>  .__/  \\ /\@
>  .  l___\\
>   # ll  l\\
>  ###LL  LL\\


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

Date: Fri, 27 Apr 2001 12:06:19 -0700
From: "Shay Harding" <sharding@ccbill.com>
Subject: Re: Regular expression for zip code
Message-Id: <9ccfed$6rg$1@node17.cwnet.frontiernet.net>

"BarryK" <notmyrealemail@fake.com> wrote in message
news:65YF6.28957$U4.6334726@news1.rdc1.tn.home.com...
> I want to create a regular expression that will replace any legitimate zip
> code in either five digit format or 5-4 digit format with something.
>
> The following regular expression does not work!
>
> s< (\b\d{5}\b) | (\b\d{5}-\d{4}\b) > <X>x;
>
> From the number "12345-1234", it will return "X-1234".


Ok, for all instances I can think of the following will work:

s/\b(?<!\S)\d{5}(-\d{4})?(?!\S)\b/X/g;


Shay









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

Date: Fri, 27 Apr 2001 14:18:09 -0500
From: xris <xris@dont.send.spam>
Subject: Re: Regular expression for zip code
Message-Id: <xris-3A4336.14180927042001@news.evergo.net>

In article <9ccfed$6rg$1@node17.cwnet.frontiernet.net>,
 "Shay Harding" <sharding@ccbill.com> wrote:

> Ok, for all instances I can think of the following will work:
> 
> s/\b(?<!\S)\d{5}(-\d{4})?(?!\S)\b/X/g;

shouldn't that be:

   s/\b(?<!\S)\d{5}(-\d{4})?(?!\S)\b/X$1/go;


and on a side note, isn't the 'o' operator supposed to speed things up a 
bit because it compiles the pattern once rather than every time? I 
haven't noticed ANY change in speed when doing benchmarks, no matter how 
complex the pattern is.



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

Date: 27 Apr 2001 19:24:24 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Regular expression for zip code
Message-Id: <9cch18$gfu$3@mamenchi.zrz.TU-Berlin.DE>

According to xris  <xris@dont.send.spam>:
> In article <9ccfed$6rg$1@node17.cwnet.frontiernet.net>,
>  "Shay Harding" <sharding@ccbill.com> wrote:
> 
> > Ok, for all instances I can think of the following will work:
> > 
> > s/\b(?<!\S)\d{5}(-\d{4})?(?!\S)\b/X/g;
> 
> shouldn't that be:
> 
>    s/\b(?<!\S)\d{5}(-\d{4})?(?!\S)\b/X$1/go;
> 
> 
> and on a side note, isn't the 'o' operator supposed to speed things up a 
> bit because it compiles the pattern once rather than every time? I 
> haven't noticed ANY change in speed when doing benchmarks, no matter how 
> complex the pattern is.

Look closer.  No speedup is to be expected as long as the regex in
question doesn't contain variables to be interpolated.

Anno


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

Date: 27 Apr 2001 14:15:06 -0500
From: Ren Maddox <ren@tivoli.com>
Subject: Re: Regular expression for zip code
Message-Id: <m3g0eurw79.fsf@dhcp9-172.support.tivoli.com>

[Jeopardectomy]

On Thu, 26 Apr 2001, notmyrealemail@fake.com wrote:

> "Ren Maddox" <ren@tivoli.com> wrote in message
> news:m3n193ttso.fsf@dhcp9-172.support.tivoli.com...
> 
>>   s< \b (\d{5}-\d{4} | \d{5}) \b > <X>x;
>>   s< \b ( \d{5} (?: -\d{4} )? ) \b > <X>x;
>>   s/ (?: ^ | (?<= \s ) ) ( \d{5} (?: -\d{4} )? ) (?= \s | $ ) /X/x;
>>   s/ (?: ^ | (?<= [^\d-] ) ) ( \d{5} (?: -\d{4} )? ) (?= [^\d-] | $
>>   ) /X/x;
> 
> None of these last four work, it pains me to say!

I assure you that I tested all of them.  Could you clarify exactly how
they fail?

-- 
Ren Maddox
ren@tivoli.com


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

Date: Fri, 27 Apr 2001 16:07:43 -0500
From: xris <xris@dont.send.spam>
Subject: Re: Regular expression for zip code
Message-Id: <xris-90170D.16074327042001@news.evergo.net>

In article <9cch18$gfu$3@mamenchi.zrz.TU-Berlin.DE>,
 anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) wrote:

> Look closer.  No speedup is to be expected as long as the regex in
> question doesn't contain variables to be interpolated.

ah, ok...  the wording in the Perl book made me think that the 
compiler/optimizer did something special to regex patterns besides just 
interpreting variables, such that all patterns could benefit from this 
option.  guess it's good to know it doesn't, though I'd hope it wouldn't 
hurt to include the 'o' anyway...



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

Date: Fri, 27 Apr 2001 14:17:41 -0700
From: "Shay Harding" <sharding@ccbill.com>
Subject: Re: Regular expression for zip code
Message-Id: <9ccn4o$11k4$1@node17.cwnet.frontiernet.net>

"xris" <xris@dont.send.spam> wrote in message
news:xris-3A4336.14180927042001@news.evergo.net...
> In article <9ccfed$6rg$1@node17.cwnet.frontiernet.net>,
>  "Shay Harding" <sharding@ccbill.com> wrote:
>
> > Ok, for all instances I can think of the following will work:
> >
> > s/\b(?<!\S)\d{5}(-\d{4})?(?!\S)\b/X/g;
>
> shouldn't that be:
>
>    s/\b(?<!\S)\d{5}(-\d{4})?(?!\S)\b/X$1/go;

I don't see why $1 is needed for the right-hand side? $1 will only contain
the '-\d{4}' portion of a match, if anything at all. Am I missing something
you refer to?

So for '12345-1234' the result would be X-1234.

According to the original poster, he just wanted a regex that would match
\d{5}(-\d{4})? format and replace it with something. 'X' being that
something.

Shay






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

Date: Fri, 27 Apr 2001 19:14:31 GMT
From: Mark Ingram <mingram@atreus-systems.com>
Subject: Re: So what do YOU use Perl for?
Message-Id: <3AE9C517.3DFAB5E6@atreus-systems.com>

Abigail wrote:

> Mark Jason Dominus (mjd@plover.com) wrote on MMDCCLXXXI September
> MCMXCIII in <URL:news:3ad60451.2149$21a@news.op.net>:
> ""
> "" I wrote a suite of Perl programs to generate all the quilt blocks of a
> "" certain type (sixteen-patch half-square triangles with 90-degree
> "" rotational symmetry) and printed out the result:
> ""
> ""         http://www.plover.com/~mjd/misc/quilt/composites/bindexs.jpg
> ""
> "" (I made an error; one block appears twice.  Can you find it?)
>
> The fifth row, the fourth and sixth figures look like mirror images to me.
>
> Abigail

Man, am I glad I didn't read this group since Mark posted that gem.
You guys are *way* too smart for me, but I had fun solving it myself anyways.
Seriously, how long did it take you to find it, Abigail?  Seconds?

I now return you to your regularly scheduled haranguing ...
ttfn,
--mi.

P.S. I didn't use Perl to solve it, sorry, so my posting is even more off-topic.




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

Date: 27 Apr 2001 15:00:51 -0500
From: Ren Maddox <ren@tivoli.com>
Subject: Re: split and array problem
Message-Id: <m366fqru30.fsf@dhcp9-172.support.tivoli.com>

On Thu, 26 Apr 2001, hpya78@postoffice.pacbell.net wrote:

> Can someone help me fix this script?
> How to get the lines that with a number between 0 and 100?
> 
> File:
> aa 45 23 22
> bb 2 12 67
> dd 99 98 100
> ff 101 99 100
> mm 56 87 1
> nn 10000 999 1
> ------------------------
> Ouput should be:
> aa 45 23 22
> bb 2 12 67
> dd 99 98 100
> mm 56 87 1

Though it is not quite what you stated above, it looks like what you
want is any line where all of the numbers are inclusively between 0
and 100.  Which means you want to skip lines that have any numbers
that do not fall in that range.

> #!/user/bin/perl -w
> 
> open(FILE,  "abc.txt") || die "Cannot open\n";

Include the filename as well as $! in that error message.

> @abc=(<FILE>);
> 
> foreach $info(@abc)

It's kind of silly to slurp the whole file into an array if you're
just going to process it a line at a time.  Instead, use:

LINE:
  while($info = <FILE>)

The "LINE:" part is going to be used below...

> {
>          ($word, @nums)=split(/\s+/, $info);
> 
>           foreach $digit(@nums)
>          {
>                if($digit>= 0 && $digit <=100)
>                {
>                       print " $word  @nums\n";
>                }

That is going to print the line once for each digit in the range.
Instead, you could do something like:

                 if($digit < 0 || $digit > 100) {
                    next LINE;
                 }

>           }

And then print the line here.  You only get here if the "next" was
never executed.

           print $info;
> }

Another way to do this is:

#!/usr/bin/perl -w
use strict;
open FILE, "abc.txt" or die "Could not read abc.txt, $!\n";
while(<FILE>) {
  print unless /-\d/ || /(\d+)/ && $1 > 100;
}
close FILE;
__END__

which can actually reduce fairly nicely to:

perl -ne 'print unless /-\d/ || /(\d+)/ && $1 > 100' abc.txt

-- 
Ren Maddox
ren@tivoli.com


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

Date: 28 Apr 2001 06:41:11 +0200
From: Jean-Louis Leroy <jll63@easynet.be>
Subject: Strange string -> num conversion
Message-Id: <m3u2394owo.fsf@enterprise.starfleet>

Why does this:

        perl -e "print '0x12' + 1"

 ...print 2.125 ??
-- 
Jean-Louis Leroy
Sound Object Logic
http://www.soundobjectlogic.com


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

Date: 27 Apr 2001 19:46:59 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Strange string -> num conversion
Message-Id: <9ccibj$gfu$4@mamenchi.zrz.TU-Berlin.DE>

According to Jean-Louis Leroy  <jll63@easynet.be>:
> Why does this:
> 
>         perl -e "print '0x12' + 1"
> 
> ...print 2.125 ??

It does?  It prints 1 for me.  Probably the output got mixed up
with your shell prompt.  Use "perl -le" to give it a linefeed.

If you didn't expect it to print 1 either, run it with "perl -wle"
to get a hint what things are and what they aren't.

Anno


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

Date: 28 Apr 2001 07:00:12 +0200
From: Jean-Louis Leroy <jll63@easynet.be>
Subject: Re: Strange string -> num conversion
Message-Id: <m3pudx4o0z.fsf@enterprise.starfleet>

anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) writes:

> If you didn't expect it to print 1 either

I did.

> run it with "perl -wle"

[jll@enterprise jll]$ perl -wle "print '0x12' + 1"
Argument "0x12" isn't numeric in addition (+) at -e line 1.
2.125
-- 
Jean-Louis Leroy
Sound Object Logic
http://www.soundobjectlogic.com


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

Date: 27 Apr 2001 20:15:13 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Strange string -> num conversion
Message-Id: <9cck0h$ilk$1@mamenchi.zrz.TU-Berlin.DE>

According to Jean-Louis Leroy  <jll63@easynet.be>:
> anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) writes:
> 
> > If you didn't expect it to print 1 either
> 
> I did.
> 
> > run it with "perl -wle"
> 
> [jll@enterprise jll]$ perl -wle "print '0x12' + 1"
> Argument "0x12" isn't numeric in addition (+) at -e line 1.
> 2.125

Something is fishy.  What Perl version are you using?  On what
system?

Anno


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

Date: 28 Apr 2001 07:54:30 +0200
From: Jean-Louis Leroy <jll63@easynet.be>
Subject: Re: Strange string -> num conversion
Message-Id: <m3lmol4lih.fsf@enterprise.starfleet>

anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) writes:

> Something is fishy.  What Perl version are you using?  On what
> system?

I found out on a Red Hat 6.2 system that had perl 5.005. I don't have
access to it right now. The examples I posted were made on my home
computer (see below).

Now if I try this on perl 5.6.0 on NT 4 in a vmware computer, I get
the expected result (i.e. 1).

And when I try again on my computer at work (SUSe 7) I get 19 (looks
like 0x12 is interpreted as a hex number; makes sense).

So the problem would be...glibc??

My home computer:

[jll@enterprise jll]$ perl -V
Summary of my perl5 (revision 5.0 version 6 subversion 0) configuration:
  Platform:
    osname=linux, osvers=2.2.5-15, archname=i586-linux
    uname='linux enterprise.starfleet 2.2.5-15 #1 mon apr 19 22:21:09 edt 1999 i586 unknown '
    config_args=''
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=undef use5005threads=undef useithreads=undef usemultiplicity=undef
    useperlio=undef d_sfio=undef uselargefiles=define
    use64bitint=undef use64bitall=undef uselongdouble=undef usesocks=undef
  Compiler:
    cc='cc', optimize='-O2', gccversion=2.95.2 19991024 (release)
    cppflags='-fno-strict-aliasing -I/usr/local/include'
    ccflags ='-fno-strict-aliasing -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64'
    stdchar='char', d_stdstdio=define, usevfork=false
    intsize=4, longsize=4, ptrsize=4, doublesize=8
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
    ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
    alignbytes=4, usemymalloc=n, prototype=define
  Linker and Libraries:
    ld='cc', ldflags =' -L/usr/local/lib'
    libpth=/usr/local/lib /lib /usr/lib
    libs=-lnsl -lndbm -lgdbm -ldb -ldl -lm -lc -lposix -lcrypt
    libc=/lib/libc-2.1.3.so, so=so, useshrplib=false, libperl=libperl.a
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-rdynamic'
    cccdlflags='-fpic', lddlflags='-shared -L/usr/local/lib'
 
 
Characteristics of this binary (from libperl):
  Compile-time options: USE_LARGE_FILES
  Built under linux
  Compiled at Mar 28 2001 07:09:19
  @INC:
    /usr/local/lib/perl5/5.6.0/i586-linux
    /usr/local/lib/perl5/5.6.0
    /usr/local/lib/perl5/site_perl/5.6.0/i586-linux
    /usr/local/lib/perl5/site_perl/5.6.0
    /usr/local/lib/perl5/site_perl
    .                                                                                                     


My computer @ work:

jll@jimi:~ > perl -V
Summary of my perl5 (revision 5.0 version 6 subversion 0) configuration:
  Platform:
    osname=linux, osvers=2.2.16, archname=i686-linux
    uname='linux jimi 2.2.16 #1 wed aug 2 20:22:26 gmt 2000 i686 unknown '
    config_args=''
    hint=previous, useposix=true, d_sigaction=define
    usethreads=undef use5005threads=undef useithreads=undef usemultiplicity=undef
    useperlio=undef d_sfio=undef uselargefiles=define
    use64bitint=undef use64bitall=undef uselongdouble=undef usesocks=undef
  Compiler:
    cc='cc', optimize='-O2', gccversion=2.95.2 19991024 (release)
    cppflags='-fno-strict-aliasing -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64'
    ccflags ='-fno-strict-aliasing -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64'
    stdchar='char', d_stdstdio=define, usevfork=false
    intsize=4, longsize=4, ptrsize=4, doublesize=8
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
    ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
    alignbytes=4, usemymalloc=n, prototype=define
  Linker and Libraries:
    ld='cc', ldflags =' -L/usr/local/lib'
    libpth=/usr/local/lib /lib /usr/lib
    libs=-lnsl -lndbm -lgdbm -ldbm -ldb -ldl -lm -lc -lposix -lcrypt
    libc=, so=so, useshrplib=false, libperl=libperl.a
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-rdynamic'
    cccdlflags='-fpic', lddlflags='-shared -L/usr/local/lib'
 
 
Characteristics of this binary (from libperl):
  Compile-time options: USE_LARGE_FILES
  Built under linux
  Compiled at Nov 16 2000 18:02:14
  @INC:
    /usr/lib/perl5/5.6.0/i686-linux
    /usr/lib/perl5/5.6.0
    /usr/lib/perl5/site_perl/5.6.0/i686-linux
    /usr/lib/perl5/site_perl/5.6.0
    /usr/lib/perl5/site_perl/5.005
    /usr/lib/perl5/site_perl
    .

-- 
Jean-Louis Leroy
Sound Object Logic
http://www.soundobjectlogic.com


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

Date: Fri, 27 Apr 2001 22:01:01 +0000 (UTC)
From: abigail@foad.org (Abigail)
Subject: Re: Things I'm just not getting in Perl
Message-Id: <slrn9ejr0t.mm6.abigail@tsathoggua.rlyeh.net>

Andrew Lee (andrew_lee@nospamearthlink.net) wrote on MMDCCXCVI September
MCMXCIII in <URL:news:3AE939B2.3D01BA08@nospamearthlink.net>:
}}  Abigail wrote:
}}  
}} > Hell, not even '||' returns 1 for "true".
}}  
}}  '||' is a binary operator ... it takes two arguments ... e.g. True OR true i
}}  true .... write a program and see for yourself.

    $ perl -wle 'print +(2 || 1)'
    2
    $

Doesn't seem to return 1 ....

}} > [1] boolean function? In *Perl*?!? There are no flippin' booleans in Perl.
}} >     It just inherits the moronic behaviour of C. Real languages have boolea
}}  
}}  So ... please define a "real" language ...


Java.


Abigail


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

Date: Fri, 27 Apr 2001 20:32:28 GMT
From: ameen @ dausha . net (Ameen Dausha)
Subject: WI Performance Hit w/ Hash || Array v Scalar?
Message-Id: <3ae9d6e8.259904063@news.bellatlantic.net>

What is the performance hit in using a Hash or Array in lieu of
scalars?

I mean, what if I used a hash with ten keys in a subroutine instead of
ten scalars in the same routine?


Ben Wilson (a.k.a. Ameen, Last of the Dausha)
____________________________
-"Ever heard of Aristotle . . . Plato . . . Socrates?!"
-"Yes."
-"Morons!"


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

Date: 27 Apr 2001 20:56:01 +0000
From: Jon Ericson <Jonathan.L.Ericson@jpl.nasa.gov>
Subject: Re: WI Performance Hit w/ Hash || Array v Scalar?
Message-Id: <86sniudpum.fsf@jon_ericson.jpl.nasa.gov>

ameen @ dausha . net (Ameen Dausha) writes:

> What is the performance hit in using a Hash or Array in lieu of
> scalars?
> 
> I mean, what if I used a hash with ten keys in a subroutine instead of
> ten scalars in the same routine?

Why not use Benchmark and find out?  I doubt this micro-optimization
will be worth the price, however.

Jon


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

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


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