[13228] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 638 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Aug 25 13:16:42 1999

Date: Wed, 25 Aug 1999 10:05:18 -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, 25 Aug 1999     Volume: 9 Number: 638

Today's topics:
    Re: A nice tough RegEx for u to solve..? <henry@dotrose.com>
    Re: A nice tough RegEx for u to solve..? <kenhirsch@myself.com>
    Re: A nice tough RegEx for u to solve..? (Bart Lateur)
    Re: A simple perl newsreader <dont_ever.spam_pvoris@earthlink.net>
        Announce: Macro.pm & macro - A macro pre-processor with summer@chest.ac.uk
    Re: canīt flock files (Richard Tibbitt)
        characters octal number hamed53@my-deja.com
        Check if user is on? <pmt@top.mitre.org>
    Re: Connecting a Informix-DB running under NT from Linu <gellyfish@gellyfish.com>
    Re: domain name -> real host resolution? <Mark@Mark.Com>
    Re: Efficient Perl Scripting <aqumsieh@matrox.com>
    Re: File Upload for WinNT W/ ActivePerl and CGI.pm-2.54 <dallas.jones@tech4learning.com>
    Re: File Upload for WinNT W/ ActivePerl and CGI.pm-2.54 <ehpoole@ingress.com>
    Re: how print a string as hex? (Larry Rosler)
    Re: how print a string as hex? (Helmut Richter)
    Re: how print a string as hex? (Larry Rosler)
    Re: Japanese characters - how do I handle them? <julien.quint@xrce.xerox.com>
    Re: newbi: Registry Help under NT (Jenda Krynicky)
        Newsgroups via PERL <ssf@fallesen-internet.dk>
        package belg4mit@mit.edu
    Re: Perl a Black Sheep? <bmetcalf@nortelnetworks.com>
    Re: Perl a Black Sheep? (Bart Lateur)
    Re: Perl a Black Sheep? <flavell@mail.cern.ch>
    Re: Perl a Black Sheep? (Greg Bacon)
    Re: Perl ISAPI and MSSQL (Jenda Krynicky)
        puzzle <m.grimshaw@salford.ac.uk>
    Re: Q: Perl to binary? (Abigail)
    Re: Question about date (M.J.T. Guy)
    Re: Question about date (M.J.T. Guy)
    Re: rename with ActivePerl (Jenda Krynicky)
    Re: Running out of Virtual Memory (Abigail)
        script now failing for password protected site <douglas@home.com>
    Re: Sorting a list of lists (Larry Rosler)
        sub aliases belg4mit@mit.edu
    Re: sub aliases (Greg Bacon)
        Digest Administrivia (Last modified: 1 Jul 99) (Perl-Users-Digest Admin)

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

Date: Wed, 25 Aug 1999 11:12:00 -0400
From: Henry Hartley <henry@dotrose.com>
Subject: Re: A nice tough RegEx for u to solve..?
Message-Id: <37C407C0.861AFCE4@dotrose.com>

Also consider what will happen if your regex comes across:

file.html">FileNumber1234567890123456789012345678901234567890<img
src="file.gif"></A>

or:

file.html" >FileNumber1234567890123456789012345678901234567890</A>

Henry

