[25374] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 7619 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Jan 7 14:05:29 2005

Date: Fri, 7 Jan 2005 11:05:15 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Fri, 7 Jan 2005     Volume: 10 Number: 7619

Today's topics:
    Re: "Make" Does Not Respond in Perl to Install LIBWWW <mritty@gmail.com>
    Re: checking at runtime if modul is installed (Anno Siegel)
    Re: checking at runtime if modul is installed <spamtrap@dot-app.org>
    Re: checking at runtime if modul is installed <tassilo.von.parseval@rwth-aachen.de>
    Re: checking at runtime if modul is installed <spamtrap@dot-app.org>
    Re: checking at runtime if modul is installed <nobull@mail.com>
    Re: CRYPT:RC5 problem, can't unencrypt <zentara@highstream.net>
    Re: Dummy regex question <mritty@gmail.com>
    Re: Dummy regex question <sbryce@scottbryce.com>
        Extarcting And Storing a String <hx_101@hotmail.com>
    Re: Extarcting And Storing a String <spamtrap@dot-app.org>
    Re: Extarcting And Storing a String <noreply@gunnar.cc>
    Re: Extarcting And Storing a String <hx_101@hotmail.com>
    Re: Extarcting And Storing a String <mjl69mjl69@myaccmyacc.net>
    Re: Extarcting And Storing a String <noreply@gunnar.cc>
    Re: How to write a program to ... <noreply@gunnar.cc>
        IPC looking for simple/best way to communicate whansen_at_corporate-image_dot_com@us.com
        LOL..... I Just Found A Gwenyth Paltrow Sex Video Onlin goqrnaoe@sk.com
    Re: multiple packages/classes in one file <noreply@gunnar.cc>
    Re: Need help sorting fixed length records <joe@inwap.com>
    Re: PHP in Perl <HelgiBriem_1@hotmail.com>
    Re: Protection of tied files <botfood@yahoo.com>
        Regex help, need to find all "<script src" calls but no <jgdoke@ra.rockwell.com>
    Re: Regex help, need to find all "<script src" calls bu <spamtrap@dot-app.org>
    Re: Regex help, need to find all "<script src" calls bu <noreply@gunnar.cc>
    Re: sharing fileglobs <bachmanns@gmx.de>
    Re: Similair command like 'ls' in perl <joe@inwap.com>
    Re: Similair command like 'ls' in perl (Anno Siegel)
    Re: Skip C like comments <nobull@mail.com>
    Re: Skip C like comments <this.address@is.invalid>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Fri, 07 Jan 2005 13:13:17 GMT
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: "Make" Does Not Respond in Perl to Install LIBWWW
Message-Id: <NVvDd.26500$rL3.9975@trnddc03>

<mary> wrote in message
news:1cbrt0dheqn85jmpaj9127ptqei7sng2c8@4ax.com...
>
> On Thu, 06 Jan 2005 20:16:43 GMT, "Paul Lalli" <mritty@gmail.com>
> wrote:
>
> ><mary> wrote in message
> >news:vv9rt0pev16njn5bkjvprhkp792t1krppv@4ax.com...
> >>
> >> perl makefile.pl
> >> make
> >> make test
> >> make install
> >>
> >> I get that "make"  is not a "recognized command".
> >> Where is "make". And what should I do?
> >> Thanks a million.
> >
> >make is a standard unix command.  The 'recognized command' error
sounds
> >suspciously like a Windows response.  Is this correct?  A google
search
> >for "make for windows" should direct you to the windows alternative,
> >'nmake'.  This is the program you need to install perl modules in
place
> >of the standard unix 'make' program.
> >
>
> Thank you, Paul.
> Nmake is already up here.

Please post your reply *below* the quote you are replying to.  Thank
you.

So, what happened when you tried replacing 'make' in the above three
commands with 'nmake'?

Paul Lalli



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

Date: 7 Jan 2005 12:27:06 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: checking at runtime if modul is installed
Message-Id: <crlv6q$8ih$1@mamenchi.zrz.TU-Berlin.DE>

Sherm Pendley  <spamtrap@dot-app.org> wrote in comp.lang.perl.misc:
> Sam wrote:
> 
> > is there a way to check if a modul is available and if so then to use it
> > I want to do
> > 
> >     use Time:HiRes qw (time);
> > 
> > if possible; but it should also run if that is not available.
> 
> Wrap it up in an eval() and check for errors. Be sure to put the eval() 
> in a BEGIN block so it happens at compile time, like use() normally does.
> 
> BEGIN {
>      unless (eval "use Time::HiRes qw(time)") {
>          warn "Couldn't load Time::HiRes: $@";
>      }
> }

