[24337] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 6526 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed May 5 21:05:44 2004

Date: Wed, 5 May 2004 18:05:11 -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           Wed, 5 May 2004     Volume: 10 Number: 6526

Today's topics:
    Re: Books online???? <***************>
    Re: Books online???? <***************>
    Re: Books online???? <***************>
    Re: Books online???? <1usa@llenroc.ude>
    Re: Directory sorted in chronological order <jtc@shell.dimensional.com>
    Re: Directory sorted in chronological order <jurgenex@hotmail.com>
    Re: Directory sorted in chronological order <tore@aursand.no>
    Re: Directory sorted in chronological order (Sam Holden)
    Re: Directory sorted in chronological order <uri@stemsystems.com>
    Re: free source authentication script <tore@aursand.no>
    Re: free source authentication script <tore@aursand.no>
    Re: free source authentication script <1usa@llenroc.ude>
    Re: function guessing regular expressions <invalid-email@rochester.rr.com>
        newbie regexp question <zturner_NOSPAM_0826@hotmail.com>
    Re: newbie regexp question <1usa@llenroc.ude>
    Re: newbie regexp question <matternc@comcast.net>
    Re: Out of memory problem <mgjv@tradingpost.com.au>
        Passing data from javascript to perl? <bcoon@sequenom.com>
    Re: read from comma delimited file (Walter Roberson)
    Re: read from comma delimited file <noreply@gunnar.cc>
    Re: read from comma delimited file <gking_236@hotmail.com>
    Re: read from comma delimited file <trammell+usenet@hypersloth.invalid>
    Re: read from comma delimited file <dannywork5@hotmail.com>
    Re: read from comma delimited file <1usa@llenroc.ude>
    Re: read from comma delimited file <noreply@gunnar.cc>
    Re: read from comma delimited file <dwall@fastmail.fm>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Wed, 05 May 2004 19:20:36 -0500
From: Henry Williams <***************>
Subject: Re: Books online????
Message-Id: <3uvi90t05sk41kka11fst4feg91cltmgtc@4ax.com>


>You make it sound like it'll take an hour a day for the rest
>of your life, simply because you noticed one and reported it.
>
>Let me assure you, that I report *every* one I see, and at most it's
>about 15 seconds to forward some report to infringement@ora.com, and
>that I can count the amount of time I spend on this activity in terms
>of minutes per decade. :)
>
>If you see it, report it.  You don't have to go crazy, but every bit
>helps.
>
>print "Just another Perl hacker,"; # and book writer


OK,

http://xxxx.xxx.xxxxxx.xx/Oreilly/perl/index.htm

(I have already emailed infringement@ora.com, with the actual URL.)

Now I'm embarrassed. You are right. I didn't know about the email
address:
 
infringement@ora.com

Or how easy that would be to simply forward the URL.

I imagined sending an email to info@oreilly.com with a subject line of
COPYRIGHT VIOLATION and a body text of:

Sirs,
I have noticed your copyrighted material afloat on the Internet. I'm
sure, after reading the copyright information included with your CD
(at the pirated site.), that you did not have in mind this
intellectual property would be freely available as pirated material.

Please take whatever corrective action you might feel appropriate.

However, please note I did *not* steal this information, but I did
read it a good bit before it dawned on me it was questionable. I them
messaged comp.lang.perl.misc and after a good thrashing was impelled
to write. Namely thanks to "Robert" and also to Randal L. Schwartz.
Please note that I'm unable to divest myself of the illicit
information I digested while I was in my "uninformed" state. If you
decide to pursue me, and take any legal action, please note I have
neither real property nor liquid assets of any kind. Additionally
please note, if I notice a large black automobile stop in the front of
my residence and men emerge from it with coat collars turned up, hats
on and obvious on their persons, weapons of the concealed sort, I will
at once exit the premises and shall from then on be unavailable for
shooting, or any other such activities as you might intend.

Thanks and Best Wishes
So & So

Color me Forgiven. (I hope.)

PS. Thanks for a great book.




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

Date: Wed, 05 May 2004 19:35:02 -0500
From: Henry Williams <***************>
Subject: Re: Books online????
Message-Id: <vr1j90hu9guvgjmgi83h601i6cqpc3om5q@4ax.com>

On Wed, 5 May 2004 08:49:02 +0200, "Bernard El-Hagin"
<bernard.el-haginDODGE_THIS@lido-tech.net> wrote:

