[19563] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1758 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Sep 17 00:06:54 2001

Date: Sun, 16 Sep 2001 21:05:07 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <1000699507-v10-i1758@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Sun, 16 Sep 2001     Volume: 10 Number: 1758

Today's topics:
    Re: ActivePerl in a Win32 environment; how do I launch  <bwalton@rochester.rr.com>
        ActivePerl in a Win32 environment; how do I launch a we (codeslayer)
    Re: ActivePerl in a Win32 environment; how do I launch  <bart.lateur@skynet.be>
        Checking for errors from sendmail <stumo@bigfoot.com>
    Re: Checking for errors from sendmail <clintp@geeksalad.org>
        debug CGI script (Joe Chung)
    Re: debug CGI script <bwalton@rochester.rr.com>
    Re: debug CGI script (Randal L. Schwartz)
    Re: debug CGI script <bwalton@rochester.rr.com>
        detecting CDROM insertion? <e@nospam:[arix.com]>
    Re: Difference between .pl, .cgi, and .pm File Extensio (Damian James)
    Re: Difference between .pl, .cgi, and .pm File Extensio (Damian James)
    Re: Discontinue the loop <bart.lateur@skynet.be>
    Re: Discontinue the loop <rob_13@excite.com>
    Re: Discontinue the loop (Martien Verbruggen)
    Re: Discontinue the loop <davidhilseenews@yahoo.com>
    Re: Discontinue the loop <rob_13@excite.com>
    Re: getting characters <jks@spam.me.not.akula.com>
    Re: HELP!  ActivePerl for Win32:  How do I compare two  <bwalton@rochester.rr.com>
    Re: irc <james@zephyr.org.uk>
        Javadoc alike <sun_tong@users.sourceforge.net>
        Looking for Perl programers in Toronto <wael@hallaj.com>
    Re: Multithreading Information <dan@tuatha.sidhe.org>
    Re: Perl (slurping) is TOO much fun <wyzelli@yahoo.com>
    Re: Perl (slurping) is TOO much fun <uri@sysarch.com>
    Re: Similar file finder <iltzu@sci.invalid>
    Re: Similar file finder <bart.lateur@skynet.be>
    Re: Tan Without The Sun <uri@sysarch.com>
        upgrading berkeley DB 1.85 to 3.3? <m.grimshaw@salford.ac.uk>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Mon, 17 Sep 2001 00:49:20 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: ActivePerl in a Win32 environment; how do I launch a web page in  Microsoft Internet Explorer using a perl script?
Message-Id: <3BA548B6.27EA0E12@rochester.rr.com>

codeslayer wrote:
> 
> I am using ActivePerl in a Win32 environment; how do I launch a web
> page in Microsoft Internet Explorer using a perl script?
> 
 ...
> Is this the right forum?

No, it's not the right forum, but why don't you try:

    start whatever.html

at a Windoze command prompt.  That should launch your default browser
with the web page in file whatever.html showing.  Then in Perl, you can
just put that inside a system call.  Note that the system call will
return immediately.

If you want to load a page from the web instead of from a file, use a
file anyway, but insert a "Refresh" meta-tag which redirects the browser
to the destination you want (if you have questions about that, please
don't bother this newsgroup with them, as it has nothing to do with
Perl).  Of course, you could write that file from Perl, so you could
compute the URL. And there might be a better way -- to find out, ask in
a browser newsgroup.
-- 
Bob Walton


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

Date: 16 Sep 2001 15:34:22 -0700
From: weedmonster_99@yahoo.com (codeslayer)
Subject: ActivePerl in a Win32 environment; how do I launch a web page in Microsoft Internet Explorer using a perl script?
Message-Id: <4b459565.0109161434.4e03f144@posting.google.com>

I am using ActivePerl in a Win32 environment; how do I launch a web
page in Microsoft Internet Explorer using a perl script?

Here is what I have tried:

EX:  I want to open google.com in internet explorer in a perl script:

# Purpose:	Testing to see if I can launch
#		a web page in internet explorer.
#


$hold = ();
$explorer = "iexplore.exe";
$explorer2 = "iexploere";
$ans = ();

print "This is a test to launch internet explorer\n\n";

print "Press any key to begin.\n";
$hold = <STDIN>;

# This should launch explorer:
#C:\Program Files\Internet Explorer

#file:///c:/program files/internet explorer/iexplore.exe;


system("$explorer");

print "Did internet explorer launch successfully";
$ans = <STDIN>;

system("$explorer2");

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

Can anyone help.  Is this the right forum?

Thank you for any replies!!!


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

Date: Mon, 17 Sep 2001 00:23:45 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: ActivePerl in a Win32 environment; how do I launch a web page in Microsoft Internet Explorer using a perl script?
Message-Id: <rhgaqtc14tf852ated8jeajom5tm11sp37@4ax.com>

codeslayer wrote:

>I am using ActivePerl in a Win32 environment; how do I launch a web
>page in Microsoft Internet Explorer using a perl script?