That isn't quite right.  "use" returns nothing at run time, whether it
succeeded or not.  You need to check $@.  Also, I would use block eval
when string eval isn't necessary.  So

BEGIN {
    eval { use Time::HiRes qw(time) };
    warn "Couldn't load module: $@" if $@;
}

Anno


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

Date: Fri, 07 Jan 2005 10:59:29 -0500
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: checking at runtime if modul is installed
Message-Id: <K9adnTQXXqh_LEPcRVn-vA@adelphia.com>

Anno Siegel wrote:

> Sherm Pendley  <spamtrap@dot-app.org> wrote in comp.lang.perl.misc:
> 
>>Wrap it up in an eval() and check for errors. Be sure to put the eval() 
>>in a BEGIN block so it happens at compile time, like use() normally does.
>>
>>BEGIN {
>>     unless (eval "use Time::HiRes qw(time)") {
>>         warn "Couldn't load Time::HiRes: $@";
>>     }
>>}
> 
> 
> That isn't quite right.  "use" returns nothing at run time, whether it
> succeeded or not.

Use() doesn't return anything, but it *does* die if the module can't be 
found, and the eval() returns false if that happens. So you can put the 
eval() in a conditional block, or check $@ afterwards - it works either way.

> Also, I would use block eval when string eval isn't necessary.  So
> 
> BEGIN {
>     eval { use Time::HiRes qw(time) };
>     warn "Couldn't load module: $@" if $@;
> }

A string eval *is* necessary here because of the different semantics of 
a block vs. a string eval. A string eval turns compile-time errors that 
happen within the evaled string into run-time errors. A block eval won't 
do that; compile-time errors within the block cause the script as a 
whole to die.

Examine the output of this:

     BEGIN {
         unless (eval 'use NoSuchModule' ) {
             warn "My custom error: $@";
         }
     }

This prints "My custom error: Can't locate NoSuchModule.pm in @INC (@INC 
contains: ...) at (eval 1) line 2.", but it's a warning not an error, 
and the program continues.

Compare that to the output from this:

     BEGIN {
         unless (eval {use NoSuchModule}) {
             warn "My custom error: $@";
         }
     }

This prints "Can't locate NoSuchModule.pm in @INC (@INC contains: ...) 
at ./test.pl line 7.". Note the location of the error, and the lack of 
the error printed by warn() - the script as a whole failed to compile, 
and eval() didn't catch the error.

sherm--

-- 
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org


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

Date: Fri, 7 Jan 2005 17:07:59 +0100
From: "Tassilo v. Parseval" <tassilo.von.parseval@rwth-aachen.de>
Subject: Re: checking at runtime if modul is installed
Message-Id: <slrncttcuv.16l.tassilo.von.parseval@localhost.localdomain>

Also sprach Sherm Pendley:

> Anno Siegel wrote:

>> Also, I would use block eval when string eval isn't necessary.  So
>> 
>> BEGIN {
>>     eval { use Time::HiRes qw(time) };
>>     warn "Couldn't load module: $@" if $@;
>> }
>
> A string eval *is* necessary here because of the different semantics of 
> a block vs. a string eval. A string eval turns compile-time errors that 
> happen within the evaled string into run-time errors. A block eval won't 
> do that; compile-time errors within the block cause the script as a 
> whole to die.

This is true. However, this whole issue can be avoided by using
'require'. One standard idiom would be:

    use constant HAVE_MODULE => eval { require Module; 1 } || 0;

    BEGIN {
	warn "Could't load Module: $@" if ! HAVE_MODULE;
    }

'use' happens to be the wrong tool for that.

Tassilo
-- 
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval


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

Date: Fri, 07 Jan 2005 11:18:42 -0500
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: checking at runtime if modul is installed
Message-Id: <i7mdnXR_rOv-K0PcRVn-jQ@adelphia.com>

Tassilo v. Parseval wrote:

> This is true. However, this whole issue can be avoided by using
> 'require'. One standard idiom would be:
> 
>     use constant HAVE_MODULE => eval { require Module; 1 } || 0;