>
>Lucky you never posted a self righteous speech about not having the 
>urge to act like a bastard or that statement would make you look like 
>an idiot...oh, wait a minute...


You guys are a real piece of work. OK so it was a tad like a
self-righteous speech, but it was well intentioned. And I don't mind
appearing as an idiot to some, I'll die one day and it won't matter.
To state:
" I can't busy myself with helping O'Reilly no matter how fond
 I am of their books."
Does not compare with the mean spirited, belittling things I see
posted here by some. You just can't compare the two.

What's so wrong with ignoring versus badgering? Both might ultimately
lead to enlightenment, but the former might have some well deserved
satisfaction while the latter never will have anything to be proud of,
and it's the intention that counts.

Henry



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

Date: Wed, 05 May 2004 19:42:56 -0500
From: Henry Williams <***************>
Subject: Re: Books online????
Message-Id: <je2j905jgnulhn6aed2ln74utlnee4k8k6@4ax.com>

On Wed, 05 May 2004 07:29:16 GMT, Charlton Wilbur
<cwilbur@mithril.chromatico.net> wrote:

>>>
>To you it looks like the experts are being bastards.  To the experts,
>it looks like they're doing the newbies a favor in the long run. 
>
>Charlton


OK, OK.

You know I read the books, the man pages and search the web. I hardly
(never) have the occasion to post any questions here. But I do read
the posts. And sometimes the replies don't sit well with me.
If the "experts" want a forum, what's wrong with a moderated NG?
That way, everything but the pristine can be filtered out and not
waste the time or bandwidth of the experts. I mean, honestly.

If Joe incorrectly answers Jane's questions, then Fred compounds the
screw-up with an adulteration of Jane's post, might it not have the
effect, in the final instance, of some happy poster giving the right
answer and challenging the others to test it?

Should it be about learning or a social protocol? I myself have little
use for the latter.

Just me though.

Henry






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

Date: 6 May 2004 00:48:58 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude>
Subject: Re: Books online????
Message-Id: <Xns94E0D3C133D85asu1cornelledu@132.236.56.8>

Henry Williams <***************> wrote in 
news:vr1j90hu9guvgjmgi83h601i6cqpc3om5q@4ax.com:

> On Wed, 5 May 2004 08:49:02 +0200, "Bernard El-Hagin"
> <bernard.el-haginDODGE_THIS@lido-tech.net> wrote:
> 
>>
>>Lucky you never posted a self righteous speech about not having the 
>>urge to act like a bastard or that statement would make you look like 
>>an idiot...oh, wait a minute...
> 
> 
> You guys are a real piece of work.

 ...

> Does not compare with the mean spirited, belittling things I see
> posted here by some. You just can't compare the two.

Let's see ...

On Fri, 30 Apr 2004 22:02:19 -0400, Robert <catcher@linuxmail.org>
wrote:

>>> They are out there and you should report them to O'Reilly.

To which, you responded:

> I was hoping you were going to! I already have a fulltime job.

The simple implication being that the rest of us here are losers with no 
jobs. That is pretty belittling IMNSHO. So, as I have a pretty good idea 
what you should do with your oversized ego.

The self-importance you feel, while impressive, is not necessary.

What kind of narcissism does one need to possess to think that if you 
reported a copyright infringement to O'Reilly, they would go after you?

If you saw an accident on the highway, would you choose not to call 911 
lest they think you had caused it?

-- 
A. Sinan Unur
1usa@llenroc.ude (reverse each component for email address)


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

Date: 5 May 2004 16:24:00 -0600
From: Jim Cochrane <jtc@shell.dimensional.com>
Subject: Re: Directory sorted in chronological order
Message-Id: <slrnc9iqc0.ni6.jtc@shell.dimensional.com>

In article <40995F47.D264A059@king-cart.com>, Marshall Dudley wrote:
> I need to get a directory listing that is sorted in chronological
> order.  Looking at the top of page 203 in the Camel book, it seems that
> the following should work, replacing the grep with a sort:
> 
> opendir (DIR,"./");
> @dir = sort -M, readdir(DIR);
> closedir DIR;
> foreach $line (@dir) {
>         $age = -M $line;
>         print "$age\n";
> }

Here's one way, using the "Schwartzian Transform" for efficiency
(from "Effective Perl"):

#!/usr/bin/perl

use strict;
use warnings;