>EX:  I want to open google.com in internet explorer in a perl script:

	system('start', 'http://www.google.com');

-- 
	Bart.


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

Date: Mon, 17 Sep 2001 02:12:50 +0100
From: "Stuart Moore" <stumo@bigfoot.com>
Subject: Checking for errors from sendmail
Message-Id: <j6cp7.20754$mj6.3377520@news6-win.server.ntlworld.com>

At the moment, I am using sendmail thus:

sub send_email{
 my ($from,$to,$subj,$msg)=@_;
 my $sendmail = "|$PATH_TO_SENDMAIL -t";
 open MAIL, $sendmail || die ("Could not open Sendmail: $!");
 print MAIL "To: $to\n";
 print MAIL "From: $from\n";
 print MAIL "Subject: $subj\n\n";
 print MAIL $msg;
 close MAIL;
}

as part of a cgi-script. My main problem is at the moment any error messages
etc. are written to STDOUT which means they muck up my web output. How can I
dispose of or ideally check for error messages? I get the vague idea that open2
or open3 may be involved - I've read the documentation but I still can't get it
working as I want.

(Alternatively if anyone has a module that'll handle this for me I'd be very
grateful - Mail::Mailer seems the closest I could find but doesn't say how error
messages are handled)

Many thanks, and apologies if I missed something obvious

Stuart




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

Date: Mon, 17 Sep 2001 01:24:19 GMT
From: "Clinton A. Pierce" <clintp@geeksalad.org>
Subject: Re: Checking for errors from sendmail
Message-Id: <3BA550AE.3050303@geeksalad.org>

Stuart Moore wrote:
> At the moment, I am using sendmail thus:
> 
> sub send_email{
>  my ($from,$to,$subj,$msg)=@_;
>  my $sendmail = "|$PATH_TO_SENDMAIL -t";
>  open MAIL, $sendmail || die ("Could not open Sendmail: $!");
>  print MAIL "To: $to\n";
>  print MAIL "From: $from\n";
>  print MAIL "Subject: $subj\n\n";
>  print MAIL $msg;
>  close MAIL;
> }
> 
> as part of a cgi-script. My main problem is at the moment any error messages
> etc. are written to STDOUT which means they muck up my web output. How can I
> dispose of or ideally check for error messages? I get the vague idea that open2
> or open3 may be involved - I've read the documentation but I still can't get it
> working as I want.

The exit status of sendmail will be returned by close().  (As part of 
reaping the now-dead child process.)  If you want to save STDERR or 
STDOUT of sendmail, by far the easiest way is to squirrel it away in a 
file and read it back later:

    # Something like this...
    open(MAIL, "| sendmail 1>&2 2>/tmp/sm$$") || die;

    close(MAIL);
    # Later..
    open(LOG, "/tmp/sm$$") || die;

    # And get rid of it!
    unlink "/tmp/sm$$" or warn "Can't remove logfile";



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

Date: Mon, 17 Sep 2001 00:34:32 GMT
From: m_010@yahoo.com (Joe Chung)
Subject: debug CGI script
Message-Id: <3ba544ff.2086059@enews.newsguy.com>

I am using the GUI perl debugger to debug perl script: 

but if I invoke a CGI script using the debugger:
perl -d:ptkdb hello_world.pl

the CGI script get invoked won't have access to server environment
variables, like:
$count_page = "$ENV{'DOCUMENT_URI'}";

the CGI program will not run correctly if it needs to access server
environment variables and invoke by perl debugger. Any way I can
attach to a running CGI process when HTTP request comes in to invoke
CGI?

thanks.


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

Date: Mon, 17 Sep 2001 01:13:10 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: debug CGI script
Message-Id: <3BA54E4B.4C812EDC@rochester.rr.com>

Joe Chung wrote:
> 
> I am using the GUI perl debugger to debug perl script:
> 
> but if I invoke a CGI script using the debugger:
> perl -d:ptkdb hello_world.pl
> 
> the CGI script get invoked won't have access to server environment
> variables, like:
> $count_page = "$ENV{'DOCUMENT_URI'}";
> 
> the CGI program will not run correctly if it needs to access server
> environment variables and invoke by perl debugger. Any way I can
> attach to a running CGI process when HTTP request comes in to invoke
> CGI?
 ...