If you do it this way, don't forget to call import() manually - 
require() won't do that for you like use() would:

     use constant HAVE_MODULE => eval {
         require Module;
         Module::import LIST;
         1;
     }

That works, but it's rather wordy, in my opinion, and trouble-prone if 
you forget to call import() - as you did in your example. I'd rather 
stay with use().

sherm--

-- 
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org


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

Date: Fri, 07 Jan 2005 17:11:16 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: checking at runtime if modul is installed
Message-Id: <crmfht$i8l$1@sun3.bham.ac.uk>



Sherm Pendley wrote:

> Anno Siegel wrote:
> 
>> Sherm Pendley  <spamtrap@dot-app.org> wrote in comp.lang.perl.misc:
>>
>>> Wrap it up in an eval() and check for errors. Be sure to put the 
>>> eval() in a BEGIN block so it happens at compile time, like use() 
>>> normally does.
>>>
>>> BEGIN {
>>>     unless (eval "use Time::HiRes qw(time)") {
>>>         warn "Couldn't load Time::HiRes: $@";
>>>     }
>>> }
>>
>>
>>
>> That isn't quite right.  "use" returns nothing at run time, whether it
>> succeeded or not.
> 
> 
> Use() doesn't return anything, but it *does* die if the module can't be 
> found, and the eval() returns false if that happens.

Yes but that is not the only situation in which eval will return false.

 > So you can put the
> eval() in a conditional block, or check $@ afterwards - it works either 
> way.

It may happen to work but the behaviour is undefined so it may happen 
not to work in future.

If you want to use the truth of the return from eval(STRING) as an 
indicator of success it is best to explicitly ensure that it will be 
true on success.

BEGIN {
     unless (eval "use Time::HiRes qw(time); 1") {
         warn "Couldn't load Time::HiRes: $@";
    }
}



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

Date: Fri, 07 Jan 2005 11:30:00 -0500
From: zentara <zentara@highstream.net>
Subject: Re: CRYPT:RC5 problem, can't unencrypt
Message-Id: <05ett0phabfu42vg29ajo33vmn4nd03bgo@4ax.com>

On 6 Jan 2005 07:09:15 -0800, derekg0@gmail.com wrote:

>I'm having a problem with decrypting a password after base64 encoding
>and writing to a file, closing the file, opening the file unencoding it
>and decrypting.  any help with this would be appreciated.  Also, after
>the program is run i'm getting control characters on the next command
>prompt, I'm guessing this has something to do with the problem?
>
>Here is my test program and the output below that:

I had a hard time reading what you were trying to do.
But in general, if on windows binmode your filehandles and
slurp the file as a scalar, and encrypt and decrypt it as one
big scalar.

Also, watch out for the newlines you throw in there, it
made my eyes bleary trying to follow whether you added or chomped,
or what. You may have unintentionally added a newline, so it
won't decrypt to the same value.

Try this script, it should work for you

#!/usr/bin/perl
use Crypt::RC5;

$key = 'e726f4a56b3e4f';
$rc5 = new Crypt::RC5($key, '12' );

open (FH,"< $0");
binmode FH;
while(<FH>){
$file .= $_ }
close FH;
print "$file\n";

$cipher = $rc5->encrypt($file);

$rc5d = new Crypt::RC5($key, '12' );

$plain = $rc5d->decrypt($cipher);

print "$plain\n";



-- 
I'm not really a human, but I play one on earth.
http://zentara.net/japh.html


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

Date: Fri, 07 Jan 2005 13:06:18 GMT
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: Dummy regex question
Message-Id: <ePvDd.26499$rL3.11121@trnddc03>

"JayEs" <not@home.net> wrote in message
news:a9rDd.12024$wi2.5482@newssvr11.news.prodigy.com...
>
> "Scott Bryce" wrote
>
>
> > You are missing the point. The reason that the first few responses
did not
> > solve your problem was that you did not know what the problem
actually
> > was. Therefore your problem description was not accurate.
>
> I liken this to asking how to turn on the light. Say, the main
question is:
> I have a room and it has an overhead fixture. How do I turn it on?
That is a
> very accurate question, with enough information to provide an answer.
That
> answer clearly should be: Find the switch and flip it.

Yeah, but asking "how do I turn on the light" when you actually need to
know "how do I turn on the television" is not an accurate question.

> My point is that a question can lead to another question. In
> this case, the person asked to be helped with switching on the light
(How do
> I split a string on a space -- accurate)