opendir (DIR, "./");
my @dir =
	map { $_->[0] }
	sort { $a->[1] <=> $b->[1] }
	map { [$_, -M] } readdir(DIR);

closedir DIR;
foreach my $line (@dir) {
        my $age = -M $line;
        print "$line: $age\n";
}

> 
>  perl getage.pl
> 
> 0.00255787037037037
> 30.0848148148148
> 0.0299537037037037
> 0.0286574074074074
> 0.0530208333333333
> 0.0525810185185185
> 0.0261689814814815
> 0.0246180555555556
> 0.00256944444444444
> 0.00269675925925926
> 
> However, as you can see, the directory is not being sorted by age at
> all.
> 
> Can anyone see what my error is?
> 
> Thanks,
> 
> Marshall
> 


-- 
Jim Cochrane; jtc@dimensional.com
[When responding by email, include the term non-spam in the subject line to
get through my spam filter.]


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

Date: Wed, 05 May 2004 22:29:40 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Directory sorted in chronological order
Message-Id: <oVdmc.89089$G_.77181@nwrddc02.gnilink.net>

Marshall Dudley wrote:
> I need to get a directory listing that is sorted in chronological
> order.  Looking at the top of page 203 in the Camel book, it seems
> that the following should work, replacing the grep with a sort:
>
> opendir (DIR,"./");
> @dir = sort -M, readdir(DIR);

The first argument to sort() should be a function that returns -1, 0, or 1
depending upon if the first argument is smaller, equal, or larger than the
second. -M neither returns -1, 0, 1 nor compares two arguments.

You need to write your own compare function.
Considering that each access to the HD is expensive it might be a good idea
to use a Schwartzian transformation, too.

jue




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

Date: Thu, 06 May 2004 01:23:35 +0200
From: Tore Aursand <tore@aursand.no>
Subject: Re: Directory sorted in chronological order
Message-Id: <pan.2004.05.05.23.20.25.327846@aursand.no>

On Wed, 05 May 2004 16:24:00 -0600, Jim Cochrane wrote:
> my @dir =
> 	map { $_->[0] }
> 	sort { $a->[1] <=> $b->[1] }
> 	map { [$_, -M] } readdir(DIR);

I have never spoken bad about ST before, but isn't this overkill in this
given situation?  Wouldn't the (untested) code below create a list of the
files in chronological order?

  my @dir = sort { -M $a <=> -M $b } readdir( DIR );

Or am I missing the point totally? :)


-- 
Tore Aursand <tore@aursand.no>
"There are three kinds of lies: lies, damn lies, and statistics."
 (Benjamin Disraeli)


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

Date: 6 May 2004 00:12:06 GMT
From: sholden@flexal.cs.usyd.edu.au (Sam Holden)
Subject: Re: Directory sorted in chronological order
Message-Id: <slrnc9j0mm.7i3.sholden@flexal.cs.usyd.edu.au>

On Thu, 06 May 2004 01:23:35 +0200, Tore Aursand <tore@aursand.no> wrote:
> On Wed, 05 May 2004 16:24:00 -0600, Jim Cochrane wrote:
>> my @dir =
>> 	map { $_->[0] }
>> 	sort { $a->[1] <=> $b->[1] }
>> 	map { [$_, -M] } readdir(DIR);
> 
> I have never spoken bad about ST before, but isn't this overkill in this
> given situation?  Wouldn't the (untested) code below create a list of the
> files in chronological order?
> 
>   my @dir = sort { -M $a <=> -M $b } readdir( DIR );
> 
> Or am I missing the point totally? :)

The ST is an optimisation technique and as such is never neccesary.

However, this case is one where it is almost certainly useful. -M
results in a stat system call and system calls are slow, even worse it
may require waiting dor a disk read which is even slower (though
filesystem level caching should prevent that happening more than once on
machines without much other disk access happening). To make matters even
worse stat calls need to access the file based on its name, which is
linear in the number of files in the directory.

So each -M in the sort comparison function is O(N) (assuming a crappy
filesystem with such linear access - which is normal) with possibly a
large constant (hitting the disk). The sort comparison function is
called O(N*logN) times and hence we have O(N*N*logN).

The ST version gives us an O(1) comparison function and hence O(N*logN)
for the sort, which is *much* better.

This is the first example I've seen where the ST actually reduces the
runtime complexity of the sort by more than a constant factor - since
it's the first time I've noticed a sort where the comparison function
isn't O(1) in terms of the size of the list being sorted.

