[20010] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2205 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Nov 26 03:05:35 2001

Date: Mon, 26 Nov 2001 00:05:08 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <1006761908-v10-i2205@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Mon, 26 Nov 2001     Volume: 10 Number: 2205

Today's topics:
    Re: [Newbie] Iterating through dirs recursively <assafl@flashnetworks.com>
    Re: A Perl Bug? <mcnuttj@dnps-linux1.telecom.missouri.edu>
    Re: A Perl Bug? <uri@stemsystems.com>
    Re: A Perl Bug? (Logan Shaw)
        MakeMaker and 'make uninstall' <mcnuttj@dnps-linux1.telecom.missouri.edu>
        Math Library Module Question <SSEA@SSEAweb.com>
    Re: Math Library Module Question <uri@stemsystems.com>
    Re: Serious Regexp help... (Garry Williams)
    Re: Serious Regexp help... <wuerz@yahoo.com>
    Re: Serious Regexp help... <skradel@mindspring.common.sense>
    Re: Serious Regexp help... <davidhilseenews@yahoo.com>
    Re: Serious Regexp help... <wuerz@yahoo.com>
    Re: Serious Regexp help... <skradel@mindspring.common.sense>
    Re: Serious Regexp help... <me@here.com>
    Re: Serious Regexp help... <ashley@pcraft.com>
    Re: Serious Regexp help... <ahamm@programmer.net>
    Re: use File:Find non-recursive (Garry Williams)
    Re: use File:Find non-recursive <hugo@fractalgraphics.com.au>
    Re: variable scope <bernard.el-hagin@lido-tech.net>
        View/Dump code produced by Class::MethodMaker? <dlc-usenet@halibut.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Mon, 26 Nov 2001 09:43:47 +0200
From: "Assaf Lavie" <assafl@flashnetworks.com>
Subject: Re: [Newbie] Iterating through dirs recursively
Message-Id: <9tsrs4$b78$1@news.att.net.il>