Well, you can easily add something like:

    %ENV{REQUEST_METHOD}='GET';
    %ENV{...
    ....

to the start of your program to set up the exact environment you want
for your debug run.  If you want to check out POST requests, you can
redirect a file to STDIN when you fire up Perl.  Or, using the debugger,
you can type in the environment variables you want.  Or put those
commands in another file and require or do it from the debugger's
command prompt.  Etc.  Debugging a program "live" from the web server
doesn't strike me as something you should be doing.  Make sure your
programs work first, then try running them as a CGI script.
-- 
Bob Walton


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

Date: 16 Sep 2001 19:08:04 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: debug CGI script
Message-Id: <m166aio9h7.fsf@halfdome.holdit.com>

>>>>> "Bob" == Bob Walton <bwalton@rochester.rr.com> writes:

Bob> Well, you can easily add something like:

Bob>     %ENV{REQUEST_METHOD}='GET';
Bob>     %ENV{...
Bob>     ....

Not if you want legal syntax. :)

print "Just another Perl hacker,"

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!


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

Date: Mon, 17 Sep 2001 03:26:13 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: debug CGI script
Message-Id: <3BA56D77.E1DC84E0@rochester.rr.com>

"Randal L. Schwartz" wrote:
> 
> >>>>> "Bob" == Bob Walton <bwalton@rochester.rr.com> writes:
> 
> Bob> Well, you can easily add something like:
> 
> Bob>     %ENV{REQUEST_METHOD}='GET';
> Bob>     %ENV{...
> Bob>     ....
> 
> Not if you want legal syntax. :)

Oops, sorry, $ENV{...}=...;

 ...
> Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 ...
-- 
Bob Walton


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

Date: Mon, 17 Sep 2001 02:50:46 GMT
From: "ekkis" <e@nospam:[arix.com]>
Subject: detecting CDROM insertion?
Message-Id: <aydp7.3218$G95.179399710@newssvr14.news.prodigy.com>

Apologies if this message double posts... my ISP's been having a lot of
problems with the usenet so I'm trying different servers...

Hi.  I have the need of runing a script of my choice whenever a CD is
inserted into my drive.  I am exclusively interested in audio CDs.  what I
did was write a process that looks like this:

until ($done) {
    sleep(10), next unless open(CDROM, "/dev/cdrom");

    # do my thing here

    close(CDROM);
    }

this works fairly well except that I discovered failed attempts leave a
trace in /var/log/messages like this:

Sep  9 04:02:06 grendel kernel: cdrom: open failed.

and, of course, I get TONS of these...  can anyone suggest what might be a
better solution? or any way to turn the errors off?

1k tia - erick







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

Date: 16 Sep 2001 23:00:45 GMT
From: damian@qimr.edu.au (Damian James)
Subject: Re: Difference between .pl, .cgi, and .pm File Extensions.
Message-Id: <slrn9qabkt.i3r.damian@puma.qimr.edu.au>

Trewth Seeker chose 14 Sep 2001 17:29:47 -0700 to say this:
>damian@qimr.edu.au (Damian James) wrote in message news:<slrn9pnqsr.o41.damian@puma.qimr.edu.au>...
>> ...
>> I suggest you refrain from making blanket statements involving such
>> generalisations until you have these details cleared up at least.

Oh well, I'd suggest this is still good advice for everyone most of the
time ;-).

>You might try actually reading the thread, wherein I wrote
>
>  The issue here is the meaning of "server"
>  in various contexts.  I think you need to do a lot more reading.
>
>"server" means "HTTP server" only to ignoramuses.  Do you suppose
>a machine must have "perl installed" to run, say, an X server?
>Or a time-sharing server?  A PC is, as I said,
>"a server of a kind" -- it serves up execution of programs.

I usually work with the term as describing a machine providing
network services of some kind or another. The peecee in question could
still be a 'server' depending on what one feels is happening on tcp ports
137 and 139, but I don't see how that is relevent to the issue. Which is
why I didn't say you were wrong as such, merely that you were confusing the
issue.

>The conclusion that what I have written suggests the "implicit
>assumption" you state is, frankly, ridiculous.  The original query
>resulted from confused thinking, and you replicate it.

Okay, fair enough -- since you hadn't cleared up the OP's point of
confusion, I assumed you were doing exactly this. My bad.

>The instruction "install .pm's onto the server" does not, as he mistakenly
>thought, divide files into those that are installed onto servers
>and those that are not, but rather merely refers to the role
>of the machine being installed onto.

Indeed, and you needed to point out that the role of the machine in
question was not relevent to whether the file was .pl, .pm or
 .new_extension_pulled_out_of_the_developers_back_orifice. Insisting that
every computer is a 'server of a kind' does not clarify the issue.

>I'd point you to the
>philosophical literature of ontology to help clarify your thinking
>about what "is", if I thought it would do any good -- "dude".

BTDTGTTS. Ontology is seldom any good at making things clearer. I'd prefer
to address such issues from an epistemological point of view, which would
suggest that the important point with regards to whether or not a machine
is a 'server' is how the terms are chosen and used: by convention. I suggest
that no ammount of ontological navel gazing will affect the outcome of such
an inquriy. 

Furrfu, can't you read Dasein on da wall? :-).

Cheers,
Damian
-- 
@:=grep!(m!$/|#!..$|),split//,<DATA>;@;=0..$#:;while($:=@;){$;=rand
$:--,@;[$;,$:]=@;[$:,$;]while$:;push@|,shift@;if$;[0]==@|;select$,,
$,,$,,1/80;print qq x\bxx((@;+@|)*$|++),@:[@|,@;],!@;&&$/}  __END__
Just another Perl Hacker, and *ALSO* ... in charge of the sheep dip


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