No.  Not accurate.  That's the whole point.  There WAS NO SPACE to split
on.  You did not have a space.  A space was not in your string.  That is
the point everyone's trying to make you understand.  Your string
contained either '&nbsp;' or "\xA0", neither of which is a space.  A
space is ' '.

Paul Lalli



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

Date: Fri, 07 Jan 2005 09:53:04 -0700
From: Scott Bryce <sbryce@scottbryce.com>
Subject: Re: Dummy regex question
Message-Id: <1-Sdnfljm5z6I0PcRVn-1Q@comcast.com>

JayEs wrote:

> I liken this to asking how to turn on the light. Say, the main question is: 
> I have a room and it has an overhead fixture. How do I turn it on? That is a 
> very accurate question, with enough information to provide an answer. That 
> answer clearly should be: Find the switch and flip it.

Your analogy breaks down. You were asking, "how do I flip this switch?" 
You were told how, then complained that it didn't make the light go on.

Your problem wasn't with the switch.

The key to turning the light on was to find out what the problem really was.

I traced it back to the circuit breaker.

It is common for people asking questions on this newsgroup to think they 
have isolated the problem, when the problem is really somewhere else. 
That is why we ask you to post code. Often in the process of trimming 
code, the poster will isolate the problem. If he can't isolate the 
problem, the regulars here probably can, but not without your code.

So you posted your code and the real problem was found. I think that is 
a good thing. You code works now, and next time you will post smarter.



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

Date: Fri, 07 Jan 2005 12:34:32 -0500
From: Digger  <hx_101@hotmail.com>
Subject: Extarcting And Storing a String
Message-Id: <auhtt054r9ddlvjhno0v8bd0agosil9bsl@4ax.com>

I am trying to extract a url from a file and store it, the problem is
I only want the first occurance of that url that meets certain
criteria.

How can I get that single url out of a file and store it to be used
for something else?

Thanks


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

Date: Fri, 07 Jan 2005 12:48:20 -0500
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: Extarcting And Storing a String
Message-Id: <aMWdnY9DJpL4VkPcRVn-jA@adelphia.com>

Digger wrote:

> How can I get that single url out of a file and store it to be used
> for something else?

You left out a critical bit of information: What format is the file in? 
If it's HTML, use HTML::Parser.

sherm--

-- 
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org


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

Date: Fri, 07 Jan 2005 18:57:10 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Extarcting And Storing a String
Message-Id: <3481gaF41kfo5U1@individual.net>

Sherm Pendley wrote:
> Digger wrote:
>> I am trying to extract a url from a file and store it, the problem is
>> I only want the first occurance of that url that meets certain
>> criteria.
>> 
>> How can I get that single url out of a file and store it to be used
>> for something else?
> 
> You left out a critical bit of information: What format is the file in? 
> If it's HTML, use HTML::Parser.

Not necessarily. The OP didn't tell which criteria will be used to 
identify the URL, but if those criteria has nothing to do with the 
positioning of the URL in relation to various HTML elements, 
HTML::Parser won't reasonably be useful for the task, even if the file 
happens to be an HTML page.

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


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

Date: Fri, 07 Jan 2005 12:56:05 -0500
From: Digger  <hx_101@hotmail.com>
Subject: Re: Extarcting And Storing a String
Message-Id: <38jtt01tn5h3kfd1t0d9k844bln8q70srv@4ax.com>

On Fri, 07 Jan 2005 12:48:20 -0500, Sherm Pendley
<spamtrap@dot-app.org> wrote:

>Digger wrote:
>
>> How can I get that single url out of a file and store it to be used
>> for something else?
>
>You left out a critical bit of information: What format is the file in? 
>If it's HTML, use HTML::Parser.
>
>sherm--

Sorry, yes......

It's a flat text log file.....

date : error message: url: other garbage





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

Date: 7 Jan 2005 18:20:33 GMT
From: "mjl69" <mjl69mjl69@myaccmyacc.net>
Subject: Re: Extarcting And Storing a String
Message-Id: <34827hF482vmmU1@individual.net>

Digger wrote:

> I am trying to extract a url from a file and store it, the problem is
> I only want the first occurance of that url that meets certain
> criteria.
> 
> How can I get that single url out of a file and store it to be used
> for something else?
> 
> Thanks

use HTML::LinkExtor;

mjl


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