"E.Chang" <echang@netstorm.net> wrote in message
news:Xns91647CBEED16Cechangnetstormnet@207.106.92.86...
> "Assaf Lavie" <assafl@flashnetworks.com> wrote in
> news:9tr602$it6$1@news.att.net.il:
>
> > "Wolfram Pfeiffer" <wolfram.pfeiffer@bigfoot.com> wrote in message
> > news:9tqgqu$q3v$1@news.rz.uni-karlsruhe.de...
> >> Assaf Lavie <assafl@flashnetworks.com> wrote:
> >> > I have a recursive function that works on every file in a
> >> > certain directory and then calls itself for any sub-directory.
> >> > Question is: How do I begin to iterate over the sub-dir's files?
> >> > Do I need to change the working directory (how?), or can I
> >> > simply do this: (<$subdir/*>)?
> >>
> >> You can change your working directory with 'chdir' (perldoc
> >> perlfunc).
> > Thanks.
> > Will I need to change it back when I return?
> >> You should have a look at File::Find, though, it probably already
> >> does what you want to do.
> > No I don't think so. I'm not searching these files; I'm doing some
> > source-control manipluation on them.
>
> Hmm. First you say you are a newbie, then you assume you know what
> File::Find does without even looking at the documentation on it.
You're right. My mistake. Sorry.
I still havn't figured out how to return to the original WD after I change
it using chdir. How do I retrieve the current working directory?

Assaf.





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

Date: 26 Nov 2001 04:18:20 GMT
From: <mcnuttj@dnps-linux1.telecom.missouri.edu>
Subject: Re: A Perl Bug?
Message-Id: <9tsfqc$ou7$1@dipsy.missouri.edu>

Uri Guttman <uri@stemsystems.com> wrote:

> this group does not tolerate top posting. you will get killfiled for
> doing it. your personal preferences have nothing to do with it. it is
> inconsiderate of all the other readers so it is very personal to them as
> well. this is not perl but usenet nettiquette and TMTOWTDI does not
> apply.

<shrug>  Elitest nonsense.  I went and read the rant in the first link you
posted earlier and it was just that:  a rant.

The fact of the matter is that people do things differently on the
Internet than in Real Life because the Internet *is* different from Real
Life.  Sometimes it makes sense to top-post, and sometimes it
doesn't.  Having some religious view about it that either way is Right or
Wrong is silly.

In the case of this thread, top-posting is irritating, because there are
multiple topics, and because the first respondant (you) chose to sprinkle
comments throughout the text.  Therefore it makes the most sense to follow
suit.

In other threads, there is only one topic and/or the replies are short and
self-contained.  In those cases, top-posting can save people who are
already familiar with the thread from having to scroll through the text
trying to make sure they don't miss the one or two lines of new text (and
when you still use 'tin' as I do, scrolling back and forth isn't as easy
as when you use Nutscrape or Internet Exploder).

Personally, I've found that the cases where top-posting makes sense are
rather few and far between, but that a pretty good general rule is to do
whatever everybody else in a particular thread is doing.  However, to rule
top-posting out as Wrong and Improper and Bad is close-minded,
judgemental, and silly.

--J

P.S.  And speaking as to the general tone of this thread, it would appear
that the elite in this newsgroup have continued their attitude of
"everyone should have already memorized all of the man pages, CPAN pages,
O'Reilly Perl Manuals, etc. before posting here."  While some nice folks
did indeed help me out in here, the super-programmer attitude is still
prevalent, leaving little room for the newbie (at least, not without 'use
Newbie::Humiliate;'...).


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

Date: Mon, 26 Nov 2001 06:02:06 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: A Perl Bug?
Message-Id: <x7wv0e83xh.fsf@home.sysarch.com>

>>>>> "XX" ==   <mcnuttj@dnps-linux1.telecom.missouri.edu> writes:

  XX> Uri Guttman <uri@stemsystems.com> wrote:
  >> this group does not tolerate top posting. you will get killfiled for
  >> doing it. your personal preferences have nothing to do with it. it is
  >> inconsiderate of all the other readers so it is very personal to them as
  >> well. this is not perl but usenet nettiquette and TMTOWTDI does not
  >> apply.

  XX> <shrug>  Elitest nonsense.  I went and read the rant in the first link you
  XX> posted earlier and it was just that:  a rant.

and your drivel is?

  XX> In other threads, there is only one topic and/or the replies are
  XX> short and self-contained.  In those cases, top-posting can save
  XX> people who are already familiar with the thread from having to
  XX> scroll through the text trying to make sure they don't miss the
  XX> one or two lines of new text (and when you still use 'tin' as I
  XX> do, scrolling back and forth isn't as easy as when you use
  XX> Nutscrape or Internet Exploder).

you don't get it. easy for you is annoying for others. and when a thread
gets long and complex, top posting makes it unintelligible very
quickly. and you can't predict where a thread will go. so top posting is
bad for that reason alone.

  XX> Personally, I've found that the cases where top-posting makes
  XX> sense are rather few and far between, but that a pretty good
  XX> general rule is to do whatever everybody else in a particular
  XX> thread is doing.  However, to rule top-posting out as Wrong and
  XX> Improper and Bad is close-minded, judgemental, and silly.

there are no good reasons for it. only corporate rules and people who
don't get netiquette (from either ignorance or selfish reasons)

  XX> P.S.  And speaking as to the general tone of this thread, it would
  XX> appear that the elite in this newsgroup have continued their
  XX> attitude of "everyone should have already memorized all of the man
  XX> pages, CPAN pages, O'Reilly Perl Manuals, etc. before posting
  XX> here."  While some nice folks did indeed help me out in here, the
  XX> super-programmer attitude is still prevalent, leaving little room
  XX> for the newbie (at least, not without 'use
  XX> Newbie::Humiliate;'...).

rtfm. this is not a helpdesk. it is a discussion group on perl. you are
expected to have TRIED to understand your problem and research the
abundant resources. otherwise this group will devolve even further down
the well intentioned path to hell. i see you are paving that path
already.

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  -------- http://www.stemsystems.com
-- Stem is an Open Source Network Development Toolkit and Application Suite -
----- Stem and Perl Development, Systems Architecture, Design and Coding ----
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org


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

Date: 26 Nov 2001 01:34:03 -0600
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: A Perl Bug?
Message-Id: <9tsr9b$ij9$1@starbuck.cs.utexas.edu>

In article <9tsfqc$ou7$1@dipsy.missouri.edu>,
 <mcnuttj@dnps-linux1.telecom.missouri.edu> wrote:
>The fact of the matter is that people do things differently on the
>Internet than in Real Life because the Internet *is* different from Real
>Life.

Also, sometimes people do things differently on Usenet, which is not at
all the same thing as the Internet.

>Sometimes it makes sense to top-post, and sometimes it
>doesn't.

Regardless, it's not considered good netiquette.

>Having some religious view about it that either way is Right or
>Wrong is silly.

It's not a religious view.  It's the standard way to do it
on Usenet.  Read the news.newusers.questions FAQ.  You're
really supposed to read that before you make your first
post to Usenet anyway.  The section on quoting is at
http://www.geocities.com/ResearchTriangle/Lab/6882/nquote.html .

If you don't believe that it's standard, go to
http://groups.google.com/ , pick a few random newsgroups, and
browse through some articles from several years ago.  You'll
find that top-posting was essentially non-existent back then,
and it's only relatively recently with the mass influx of new
people that top-posting has started to happen on Usenet.

  - Logan
-- 
"In order to be prepared to hope in what does not deceive,
 we must first lose hope in everything that deceives."

                                          Georges Bernanos


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

Date: 26 Nov 2001 03:48:09 GMT
From: <mcnuttj@dnps-linux1.telecom.missouri.edu>
Subject: MakeMaker and 'make uninstall'
Message-Id: <9tse1p$mt6$1@dipsy.missouri.edu>

Okay, more on learning MakeMaker...

I found the built-in uninstall function in MakeMaker, which is disabled by
default.  I wondered, "Why is this disabled by default, and why is the
packlist messed up?"

Of course, as it turns out these two questions are related, since I'm
running Perl 5.6.1.  From perl-5.6.1.announce:

    + .packlist files generated by Perl 5.6.1 were accidentally
      incompatible with earlier versions.  This problem usually shows
      up as the inability to uninstall extensions using MakeMaker, or
      tools such as PPM.  If you are affected by this, consider applying
      patch 9706.

Since I didn't install from source, applying this patch may be more
trouble than it's worth.  This raises some questions:

Does every other version of Perl (or certain versions like shall we
say, >= 5.6.0 maybe?) have a working 'make uninstall' when MakeMaker is
used?

If every other Perl's MakeMaker works, I don't want to write my own
uninstall routine, since it's only this one version that has the
problem.  If that's the case, is it safe to get the sources for Perl 5.6.1
(or higher?), apply the patch and reinstall over the top of the existing
stuff?  System is Slackware 8.0, for those of you familiar with the
default layout of that.  Point is, it won't screw up RPM, since Slackware
doesn't use it.  :-)

If other MakeMakers don't work, or if it isn't safe to install the new
Perl over the old, I will want to override and/or modify the install and
uninstall methods in MakeMaker.

The install method (for Perl 5.6.1) will need to keep better track of
where the files go, preferably via a file like ./packlist.  The uninstall
method would need to parse that file and remove all files that were
installed, plus perhaps some other files that I anticipate the user will
have created (/etc/jscan.conf, for example).  Then the realclean method
will need to pick up that ./packlist file as well.

Question is, how do I modify or override these methods and have the
correct schtuff thrown into the Makefile?  I've hunted through the man
file for ExtUtils::MakeMaker, but the examples are either unclear or over
my head or both.  The ExtUtils::Install page pretty much just describes
the existing methods.  All of the other Makefile.PL files are the same way
(either over my head or they just use the default methods).

Could someone tell me how to override MakeMaker so that the resulting
Makefile includes something like this:

uninstall:
	/bin/echo "Prefix was $(PREFIX)."
	/bin/echo "Your override worked."

If I could see the code that would do that, I could extrapolate what I
need to do more fancy things.

Anyway, thanks in advance for any help, and for the help so far (see the
earlier thread on installing a Perl app...)

--J


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

Date: Mon, 26 Nov 2001 06:24:50 GMT
From: "Basil Skordinski" <SSEA@SSEAweb.com>
Subject: Math Library Module Question
Message-Id: <SelM7.6515$WC1.698479@newsread2.prod.itd.earthlink.net>

Does anyone out there know of any problems with the Perl 5 version of the
"Math::BigFloat" library module?  Every time I try to convert a number
string that is expressed in scientific notation to a big float number I get
the following message:

"Use of uninitialized value at /usr/perl5/5.00503/Math/BigFloat.pm line 80."

In the code fragment that I use I assign a number string to the variable
$dp51 elsewhere in my program and then try to convert it to a big float in
the following manner:

use Math::BigFloat;
$dp5 = Math::BigFloat->("$dp51");

I've looked at line 80 in BigFloat.pm and it seems to me that $6 within the
scope of its regular expression is undefined.  However, I could be wrong.
Can anyone shed some light on my problem?  Thanks.






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

Date: Mon, 26 Nov 2001 06:36:25 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Math Library Module Question
Message-Id: <x7u1vi82c8.fsf@home.sysarch.com>

>>>>> "BS" == Basil Skordinski <SSEA@SSEAweb.com> writes:


  BS> "Use of uninitialized value at /usr/perl5/5.00503/Math/BigFloat.pm
  BS> line 80."

  BS> In the code fragment that I use I assign a number string to the variable
  BS> $dp51 elsewhere in my program and then try to convert it to a big float in
  BS> the following manner:

  BS> use Math::BigFloat;
  BS> $dp5 = Math::BigFloat->("$dp51");
                              ^     ^
don't need quotes there

  BS> I've looked at line 80 in BigFloat.pm and it seems to me that $6
  BS> within the scope of its regular expression is undefined.  However,
  BS> I could be wrong.  Can anyone shed some light on my problem?

could you post the number you tried? and make sure it is demarked so we
can see all the characters. 

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  -------- http://www.stemsystems.com
-- Stem is an Open Source Network Development Toolkit and Application Suite -
----- Stem and Perl Development, Systems Architecture, Design and Coding ----
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org


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

Date: Mon, 26 Nov 2001 05:35:20 GMT
From: garry@ifr.zvolve.net (Garry Williams)
Subject: Re: Serious Regexp help...
Message-Id: <slrna03l4v.sdi.garry@zfw.zvolve.net>

On Sun, 25 Nov 2001 21:50:07 -0700, Ashley M. Kirchner
<ashley@pcraft.com> wrote:
> 
>     I need to break each line in this text (wrapping alert):
> 
> 4x6                 1        4"x6" Standard Print (full-frame from
> 35mm) Image:Uploaded Image 1     .75     $0.75
> 
> 4x6                 1        4"x6" Standard Print (full-frame from
> 35mm) Image:Uploaded Image 2     .75     $0.75
> 
> 5x7.5               1        5x7.5 Image:Uploaded Image 3      4.25
> $4.25
> 
> 8x12                1        8x12 Classic Full Frame Image:Uploaded
> Image 4   10.25    $10.25
> 
>     ...into 6 pieces. Based on the first line, I need:
> 
>     1.  4x6
>     2.  1
>     3.  4"x6"
>     4.  Standard Print (full-frame from 35mm) Image:Uploaded Image 1
>     5.  .75
>     6.  $0.75
> 
>     And as you can see, the 3rd item is written differently on two
>     of those lines - I need to account for that.  Also, the first
>     item could also be simple text (letters) instead of just numbers
>     (and an 'x').

Assuming that the first item never contains spaces, you could use a
regular expression: 

  /^
    (\S+)        # $1 =  4x6
    \s+
    (\d+)        # $2 =  1
    \s+
    (.*)         # $3 =  Standard Print...
    ([.\d]+)     # $4 =  .75
    \s+
    (\$\d+\.\d+) # $5 =  $0.75
  $/x

If not, you will probably need to use unpack() for the first three
fields.  

Be sure to check for a match before using, $1, $2, etc.  The value in
$3 will have trailing spaces that you may want to remove.  

It might be better to use a combination of unpack() and a regex to
grab the last two prices, though.  

Your specification is not very complete, so this may be too fragile to
be used in your application.  

-- 
Garry Williams


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

Date: 26 Nov 2001 00:38:51 -0500
From: Mona Wuerz <wuerz@yahoo.com>
Subject: Re: Serious Regexp help...
Message-Id: <m3wv0eqefo.fsf@DCCMBX01.njitdm.campus.njit.edu>

"Ashley M. Kirchner" <ashley@pcraft.com> writes:

>     I need to break each line in this text (wrapping alert):
> 
> 4x6                 1        4"x6" Standard Print (full-frame from 35mm) Image:Uploaded Image 1     .75     $0.75
> 
> 4x6                 1        4"x6" Standard Print (full-frame from 35mm) Image:Uploaded Image 2     .75     $0.75
> 
> 5x7.5               1        5x7.5 Image:Uploaded Image 3      4.25     $4.25
> 
> 8x12                1        8x12 Classic Full Frame Image:Uploaded Image 4   10.25    $10.25
> 
> 
>     ...into 6 pieces. Based on the first line, I need:
> 
>     1.  4x6
>     2.  1
>     3.  4"x6"
>     4.  Standard Print (full-frame from 35mm) Image:Uploaded Image 1
>     5.  .75
>     6.  $0.75
> 
>     And as you can see, the 3rd item is written differently on two
> of those lines - I need to account for that.  Also, the first item
> could also be simple text (letters) instead of just numbers (and an
> 'x'). 

If the whitespace between fields consists of tab characters (and they
look like they do), then a simple:

my @pieces = split /\t/, $line;

will do. If not, a simple RE solution could look like:

my @pieces = $line =~ /^(\S+)\s+(\d+)\s+(\S+)\s+(.+?)\s+(\S+)\s+(\$\S+)$/;

That works at least for the data you provided. Some redundancy checks
would be good, too (e.g. items 1 and 3 appear to be related, as do
items 5 and 6) to make sure the lines got parsed as intended.

-- 
$_="\n,rekcah egnufeB rehtona tsuJ";#v1<?>g\:pv-<5<
s s\S+(?:B)sunpack'u',q q$;')E4qsee;#>60#^<(v!<)g6<
print scalar reverse,$@ unless m,[+;#]55,;m:_,:#^1<


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

Date: Mon, 26 Nov 2001 00:40:45 -0500
From: "Steve K" <skradel@mindspring.common.sense>
Subject: Re: Serious Regexp help...
Message-Id: <3c01d31b_4@corp.newsgroups.com>


"Ashley M. Kirchner" <ashley@pcraft.com> wrote in message
news:3C01C9FF.7152F9E2@pcraft.com...
>
>     I need to break each line in this text (wrapping alert):
>
> 4x6                 1        4"x6" Standard Print (full-frame from 35mm)
Image:Uploaded Image 1     .75     $0.75
>
> 4x6                 1        4"x6" Standard Print (full-frame from 35mm)
Image:Uploaded Image 2     .75     $0.75
>
> 5x7.5               1        5x7.5 Image:Uploaded Image 3      4.25
$4.25
>
> 8x12                1        8x12 Classic Full Frame Image:Uploaded Image
4   10.25    $10.25

if ($ln =~ m/^(\S+)\s+(\1)\s+(.*)\s+(\1)\s+(\1)$/) {
    ($dims1, $num1, $dims2, $desc, $num2, $cash) = ($1, $2, $3, $4, $5, $6);
    # do stuff
}

Could be prettier, but should get the job done.

--Steve

>
>
>     ...into 6 pieces. Based on the first line, I need:
>
>     1.  4x6
>     2.  1
>     3.  4"x6"
>     4.  Standard Print (full-frame from 35mm) Image:Uploaded Image 1
>     5.  .75
>     6.  $0.75
>
[remainder snipped]




-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----==  Over 80,000 Newsgroups - 16 Different Servers! =-----


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

Date: Mon, 26 Nov 2001 05:42:34 GMT
From: "David Hilsee" <davidhilseenews@yahoo.com>
Subject: Re: Serious Regexp help...
Message-Id: <eDkM7.55257$Ze5.30622616@news1.rdc1.md.home.com>

"Ashley M. Kirchner" <ashley@pcraft.com> wrote in message
news:3C01C9FF.7152F9E2@pcraft.com...
>
>     I need to break each line in this text (wrapping alert):
>
> 4x6                 1        4"x6" Standard Print (full-frame from 35mm)
Image:Uploaded Image 1     .75     $0.75
>
> 4x6                 1        4"x6" Standard Print (full-frame from 35mm)
Image:Uploaded Image 2     .75     $0.75
>
> 5x7.5               1        5x7.5 Image:Uploaded Image 3      4.25
$4.25
>
> 8x12                1        8x12 Classic Full Frame Image:Uploaded Image
4   10.25    $10.25
>
>
>     ...into 6 pieces. Based on the first line, I need:
>
>     1.  4x6
>     2.  1
>     3.  4"x6"
>     4.  Standard Print (full-frame from 35mm) Image:Uploaded Image 1
>     5.  .75
>     6.  $0.75
>
>     And as you can see, the 3rd item is written differently on two of
those lines - I need to account for that.  Also, the first item could also
be simple text (letters) instead of just numbers (and an 'x').
>
>     Anyone?
>
> --
> H | "Life is the art of drawing without an eraser." - John Gardner
>   +--------------------------------------------------------------------
>   Ashley M. Kirchner <mailto:ashley@pcraft.com>   .   303.442.6410 x130
>   Director of Internet Operations / SysAdmin    .     800.441.3873 x130
>   Photo Craft Laboratories, Inc.            .     3550 Arapahoe Ave, #6
>   http://www.pcraft.com ..... .  .    .       Boulder, CO 80303, U.S.A.
>
>

It seems to me that the easy way out would be:

@contents = split /\s{3,}/; # number 3 is somewhat arbitrary

The division of the third field into its proper components could also be
done with a simple split, like:

($field3, $field4) = split ' ', $contents[2], 2;

# or, alternatively, to put it in the same array...
splice @contents, 2, 1, split ' ', $contents[2], 2;

Hope this helps.  It simply divides the line on sequences of whitespace
characters that are 3 characters or longer, and works with the text from
there.  Please reply if this solution is too simplistic to meet your needs.

--
David Hilsee




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

Date: 26 Nov 2001 00:48:13 -0500
From: Mona Wuerz <wuerz@yahoo.com>
Subject: Re: Serious Regexp help...
Message-Id: <m3snb2qe02.fsf@DCCMBX01.njitdm.campus.njit.edu>

"Steve K" <skradel@mindspring.common.sense> writes:

> "Ashley M. Kirchner" <ashley@pcraft.com> wrote in message
> news:3C01C9FF.7152F9E2@pcraft.com...
> >
> >     I need to break each line in this text (wrapping alert):
> >
> > 4x6                 1        4"x6" Standard Print (full-frame from 35mm)
> Image:Uploaded Image 1     .75     $0.75
> >
> > 4x6                 1        4"x6" Standard Print (full-frame from 35mm)
> Image:Uploaded Image 2     .75     $0.75
> >
> > 5x7.5               1        5x7.5 Image:Uploaded Image 3      4.25
> $4.25
> >
> > 8x12                1        8x12 Classic Full Frame Image:Uploaded Image
> 4   10.25    $10.25
> 
> if ($ln =~ m/^(\S+)\s+(\1)\s+(.*)\s+(\1)\s+(\1)$/) {
                         ^^            ^^     ^^
These are backreferences, trying to match what has been captured by
the first (\S+).

>     ($dims1, $num1, $dims2, $desc, $num2, $cash) = ($1, $2, $3, $4, $5, $6);
>     # do stuff
> }
> 
> Could be prettier, but should get the job done.

Did you try it?

-- 
$_="\n,rekcah egnufeB rehtona tsuJ";#v1<?>g\:pv-<5<
s s\S+(?:B)sunpack'u',q q$;')E4qsee;#>60#^<(v!<)g6<
print scalar reverse,$@ unless m,[+;#]55,;m:_,:#^1<


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

Date: Mon, 26 Nov 2001 00:58:17 -0500
From: "Steve K" <skradel@mindspring.common.sense>
Subject: Re: Serious Regexp help...
Message-Id: <3c01d72b_2@corp.newsgroups.com>


"Mona Wuerz" <wuerz@yahoo.com> wrote in message
news:m3snb2qe02.fsf@DCCMBX01.njitdm.campus.njit.edu...
> "Steve K" <skradel@mindspring.common.sense> writes:
[snip]
> > if ($ln =~ m/^(\S+)\s+(\1)\s+(.*)\s+(\1)\s+(\1)$/) {
>                          ^^            ^^     ^^
> These are backreferences, trying to match what has been captured by
> the first (\S+).

Oops, so they are.  Mea culpa, etc.

--Steve




-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----==  Over 80,000 Newsgroups - 16 Different Servers! =-----


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

Date: Mon, 26 Nov 2001 06:11:53 GMT
From: "ME" <me@here.com>
Subject: Re: Serious Regexp help...
Message-Id: <J2lM7.16096$V46.3711624@news1.rdc1.va.home.com>

If those are tabs between each item (looks like it) you could just do:
while <FILEHANDLE>{
    ($size, $number, $description, $cost, $extended) = split(/\t/) ;
   # split out the numbers part from the description

$description =~ s/(\d+\.?\d*\"?[Xx]\d+\.?\d*\"? )// ;  #space at end is so
that description doesnt have leading space.
$size_desc = $1 ;
        }
Heres how it breaks down:
    s/(\d+     #one or more digits
        \.?        #might be followed by a period
        \d*        #might have more digits after period
        \"?        #digits might be followed by double quotes
        [Xx]       #next is one upper or lower case "X"
        \d+         #followed by one or more digits
        \.?            #might have a period after it
        \d*            #might have more digits after the period
        \"? )//         # might have quotes after the number
                            #has a space after it.

I hope that this helps ya. I tested all of the description strings using the
substitution and it assigned the right stuff to the variables for me.

Brian

b**NOSPAM**king**NOSPAM**AT**NOSPAM**AFFCU**NOSPAM**D0t**NOSPAM**C0m


Ashley M. Kirchner wrote in message <3C01C9FF.7152F9E2@pcraft.com>...
>
>    I need to break each line in this text (wrapping alert):
>
>4x6                 1        4"x6" Standard Print (full-frame from 35mm)
Image:Uploaded Image 1     .75     $0.75
>
>4x6                 1        4"x6" Standard Print (full-frame from 35mm)
Image:Uploaded Image 2     .75     $0.75
>
>5x7.5               1        5x7.5 Image:Uploaded Image 3      4.25
$4.25
>
>8x12                1        8x12 Classic Full Frame Image:Uploaded Image 4
10.25    $10.25
>
>
>    ...into 6 pieces. Based on the first line, I need:
>
>    1.  4x6
>    2.  1
>    3.  4"x6"
>    4.  Standard Print (full-frame from 35mm) Image:Uploaded Image 1
>    5.  .75
>    6.  $0.75
>
>    And as you can see, the 3rd item is written differently on two of those
lines - I need to account for that.  Also, the first item could also be
simple text (letters) instead of just numbers (and an 'x').
>
>    Anyone?
>
>--
>H | "Life is the art of drawing without an eraser." - John Gardner
>  +--------------------------------------------------------------------
>  Ashley M. Kirchner <mailto:ashley@pcraft.com>   .   303.442.6410 x130
>  Director of Internet Operations / SysAdmin    .     800.441.3873 x130
>  Photo Craft Laboratories, Inc.            .     3550 Arapahoe Ave, #6
>  http://www.pcraft.com ..... .  .    .       Boulder, CO 80303, U.S.A.
>
>




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

Date: Mon, 26 Nov 2001 00:12:49 -0700
From: "Ashley M. Kirchner" <ashley@pcraft.com>
Subject: Re: Serious Regexp help...
Message-Id: <3C01EB71.D321AB4B@pcraft.com>

Mona Wuerz wrote:

> If the whitespace between fields consists of tab characters (and they
> look like they do), then a simple:

    I WISH they were tabs - but they're not.


> my @pieces = $line =~ /^(\S+)\s+(\d+)\s+(\S+)\s+(.+?)\s+(\S+)\s+(\$\S+)$/;
>
> That works at least for the data you provided. Some redundancy checks
> would be good, too (e.g. items 1 and 3 appear to be related, as do
> items 5 and 6) to make sure the lines got parsed as intended.

    This works though.  Thanks!  Yes, items 1 and 3 are pretty much the same thing, but that's the way the system works.  As for 5 and 6, that depends.  5 is a unit price, while 6 is a total price for whatever quantity of that unit they're picked.

--
H | "Life is the art of drawing without an eraser." - John Gardner
  +--------------------------------------------------------------------
  Ashley M. Kirchner <mailto:ashley@pcraft.com>   .   303.442.6410 x130
  Director of Internet Operations / SysAdmin    .     800.441.3873 x130
  Photo Craft Laboratories, Inc.            .     3550 Arapahoe Ave, #6
  http://www.pcraft.com ..... .  .    .       Boulder, CO 80303, U.S.A.




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

Date: Mon, 26 Nov 2001 18:23:31 +1100
From: "Andrew Hamm" <ahamm@programmer.net>
Subject: Re: Serious Regexp help...
Message-Id: <3c01edf0_1@news.iprimus.com.au>

Garry Williams wrote in message ...
>
>  /^
>    (\S+)        # $1 =  4x6
>    \s+
>    (\d+)        # $2 =  1
>    \s+
>    (.*)         # $3 =  Standard Print...
>    ([.\d]+)     # $4 =  .75
>    \s+
>    (\$\d+\.\d+) # $5 =  $0.75
>  $/x
>
Careful there - your (.*) is greedy and will consume all of the 2nd-last
field, then the backtracking will give back ONE character so that the
2nd-last field is incorrectly matched. You've also neglected to discard the
spaces between field #3 and #4.

Change to this and try again:

  /^
    (\S+)        # $1 =  4x6
    \s+
    (\d+)        # $2 =  1
    \s+
    (.*?)         # $3 =  Standard Print...
    \s+
    ([.\d]+)     # $4 =  .75
    \s+
    (\$\d+\.\d+) # $5 =  $0.75
  $/x

no, I haven't tested it either ;-) but it looks better.

Various comments can be made depending on the nature of the data, but i'm as
much in the dark as you are. Your assumptions hold given the limited sample
data.





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

Date: Mon, 26 Nov 2001 05:11:27 GMT
From: garry@ifr.zvolve.net (Garry Williams)
Subject: Re: use File:Find non-recursive
Message-Id: <slrna03jo7.sdi.garry@zfw.zvolve.net>

On Mon, 26 Nov 2001 12:37:26 +0800, hugo <hugo@fractalgraphics.com.au> wrote:
> Hi Gary
> 
> I am very sorry, you must think I am daft, but I still do not get it. In
> this code, where and when do I search for my substring and store it in
> @file? 
> 
> I am sorry but I am really in the dark here. Could you elaborate on the
> code below and insert the line where I search for a substring, i.e. the
> line I normally use: 
> 
> find sub { push @file, $File::Find::name if /$filext$/ }, @_; 

[snip]

>>   find sub {
>>     print;
>>     if ( -d and $File::Find::name ne $File::Find::topdir ) {
>>       $File::Find::prune = 1;
>>     }

       return unless /$filext$/;
       push @file, $_;
       # or push @file, $File::Find::name

>>   }, ".";
      ^^^^^^^
Sorry, I didn't mention this last bit in my post.  The find() sub
takes a list of directories after the wanted sub as its arguments.  

-- 
Garry Williams


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

Date: Mon, 26 Nov 2001 15:40:14 +0800
From: hugo <hugo@fractalgraphics.com.au>
Subject: Re: use File:Find non-recursive
Message-Id: <3C01F1DE.D7695F0F@fractalgraphics.com.au>

Thanks very much Steve and Garry for your help with this code for
finding files non-recursively. 

I finally got it to work properly.

Thanks again. 

Cheers

Hugo   

hugo wrote:
> 
> Hi
> 
> I saw a posting recently on the use of File:Find which in fact is just
> what I need for a script I am building.
> However, I would like to offer the user the option to user File:Find
> recursively or non-recursively. I saw in perldoc you can use the &wanted
> function, but I can't get it to work.
> 
> The original posting was something like this:
> 
> #!/usr/bin/perl -w
> use strict;
> use File::Find;
> 
> my $dir = '/home/httpd';
> print "$_\n" foreach find_htm($dir);
> 
> sub find_htm {
>    my @htm;
> 
>    find sub { push @htm, $File::Find::name if /\.htm$/ }, @_;
> 
>    return @htm;
> }
> 
> I thought if I do this I can make File:Find only apply to the current
> directory.
> 
> sub find_non_recursive {
>  find(\&wanted, '.');
>     sub wanted {
>       find sub { push @file, $File::Find::name if /$filext$/ }, @_;
>       return @file;
>    }
> }
> 
> In other words, I am instructing File::Find only to go to . (the current
> directory), then search for the file extension people have put in
> ($filext). When I find that, I push this onto the array @file.
> 
> However, it does not work.
> 
> Can anyone help me with finding a way to use File:Find non-recursively?
> 
> Thanks
> 
> Hugo
> 
> --
> Dr Hugo Bouckaert
> R&D Support Engineer, Fractal Graphics
> 57 Havelock Street, West Perth 6005
> Western Australia 6009
> Tel: +618 9211 6000 Fax: +618 9226 1299
> Email:hugo@fractalgraphics.com.au
> Web: http://www.fractalgraphics.com.au

-- 
Dr Hugo Bouckaert
R&D Support Engineer, Fractal Graphics 
57 Havelock Street, West Perth 6005
Western Australia 6009
Tel: +618 9211 6000 Fax: +618 9226 1299
Email:hugo@fractalgraphics.com.au
Web: http://www.fractalgraphics.com.au


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

Date: 26 Nov 2001 08:00:13 GMT
From: Bernard El-Hagin <bernard.el-hagin@lido-tech.net>
Subject: Re: variable scope
Message-Id: <slrna040i1.qsr.bernard.el-hagin@gdndev25.lido-tech>

On Thu, 22 Nov 2001 21:04:29 GMT, Gisle Aas <gisle@ActiveState.com> wrote:
> mjd@plover.com (Mark Jason Dominus) writes:
> 
>> Even if it's only Matt and Dijkstra against the rest of the world, I'd
>> have to think twice before picking the rest of the world.
> 
> They seem to have a significant ally.  C# does not allow you to
> redefine a variable in an inner scope.


Significant?


Cheers,
Bernard


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

Date: Sun, 25 Nov 2001 21:38:27 -0800
From: Dave <dlc-usenet@halibut.com>
Subject: View/Dump code produced by Class::MethodMaker?
Message-Id: <jkd30u8q73spshk00jhaf1u6v7pj9sfv82@4ax.com>


Is it possible to view/save the code generated by Class::MethodMaker?
I've spent a couple of hours looking at its source and poking around
with the debugger, but I can't figure it out.




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

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


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