Date: 17 Sep 2001 03:36:02 GMT
From: damian@qimr.edu.au (Damian James)
Subject: Re: Difference between .pl, .cgi, and .pm File Extensions.
Message-Id: <slrn9qarp1.56r.damian@puma.qimr.edu.au>

Trewth Seeker chose 14 Sep 2001 17:29:47 -0700 to say this:
>damian@qimr.edu.au (Damian James) wrote in message news:<slrn9pnqsr.o41.damian@puma.qimr.edu.au>...
>> ...
>> I suggest you refrain from making blanket statements involving such
>> generalisations until you have these details cleared up at least.

Oh well, I'd suggest this is still good advice for everyone most of the
time ;-).

>You might try actually reading the thread, wherein I wrote
>
>  The issue here is the meaning of "server"
>  in various contexts.  I think you need to do a lot more reading.
>
>"server" means "HTTP server" only to ignoramuses.  Do you suppose
>a machine must have "perl installed" to run, say, an X server?
>Or a time-sharing server?  A PC is, as I said,
>"a server of a kind" -- it serves up execution of programs.

I usually work with the term as describing a machine providing
network services of some kind or another. The peecee in question could
still be a 'server' depending on what one feels is happening on tcp ports
135 and 139, but I don't see how that is relevent to the issue. Which is
why I didn't say you were wrong as such, merely that you were confusing the
issue.

>The conclusion that what I have written suggests the "implicit
>assumption" you state is, frankly, ridiculous.  The original query
>resulted from confused thinking, and you replicate it.

Okay, fair enough -- since you hadn't cleared up the OP's point of
confusion, I assumed you were doing exactly this. My bad.

>The instruction "install .pm's onto the server" does not, as he mistakenly
>thought, divide files into those that are installed onto servers
>and those that are not, but rather merely refers to the role
>of the machine being installed onto.

Indeed, and you needed to point out that the role of the machine in
question was not relevent to whether the file was .pl, .pm or
 .new_extension_pulled_out_of_the_developers_back_orifice. Insisting that
every computer is a 'server of a kind' does not clarify the issue.

>I'd point you to the
>philosophical literature of ontology to help clarify your thinking
>about what "is", if I thought it would do any good -- "dude".

BTDTGTTS. Ontology is seldom any good at making things clearer. I'd prefer
to address such issues from an epistemological point of view, which would
suggest that the important point with regards to whether or not a machine
is a 'server' is how the terms are chosen and used: by convention. I suggest
that no ammount of ontological navel gazing will affect the outcome of such
an inquriy. 

Furrfu, can't you read Dasein on da wall? :-).

Cheers,
Damian
-- 
@:=grep!(m!$/|#!..$|),split//,<DATA>;@;=0..$#:;while($:=@;){$;=rand
$:--,@;[$;,$:]=@;[$:,$;]while$:;push@|,shift@;if$;[0]==@|;select$,,
$,,$,,1/80;print qq x\bxx((@;+@|)*$|++),@:[@|,@;],!@;&&$/}  __END__
Just another Perl Hacker, and *ALSO* ... in charge of the sheep dip


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

Date: Mon, 17 Sep 2001 00:13:01 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Discontinue the loop
Message-Id: <sufaqt8gavi20f3j2ug2i02ah8rjguv18u@4ax.com>

Bob Walton wrote:

>> > # I want to ignore the first element in @lines
>> 
>> Could do this:
>> 
>> $ig = 0;
>> foreach $line (@lines) {
>>   next if $ig == 0;
>>   $ig++;
>> .....
>> }
>
>Surely you mean:
>
>$ig = 0;
>foreach $line (@lines) {
>  $ig++;
>  next if $ig == 1;
>  .....
>}

While we're at it...

	my $ig;
	foreach $line (@lines) {
	  $ig++ or next;
	  .....
 	}

-- 
	Bart.


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

Date: Mon, 17 Sep 2001 00:10:15 GMT
From: "Rob - Rock13.com" <rob_13@excite.com>
Subject: Re: Discontinue the loop
Message-Id: <Xns911ECD250EB1Erock13com@64.8.1.226>

Bob Walton <news:3BA51959.B540A5B4@rochester.rr.com>:

Hey, Bob you need to fix your newsreader. You sent me an email.

> "Rob - Rock13.com" wrote:
>> 
>> uma shanker
>> <news:b4a4a838.0109161156.33c5171c@posting.google.com>:
>> 
>> > what are the possible ways to come out of this loop. I
>> > searched the docs, but found no special info.
>> >
>> > # I want to ignore the first element in @lines
>> 
>> Could do this:
>> 
>> $ig = 0;
>> foreach $line (@lines) {
>>   next if $ig == 0; $ig++; .....
>> }
> 
> Surely you mean:
> 
> $ig = 0;
> foreach $line (@lines) {
>   $ig++;
>   next if $ig == 1;
>   .....
> }