Date: Fri, 07 Jan 2005 19:40:31 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Extarcting And Storing a String
Message-Id: <34841oF47l7seU1@individual.net>

Digger wrote:
> Sherm Pendley wrote:
>> Digger wrote:
>>> How can I get that single url out of a file and store it to be
>>> used for something else?
>> 
>> You left out a critical bit of information: What format is the file
>> in? If it's HTML, use HTML::Parser.
> 
> Sorry, yes......
> 
> It's a flat text log file.....
> 
> date : error message: url: other garbage

What part of the task do you have difficulties with? Show us what you
have tried so far, and somebody may be able to point you in the right
direction.

A hint: check out the split() function.

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


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

Date: Sun, 02 Jan 2005 04:34:31 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: How to write a program to ...
Message-Id: <33p8bqF42c8m3U1@individual.net>

gjena1 wrote:
> I'm new to perl.  Would someone please give me an example
> of a perl program to read from a fileA which has several
> datas, and search fileA for string1 and change it to string2
> in fileA.  string1 is located in various places in each
> line.  Find the the string1 that is located 10 spaces from
> the beginning of each line in fileA.

If you want somebody to write a script for you, hire a consultant.

If you want to learn how to program in Perl, read a beginners book 
and/or tutorial, do some exercises, etc. This is a good starting-point:

     http://learn.perl.org/

Good luck!

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


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

Date: Fri, 07 Jan 2005 18:29:31 GMT
From: whansen_at_corporate-image_dot_com@us.com
Subject: IPC looking for simple/best way to communicate
Message-Id: <41ded263.3951491@news.sonic.net>

I'm trying to find the best way to do something. I've got 50 processes
(may have 200 soon) that need to broadcast simple messages to each of
them. I tried doing this with sockets, but although I was able to get
them to read a socket without halting succesfully I found that when
one process reads a socket it removes the message from the socket and
the other processes don't see it. My current solution works using
IPC::Shareable, but is slow and hogs memory as well as the CPU.
Shareable lets you set a variablle that multiple programs can read and
write to. In my case they read and write to the list that they all run
off.

Basicly each process is iterating over a list (array) and every so
often a process gets a result that means that item no longer needs to
be ran, so it should remove it from it's list and notify the other
processes so that they can remove it from theirs as well. Whith
IPC::Shareable it works nicely as when one process removes the item,
all the others have it removed also, but it appers that the shareable
module is slowing things down considerablly (CPU usage doubled).

If someone could point me in the right direction, that would be great.
I have an idea for speeding up shareable a little, but it's still not
going to be fast.


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

Date: Sat, 01 Jan 2005 12:59:21 GMT
From: goqrnaoe@sk.com
Subject: LOL..... I Just Found A Gwenyth Paltrow Sex Video Online. Take A Look....... 3NE6
Message-Id: <131399937205136896@sk.com>

Hi
 
LOL.... I cant believe she did this... Its not bad either!!
 
I have put it on my site here    http://www.sonicboards.com/sk.htm         Take a look :)
 
 
----------------------------------------------------------------------------


---

Mudac pegiveg wasocel patara ked topidahap nesodis cewatesedos babitibino fonodocalah mi .



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

Date: Sun, 02 Jan 2005 04:29:08 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: multiple packages/classes in one file
Message-Id: <33p81mF405jmbU1@individual.net>

ioneabu@yahoo.com wrote:
> I was trying to put together a simple example of a couple of classes in
> a single file in order to experiment with basic perl OO concepts.  My
> example did not work, so I tried a more basic example right out of the
> Perl Cookbook:
> 
> #!/usr/bin/perl
> use strict;
> use warnings;
> 
> package Alpha;
> $name = "first";

The Cookbook or not, since strictures are enabled, you need to either 
declare variables or use their fully qualified names:

     our $name = "first";

> package Omega;
> $name = "last";

     our $name = "last";

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


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

Date: Fri, 07 Jan 2005 03:26:08 -0800
From: Joe Smith <joe@inwap.com>
Subject: Re: Need help sorting fixed length records
Message-Id: <TpWdnWCLMM5J7EPcRVn-gg@comcast.com>

lbeckm3@hotmail.com wrote:
> Thanks Uri.  The unix sort command did work, but I didn't find the
> solution in any of the man pages (yes I did read them!)

The Linux man page for sort does a lousy job at explaining that.
I learned it from the BSD/SunOS man pages.  The old syntax is

   sort +0.87 -0.89 file   # Start at column 88, stop before column 90.