Hence I'd say far from being overkill, it will make a *huge* difference
if DIR contains a *lot* of files.

-- 
Sam Holden


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

Date: Thu, 06 May 2004 00:50:53 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Directory sorted in chronological order
Message-Id: <x7n04m4bv7.fsf@mail.sysarch.com>

>>>>> "SH" == Sam Holden <sholden@flexal.cs.usyd.edu.au> writes:

  SH> On Thu, 06 May 2004 01:23:35 +0200, Tore Aursand <tore@aursand.no> wrote:
  >> On Wed, 05 May 2004 16:24:00 -0600, Jim Cochrane wrote:
  >>> my @dir =
  >>> map { $_->[0] }
  >>> sort { $a->[1] <=> $b->[1] }
  >>> map { [$_, -M] } readdir(DIR);
  >> 
  >> my @dir = sort { -M $a <=> -M $b } readdir( DIR );
  >> 
  SH> The ST is an optimisation technique and as such is never neccesary.

  SH> However, this case is one where it is almost certainly useful. -M
  SH> results in a stat system call and system calls are slow, even
  SH> worse it may require waiting dor a disk read which is even slower
  SH> (though filesystem level caching should prevent that happening
  SH> more than once on machines without much other disk access
  SH> happening). To make matters even worse stat calls need to access
  SH> the file based on its name, which is linear in the number of files
  SH> in the directory.

  SH> So each -M in the sort comparison function is O(N) (assuming a crappy
  SH> filesystem with such linear access - which is normal) with possibly a
  SH> large constant (hitting the disk). The sort comparison function is
  SH> called O(N*logN) times and hence we have O(N*N*logN).

  SH> The ST version gives us an O(1) comparison function and hence O(N*logN)
  SH> for the sort, which is *much* better.

all of the sort optimization techniques (ST, GRT and orcish) do
that. the real savings is in converting any O( N log N ) work to O(N)
work (running -M on each file only once). you have to count the work of
-M as a constant in general. it may be O(N) when scanning the dir but
that will be cached in ram for sure as it will be hit often. the inodes
could be scattered around (or clustered on some file systems) but that
could be more disk or other complex access. disk accesses outweigh any
linear scan in ram times so ignore the file name search time.

  SH> This is the first example I've seen where the ST actually reduces the
  SH> runtime complexity of the sort by more than a constant factor - since
  SH> it's the first time I've noticed a sort where the comparison function
  SH> isn't O(1) in terms of the size of the list being sorted.

your analysis is slightly off IMO. you need to count inode accesses as
the main work and that is still O(N log N) and with caching who knows?
factoring out the -M to O(N) time is the win.

and the GRT factors out even more by removing the callback code itself
and using the internal cmp function.

and a perfect time to plug my soon to be released Sort::Maker
module. here is how it would be used to solve this:

	use Sort::Maker ;

	my $M_sorter = make_sorter( 'ST', number => '-M' ) ;

	my @sorted = $M_sorter->( readdir(DIR) ) ;

or with the GRT for more speed:

	my $M_sorter = make_sorter( 'GRT',
        		number => {
				code => '-M',
                                unsigned_float => 1,
			}
	) ;

	my @sorted = $M_sorter->( readdir(DIR) ) ;

if anyone wants to get a beta of this module i can get you the url. it
works for all 4 sort styles and has decent pod. it need many more tests,
benchmarks and examples in pod. if you want to be a beta tester and
provide any feedback, email me. my goal is to release it before
yapc::buffalo as i am giving a talk on it there.

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: Thu, 06 May 2004 01:23:36 +0200
From: Tore Aursand <tore@aursand.no>
Subject: Re: free source authentication script
Message-Id: <pan.2004.05.05.23.00.34.446316@aursand.no>

On Wed, 05 May 2004 10:33:55 -0800, Robin wrote:
>> * You're _still_ not indenting your code properly.

> It's indented in the way I like it. How would you define "properly"?

By the way 90% (at least) of the other Perl programmers indent it.

>> * You're _still_ not using 'strict' (or 'warnings').

> Most of my code does and this one will too, as soon as I get around to
> it.

Until then:  Please don't post - or refer to - malicious scripts.  If you
do, please include the warning I wrote.

>> * You're _still_ not checking the outcome of 'open()'.

> Yeah, I figure [...]