Same thing. If you want to ignore the first element of @array you 
'next' the first iteration.

-- 
Rob - http://rock13.com/
Web Stuff: http://rock13.com/webhelp/


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

Date: Mon, 17 Sep 2001 11:28:36 +1000
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: Discontinue the loop
Message-Id: <slrn9qake4.jr6.mgjv@martien.heliotrope.home>

On Mon, 17 Sep 2001 00:10:15 GMT,
	Rob - Rock13.com <rob_13@excite.com> wrote:
> Bob Walton <news:3BA51959.B540A5B4@rochester.rr.com>:
> 
>> "Rob - Rock13.com" wrote:
>>> 
>>> $ig = 0;
>>> foreach $line (@lines) {
>>>   next if $ig == 0; $ig++; .....
>>> }
>> 
>> Surely you mean:
>> 
>> $ig = 0;
>> foreach $line (@lines) {
>>   $ig++;
>>   next if $ig == 1;
>>   .....
>> }
> 
> Same thing. If you want to ignore the first element of @array you 
> 'next' the first iteration.

Not entirely the same thing. Think about what value $ig has on the
second iteration. And on the third. And on all subsequent iterations.

Phrased differently: When does $ig actually get incremented in your
code?

Martien
-- 
Martien Verbruggen              | 
Interactive Media Division      | life ain't fair, but the root
Commercial Dynamics Pty. Ltd.   | password helps. -- BOFH
NSW, Australia                  | 


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

Date: Mon, 17 Sep 2001 01:38:09 GMT
From: "David Hilsee" <davidhilseenews@yahoo.com>
Subject: Re: Discontinue the loop
Message-Id: <5ucp7.22692$gU.7016634@news1.rdc1.md.home.com>


"Rob - Rock13.com" <rob_13@excite.com> wrote in message
news:Xns911ECD250EB1Erock13com@64.8.1.226...
> Bob Walton <news:3BA51959.B540A5B4@rochester.rr.com>:
>
> Hey, Bob you need to fix your newsreader. You sent me an email.
>
> > "Rob - Rock13.com" wrote:
> >>
> >> uma shanker
> >> <news:b4a4a838.0109161156.33c5171c@posting.google.com>:
> >>
> >> > what are the possible ways to come out of this loop. I
> >> > searched the docs, but found no special info.
> >> >
> >> > # I want to ignore the first element in @lines
> >>
> >> Could do this:
> >>
> >> $ig = 0;
> >> foreach $line (@lines) {
> >>   next if $ig == 0; $ig++; .....
> >> }
> >
> > Surely you mean:
> >
> > $ig = 0;
> > foreach $line (@lines) {
> >   $ig++;
> >   next if $ig == 1;
> >   .....
> > }
>
> Same thing. If you want to ignore the first element of @array you
> 'next' the first iteration.
>
> --
> Rob - http://rock13.com/
> Web Stuff: http://rock13.com/webhelp/

I think Bob's point was that what you wrote is not the same thing.

--
David Hilsee




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

Date: Mon, 17 Sep 2001 03:04:14 GMT
From: "Rob - Rock13.com" <rob_13@excite.com>
Subject: Re: Discontinue the loop
Message-Id: <Xns911EEAA0BB710rock13com@64.8.1.226>

Martien Verbruggen
<news:slrn9qake4.jr6.mgjv@martien.heliotrope.home>: 

> Rob - Rock13.com wrote:
>> Bob Walton <news:3BA51959.B540A5B4@rochester.rr.com>:
>>> "Rob - Rock13.com" wrote:
>>>> 
>>>> $ig = 0;
>>>> foreach $line (@lines) {
>>>>   next if $ig == 0; $ig++; ..... }
>>> 
>>> Surely you mean:
>>> 
>>> $ig = 0;
>>> foreach $line (@lines) { $ig++;
>>>   next if $ig == 1; ..... }
>> 
>> Same thing.

> Not entirely the same thing. Phrased differently: When does $ig
> actually get incremented in your code?

Doh! Thanks, for you kindness--that was rather silly mistake on my 
part.

-- 
Rob - http://rock13.com/
Web Stuff: http://rock13.com/webhelp/


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

Date: Sun, 16 Sep 2001 22:42:30 -0000
From: Joseph Shraibman <jks@spam.me.not.akula.com>
Subject: Re: getting characters
Message-Id: <tqaamm5p76q71a@corp.supernews.com>

"Jürgen Exner" <jurgenex@hotmail.com> wrote:
> "Joseph Shraibman" <jks@spam.me.not.akula.com> wrote in message
> news:tpqed92j06lp9b@corp.supernews.com...
>> I have a script that reads some text and converts it into xml.  The
>> problem is that characters > 128 sometimes don't parse, so I want to
>> convert them into &#<num>; sequences.  How can I get each individual
>> character and treat it as a number?  I can get individual strings of 1
>> character each but I don't know how to treat them as numbers.

> Are you looking for "ord"?