The -k option, which counts from 1 instead of from 0, is better.
	-Joe


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

Date: Fri, 07 Jan 2005 14:21:14 +0000
From: Helgi Briem <HelgiBriem_1@hotmail.com>
Subject: Re: PHP in Perl
Message-Id: <ml6tt0ptcbaap9jd3qil295bfgqgej04ho@4ax.com>

On Wed, 05 Jan 2005 18:47:03 -0500, Dave F <dfischer348@comcast.net>
wrote:

>Is it possible to embed some PHP script in an HTML stream being
>returned from a Perl script?  I know it sounds wacky, but I'd like
>to use chart library that uses PHP's support for the GD library.
>PHP works on the system (I know .php files in the html
>folder are served fine, so PHP is running.)

???  Why not simply use GD directly from Perl?  
Far easier, I would have thought.

--
Helgi Briem  hbriem AT simnet DOT is

A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?


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

Date: 7 Jan 2005 07:19:26 -0800
From: "botfood" <botfood@yahoo.com>
Subject: Re: Protection of tied files
Message-Id: <1105111166.754624.241230@f14g2000cwb.googlegroups.com>

are you asking about flock() considerations to prevent other scripts
from stepping on a tied file, or a permission issue with keeping
network users from touching a file?



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

Date: 7 Jan 2005 10:03:06 -0800
From: "John" <jgdoke@ra.rockwell.com>
Subject: Regex help, need to find all "<script src" calls but not if the call has menu.js in it.
Message-Id: <1105120986.396536.60860@z14g2000cwz.googlegroups.com>

I have been reading but cannot find a way to find all strings  that
start with <script src  but disreguard the ones that have menu.js as
the call.

Examples:

<script src=script.js></script>  (keep)
<script src=/widjets/footer.js></script>  (keep)
<script src=/thingys/left_nav.js></script> (keep)
<script src=menu.js></script>  (throw away)



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

Date: Fri, 07 Jan 2005 13:06:07 -0500
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: Regex help, need to find all "<script src" calls but not if the call has menu.js in it.
Message-Id: <dtCdnay6RNkNUkPcRVn-iw@adelphia.com>

John wrote:

> I have been reading but cannot find a way to find all strings  that
> start with <script src  but disreguard the ones that have menu.js as
> the call.

You're using the wrong tool for the job. Don't use regexes to parse 
HTML, use the module designed for that: HTML::Parser.

sherm--

-- 
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org


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

Date: Fri, 07 Jan 2005 19:26:04 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Regex help, need to find all "<script src" calls but not if the call has menu.js in it.
Message-Id: <34836kF45306vU1@individual.net>

John wrote:
> I have been reading but cannot find a way to find all strings  that
> start with <script src  but disreguard the ones that have menu.js as
> the call.
> 
> Examples:
> 
> <script src=script.js></script>  (keep)
> <script src=/widjets/footer.js></script>  (keep)
> <script src=/thingys/left_nav.js></script> (keep)
> <script src=menu.js></script>  (throw away)

     grep !/menu\.js/, $string =~ /<script\s+src.+?<\/script\s*>/gis;

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


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

Date: Fri, 7 Jan 2005 13:39:29 +0100
From: Sven Bachmann <bachmanns@gmx.de>
Subject: Re: sharing fileglobs
Message-Id: <slrnctt0o2.hec.bachmanns@box.brookman.home>

On 2005-01-05, Sven Bachmann <bachmanns@gmx.de> wrote:
> I'd like to use perl threads but I encountered a problem when I want to
> share fileglobs stored in a hash.
> Google only showed me, that sharing fileglobs isn't possible yet.
>
> Maybe I don't need fileglobs. So I ask you if there is another
> possibility to share open sockets (stored in a hash) with threads?

Ingo Menger answered me in de.comp.lang.perl.misc. The solution is to
share not the glob but instead the fileno. To assign it again use
fdopen.

Bye
  Sven



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

Date: Fri, 07 Jan 2005 03:14:55 -0800
From: Joe Smith <joe@inwap.com>
Subject: Re: Similair command like 'ls' in perl
Message-Id: <q_GdncxFcYKv8kPcRVn-sw@comcast.com>