You aren't the one to "figure out" things here - Perl is!  Don't _EVER_
think that "oh, this will work in any case, 'cause...", because the case
where it doesn't work will eventually come.

Murphy's law:  What can go wrong, will go wrong (at least that's the law
translated directly from Norwegian, my primary language).

>> * Yoy're _still_ using 'exit' where it's inappropriate.

> Where? :-)

Don't you have an editor with a "Search" or "Find" function?  Please get
one; I'm sure I saw at least two calls to 'exit' in your script.

>> * You're _still_ mixing HTML and Perl code.

> Well, as tassilo said, what's the point of not using perl? Perl is great
> for interpolation of variables in html code and stuff.

Please see my answer to Tassilo about this.

>> * You're _still_ not validating the data you are using
>>   throughout the script.

> What do you mean exactly?

Your scripts are accepting input from the outside world, but you never
care to validate that input.  People _will_ eventually try to send your
script "bad input".


-- 
Tore Aursand <tore@aursand.no>
"When you love someone, all your saved-up wishes start coming out."
 (Elizabeth Bowen)


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

Date: Thu, 06 May 2004 01:23:36 +0200
From: Tore Aursand <tore@aursand.no>
Subject: Re: free source authentication script
Message-Id: <pan.2004.05.05.23.11.07.243282@aursand.no>

On Wed, 05 May 2004 17:54:05 +0200, Tassilo v. Parseval wrote:
>> * You're _still_ mixing HTML and Perl code.

> I'd rather gnaw my arm off than recommending the use of a templating
> system to anyone. I tried quite a few and hated each one of them.
> 
> Perl already is the best templating system around with all its
> capabilities of interpolating variables and code in strings. Templating
> systems tend to come with their own syntax. This is a waste of time when
> considering that one already knows Perl.

I think we're talking about two different templating systems.  I actally
haven't used many of the template modules found on CPAN, as the company I
worked for rolled out their own templating module.

It was a "pure template module" with almost no possibilities when it came
to logic.  All the logic still resided in the Perl scripts.

Example #1: Substitution of values

  script.pl
  ---------
  $Template->subst( 'FIRSTNAME', $firstname );
  $Template->subst( 'LASTNAME', $lastname );

  script.thtml
  ------------
  <b>Firstname:</b> <!-- %%FIRSTNAME%% --><br />
  <b>Lastname:</b> <!-- %%LASTNAME%% --><br />