Thanks.  I knew it had to be something obvious, but I couldn't find it.


-- 
--
TuPari
Joseph Shraibman
jks(at)iname.com


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

Date: Sun, 16 Sep 2001 22:08:51 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: HELP!  ActivePerl for Win32:  How do I compare two text files and  output/print the differences only?
Message-Id: <3BA52323.A6C5C1DD@rochester.rr.com>

codeslayer wrote:
> 
> HELP!  ActivePerl for Win32:  How do I compare two text files and
> output/print the differences only?
> ==============================================================================
> 
> After searching many posts, I have discovered that this is similar to
> some queries out there, and thus, I hesitated to write this.  However,
> there are major differences which require me to post this.
> 
> Firstly,  I simply want to take two (2) text files (or html, etc.),
> compare their contents and print differences to a difference log file.
>  I am using Active Perl ActivePerl on a Win32 (specifically WindowsME)
> system, not UNIX.
> 
> Second,  the script offerings I have found will give a return code
> only (not print the difference).   Here are some things I have tried
> or read about already:
> 
> 1)      diff
> 2)      testcmp
> 3)      File::Compare
> 
> 4)      Algorithm::Diff
> 
> 5)      Here is some code I tried to implement which I found
>         in another post.   It didn't work.   I added the definitions
>         of $file1 and $file2; the rest of this code is someone
>         else's ( between double quotes):
> 
> "
> # Step 1: scan file 1, and make an entry in the filelines{} hash array
> # for each line of file 1. The whole text of the line is the array
> # subscript, or hash key if you prefer. (If you have a choice, use
> # the shorter file as file 1, since the memory used for the hash
> # array will be proportional to the size of file 1.)
> 
> $file1= "C:/WINDOWS/Desktop/my_scripts.dir/testfile1.txt";
> $file2 = "C:/WINDOWS/Desktop/my_scripts.dir/testfile2.txt";
> 
>  open(INFILE, "$file1") || die "Failed to read file1: $!\n";
> 
>      while (<INFILE>) {
> 
>         filelines{$_} = 1;               # $_ is the line just read from
          ^
          $

 INFILE
> 
>       } close(INFILE);
> 
> # Now, scan file 2, and print out every line that is found in
> filelines{}.
  ^
  $