Paul Dobbs wrote:
> 
> s/[\">]?(\S{40,})[<\/A>]?/substr($1,0,39)."
> ".substr($1,39)/ieg;
> 
> The desire is to grab all the text between in a large string
> but only
> at those spots in the string where the text is between ">
> and </A> AND
> only if the string is 40 or more characters, and then split
> that text
> up with a single blank space.


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

Date: Wed, 25 Aug 1999 11:42:34 -0400
From: "Ken Hirsch" <kenhirsch@myself.com>
Subject: Re: A nice tough RegEx for u to solve..?
Message-Id: <7q12va$cnl$1@oak.prod.itd.earthlink.net>


Paul Dobbs wrote:
> s/[\">]?(\S{40,})[<\/A>]?/substr($1,0,39)."
> ".substr($1,39)/ieg;
>
> The desire is to grab all the text between in a large string
> but only
> at those spots in the string where the text is between ">
> and </A> AND
> only if the string is 40 or more characters, and then split
> that text
> up with a single blank space.
>
> EG:
> file.html">FileNumber1234567890123456789012345678901234567890</A>
> Should become
> file.html">FileNumber12345678901234567890123456789
> 01234567890</A>
> But right now file.html">FileNumber123456789012345678
> 9012345678901234567890</A>
>
>  What is my mistake? Why won't it stick to just the defined
> section of text?

Several problems:
1. Your $1 is going to be
  file.html">FileNumberFileNumber12345678901234567890123456789
because you made the "> optional
2. You are using square brackets [] which indicate character classes
3.  You are deleting the parts of the match that are not in $1 or $2

It bears repeating that unless your HTML is quite restricted, regular
expresssions are not adequate for the task of parsing and manipulating HTML.
You should be using the HTML::Parser module.

If you know that you only have text between your <a> and </a> and you know
that they are on the same line, and you know that there aren't any quoted
"<" or ">", then you probably can do it.

E. g.
s!(>\S{40})(\S+</a>)!$1 $2!ig;

I'm using ! so that I don't have to escape the forward slash /

In general you have to be worried about matching more than you intended,
  e.g. match <a href="foo">abcdefghijk</a><a href="bar">abcdefghijk</a>
but you should be okay in this case since <a> tags (should) always have a
space character.

Ken Hirsch
kenhirsch@myself.com
Freelance Perl Programmer






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

Date: Wed, 25 Aug 1999 16:35:02 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: A nice tough RegEx for u to solve..?
Message-Id: <37c6194e.1273765@news.skynet.be>

Paul Dobbs wrote:

>s/[\">]?(\S{40,})[<\/A>]?/substr($1,0,39)."
>".substr($1,39)/ieg;
>
>The desire is to grab all the text between in a large string
>but only
>at those spots in the string where the text is between ">
>and </A> AND
>only if the string is 40 or more characters, and then split
>that text
>up with a single blank space.

You mistook "[...]" for grouping. It's "(...)", or "(?:...)" if you want
it non-capturing.

Fix your regex. It allows *optional* '"' or '>', and then at least 40
non-spaces. 

	file.html">FileNumber1234567890123456789012345678901234567890

matches that requirement.

You'd better limit the string pattern to [^<>]{40,0}. And I use
"(?:...)" for lookahead (required, but not part of the match).

  s/([^<>]{40,})(?=<\/A>)/substr($1,0,39)." ".substr($1,39)/ieg;

Then again, why substr()?

  s/([^<>]{39})([^<>]+)(?=<\/A>)/$1 $2/ig;

	Bart.


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

Date: Wed, 25 Aug 1999 09:35:40 -0700
From: Joe Schmoe <dont_ever.spam_pvoris@earthlink.net>
Subject: Re: A simple perl newsreader
Message-Id: <37C41B5C.7A4CB9@earthlink.net>

This might help, but doesn't cover saving to disk--a relatively trivial
issue.

I designed it to use ansicolor and require some configuration up top. 
Read comments.

#!/usr/bin/perl -w

##
## INSTALL THESE MODULES
##

use Net::NNTP;
use Term::ANSIColor qw(:constants);

## newsgroup to look through

$group = 'comp.lang.perl.misc';

## max number of articles

$limit = '500';

##
## SET THESE VALUES:
##

($username, $password, $newsserver)=();

$server = Net::NNTP->new($newsserver) 
    or die "can't connect to news server.\n"; 

$server->authinfo($username, $password)
    or die "can't connect with $password.\n";

($num_articles, $first, $last) = $server->group("$group")
    or die "can't connect to $group on $newsserver.\n";

print "\n" . '='x25 . "| " . uc $group . " |" . '='x25 . "\n\n";
print "$num_articles articles available: ($first -> $last)\n";

if ($num_articles > $limit) {
    $first = $last - $limit;
    $num_articles = $limit;
    print "Most recent $num_articles articles scanned: ($first ->
$last)\n\n";
}

# POST: for ($num = $first; $num <= $last; $num++) {
POST: foreach $num ($first .. $last) {

    $header = $server->head($num) or next;

## grep for a subject line pattern 
## and then test it against SEARCH PATTERN
## and show those postings that matched (in color)

    foreach (grep (/ubject/, @{$header})){

        # THE SEARCH PATTERN
        if (/news/) {
            print BLUE, '_'x70 . "\n\n";
            print RED, "Article #: $num\n";
            print YELLOW, "$_";
            print BLUE, '_'x70;
            print RESET, "\n\n";
            $body = $server->body($num) or next POST;
            print @{$body};
        }
    }
}



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

Date: Wed, 25 Aug 1999 16:31:04 GMT
From: summer@chest.ac.uk
Subject: Announce: Macro.pm & macro - A macro pre-processor with embedded perl capability
Message-Id: <7q15o8$18g$1@nnrp1.deja.com>

I've put up a module that provides the kind of macro processing of a
pre-processor, e.g. CPP. Its simple and written in pure perl.
It supports definitions which can be simple constants or which can be
little perl scripts (the last expression being the thing that replaces
the macro name).

There's also a wrapper script which can be used as a macro pre-processor
without having to know the module. The wrapper also allows you to use an
embedded perl approach, i.e. to only replace within specified
delimiters.

They are available from CPAN:
/packages/CPAN/authors/id/S/SU/SUMMER/
__________________________________________
summer@chest.ac.uk  http://www.chest.ac.uk


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: Wed, 25 Aug 1999 15:32:39 GMT
From: tibbs@netcomuk.co.uk (Richard Tibbitt)
Subject: Re: canīt flock files
Message-Id: <37c50826.23860634@nntp.netcomuk.co.uk>

isabelle Leroy <isabelle@unixpro.mch.pn.siemens.de> wrote:

>I tried two ways to lock files but it doesnīt work, could you help me?
>Thanks.
>
>first  I tried:
>
>sub easy_lock {
>open (ISA, "isa.txt") || die "Can't Open isa.txt $!\n";
>flock (ISA, 2) or warn ("canīt lock right now, will try again soon\n");
>close (ISA);
>}

A couple of points to note here - by default, flock doesnt return
until it can achieve the lock or it fails - your 'warn' would be
better as a 'die' with $! in the message to tell you exactly why flock
is failing - it is unlikely to be because the file is currently locked
by another process - an OPERATION of 2 is probably an exclusive
blocking lock on your system (but it may not necessarily be - see FAQ
5 etc for details).

Trying to obtain an exclusive lock on a file opened only for reading
(as you have above) may generate an error on some systems - it hasn't
for me on half a dozen different versions of Perl5 & flavours of Unix
until I tried out a Cobalt RAQ2 with Perl 5.004_04 built for
mips-Linux - flock failed with a "Bad file descriptor" error.

Hope this helps


-- 
Richard Tibbitt
Looe, Cornwall, UK
tibbs@netcomuk.co.uk


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

Date: Wed, 25 Aug 1999 15:00:45 GMT
From: hamed53@my-deja.com
Subject: characters octal number
Message-Id: <7q10en$tao$1@nnrp1.deja.com>

hi
does anyone know how to get any characters octal number?
for example:
a = 141
thanks
hamed


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: Wed, 25 Aug 1999 11:08:20 -0400
From: Patrick Tully <pmt@top.mitre.org>
Subject: Check if user is on?
Message-Id: <37C406E4.83586F5E@top.mitre.org>

Hi,
    I run a user-based website, and would like it to be possible to
check if a user is 'loged-in'.  I use cookies to keep track of sessions
and don't know if this would be of any help.  I don't know the best way
to approch this task.  Just checking if an IP address is active is not
an option, because of dynamicly assigned addresses.  I was thinking of
if a user logged it, the login script would write to a file and when a
user logged out, it would delete the entry from the file.  The only
problem with that, is i know its common for users to not log-out, and
just type in a different site.  Is there anyway to force a user to log
out before leaving the site?  Is there a better approch to this
problem?  Any ideas?
Thanks,

-Patrick Tully-
tcblue82@yahoo.com



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

Date: 25 Aug 1999 16:25:58 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Connecting a Informix-DB running under NT from Linux
Message-Id: <37c40b06_2@newsread3.dircon.co.uk>

Oliver Thinnes <oliver_thinnes7845@my-deja.com> wrote:
> Hallo.
> 
> I'm not familiar with perl. I read any information about DBI and
> Informix.
> 
> Is there any chance to connect Informix Online Dynamic Server 7.2
> running under MS NT 4.0 from Linux over TCP/IP?
> 
> Which programs are necessary?

This is entirely possible.

You will need to download DBI & DBD::Informix from CPAN.  You will also
need to obtain the Informix client SDK for Linux from the Intraware site.

<http://www.intraware.com>

Once the latter is installed you should be able to build the former in the
usual manner.

/J\
-- 
"Buzz Aldrin was the second man to walk on the moon and the first to
fill his pants" - Violet Berlin, The Big Bang


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

Date: Wed, 25 Aug 1999 16:55:09 +0100
From: Mark <Mark@Mark.Com>
Subject: Re: domain name -> real host resolution?
Message-Id: <37C411DD.9CDC6328@Mark.Com>



California Man wrote:

> Im relatively new to perl and network software.
> Im trying to take links in an HTML file such as:
>
> www.somesite.com and find the real host to
> use a socket connection on.
>
> If the www.somesite.com is aliased to another
> site (the host site) and I try to connect to
> somesite.com, I get an error.
>
> If there are packages/modules that do this for
> me, Id appreciate a small example, if not,
> how do you do this?
>
> I thought gethostbyname would work, but seems
> to return the same hostname.
>
> Thanks in Advance

Why?

Hosts are the same if their IP addresses/numbers are the same (the quad
number). You can specify any of the names that map
onto the correct number, assuming for DNS lookup (or equivalent) is OK.
Try using www.somsite.com, if that is the host you are connecting to. If
that doesn't work your DNS is screwed.





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

Date: Wed, 25 Aug 1999 10:56:11 -0400
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: Efficient Perl Scripting
Message-Id: <x3y1zcrykmt.fsf@tigre.matrox.com>


"Scott Beck" <admin@gatewaysolutions.net> writes:

> I just have a few questions about how to make
> my programs more efficient.

What is your definition of "efficient"? Fast? Uses less memory? cooks
lasagna?

> I am self taught and have never seen the inside
> of a perl programming classroom so be easy on
> me. =)

Neither have I, and many of the other people on this ng. But keep in
mind that this is not an excuse for not researching and asking silly
FAQs (I am not implying here that your question is an FAQ).

> Which is the most efficient loop for iterating through
> an array(for, foreach, while)?

It all depends on what you want to do. Take note that for() and
foreach() are just aliases of one another, and therefore are exactly
identical. This is described very well in perlsyn:

     The foreach keyword is actually a synonym for the for
     keyword, so you can use foreach for readability or for for
     brevity.

Some common ways for iterating through arrays:

    for my $elem (@array) {
	# $elem will be an "alias" to each element in @array
	# if you change $elem here, @array will change
    }

    for my $i (0..$#array) {
	# here you access the elements as $array[$i]
	# I find this useful only in the case where I want
	# to know the index of the element in the array
    }

    while (defined($elem = shift @array)) {
	# this extracts each element from @array in order.
	# @array will be empty at the end of the loop
    }

Have a look at perlsyn for more details.

> How does eval affect the speed and or efficiency of
> a script?

eval() is generally slower since it's evaluated at run-time. In most
cases you can find a better approach to do whatever you want, and
avoid eval(). But it's indeed useful other times, and can provide an
excellent exception handling mechanism. Read Ch.5 in the Panther
(Advanced Perl Programming).

Note also that eval()ing string coming from the outside world is very
dangerous.

	$str = 'system "rm -rf /"';
	eval($str);

This is disasterous.

> What kind of a difference does BEGIN make?

Well, now you are starting to ask FAQs. Have a look at perlrun for
info on BEGIN. It is VERY useful.

> If you know of a reference that will help me learn these
> facts that would help tremendously.

Read the online perldocs. Type perldoc perldoc for more help.

HTH,
Ala



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

Date: Wed, 25 Aug 1999 16:09:40 GMT
From: "Dallas Jones" <dallas.jones@tech4learning.com>
Subject: Re: File Upload for WinNT W/ ActivePerl and CGI.pm-2.54
Message-Id: <8zUw3.42657$pq3.238949@news1.rdc1.sdca.home.com>

Hey, all --

Thanks for the suggestions here and by e-mail. My upload script works great
on FreeBSD, but I can't get it to work at all on Win NT. So -- I scrapped
PERL on the NT machine and went with ASP instead. The moral seems to be that
PERL likes UNIX a lot more than Win32...

-Dallas

Dallas Jones <dallas.jones@tech4learning.com> wrote in message
news:jSkw3.40759$pq3.207914@news1.rdc1.sdca.home.com...
> Hi, all:
>
> I'm running NT and have ActivePerl and CGI.pm-2.54 installed. I can't get
> any of the scripts I've found to upload a file from a user's browser. I've
> searched through the posts herein and through the help files, but I still
> don't really have a handle on what's going on. If someone would be so kind
> as to explain to me what needs to be done, I will in turn create a web
page
> explaining that same process and post it as a resource for people who ask
in
> the future.
>
> Thanks,
>
> Dallas
>
>
>




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

Date: Wed, 25 Aug 1999 12:50:10 -0400
From: "Ethan H. Poole" <ehpoole@ingress.com>
Subject: Re: File Upload for WinNT W/ ActivePerl and CGI.pm-2.54
Message-Id: <37C41EC2.7BB84841@ingress.com>

Dallas Jones wrote:
> 
> Hey, all --
> 
> Thanks for the suggestions here and by e-mail. My upload script works great
> on FreeBSD, but I can't get it to work at all on Win NT. So -- I scrapped
> PERL on the NT machine and went with ASP instead. The moral seems to be that
> PERL likes UNIX a lot more than Win32...

I would have to disagree on that point.  I have written numerous scripts
that run just as happily under NT as they do under UNIX variants. 
Including handling of file uploads.  

-- 
Ethan H. Poole           ****   BUSINESS   ****
ehpoole@ingress.com      ==Interact2Day, Inc.==
(personal)               http://www.interact2day.com/


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

Date: Wed, 25 Aug 1999 08:33:15 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: how print a string as hex?
Message-Id: <MPG.122dac931d1a5ce9989e96@nntp.hpl.hp.com>

[Posted and a courtesy copy sent.]

In article <7q0n03$mo8$1@sparcserver.lrz-muenchen.de> on 25 Aug 1999 
12:19:15 GMT, Helmut Richter <Helmut.Richter@lrz-muenchen.de> says...
> I want to convert a string to hex. The solution I have come up with is
> the second line below but I suspect that this is unnecessarily
> complex.  Is there a simpler way to do it?

Much simpler and *much* faster!

> $x = "abc\376";
> $y = join ('', map (sprintf ("%2.2x", ord($_)), split (//, $x)));
> print "$y\n";

  $x = "abc\376";
  $y = unpack 'H*' => $x;
  print "$y\n";

perldoc -f unpack
perldoc -f pack

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: 25 Aug 1999 15:52:14 GMT
From: Helmut.Richter@lrz-muenchen.de (Helmut Richter)
Subject: Re: how print a string as hex?
Message-Id: <7q13fe$5rq$1@sparcserver.lrz-muenchen.de>

lr@hpl.hp.com (Larry Rosler) writes:

>[Posted and a courtesy copy sent.]

>In article <7q0n03$mo8$1@sparcserver.lrz-muenchen.de> on 25 Aug 1999 
>12:19:15 GMT, Helmut Richter <Helmut.Richter@lrz-muenchen.de> says...
>> I want to convert a string to hex. The solution I have come up with is
>> the second line below but I suspect that this is unnecessarily
>> complex.  Is there a simpler way to do it?

>Much simpler and *much* faster!

>> $x = "abc\376";
>> $y = join ('', map (sprintf ("%2.2x", ord($_)), split (//, $x)));
>> print "$y\n";

>  $x = "abc\376";
>  $y = unpack 'H*' => $x;
>  print "$y\n";

Thank you very much indeed. In fact, I suspected that a simpler and faster
method would work with pack and unpack, but after reading their 
documentation ten times without getting a clue I finally posted it.

Do you know where pack and unpack are described so that one
understands what they actually do? According to what I found, unpack
unpacks things into a *list* of scalars but here I wanted it to
produce one single scalar. Nice that it works but I do not know why.

Helmut Richter


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

Date: Wed, 25 Aug 1999 09:36:48 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: how print a string as hex?
Message-Id: <MPG.122dbb7542bc0c76989e97@nntp.hpl.hp.com>

In article <7q13fe$5rq$1@sparcserver.lrz-muenchen.de> on 25 Aug 1999 
15:52:14 GMT, Helmut Richter <Helmut.Richter@lrz-muenchen.de> says...
> lr@hpl.hp.com (Larry Rosler) writes:
> 
> >[Posted and a courtesy copy sent.]

Next time you respond by email as well as posting, please label it as I 
have done above, so the recipient doesn't have to respond twice.

> Thank you very much indeed. In fact, I suspected that a simpler and faster
> method would work with pack and unpack, but after reading their 
> documentation ten times without getting a clue I finally posted it.

Experiment!
 
> Do you know where pack and unpack are described so that one
> understands what they actually do? According to what I found, unpack
> unpacks things into a *list* of scalars but here I wanted it to
> produce one single scalar. Nice that it works but I do not know why.

unpack TEMPLATE,EXPR

Unpack() does the reverse of pack(): it takes a string representing a
structure and expands it out into a list value, returning the array 
value.  (In scalar context, it returns merely the first value produced.)

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Wed, 25 Aug 1999 17:19:41 +0200
From: Julien Quint <julien.quint@xrce.xerox.com>
Subject: Re: Japanese characters - how do I handle them?
Message-Id: <37C4098D.5E122CFD@xrce.xerox.com>

kev wrote:
> 
> I have written a spider which goes out and collects news headlines from
> various websites. However, it crossed my mind recently that I will also
> have to do the same for a few Japanese sites, and I haven't got a clue
> how to handle Japanese character sets.
> 
> Can anyone point me in the right direction?

By no means am I a specialist of such questions, but I would advise
looking at the excellent book by Ken Lunde called "CJKV Information
Processing" (O'Reilly, 1998), that deals with Chinese, Japanese, Korean
and Vietnamese matters. It is very much perl-aware, and very useful;
however it is very big and expensive ($65). You can find more info on
the O'Reilly web site: 

	http://www.oreilly.com/catalog/cjkvinfo/noframes.html

For on-line resources, you should check the author's homepage and search
your way on the web from there:

	http://www.ora.com/people/authors/lunde/

Also you might find the Unicode modules (Unicode::String, Unicode::Map8,
Unicode::Map, etc.) on CPAN to be of some help.

Julien


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

Date: Wed, 25 Aug 1999 16:13:36 GMT
From: Jenda@Krynicky.cz (Jenda Krynicky)
Subject: Re: newbi: Registry Help under NT
Message-Id: <1103_935597616@prague_main>

On Wed, 25 Aug 1999 09:02:31 +1000, elephant@squirrelgroup.com (elephant) wrote:
> [ item posted to comp.lang.perl.misc and CCed to Andrew C. Holmes ]
> 
> Andrew C. Holmes writes ..
> >I am trying to extract a value from an NT Server registry.
> >When I run this I get "Query: Cannot create a file when that file already
> >exists."
> >Obviously the QueryValue is failing, but why.  any ideas anybody???
> 
> my recommendation is to use Win32::TieRegistry instead of 
> Win32::Registry .. IMHO it's neater / easier / better
> 
> failing that - if you really want to pursue with Win32::Registry then 
> get Jenda's patch for Win32::Registry from her web site

HIS site!

Oh well. I guess I should put a picture of me online or at least specify my sex on my site.

Never mind :-)

Jenda
http://Jenda.Krynicky.cz



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

Date: Wed, 25 Aug 1999 18:07:46 +0200
From: "Steffan S. Fallesen" <ssf@fallesen-internet.dk>
Subject: Newsgroups via PERL
Message-Id: <lvUw3.272$cU5.468@news.get2net.dk>

Dear Group,

I'm looking for a perl / php script that allows the vistors om my homepage
to get acces to Newsgrups via the web.

Can anyone help me?



Best regards
Steffan Søndermark




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

Date: Wed, 25 Aug 1999 16:45:12 GMT
From: belg4mit@mit.edu
Subject: package
Message-Id: <7q16ik$1s5$1@nnrp1.deja.com>

Is there a way to tell if a given package is loaded?
I'm writing one package and I'd like my behavior to vary depending on
whether or not this other package is loaded.

Any ideas?

Thanks!

PS> Sorry for deja, but my ISP's newsfeed is mucked right now


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: Wed, 25 Aug 1999 08:44:11 -0700
From: Brandon Metcalf <bmetcalf@nortelnetworks.com>
Subject: Re: Perl a Black Sheep?
Message-Id: <37C40F4A.7221EB63@nortelnetworks.com>



joeyandsherry@mindspring.com wrote:

> I told him of my learning of Perl and of how I used it, etc. As soon as I
> mentioned Perl and the UNIX server I use, he snarled. It was if I was
> speaking of a plague...He commented that Perl was not a "real" programming
> language, it is a scripting language and offered his dissertation on
> programming and Unix and other such things.
>
> Why is Perl treated with such disdain? I've found many occasions where Perl
> programmers say "Perl can do that...", which doesn't seem to reinforce what
> I experienced today.

Quite frankly, this admissions counselor is a complete idiot.  Furthermore,
because of his comments I wouldn't even entertain the idea of taking
certirfication courses thru him.

I've never encountered anyone with such an attitude.  Perl is a very powerful
PROGRAMMING LANGUAGE that has its niche just like any other language.  I'll bet
this counselor can't even write one line of Perl.

Ignore this idiot and continue to use Perl and Unix.

Brandon



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

Date: Wed, 25 Aug 1999 16:24:32 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Perl a Black Sheep?
Message-Id: <37c5182a.982113@news.skynet.be>

<joeyandsherry@mindspring.com> wrote:

>I spoke to the admissions counselor and I questioned which training program
>would best enhance my limited exposure to NT. The Counselor introduced me to
>the Training Director, partly to answer my question and partly for
>prequalification...He asked of my experience.
>
>I told him of my learning of Perl and of how I used it, etc. As soon as I
>mentioned Perl and the UNIX server I use, he snarled. It was if I was
>speaking of a plague...

Whoever is pro Microsoft and contra Perl, is a clueless idiot.

	Bart.


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

Date: Wed, 25 Aug 1999 18:30:04 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Perl a Black Sheep?
Message-Id: <Pine.HPP.3.95a.990825182131.5097D-100000@hpplus03.cern.ch>

On 25 Aug 1999, Mark D. Leitch wrote:

> I have programmed in more languages than I can remember and to say "Perl" is
> not a real programming language is ludicrous. 

Amen to that.

If you want references, as a jack of many trades (and master of none)
I've programmed in several machine codes, in several assembler codes, in
BCPL, in FORTRAN, a little Pascal, a little C, occasional non-procedural
languages, also in REXX+Pipelines, even BASIC etc.  etc. over about
forty years.  I think I know a real programming language when I see one.

I really do miss CMS Pipelines though...



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

Date: 25 Aug 1999 16:53:33 GMT
From: gbacon@itsc.uah.edu (Greg Bacon)
Subject: Re: Perl a Black Sheep?
Message-Id: <7q172d$j01$1@info2.uah.edu>

In article <7pvma4$ab5$1@nntp3.atl.mindspring.net>,
	<joeyandsherry@mindspring.com> writes:

: I told him of my learning of Perl and of how I used it, etc. As soon
: as I mentioned Perl and the UNIX server I use, he snarled.

That's the response you'll get from the typical pencil-necked NT weenie.
The snarl is a prejudicial response brought on by their fears of such
"scary" and "unintuitive" features like command lines and pipes.  NT
weenies like to have all their options laid out in front of them in the
form of happy little menus and buttons.  They hate to think for
themselves.

:                                                            It was if I
: was speaking of a plague...He commented that Perl was not a "real"
: programming language, it is a scripting language and offered his
: dissertation on programming and Unix and other such things.

"Scripting language" (if you even believe in the existence of such a
thing) is a term that we never should have let outside our circle.  It's
unfortunate, but people with no programming background or knowledge
wrongly assume that programming in a so-called scripting language is
somehow less than serious.

I'd also be interested in hearing what this character had to say about
Unix and programming in general.  At a place I used to work, this guy
was puffing himself up in a meeting because he had done "some really
cool stuff" for the company intranet.  He was talking about how great
IIS and NT were and made the remark that he didn't have to use "old,
archaic tools like Perl".  What the hell does he think all the CP/M
hindrance and baggage stuff in NT is? :-)

: Why is Perl treated with such disdain?

Well, this guy is an idiot.  You shouldn't give any weight to his
opinion.  Don't take this to mean that Perl doesn't have its problems.
W. Richard Stevens once called Perl a write-only language.  I'm told
that Eric Allman (of sendmail fame) even said that Perl code is hard to
read, but his beautiful glass house will be shattering at any time. :-)
Parsing Perl is a nightmare, but anyone can retrieve the source to the
best Perl parser in the world.  There are other problems too, but you'll
discover those if you use Perl enough (or read enough of tchrist's
rant^Wposts).

:                                        I've found many occasions where
: Perl programmers say "Perl can do that...", which doesn't seem to
: reinforce what I experienced today.

Perl is a language that prides itself on making easy things easy and
hard things possible.  It's for getting the job done in a reasonable
amount of time.  (I love wowing cow orkers with how quick and easy it
is to write simple Perl programs to do moderately complex tasks.)  If
this is what keeps Perl from being a "real programming language" in
the eyes of some people, then I hope I'm never forced to use a real
programming language.

Greg
-- 
I love the metric system.  Where else, when someone asks you how big is
your penis, can you answer 'A HUNDRED AND FIFTY SEVEN!'?
    -- Robin Williams


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

Date: Wed, 25 Aug 1999 16:26:00 GMT
From: Jenda@Krynicky.cz (Jenda Krynicky)
Subject: Re: Perl ISAPI and MSSQL
Message-Id: <1104_935598360@prague_main>

On Wed, 25 Aug 1999 07:16:13 GMT, nr42@my-deja.com wrote:
> Hi!
>
> ... 
>
> I use latest version of Perl (5.19) and the SQLlib from:
> http://www.algonet.se/~sommar/mssql/
> 
> Anybody have had similar problems? Solutions?
> 
> /Magnus

Sorry I do not have any suggestion on the problem.

I would just like to ask why do people keep confusing version with build number.

Try to run 
    perl -v

You'll get something like :

==================================
This is perl, version 5.005_02 ...

Copyright 1987-1998, Larry Wall

Binary build 519 provided by ActiveState Tool Corp.
 ..
==================================

If you'd say you have ActivePerl 519, that'd be OK. But realy there's nothing like
Perl 5.19.

Jenda
http://Jenda.Krynicky.cz



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

Date: Wed, 25 Aug 1999 17:24:36 +0100
From: Mark Grimshaw <m.grimshaw@salford.ac.uk>
Subject: puzzle
Message-Id: <37C418C4.6FB0A12D@salford.ac.uk>

Dear all,

Here's an interesting puzzle that someone might like to help me with.

I have some music on a certain well-known downloadable web music site
from which visitors can listen to music and order CDs etc. and in which
the music (3 tracks) participates in a hit-parade.  With over 100,000
pieces on the site, those songs that appear in the top 40 will obviously
attract more attention and are likely to sell more CDs.  In the
time-honoured tradition of musical hype (cf popular music record
companies buying albums to push them up the charts!), I'd like to hype
my music and push it up the charts.

I'm reasonably competent in Perl, have su access to a web server machine
and have written a script that downloads the songs in question several
thousands of times with as much randomness as I can think of (which
songs, which of the several download servers they have, fictitious email
etc.).  However, this does not seem to have any effect.

If anyone would like to investigate this with me please email me at:
m.grimshaw@salford.ac.uk

P.S.  I'm not into hacking and there's nothing illegal about hype!






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

Date: 25 Aug 1999 10:06:32 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: Q: Perl to binary?
Message-Id: <slrn7s81le.lb2.abigail@alexandra.delanet.com>

andre (a_t_r@dds.nl.NOSPAM) wrote on MMCLXXXV September MCMXCIII in
<URL:news:37C3B2CD.BEE8E75F@dds.nl.NOSPAM>:
~~ Hi perl experts,
~~ 
~~ I have a question over perl.
~~ Is it possible to convert perl script to a binary ?
~~ Which program do you use for converting ?

FAQ.

~~ I will use binary's for performance reason..


No, you won't. Go read the FAQ to find out why.

"Binary" isn't a magic wand you wave to get better performance.
If you want better performance, write better code.



Abigail
-- 
sub f{sprintf'%c%s',$_[0],$_[1]}print f(74,f(117,f(115,f(116,f(32,f(97,
f(110,f(111,f(116,f(104,f(0x65,f(114,f(32,f(80,f(101,f(114,f(0x6c,f(32,
f(0x48,f(97,f(99,f(107,f(101,f(114,f(10,q ff)))))))))))))))))))))))))


  -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
   http://www.newsfeeds.com       The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including  Dedicated  Binaries Servers ==-----


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

Date: 25 Aug 1999 16:40:44 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: Question about date
Message-Id: <7q16ac$ptq$1@pegasus.csx.cam.ac.uk>

In article <FGpqBL.FHq@csc.liv.ac.uk>, I.J. Garlick <ijg@connect.org.uk> wrote:
>In article <SrLu3.44$z44.10835@vic.nntp.telstra.net>,
>"Wyzelli" <wyzelli@yahoo.com> writes:
>> Jimtaylor5 <jimtaylor5@aol.com> wrote in message
>> news:19990819000209.08662.00000298@ng-fn1.aol.com...
>>> >> Can anyone tell me how I would check a date to see if two or more days
>>> >> have passed?
>> 
>> How about if 'now' > 'date of writing file + 172,800' delete file?
>[ rest of code barking up the wrong tree snipped ]
>
>No. Use the -M unary operator (somewhere in the perlfunc man page, but I
>can't get perldoc -f to find them)
>
>I dare say something like this would work
>
>	opendir DR, $dir or die "Can't open directory $dir: $!";
>	foreach (grep !/^\./, readdir DR) { # all files not hidden
>		unlink $_ if -M $_ > 2;
>	}
>
>on the directory contained in $dir. (If you don't feel like deleteing
>files all over the place just swap the unlink for print to test it
>harmlessly).

Aaaargh!      Standard directory reading blunder!     You're in danger
of losing unexpected files.

Make that line

              unlink "$dir/$_" if -M "$dir/$_" > 2;


Mike Guy


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

Date: 25 Aug 1999 16:46:06 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: Question about date
Message-Id: <7q16ke$q9i$1@pegasus.csx.cam.ac.uk>

In article <FGr85A.Kx1@csc.liv.ac.uk>, I.J. Garlick <ijg@connect.org.uk> wrote:
>lr@hpl.hp.com (Larry Rosler) writes:
>> 
>> We discovered this recently:
>> 
>> On Unix:  perldoc -f -- -X
>
>I did try that but just got a perldoc usage message, (this is perl
>5.004_04, which probably explains it).

It's in all current Perls, i.e perl5.004_05 and perl5.005_03 onwards.

>Once you have been bitten by the '-' at the front of a filename problem
>you never forget about the -- option :-) In my case I was trying to help
>some one who had reversed the arguments on split in someway and ended up
>with a file named -

Actually, Larry is wrong here.   You don't want the '--' even on Unix.
Just try

          perldoc -f -X


Mike Guy


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

Date: Wed, 25 Aug 1999 16:55:25 GMT
From: Jenda@Krynicky.cz (Jenda Krynicky)
Subject: Re: rename with ActivePerl
Message-Id: <1105_935600125@prague_main>

On Wed, 25 Aug 1999 12:01:27 GMT, 2002@antispam.calva.net (Christophe Oddo) wrote:
> Hi group,
> 
> Using the last release of ActivePerl (Win 32), I need to rename a file
> in a program, by:
>           rename($filename,$newname);
> 
> It fails every time, with the following error message:
>           Permission denied
> 
> What is the problem?

Without some more info we can only guess.

Are you sure you have permissions to rename the file? 
Could the file be locked?

I'm not aware of any special problem with rename() on Win98.

Jenda
http://Jenda.Krynicky.cz



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

Date: 25 Aug 1999 10:09:11 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: Running out of Virtual Memory
Message-Id: <slrn7s81qc.lb2.abigail@alexandra.delanet.com>

Red Hat Linux User (chuaswee@ccunx.ncs.com.sg) wrote on MMCLXXXV
September MCMXCIII in <URL:news:37c350fe.0@news.cyberway.com.sg>:
,, 
,,   When I am compiling my perl 5.005_03, it gives run out of virtual memory.
,,   Has anyone faced the same problem before?
,,   How was it resolved?


That's not a Perl problem. 

Resolving is easy. Get more virtual memory.



Abigail
-- 
package Just_another_Perl_Hacker; sub print {($_=$_[0])=~ s/_/ /g;
                                      print } sub __PACKAGE__ { &
                                      print (     __PACKAGE__)} &
                                                  __PACKAGE__
                                            (                )


  -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
   http://www.newsfeeds.com       The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including  Dedicated  Binaries Servers ==-----


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

Date: Wed, 25 Aug 1999 15:07:29 GMT
From: Douglas Galbraith <douglas@home.com>
Subject: script now failing for password protected site
Message-Id: <37C406A5.AE7B8F21@home.com>

Hello and thanks for the help in advance.

I use the script below to retrieve data from web sites with passwords.

The PERL script below worked until last Monday (the web site that it
accesses was changed that day).  Unfortunately, I do not know how to fix
this script.

Running this script now produces the error message:
    416 Requested Range Not Satisfiable

How do I fix this problem?
thanks,
DGalbra862@aol.com


@rem = '--*-Perl-*--
@echo off
perl -x -S %0 %1 %2 %3 %4 %5 %6 %7 %8 %9
goto endofperl
@rem ';
#!perl -w
#line 8

 $http_addr='http://quotes.freerealtime.com/rt/frt/quotes?symbol=ACTL';

 use LWP::UserAgent;
 $ua = LWP::UserAgent->new;
 $request = HTTP::Request->new(GET => $http_addr);
 $request->authorization_basic('D046', 'D046');
 $response = $ua->request($request);
 $content = $response->content();

 if ($response->is_success) {
  print $response->content;
 } else {
   print $response->status_line, "\n";
 }

__END__
:endofperl


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

Date: Wed, 25 Aug 1999 08:20:25 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Sorting a list of lists
Message-Id: <MPG.122da987d00c443a989e95@nntp.hpl.hp.com>

In article <Arved_37-2508991015340001@dyip-28.chebucto.ns.ca> on Wed, 25 
Aug 1999 10:15:34 -0300, Arved Sandstrom <Arved_37@chebucto.ns.ca> 
says...
> In article <37c3603e@news.sisna.com>, "DJ" <djten@sisna.com> wrote:
> 
> > If I had ORDER BY capability, I would order by field3.  I've been trying to
> > figure out code that will do a sort that will achieve the same result.  I
> > was hoping... actually been _trying_ to get some implementation of the
> > Schwartzian Transform to work, but have so far failed.  Might be on the
> > wrong track.  I'm thinking this has to have been dealt with before, and that
> > someone must have a recipe, or something, that will perform a sort on a list
> > of lists, based upon one element of the list within the list.
> 
> A Schwartzian Transform will do it. Take the most basic example right out
> of the Perl Cookbook or a manpage, and make your computable field $_->[2].

No transform is necessary, as the field to sort by is already split out 
of the data.  See Julien Quint's post in this thread.

It is possible to squeeze better performance out of this by packing the 
sortkey and the data, but it seems hardly worth the trouble.

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Wed, 25 Aug 1999 16:48:28 GMT
From: belg4mit@mit.edu
Subject: sub aliases
Message-Id: <7q16om$24n$1@nnrp1.deja.com>

Is there a way to provide an alias for a sub?

given sub foo{ ... }

I'd like to call &bar and have it do the same thing as &foo

I know I could do

sub bar{ &foo(@_); }

But is there something more elegant?
Maybe make bar be a reference directly to the code of foo?
I haven't been able to figure anything out.. Any ideas?

Thanks!

PS> Sorry for deja, but my ISP's newsfeed is mucked right now


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: 25 Aug 1999 17:04:13 GMT
From: gbacon@itsc.uah.edu (Greg Bacon)
Subject: Re: sub aliases
Message-Id: <7q17md$j01$3@info2.uah.edu>

In article <7q16om$24n$1@nnrp1.deja.com>,
	belg4mit@mit.edu writes:
: Is there a way to provide an alias for a sub?
: 
: given sub foo{ ... }
: 
: I'd like to call &bar and have it do the same thing as &foo

    *bar = \&foo;

This makes &bar another name (aka an alias) for &foo.

Greg
-- 
File names are infinite in length where infinity is set to 255 characters.
    -- Peter Collinson


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

Date: 1 Jul 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 1 Jul 99)
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.misc (and this Digest), send your
article to perl-users@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.

The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq" from
almanac@ruby.oce.orst.edu. The real FAQ, as it appeared last in the
newsgroup, can be retrieved with the request "send perl-users FAQ" from
almanac@ruby.oce.orst.edu. Due to their sizes, neither the Meta-FAQ nor
the FAQ are included in the digest.

The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq" from
almanac@ruby.oce.orst.edu. 

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 V9 Issue 638
*************************************


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