Example #2: List

  script.pl
  ---------
  $Template->create_list( 'PERSONS', 'FIRSTNAME', 'LASTNAME' );
  $Template->sort_list( 'PERSONS', 'LASTNAME,STR,ASC;FIRSTNAME,STR,ASC);
  foreach ( @Persons ) {
      $Template->push_list( 'PERSONS', $_>firstname(), $_->lastname() );
  }
  $Template->done_list( 'PERSONS' );

  script.thtml
  ------------
  <!-- %%PERSON_LIST BEGIN%% -->
  <!-- %%LASTNAME%% -->, <!-- %%FIRSTNAME%% --><br />
  <!-- %%PERSON_LIST END%% -->

Very easy, as we had an own department with designers who knew little or
nothing about programming.

I see that a lot (too many, probably) of the template solutions found on
CPAN involves including logic.  I agree with you; that's bad.  But for
easy things like above (lists, substitutions etc.), I still think that
separating Perl code from HTML (or whatever format we're using) is the
best thing in the end.

One example comes to my mind: Let's say you have a script which should
output the same thing, but to different medias (HTML, pure text etc.). 
Wouldn't it be better to have separate template files depending on the
media and letting the script choose which template to use from the context?

Just my $0.02.


-- 
Tore Aursand <tore@aursand.no>
"Writing is a lot like sex. At first you do it because you like it.
 Then you find yourself doing it for a few close friends and people you
 like. But if you're any good at all, you end up doing it for money."
 (Unknown)


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

Date: 5 May 2004 23:27:44 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude>
Subject: Re: free source authentication script
Message-Id: <Xns94E0C5FB1BC29asu1cornelledu@132.236.56.8>

"Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de> wrote in 
news:c7b2n0$1opp1$1@ID-231055.news.uni-berlin.de:

> I'd rather gnaw my arm off than recommending the use of a templating
> system to anyone. I tried quite a few and hated each one of them.

There is a benefit to strict separation of HTML from Perl code. You can 
play around with the HTML much more easily. Even though I work on both 
facets of my programs myself, I find it useful to tinker with the HTML and 
CSS separately without having to run the script etc. In that regard, I have  
been very fond of HTML::Template. Of course, tastes vary.

Sinan.

-- 
A. Sinan Unur
1usa@llenroc.ude (reverse each component for email address)


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

Date: Thu, 06 May 2004 00:39:57 GMT
From: Bob Walton <invalid-email@rochester.rr.com>
Subject: Re: function guessing regular expressions
Message-Id: <40998959.2050702@rochester.rr.com>

wieniuszka wrote:

 ...
> have anyone tried to develop a function which given a number of strings
> which have something in common returns a regular expression fitting those
> strings?
> Is something like this possible at all?
> I'm affraid that the most difficult thing would be to teach the program
> choose the best pattern, because the strings may have many features in
> common and the computer woud have to choose 'the best' - and that would
> require 'AI'. But maybe I'm wrong.
> Any ideas?
> 

Check out the module:  String::Approx  on CPAN (http://www.perl.com/CPAN/)

It might give you some ideas, or might be close enough to what you want.

And who knows, maybe there's another module amongst those 6316 modules 
that would do the trick?

-- 
Bob Walton
Email: http://bwalton.com/cgi-bin/emailbob.pl



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

Date: Wed, 05 May 2004 23:56:23 GMT
From: "Zachary Turner" <zturner_NOSPAM_0826@hotmail.com>
Subject: newbie regexp question
Message-Id: <Hafmc.67091$NR5.54148@fe1.texas.rr.com>

Why doesn't this work like I expect it to?

if ($string =~ /$pattern/) {
    ...
}

Basically I built the pattern on the fly, so I can't hardcode it.  My guess
is that it's not interpolating the variable.  So how do I get it to do this?

Thanks




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

Date: 6 May 2004 00:06:28 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude>
Subject: Re: newbie regexp question
Message-Id: <Xns94E0CC8C127BEasu1cornelledu@132.236.56.8>

"Zachary Turner" <zturner_NOSPAM_0826@hotmail.com> wrote in
news:Hafmc.67091$NR5.54148@fe1.texas.rr.com: 

> Why doesn't this work like I expect it to?
> 
> if ($string =~ /$pattern/) {
>     ...
> }

What do you expect? How is what happens different than what you expect? 
For example:

use strict;
use warnings;

my $string = 'How many mind readers are there in comp.lang.perl.misc?';
my $pattern = 'mind';

if($string =~ /$pattern/) {
    print "Found\n";
}

> Basically I built the pattern on the fly, so I can't hardcode it.  My
> guess is that it's not interpolating the variable.  So how do I get it
> to do this? 

Read http://www.catb.org/~esr/faqs/smart-questions.html

-- 
A. Sinan Unur
1usa@llenroc.ude (reverse each component for email address)


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

Date: Wed, 05 May 2004 20:31:48 -0400
From: Chris Mattern <matternc@comcast.net>
Subject: Re: newbie regexp question
Message-Id: <IeudnY7i6LzrGgTdRVn-hQ@comcast.com>

Zachary Turner wrote:

> Why doesn't this work like I expect it to?

I dunno.  How do you expect it to work?
> 
> if ($string =~ /$pattern/) {
>     ...
> }
> 
> Basically I built the pattern on the fly, so I can't hardcode it.  My
> guess
> is that it's not interpolating the variable.  So how do I get it to do
> this?
> 
Not knowing: 
a) what you expect it to do,
b) what it *is* doing,
c) the contents of $string, or
d) the contents of $pattern,
it is utterly impossible to give you any help whatsoever.

About all that can be said is that the statement you give *will*
interpolate $pattern (and $string, for that matter).
-- 
             Christopher Mattern

"Which one you figure tracked us?"
"The ugly one, sir."
"...Could you be more specific?"


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

Date: 05 May 2004 22:56:19 GMT
From: Martien Verbruggen <mgjv@tradingpost.com.au>
Subject: Re: Out of memory problem
Message-Id: <slrnc9is8i.4ck.mgjv@verbruggen.comdyn.com.au>

On 5 May 2004 10:49:30 -0700,
	Shikhar <shikhar_srivastava@tufts-health.com> wrote:
> Perl Gurus,
> 
> I have a Perl program that reads certain file(s) and stores contents
> in hash maps. The files are not huge per se,. One of the file is 100
> bytes long * 100,000 records (80 megs).