> # This is basically a string-keyed hash table lookup for each line,
> # and ought to be quite fast.
> # Note that we have no dependency at all on the ordering of the lines
> # in the files, except that duplicate lines will be printed in the
> # order that they appear in file 2.
> 
> open(INFILE, "file2") || die "Failed to read file2: $!\n";
> 
> while (<INFILE>) {
> 
>    if (filelines{$_}) {
         ^
         $filelines{...

Perl variables always start with $ if they return a scalar, with @ if
they return an array, or % if they return a hash.  There are a coupld of
others, too, but you aren't ready to have those mentioned yet.

> 
>      print $_;
> 
>    }
> 
> } close(INFILE);
> 
> # Grand total of twelve non-blank, non-comment lines of code...
> # and I bet it will compare very favorably with the performance
> # of a C-coded routine, let alone any sort of shell script.
> "
> 
> ... but like I said, it didn't work.  ActivePerl doesn't seem to
> recognize "filelines{$_}".

As mentioned above, it is $filelines{$_}.  And even if you got that
right, it still wouldn't do what you expect, since two files that were
the same except that the order of the lines was shuffled between them
would indicate they compared exactly.

> 
> I don't really know what the $_ means.  

$_ is Perl's default scalar variable.  If you do something that requires
a scalar variable, but the scalar variable is omitted, Perl with
automagically use $_.  One example would be:

    for(@array){...}

Because the variable after "for" is omitted, Perl will use $_ for the
index variable.  See:

    perldoc perlvar

No explanation I have found
> thus far cleary explains this.   That may be one stumbling block for
> me.
> 
> I even tried to write my own code from scratch, but that failed
> miserably.   At this point, I feel that including my code in this post
> would just muddy the issue.
> 
> Finally,  this is a plea to those familiar with ActivePerl:   Can
> anyone help me please?
> 
> Thanks for any responses.

I don't think you'll do any better than using the Unix diff command. 
You can have it for Windoze if you get Cygwin.  If you put Cygwin's
diff.exe and the Cygwin DLL on your path, it will work from the Windoze
command prompt and from within Perl via the qx() operator.  That way you
can have patch (the inverse of diff) too.  One warning:  if you put all
of Cygwin's stuff on your path, there are a couple of commands that will
conflict because some Unix and some Windoze commands have the same name
-- that is, you'll get either the Unix or the Windoze version of the
command, depending upon which is first on the path.  "sort" is one such
command.
-- 
Bob Walton


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

Date: Mon, 17 Sep 2001 03:57:32 +0100
From: James Coupe <james@zephyr.org.uk>
Subject: Re: irc
Message-Id: <8sm$WuccaWp7Ew4S@gratiano.zephyr.org.uk>

In message <h_6p7.136$lU1.1596@pollux.casema.net>, Archie Ballantine
<zoetnet@wanadoo.nl> writes
>does anyone know if there is a way (on undernet) to modify the
>hostname/userhost before joing a channel, for example to get around a host
>ban?

To the best of my knowledge, this is determined by your reverse DNS,
something which the Perl module does not address.  You could, of course,
issue a "/nick" command if that were part of the ban.

This is not, in essence, a Perl issue however.

-- 
James Coupe                                                PGP Key: 0x5D623D5D
Close your eyes so you don't feel them                           EBD690ECD7A1F
They don't need to see you cry                                   B457CA213D7E6
I can't promise I will heal you, but if you want to I will try  68C3695D623D5D


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

Date: 17 Sep 2001 00:31:23 -0300
From: * Tong * <sun_tong@users.sourceforge.net>
Subject: Javadoc alike
Message-Id: <sa8u1y27at0.fsf@suntong.personal.users.sourceforge.net>

Hi,

Is there any well-known tool for Perl as Javadoc to Java?
How popular they are? (I assume there are more than one)

-- 
Tong (remove underscore(s) to reply)
  *niX Power Tools Project: http://xpt.sourceforge.net/
  - All free contribution & collection


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

Date: Mon, 17 Sep 2001 01:35:16 GMT
From: "hallaj.com" <wael@hallaj.com>
Subject: Looking for Perl programers in Toronto
Message-Id: <orcp7.60560$j65.10376207@news4.rdc1.on.home.com>

Hi

I'm looking for perl programers in Toronto. Contact me if you know one.

wael@hallaj.com
416-875-4044




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

Date: Mon, 17 Sep 2001 00:00:21 GMT
From: Dan Sugalski <dan@tuatha.sidhe.org>
Subject: Re: Multithreading Information
Message-Id: <p2bp7.10314$NT3.1721273@news1.rdc1.ct.home.com>

Raymond McCrae <raymond.mccrae@ntlworld.com> wrote:
> Hi

> Where can I find information (and a tutorial or two) about writing 
> multithreaded applications?

Dave Butenhof's _Programming with POSIX Threads_ is a really nice
book. The docs that come with perl (presuming you want perl multithread
programming) are adequate.

Dave's book is better, though.

					dan


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

Date: Mon, 17 Sep 2001 09:25:02 +0930
From: "Wyzelli" <wyzelli@yahoo.com>
Subject: Re: Perl (slurping) is TOO much fun
Message-Id: <ASap7.5$i22.595@wa.nnrp.telstra.net>

"Anno Siegel" <anno4000@lublin.zrz.tu-berlin.de> wrote in message
news:9ntahe$pr0$2@mamenchi.zrz.TU-Berlin.DE...
> According to Wyzelli <wyzelli@yahoo.com>:
> >
> > Not sp much 'bad practice' as 'a practice which may have some gotchas'
ie it
> > can take up a lot of memory.
>
> If done routinely, as the default way of file processing, slurping is
> definitely bad practice.  Unfortunately this is seen too often.
>

I find that comment from the Cardinal too generalistic for my tastes.  If
done routinely as the default way, when all you are processing is small
files (for some definition of small which varies with system resources)
there should be no problem.  The problem arises when trying to slurp large
files (for some definition of large) and any good programmer should know of
the caveats and have several different options in their toolkit.

There are even several occasions which require slurping of entire files into
scalars, and that (probably slightly less so than arrays) has just the same
caveats in terms of RAM usage.

I think the Cardinal is trying to ensure that this group doesn't provide
slurping into arrays as the default file reading mechanism to newbies, and I
can agree with that, though I think it has it's place and should be
discussed, along with its caveats.

The solution, as with most programming techniques ("never open a file
without testing for the success") is education, not banning of potentially
useful tools.

Maybe there needs to be a FAQ about this?

Wyzelli [hoping not to be excommunicated for discussing heresy... :)]
--
@x='074117115116032097110111116104101114032080101114108032104097099107101114
'=~/(...)/g;
print chr for @x;




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

Date: Mon, 17 Sep 2001 03:05:45 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Perl (slurping) is TOO much fun
Message-Id: <x7iteiectd.fsf@home.sysarch.com>

>>>>> "W" == Wyzelli  <wyzelli@yahoo.com> writes:

  W> "Anno Siegel" <anno4000@lublin.zrz.tu-berlin.de> wrote in message
  W> news:9ntahe$pr0$2@mamenchi.zrz.TU-Berlin.DE...
  >> According to Wyzelli <wyzelli@yahoo.com>:
  >> >
  >> > Not sp much 'bad practice' as 'a practice which may have some gotchas'
  W> ie it
  >> > can take up a lot of memory.
  >> 
  >> If done routinely, as the default way of file processing, slurping is
  >> definitely bad practice.  Unfortunately this is seen too often.
  >> 

  W> I find that comment from the Cardinal too generalistic for my
  W> tastes.  If done routinely as the default way, when all you are
  W> processing is small files (for some definition of small which
  W> varies with system resources) there should be no problem.  The
  W> problem arises when trying to slurp large files (for some
  W> definition of large) and any good programmer should know of the
  W> caveats and have several different options in their toolkit.

  W> There are even several occasions which require slurping of entire
  W> files into scalars, and that (probably slightly less so than
  W> arrays) has just the same caveats in terms of RAM usage.

hmm, do you ever use a perl module or require one? those files are
slurped in whole as the perl parser doesn't work line by line. in fact
'do' file function is effectively a slurp and eval. use and require are
just variants on 'do'

i agree that teaching line by line processing to newbies is a good
idea. and there are many cases where that is more efficient and
applicable. but knocking slurping with no solid reasons is not helpful.

and when i slurp, i use that sub i wrote. no need to reinvent it.

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture and Stem Development ------ http://www.stemsystems.com
Search or Offer Perl Jobs  --------------------------  http://jobs.perl.org


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

Date: 16 Sep 2001 22:25:08 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: Similar file finder
Message-Id: <1000678510.14261@itz.pp.sci.fi>

In article <3ba4dde2.319a$116@news.op.net>, Mark Jason Dominus wrote:
>
>Perhaps you could take a look at the nilsimsa algorithm:
>
>        http://lexx.shinn.net/cmeclax/nilsimsa.html

Okay, so does anyone have an English description of the algorithm?  The
source is mostly uncommented, haphazardly structured C code, and the few
comments that are there are half in Lojban, of all things!

It's obviously computing a histogram of some statistical property of the
data, and then mangling that into a bit vector.  But just what is the
property it's analyzing?  Character frequency?  Adjacent characters?
Something completely different?

-- 
Ilmari Karonen -- http://www.sci.fi/~iltzu/
"Get real!  This is a discussion group, not a helpdesk.  You post something,
we discuss its implications.  If the discussion happens to answer a question
you've asked, that's incidental."           -- nobull in comp.lang.perl.misc



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

Date: Mon, 17 Sep 2001 00:21:43 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Similar file finder
Message-Id: <m7gaqtojdkq5v0n5kbpcv3jn7jfvof184t@4ax.com>

* Tong * wrote:

>What's in my mind is much more powerful than it. It can not only
>find out *identical* files but also find out similar files. Ok, what
>are similar files? Files that have different file name, time and
>size (might be content also), and yet they represent same thing.
 ...
>Moreover, sample rate make a huge different in
>MP3 files, even if they sound no much different to human ears.

It sounds like you're trying to reinvent what Napster calls the
"fingerprinting technology". And it seems to me that that isn't exactly
simple. No, I'm not an insider.

So let's say you want to recognize files of the same audio track, or
image files at a different resolution. So what can you do? First,
uniformize it, I'd think. Make a small version of preset size, in case
of pictures, or sample rate, in case of audio. And then, overlay those,
and see how similar they are.

-- 
	Bart.


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

Date: Mon, 17 Sep 2001 03:19:17 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Tan Without The Sun
Message-Id: <x7g09mec6t.fsf@home.sysarch.com>


funny, i can call tan on my linux OR sun boxes. your subject is lying
then.

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture and Stem Development ------ http://www.stemsystems.com
Search or Offer Perl Jobs  --------------------------  http://jobs.perl.org


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

Date: Sun, 16 Sep 2001 14:11:25 +0100
From: mark grimshaw <m.grimshaw@salford.ac.uk>
Subject: upgrading berkeley DB 1.85 to 3.3?
Message-Id: <3BA4A4F8.C1F7A591@salford.ac.uk>

Hi all,

I'm currently in the process of transferring our web server from SGI
IRIX to Linux.  All databases on IRIX used berkeley db 1.85 and ran with
perl 5.005_02.  All files transferred have been transferred with
original owner, group and permissions.

LINUX: berkeley 3.3, DB_File (that comes with the 3.3 dist.) and perl
5.6.1

With all the above installed however, none of my perl scripts (unedited
scripts that ran fine on IRIX) will tie() the 1.85 files that were
transferred across from the IRIX box.  The readme files for berkeley 3.3
mentioned possible problems with the perl dist (5.6.0) that comes with
some linux distributions hence my reason for installing 5.6.1 (and then
reinstalling 3.3 and DB_File).

Has anyone had this problem and resolved it?  If so, what is the
solution?

Just in case there's an incompatibility between the earlier perl scripts
now running on 5.6.1, I'm using the following:

#!/usr/local/bin/perl -w

use DB_File; use POSIX; use Fcntl qw(:DEFAULT);

my %T;
my $db = '/music/cgi-bin/q3aforum/topicdb';

if(! -e $db)
{
    print "Can't FIND $db\n\n";
    exit;
}
if(! tie(%T, "DB_File", $db, O_RDONLY))
{
    print "Can't OPEN $db\n\n";
    exit;
}
untie(%T);
exit;

################

The last message is what is printed.



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

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


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