Glenn Jackman wrote:
> At 2005-01-05 03:03PM, Joe Smith <joe@inwap.com> wrote:
> 
>>    perl -e '%c=map {-M $_,$_} <* .*>; printf "%8.2f %s\n",$_,$c{$_} for sort {$a<=>$b} keys %c'
> 
> That may not work as you expect.
> Filenames are unique in a directory, but last modified times aren't.  
> Your %c hash may be missing files.

Yes, I know.  A proper solution would be to use something like a
Schwartzian Transform.
	-Joe




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

Date: 7 Jan 2005 13:01:49 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Similair command like 'ls' in perl
Message-Id: <crm17t$bek$1@mamenchi.zrz.TU-Berlin.DE>

Joe Smith  <joe@inwap.com> wrote in comp.lang.perl.misc:
> Glenn Jackman wrote:
> > At 2005-01-05 03:03PM, Joe Smith <joe@inwap.com> wrote:
> > 
> >>    perl -e '%c=map {-M $_,$_} <* .*>; printf "%8.2f %s\n",$_,$c{$_}
> for sort {$a<=>$b} keys %c'
> > 
> > That may not work as you expect.
> > Filenames are unique in a directory, but last modified times aren't.  
> > Your %c hash may be missing files.
> 
> Yes, I know.  A proper solution would be to use something like a
> Schwartzian Transform.

You can use a hash in "something like" a Schwartzian Transform, just
the other way around:

    my %c = map { $_ => -M $_ } <* .*>;
    printf "%8.2f %s\n", $c{ $_}, $_ for
        sort { $c{ $a} <=> $c{ $b} } keys %c;

Like the Schwartzian Transform, it calculates the sort key only once for
each list element.  In this case it wouldn't have any advantages over
the standard Schwartzian (in fact it would be a little slower since
hashes are slower than arrays).

When there are duplicates in the list to be sorted, it *can* have an
advantage when the hash is built like this:

    my %c;
    @c{ @array} = ();
    $c{ $_} = sort_key( $_) for keys $c;
    # etc...

This way, the sort key is only calculated once for every unique element
in the list.

Anno


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

Date: Fri, 07 Jan 2005 12:11:11 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: Skip C like comments
Message-Id: <crltv9$a0h$1@sun3.bham.ac.uk>



robertday5@gmail.com wrote:
> I have written a small program to search all files in a directory for a
> particular string. I want to add the feature that it should not search
> for the string inside comments. I was able to skip single line comments
> but I need help in skipping multiple line C style comments /* blah
> blah...*/

See FAQ "How do I use a regular expression to strip C style com­
ments from a file?"

> Currently while looking for the search string I do a line by line
> search.

That will make life a lot harder since you will have to track the state, 
inside/not inside quotes, inside/not inside comments at each line/



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

Date: Fri, 7 Jan 2005 13:06:00 +0000
From: Stephane CHAZELAS <this.address@is.invalid>
Subject: Re: Skip C like comments
Message-Id: <slrnctt29o.4fe.stephane.chazelas@spam.is.invalid>

2005-01-07, 12:11(+00), Brian McCauley:
>
>
> robertday5@gmail.com wrote:
>> I have written a small program to search all files in a directory for a
>> particular string. I want to add the feature that it should not search
>> for the string inside comments. I was able to skip single line comments
>> but I need help in skipping multiple line C style comments /* blah
>> blah...*/
>
> See FAQ "How do I use a regular expression to strip C style com­
> ments from a file?"
[...]

Note that the solution provided:

$/ = undef;
$_ = <>;

s#/\*[^*]*\*+([^/*][^*]*\*+)*/|([^/"']*("[^"\\]*(\\[\d\D][^"\\]*)*"[^/"']*|'[^'\\]*(\\[\d\D][^'\\]*)*'[^/"']*|/+[^*/][^/"']*)*)#$2#g;


is unnecessarily complicated. One can make use of non-greedy
perl operators and the special way alternation works in perl
(left to right instead of longest as in ERE).

And it fails for inputs like:

foo/* comment */bar (which cpp turns into "foo bar", not
"foobar" as with that perl solution).

 s{
     /\*.*?\*/
   | //[^\n]*
   | (
        "(?:\\.|.)*?"
      | '(?:\\.)?.*?'
      | \?\?'
      | .[^'"/]*
     )
  }{if ($1 eq ""){" "}else{$1}}exsg

should be enough and work as well on valid C code.

(??' is a trigraph).

-- 
Stephane


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

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


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