Perl will probably need a bit more than that 80 MB, due to some
overhead, but not hugely more.

> I have always thought/read that Perl can read whole file and work
> efficiently.  I had this program running nicely with a 40 meg file.
> Now I am getting "Out of Memory!" problem with 80 meg file.
> 
> 
> In Java I can use heap size parameters to set initial and maximum heap
> sizes and they work nicely.
> 
> How can I deal with situation here.   I checked in Top and memory
> utilization for the process was  around 56,264 K which does not seem a
> lot.

That is not a lot at all. especially given:

> Memory Info
> 
> 4 gb physical
> 
> From glance : Total VM : 279.5mb   Sys Mem  : 270.6mb   User Mem: 
> 1.50gb   Phys Mem:  4.00gb

With this to back it up, there should be no problem at all for Perl to
have 100,000 key-value pairs in a hash, with each key-value pair
representing 100 bytes of data.


I'd say your system probably has some user limitations configured by
default. Type in something like:

$ ulimit -a

I suspect that AIX has one or more entries in there for memory size.
If they're not set to unlimited, you're probably hitting those. talk
to your system admin about those limits if they're there.

Martien
-- 
                        | 
Martien Verbruggen      | If at first you don't succeed, try again.
Trading Post Australia  | Then quit; there's no use being a damn fool
                        | about it.


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

Date: Wed, 05 May 2004 22:45:36 GMT
From: Bryan Coon <bcoon@sequenom.com>
Subject: Passing data from javascript to perl?
Message-Id: <k8emc.60621$4o1.57902@newssvr25.news.prodigy.com>

Hi,

I have some perl scripts built which do pagination.  They just connect 
to mysql and retrieve data sets using limit().  I have been informed by 
the powers that be however that they want to have multiple selections 
available -accross- pages.

I set up CGI::Session, and have built in the functionality to store the 
id's of all items checked in the Session object, and to recheck items 
that were previously checked.  The big problem is if a user deselects an 
item.  How do I notify the perl script which item or items (there could 
be a bunch per page) have been deselected????

At the end of the day, I need to have a perl array with the deselected 
values in it, so I can compare it to the previously selected items 
stored in their array in the Session object.  It would then be easy to 
compare and remove the deselected items.

The only thing I can think of at the moment is some javascript array 
that stuffs in the deselected id's, and then passes this array to the 
perl cgi.  But there's no way I know of to pass a javascript array to 
perl...

Anyone have any ideas?

B


-- 
PLEASE NOTE: comp.infosystems.www.authoring.cgi is a
SELF-MODERATED newsgroup. aa.net and boutell.com are
NOT the originators of the articles and are NOT responsible
for their content.

HOW TO POST to comp.infosystems.www.authoring.cgi:
http://www.thinkspot.net/ciwac/howtopost.html


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

Date: 5 May 2004 22:25:24 GMT
From: roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)
Subject: Re: read from comma delimited file
Message-Id: <c7bpkk$65p$1@canopus.cc.umanitoba.ca>

In article <Fudmc.146062$Gd3.35177306@news4.srv.hcvlny.cv.net>,
Danny <dannywork5@hotmail.com> wrote:
:How can I read from a comma delimited text file and export to a tab
:delimited file using perl.
:the file has quotes around the fields when another comma is in the string,
:but nothing if it is a regular string.
:Like:
:"this field has a comma, in it", but tihs field does not, good bye

What happens if the field has quotes in it? Quotes at the beginning and
end? With or without commas?

You haven't really fully specified the problem to us as yet.
-- 
   Rump-Titty-Titty-Tum-TAH-Tee             -- Fritz Lieber


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

Date: Thu, 06 May 2004 00:21:28 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: read from comma delimited file
Message-Id: <c7bplq$281dv$1@ID-184292.news.uni-berlin.de>

Danny wrote:
> How can I read from a comma delimited text file and export to a tab
> delimited file using perl.
> the file has quotes around the fields when another comma is in the
> string, but nothing if it is a regular string.
> Like:
> "this field has a comma, in it", but tihs field does not, good bye
> 
> I have searched for this but most do not account for the "quotes"
> around the fields

If you really have searched for it, why are you asking a FAQ?

     perldoc -q delimited

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



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

Date: Wed, 05 May 2004 18:35:34 -0400
From: "George236" <gking_236@hotmail.com>
Subject: Re: read from comma delimited file
Message-Id: <f2fad2ff537ec7c804fccc909abd0467@localhost.talkaboutprogramming.com>

Seems parsing the records one character at a time as in 'normal'
programming languages is a sensible way of doing things.

Its not that hard.

George
<frankenstein.grabafreebie.com>



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

Date: Wed, 5 May 2004 22:51:29 +0000 (UTC)
From: "John J. Trammell" <trammell+usenet@hypersloth.invalid>
Subject: Re: read from comma delimited file
Message-Id: <slrnc9irvh.8en.trammell+usenet@hypersloth.el-swifto.com.invalid>

On Wed, 05 May 2004 22:01:09 GMT, Danny <dannywork5@hotmail.com> wrote:
> How can I read from a comma delimited text file and export to a tab
> delimited file using perl.

One solution would be to use the Text::CSV_XS module to read your
comma-delimited file.



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

Date: Thu, 06 May 2004 00:34:40 GMT
From: "Danny" <dannywork5@hotmail.com>
Subject: Re: read from comma delimited file
Message-Id: <AKfmc.146319$Gd3.35709538@news4.srv.hcvlny.cv.net>


"Danny" <dannywork5@hotmail.com> wrote in message
news:Fudmc.146062$Gd3.35177306@news4.srv.hcvlny.cv.net...
> How can I read from a comma delimited text file and export to a tab
> delimited file using perl.
> the file has quotes around the fields when another comma is in the string,
> but nothing if it is a regular string.
> Like:
> "this field has a comma, in it", but tihs field does not, good bye
>
> I have searched for this but most do not account for the "quotes" around
the
> fields
>
> THanks in advance
>
>

I tried using the split() function but that really does not work
imagine cases like this:
"the quotes need to be here because of a , in the field"
so the split will not work for these fields

You can't remove the quotes before the split either

does anybody have a sample I can try?




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

Date: 6 May 2004 00:41:41 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude>
Subject: Re: read from comma delimited file
Message-Id: <Xns94E0D28474644asu1cornelledu@132.236.56.8>

"Danny" <dannywork5@hotmail.com> wrote in
news:AKfmc.146319$Gd3.35709538@news4.srv.hcvlny.cv.net: 

> You can't remove the quotes before the split either
> does anybody have a sample I can try?

 perldoc -q delimited


-- 
A. Sinan Unur
1usa@llenroc.ude (reverse each component for email address)


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

Date: Thu, 06 May 2004 02:41:48 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: read from comma delimited file
Message-Id: <c7c1t0$253i3$1@ID-184292.news.uni-berlin.de>

Danny wrote:
> Danny wrote:
>> How can I read from a comma delimited text file and export to a
>> tab delimited file using perl.
>> the file has quotes around the fields when another comma is in
>> the string, but nothing if it is a regular string.
>> Like:
>> "this field has a comma, in it", but tihs field does not, good
>> bye
>> 
>> I have searched for this but most do not account for the "quotes"
>> around the fields
> 
> I tried using the split() function but that really does not work
> imagine cases like this:
> "the quotes need to be here because of a , in the field"
> so the split will not work for these fields
> 
> You can't remove the quotes before the split either
> 
> does anybody have a sample I can try?

You did get a few suggestions, but apparently you chose to ignore 
them. Also, you haven't showed us any code that you have been trying.

Considering that, why would anybody be interested in posting code?

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



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

Date: Thu, 06 May 2004 01:02:18 -0000
From: "David K. Wall" <dwall@fastmail.fm>
Subject: Re: read from comma delimited file
Message-Id: <Xns94E0D6049A3BEdkwwashere@216.168.3.30>

Gunnar Hjalmarsson <noreply@gunnar.cc> wrote:

> Danny wrote:
>> How can I read from a comma delimited text file and export to a tab
>> delimited file using perl.
>> the file has quotes around the fields when another comma is in the
>> string, but nothing if it is a regular string.
>> Like:
>> "this field has a comma, in it", but tihs field does not, good bye
>> 
>> I have searched for this but most do not account for the "quotes"
>> around the fields
> 
> If you really have searched for it, why are you asking a FAQ?
> 
>      perldoc -q delimited

I think whoever wrote the FAQ entry has been using the Concurrent Versions 
System too much. Text::CVS? Text::CVS_XS?  :-)

I'm still using 5.8.0 here at home, so possibly the FAQ has been corrected by 
now.



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

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


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