[9885] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3478 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Aug 18 21:07:13 1998

Date: Tue, 18 Aug 98 18:00:25 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Tue, 18 Aug 1998     Volume: 8 Number: 3478

Today's topics:
    Re: #!usr/bin/perl is ignored, WHY? (Ethan H. Poole)
    Re: can you un encrypt htpasswd? <jbminn@greensfeldertech.com>
    Re: comp.lang.perl.announce redux <dan@fearsome.net>
    Re: Continuing misunderstanding of symbol table manipul (Tye McQueen)
        Converting pod's to a Latex Book (Kirill Sapelkin)
    Re: difference between dates (Randy Kobes)
    Re: Dynamic scoping across closures? (Tye McQueen)
    Re: filehandle in CGI.pm <mmachado@hmsi.com>
    Re: here's an implementation of diff in perl (Abigail)
        I need help with Hello World--Only works when modified  <robards@jps.net>
    Re: MD5 and perl <briant@packeteer.com>
    Re: mv, move, or some way to move files in perl <jdf@pobox.com>
    Re: mv, move, or some way to move files in perl (Martien Verbruggen)
        pattern matching with parenthesis julzrulz@my-dejanews.com
    Re: Performing an Access query from Perl <pkeefe@ix.netcom.com>
    Re: Period.pm or any other time module <jdw@dev.tivoli.com>
    Re: Perl Style <zenin@bawdycaste.org>
    Re: quotemeta (Patrick Clauberg)
    Re: Recommend a good editor <zenin@bawdycaste.org>
    Re: reference to anonymous scalar? (Tramm Hudson)
    Re: regular expression. Help !!!! (Martien Verbruggen)
    Re: Why dont people read the FAQs (Owen Cook)
    Re: Why dont people read the FAQs (Larry Rosler)
    Re: Why dont people read the FAQs (Michael J Gebis)
    Re: Why dont people read the FAQs <jdf@pobox.com>
    Re: Win32 Perl rm -rf Equivalent? <Savage.Ron.RS@bhp.com.au>
        Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)

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

Date: 18 Aug 1998 22:15:02 GMT
From: ehp@gte.net (Ethan H. Poole)
Subject: Re: #!usr/bin/perl is ignored, WHY?
Message-Id: <6rcud6$k6j$1@news-1.news.gte.net>

[Posted and Emailed]  In article <6rcbp1$j03$1@hiram.io.com>, 
tigger@io.nospaam.com says...
>
>Well, without seeing the actual error message from doing a './test.pl', I
>can't say for sure, but my guess is that either your #!/usr/bin/perl isn't
>on the very first line of your script, or it has some bad characters in
>it. Try deleting the first line of the script and redoing it.
>HTH,
>
>Paul Archer
>
>> Could it be that the first command
>> #!usr/bin/perl
>> is ignored?
>
>> Being in the cgi-bin directory (Unix shell), I tried to start another
>> script using:
>> ./test.pl
>> It didn't work, as well. But using:
>> usr/bin/perl test.pl
>> it worked perfectly...

Actually, the problem is more likely to be the missing forward slash after the 
"#!", try "#!/usr/bin/perl" (without the quotes) and see what happens

-- 
Ethan H. Poole            | Website Design and Hosting,
                          | CGI Programming (Perl & C)..
========Personal========= | ============================
* ehp @ gte . net *       | --Interact2Day--
http://home1.gte.net/ehp/ | http://www.interact2day.com/



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

Date: Tue, 18 Aug 1998 16:16:06 -0600
From: John Minnihan <jbminn@greensfeldertech.com>
Subject: Re: can you un encrypt htpasswd?
Message-Id: <35D9FD26.16210B53@greensfeldertech.com>

> stan zylowski wrote:
>
> > can you un encrypt htpasswd file for those that forget it?

I solved my .htpasswd user additions & password maintenance using this
little script:

    http://www.greensfeldertech.com/configman/makeGoodAliases.pl

Have root change the password manually this time, but use this script to
keep your .htpasswd file up-to-date going forward.  It presumes that you'd
like to use yellow pages passwd as a basis for .htpasswd.  I also
construct a mail aliases file from yp passwd as well.  Does this avoid the
"I forgot my password" issue?  No, but it makes user management very
simple.  Allow root to manage the yellow pages passwd file & simply borrow
it for httpd.  If /etc/passwd doesn't map to your user list, this script
will not be helpful.  This is meant for http admins who are managing
intranet apps & thus are likely to have as users those folks already in
/etc/passwd.

--
John Minnihan
President, Greensfelder Technology Corp.
Software Process Improvements
http://www.greensfeldertech.com/configman
303-903-6130




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

Date: Wed, 19 Aug 1998 01:03:47 +0100
From: "Daniel Adams" <dan@fearsome.net>
Subject: Re: comp.lang.perl.announce redux
Message-Id: <903485155.14302.0.nnrp-11.c2deb1c5@news.demon.co.uk>

Actually, Paddy was entirely correct in what he said. The language known as
English is documented in dictionaries such as the Oxford English Dictionary.
American English, whilst stemming from the same origins as British English,
is sufficiently different to be classified as a different language. That is
why many products ship with electronic dictionaries in which American
English and British ENglish are two options.

That is not to say that British English (more commonly just called "English"
is more "English" than American English (you following? ;-)
In fact, as many linguistic experts will tell you, many aspects of American
English are more closely related to Old English then is current day British
English.

Of course, the whole issue is clouded by the fact that American
ENglish-speakers can understand British English-speakers (most of the time!)
and so the question of true language divisions is brought into question.
However, the divisions between American English and British English are too
great to fall under any lesser category of divission (such as "dialect") and
have reached a stage where they are two seperate languages in their own
right. However, people in Britain can't lay any more claim to English proper
or "real" English than Americans - Americans speak American English and
Britons speak British English, that is all.

To use an analogy, think of species development - if you accept evolution as
at least premise if not proven (as anyone bar a neanderthal fundamentalist
would do - but lets leave that for another ng shall we?) then all species
developed from an early species - basically two species (lets call them AE
and BE) developed from an earlier organism. SLowly, AE and BE evolved into
different organisms although they served a common root. At no generation was
there a sudden divergence where AE was suddenly different from BE, they just
slowly evolved apart until the stage where they warranted being referred to
as different species.

The point has come where American English and British English have diverged
sufficiently that it is useful (for those writing electronic dictionaries,
if nothing else) to refer to them as two seperate languages, and that is
what they are. If you disagree, teach your (American) children to spell
words as the British do and you'll see what I mean.

<phew> that was a long (and off-topic) post.

Dan Adams
dan@fearsome.net
Tom Christiansen wrote in message <6q9p22$6ii$1@csnews.cs.colorado.edu>...
>In comp.lang.perl.misc, paddy.spencer@parallax.co.uk writes:
>:: I am a native speaker of English,
>:Not if you're American you're not - and I don't know if you are or not.
>
>What you say there I have heard before, and it is a terrible injustice,
>nothing but a way of putting down anyone else whose language is English
>but who doesn't happen to live in England.  It's a totally ludicrous
>proposition, as any linguist will quickly report.  Next time you're in
>a bookstore, I recommend you pick up Fowler's Modern English, which has
>a word or two to say about this matter -- and many others.
>
>Now, if you insist, I am perfectly pleased to scribe these notes in
>non-English, mais j'ai peur che gli altri no me vayan a entender bien
>wenn ich such words write.  *THAT* was not English, but what I
>customarily scrawl here most certainly is.  Do you truly not see
>the difference, or is this just more posturing?
>
>So I shall continue to write in this, my native tongue, and I and a
>quarter billion others would greatly appreciate it if you and yours
>would be so kind as to stop propagating your provincial prevarications
>that Americans neither speak nor write English.  It's a divisive lie
>with no basis in honest linguistics.
>
>However, I am happy to encourage others to write as they best can
>in whatever language they choose, and I shall try my very best to
>understand them.  I would hope that you might do the same.
>
>--tom
>--
> Nuclear war doesn't prove who's Right, just who's Left (ABC news 10/13/87)




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

Date: 18 Aug 1998 18:50:39 -0500
From: tye@fumnix.metronet.com (Tye McQueen)
Subject: Re: Continuing misunderstanding of symbol table manipulation (was Re: Have package use another symbol table?)
Message-Id: <6rd40f$enh@fumnix.metronet.com>

gbacon@cs.uah.edu (Greg Bacon) writes:
)
) That's very odd.  Consider this program:
) 
)     #! /usr/bin/perl -w
) 
)     use strict;
) 
)     $FOO::x = 10;
)     $BAR::x = 20;
) 
)     %BAR:: = %FOO::;
)     print "\$FOO::x = $FOO::x\n";
)     print "\$BAR::x = $BAR::x\n";
) 
) When run from the command line, I get this output
) 
)     $FOO::x = 10
)     $BAR::x = 20
[...]
) Apparently, it's working as you (and I) would expect in the debugger.
) A bug?

I think it is just Perl optimizing access to $FOO::x.  If Perl
had to access %FOO:: every time it had to access a variable
from the FOO package, scripts would run slower.  When Perl
compiles code, it replaces uses of variables with more efficient
references than the equivalent of $FOO::x{SCALAR}.

Perhaps C< $BAR::{x}= $FOO::{x} > "flushes the cache" but
C< %BAR::= %FOO:: > does not [which doesn't surprise me since
it is a pretty strange thing to do].  The "fix" might slow down
this operation in cases when you don't need to do that work.

I suggest you just write:

    %BAR::= ();	# Does this line introduce a bug?
    foreach $key ( keys %FOO:: ) { $BAR::{$key}= $FOO::{$key}; }

But I'm no expert on this.
-- 
Tye McQueen    Nothing is obvious unless you are overlooking something
         http://www.metronet.com/~tye/ (scripts, links, nothing fancy)


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

Date: 18 Aug 1998 17:32:14 -0700
From: znanie@best.com (Kirill Sapelkin)
Subject: Converting pod's to a Latex Book
Message-Id: <znanie.903486563@shell5.ba.best.com>
Keywords: pod's latex

Where can I find instruction to convert the pod's or the texi's on CPAN
to a proper Latex Book with TOC and index?

The postscript doc's do not seem to have a very good TOC and maybe no
index.  A book of that large size (1000+ pages) should have both, I think.

Kirill


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

Date: 18 Aug 1998 21:31:09 GMT
From: randy@theory.uwinnipeg.ca (Randy Kobes)
Subject: Re: difference between dates
Message-Id: <slrn6tjt3v.l3g.randy@theory.uwinnipeg.ca>

On Tue, 18 Aug 1998 17:36:03 GMT, HeliSpot <news@helispot.com> wrote:
>I'm running a database site (mysql), and I want to flag items
>displayed as "new" if they were added less then 30 days prior to the
>system date.  The added-date is a field in the database.
>
>Is there an easy way to do this in perl?
>
>Something along the lines of:
>
>if (formula < 30)  {
>	print "new" ;
>}
>
>Thanks.
>
>Alex
>HeliSpot
>news@helispot.com
>

Hi,
   In the generic case, you would want to formulate the query
along the lines of
	select * from table where ( ($today - added_date) <= $age )
where $age is the maximum age in days the entry should be, added_date
is the field containing the date the entry was added, and $today
is today's date. $today should be in the same format as added_date,
which you can gather from 
	perldoc -f localtime. 
However, mysql contains the function curdate() which gives today's
date in the desired format already, so in this case the query
	select * from table where ( (curdate() - added_date) <= $age )
would work.
-- 
		Best regards,
		Randy Kobes

Physics Department		Phone: 	   (204) 786-9399
University of Winnipeg		Fax: 	   (204) 774-4134
Winnipeg, Manitoba R3B 2E9	e-mail:	   randy@theory.uwinnipeg.ca
Canada				http://theory.uwinnipeg.ca/


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

Date: 18 Aug 1998 18:36:00 -0500
From: tye@fumnix.metronet.com (Tye McQueen)
Subject: Re: Dynamic scoping across closures?
Message-Id: <6rd350$c11@fumnix.metronet.com>

tbhudso@panther.cs.sandia.gov (Tramm Hudson) writes:
) 
) I seem to have run into a mental problem with dynamic scoping
) and calls into closures across package boundaries.

They don't really have much to do with each other.

Closures work with lexically scoped variables (created via
C<my>) which have no package association.

Accessing another package's variables is no different when
done from a closure as when done from a "normal" subroutine.
-- 
Tye McQueen    Nothing is obvious unless you are overlooking something
         http://www.metronet.com/~tye/ (scripts, links, nothing fancy)


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

Date: Tue, 18 Aug 1998 12:41:00 -0700
From: Monika Machado <mmachado@hmsi.com>
Subject: Re: filehandle in CGI.pm
Message-Id: <35D9D8CC.EF2977F3@hmsi.com>

I.J. Garlick wrote:

> > i always get zero bytes in b.html. where am i doing wrong?
> >
> > thx for any help.
>

I have (still) the same problem, 0 bytes,  in the upload file if  the user
uploading the file is using a proxy.Look in your proxyes configuration.

> Oh. One further thought, where are you printing the Content-Type header
> line bfore or after you read and print out the file?
>
> It's just a thought as I have had problems with this but cannot remember
> exactly if it was to do with this.
>
> --
> --
> Ian J. Garlick
> ijg@csc.liv.ac.uk
>
> Your conscience never stops you from doing anything.  It just stops you
> from enjoying it.





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

Date: 18 Aug 1998 22:03:59 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: here's an implementation of diff in perl
Message-Id: <6rctof$ivr$2@client3.news.psi.net>

Greg Bacon (gbacon@cs.uah.edu) wrote on MDCCCXIII September MCMXCIII in
<URL: news:6rcfp2$rfm$21@info.uah.edu>:
++ In article <6rcf1b$jug$1@pegasus.csx.cam.ac.uk>,
++ 	mjtg@cus.cam.ac.uk (M.J.T. Guy) writes:
++ : In article <6rcdf6$rfm$20@info.uah.edu>,
++ :   Greg Bacon <gbacon@cs.uah.edu> wrote:
++ : >O(n + n lg n) is the same as O(n lg n).
++ : 
++ : What's that got to do with Abigail's (correct) statement?
++ 
++ It takes O(n) comparisons to check whether a set is already sorted.

Goodie. I take a sorted array. I swap the last and the last but one
element. I spend O (n) to check if it's sorted. It's not.

Then what? Quicksort still doesn't take O (n log n) to sort that array.

++ This is a simple approach, but most modern implementations of quicksort
++ do something to avoid quicksort's O(n**2) worst case.

That would be bad, as the overhead to garantee O (n log n) behaviour
tends to be a lot. Randomized versions of quicksort take O (n log n)
expected time. But that doesn't make quicksort O (n log n).



Abigail
-- 
perl -MNet::Dict -we '(Net::Dict -> new (server => "dict.org")\n-> define ("foldoc", "perl")) [0] -> print'


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

Date: 19 Aug 98 00:14:33 GMT
From: "Glenn Robards" <robards@jps.net>
Subject: I need help with Hello World--Only works when modified to one line separated by black rectangle
Message-Id: <01bdcb07$4ce61a80$08c7efd1@default>

Help;
How do I get from a simple perl text like this:
#!/usr/bin/perl
# Location of the perl program, this is important!!!


print <<__END__;
Content-Type: text/html

<html><head><title>Hello World</title></head>
<body bgcolor=#ffffff text=#000000>
<center><h2>Hello World</h2></center>
</body></html>
__END__

To a file that is one line no cr lf with a solid rectangle that replaces cr
lf 
I tried to look at one of the faqs, but I sure would like help on this. I
am using JPS.NET that's http://www.jps.net/
Does anyone know how to accomplish this on JPS.NET ?




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

Date: Tue, 18 Aug 1998 15:55:16 -0700
From: Brian Tiemann <briant@packeteer.com>
Subject: Re: MD5 and perl
Message-Id: <35DA0654.9F544885@packeteer.com>

John Porter wrote:

> No, that isn't Perl's entire philosophy.
> Part of Perl's philosophy is to be able to glue together
> bits of code written in other languages.
> And C is rather portable too, so it makes a natural choice
> for writing the bits of code that need to be fast.

	True enough. It's just that when we're dealing with Win32, where one
can't guarantee that all one's target audience will have a C compiler
handy, these issues become much thornier.

	In the age of eyes-rolled-heavenward acquiescence to having to code for
interoperability with both UNIX and Windows, perl becomes an outstanding
choice for building applications-- as long as it's guaranteed that all
the glued-together bits will work wherever they're run. That's what
eventually forced me to quit using `date` and switch to localtime(). :)

	Not to refute your point at all. Just pointing out that sometimes
perl's ability to stand completely on its own is its biggest asset.

Brian


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

Date: 18 Aug 1998 17:53:17 -0500
From: Jonathan Feinberg <jdf@pobox.com>
To: tfo@telalink.net (Thomas Frederick O'Connell)
Subject: Re: mv, move, or some way to move files in perl
Message-Id: <af51297m.fsf@mailhost.panix.com>

tfo@telalink.net (Thomas Frederick O'Connell) writes:

> to move directory trees across filesystems in perl? i could have
> sworn that there used to be a mv function in File::Copy, but when i
> went looking today, it wasn't there.

Hmm.  It's in both 5.004 and 5.005.  What perl version do you have?
Oh, BTW, it's called move(), not mv().  perldoc File::Copy.

-- 
Jonathan Feinberg   jdf@pobox.com   Sunny Brooklyn, NY
http://pobox.com/~jdf/


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

Date: 18 Aug 1998 22:50:43 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: mv, move, or some way to move files in perl
Message-Id: <6rd0g3$c1s$2@nswpull.telstra.net>

In article <tfo-1808981639470001@jesus.telalink.net>,
	tfo@telalink.net (Thomas Frederick O'Connell) writes:
> is there a good way other than
> 
> system( "mv ..." );
> 
> to move directory trees across filesystems in perl? i could have sworn
> that there used to be a mv function in File::Copy, but when i went looking

It's still there. You might need a failry recent version of perl. I'm
not sure which version included it initially.

> today, it wasn't there. but my memory of looking for something similar is
> about a year old, so i could be wrong. i would also rather avoid
> 
> copy( ... );
> unlink( ... );

You could try a rename(), and if that fails, fall back on a use
File::Copy; cp() (check the return value), followed by an unlink. That
is basically how mv(1) does it on some systems as well.

I don't know how much better it is than a system(mv), but it's at
least more portable.

> why isn't there a File::Move module, incidentally?

feel free to write one and submit it to CPAN :)

Martien
-- 
Martien Verbruggen                      |
Webmaster www.tradingpost.com.au        | "In a world without fences,
Commercial Dynamics Pty. Ltd.           |  who needs Gates?"
NSW, Australia                          |


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

Date: Tue, 18 Aug 1998 23:09:02 GMT
From: julzrulz@my-dejanews.com
Subject: pattern matching with parenthesis
Message-Id: <6rd1id$ei9$1@nnrp1.dejanews.com>

unless (open (SAM, "$SAMFILE")){
 	&CgiDie ("Can't open $SAMFILE: $!");
}
while (<SAM>) {
	chomp;
	next unless $_;
	@field = split(/\t/);
	$next = 0;
if ($in{'class'}) {
    $next = 0;
	foreach $pat (split(/\0/,$in{'class'})){
	    if ($field[4] =~ /$pat/i) {
		$next = 1;
		$found = 1;
		last;
	    }
	}
			next if !$next;
}

push (@file, $_) if $next;
}     # end while loop

<select name="class">
<option value="ACM (SHORE)">ACM (SHORE)</option>
Stored in SAMFILE as ACM (SHORE)

What I am doing is getting the value of class from a form.
I'm comparing that value against each line in the SAMFILE.
What I'm finding is this works on every single item,
except those with () parenthesis in the word.
Why is this? Some items have -, or /, and the match still works,
but the match doesn't work on ().  Is this some kind of bug?
I am using cgi-lib.pl.
Thanks,
julzrulz@my-dejanews.com



-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum


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

Date: Tue, 18 Aug 1998 18:12:30 -0400
From: "Pete Keefe" <pkeefe@ix.netcom.com>
Subject: Re: Performing an Access query from Perl
Message-Id: <6rcu7t$jgp@dfw-ixnews8.ix.netcom.com>

Maybe this will help:
1.  You either must register the database in the ODBC manager (in Control
Panel) as a system dataset or use the ConfigDSN to do it from Perl.
2.  From you code fragments, I can not tell if $O was ever initialize
properly.. here is an example that works:
    use Win32::ODBC;

    #  establish a object that points to a database
    $query = new Win32::ODBC("ServerData") # ServerData is a pre-registered
system dataset
         or die "Error opening ODBC srvdata file $!";

    $sql = "SELECT * FROM servers;"; # SQL query statement (servers is a
table)

    $rc = $query->Sql($sql);    # Execute SQL, return code into $rc

    if ($rc) {         # check for bad result
         print $query->{'ErrText'} . "\nExiting!\n";  # Print error message
         $query->Close();     # close the object on error
         exit;
    }
     while($query->FetchRow) {    # get one row at a time from result set
         print $query->Data . "\n";   # print all columns of one row
     }
    $query->Close();

good luck
Pete

Sucheta Khot wrote in message <35D9E055.7D6B@nmtec.com>...
>Could anybody please answer my questions:-
>
>I am getting an error:
>Use of uninitialized value at peppersearch.pl line 12.
>Cannot open ODBC connection to "Article":911[Microsoft][ODBC Driver
>Manager] Dat
>a source name not found and no default driver specified
>
>Where line 12 is :
>my($db) = new Win32::ODBC($DSN) ||
>        die qq{Cannot open ODBC connection to "$DSN":},
>Win32::ODBC::Error, qq{\n}; #******** METHOD I *************
>
>There is an Access database called 'Article' exising in the same
>directoty as of the perl script.
>
>Instead, if I use,
>if (Win32::ODBC::ConfigDSN(ODBC_ADD_DSN, $DriverType, ("DSN=$DSN",
>"Description=The Win32 ODBC Test DSN for Perl", "DBQ=$Dir\\$DBase",
>"DEFAULTDIR=$Dir", "UID=", "PWD="))){
> print "Successful!\n";
>}else{
> print "Failure\n";
>} #****************METHOD II******************
>
>where,
>    $Dir = `cd`;
>    $DBase = "Article.mdb";
>
>Then, I can successfully add the DSN and then if I use 'new' method to
>open a connection to the database, i can do it successfully.
>Q1. BUT Why this same is not working without using
>Win32::ODBC::ConfigDSN method?
>Q2. If I use method II, then further in my code code if I place a query
>such as,
>        $stmt = "Select * from BugSpec";
>        $rc = $O->Sql($stmt);
>        die qq{SQL failed "$stmt": }, $O->Error(), qq{\n} if $rc;
>
> Then, nothing is happening, why? How should I print the result of this
>query to the screen?
>
>Thank you.




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

Date: 18 Aug 1998 16:02:32 -0500
From: "Jim Woodgate" <jdw@dev.tivoli.com>
Subject: Re: Period.pm or any other time module
Message-Id: <obyasmhul3.fsf@alder.dev.tivoli.com>


Anthony Lee-Masis <anthony@nc.com> writes:
> I have a problem i hope you can help with. I need to somehow find out if
> a certain day falls within  a period of a week or 2 weeks.
> 
> Example given the range 7/2/98 - 7/19/98
> Now given the date 7/14/98 , does this date fall within the range. I
> need to find out how to do that. I poked around CPAN and found a module
> called Period.pm and have tried to implement that. The closest i could

Using Time::Local, you could compute time for each date, then simply
compare the time values.  (I didn't check Time::Local very closely,
but I'm guessing you have to subtract one from the month)


use Time::Local;

my $start_period = timelocal (0, 0, 0,  2, 6, 98);
my $stop_period  = timelocal (0, 0, 0, 19, 6, 98);

my $check_date   = timelocal (0, 0, 0, 14, 6, 98);

if ( $check_date >= $start_period &&
	$check_date <= $stop_period ) {
  # insert code here...
}

-- 
Jim Woodgate 
Tivoli Systems
E-Mail: jdw@dev.tivoli.com


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

Date: 18 Aug 1998 22:34:47 GMT
From: Zenin <zenin@bawdycaste.org>
Subject: Re: Perl Style
Message-Id: <903480320.76087@thrush.omix.com>

John Porter <jdporter@min.net> wrote:
: Zenin wrote:
        >snip<
: > The only reason "||" doesn't say "or" to one's mind as quickly or
: > faster even then "or" is simply because they haven't been
: > programming in C styled languages for long enough.
        >snip<
: By that token (:-) it can be considered a "bug" to argue that
: one should use "or" for readability.

        Yes, this is my point.

        BEGIN {
            $programmer =~ /read perl code/
                or exec 'perldoc', 'perlsyn';
        }

: I use "or" for exactly
: one reason: it's a low-precedence alternation conjunction.

        Yes, for exactly the "right" reason. :-)

: So what if it's written "or".  As has been pointed out, it could
: have been any cryptic sequence of chars... \/ or whatever.

        Again, this is my point, more or less.

-- 
-Zenin (zenin@archive.rhps.org)           From The Blue Camel we learn:
BSD:  A psychoactive drug, popular in the 80s, probably developed at UC
Berkeley or thereabouts.  Similar in many ways to the prescription-only
medication called "System V", but infinitely more useful. (Or, at least,
more fun.)  The full chemical name is "Berkeley Standard Distribution".


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

Date: Tue, 18 Aug 1998 21:19:49 GMT
From: pat@uni.de (Patrick Clauberg)
Subject: Re: quotemeta
Message-Id: <35d9ef3b.214391@news.nef.wh.uni-dortmund.de>

On Tue, 18 Aug 1998 12:38:34 -0400, John Porter <jdporter@min.net>
wrote:

>Patrick Clauberg wrote:
>> 
>> I have mp3 files like artist # song.mp3 and want to get artist
>> and song into my database
>> 
>> if ($file =~ /^(\w+\s+.*)+\s*#\s*(\w+\s*.*).mp3/) {
>
>Um, what's wrong with
>
>	( $artist, $song ) = split /\s*#\s*/, $file;

well I have to chek out, if the file is of the artist # song.mp3
format at all.

Since there are lots of files, which either aren't mp3s or are mp3s
but do not have names like this, I have to test in any way, if the
split thing is applicable

I really would like to know ,if I could do a unquotemeta or something
like this.

Thx

Patrick



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

Date: 18 Aug 98 22:34:55 GMT
From: Zenin <zenin@bawdycaste.org>
Subject: Re: Recommend a good editor
Message-Id: <903480608.236168@thrush.omix.com>

scott@softbase.com wrote:
: Since this thread has degenerated into naming editors at random, I have
: to mention Multi-Edit, my favorite: although it is a commercial
: product, it is only $100, and has many important features that make it
: worth the price. The main one is printing support, which Emacs and
: probably none of the other UNIX ports have in Windows. (Yes, I am aware
: Emacs can generate PS files, but printing those is convoluted and
: certainly not as good as File/Print....) 

        Convoluted?  Does emacs not have a simple way to pipe that
        output (postscript, text, or otherwise) into lpr...?

-- 
-Zenin (zenin@archive.rhps.org)           From The Blue Camel we learn:
BSD:  A psychoactive drug, popular in the 80s, probably developed at UC
Berkeley or thereabouts.  Similar in many ways to the prescription-only
medication called "System V", but infinitely more useful. (Or, at least,
more fun.)  The full chemical name is "Berkeley Standard Distribution".


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

Date: 18 Aug 1998 17:43:02 -0600
From: tbhudso@panther.cs.sandia.gov (Tramm Hudson)
Subject: Re: reference to anonymous scalar?
Message-Id: <6rd3i6$p6$1@panther.cs.sandia.gov>

In article <35D9EF6A.1F11CBFB@lmco.com>,
Brett Denner  <Brett.W.Denner@lmco.com> wrote:
>Is there a similar way to compose a reference to an anonymous
>scalar? (Yes, I do have a need for such a thing.)
>
>    $scalarref = ????

I assume you've tried the simple

$scalarref = \"foo";

but require a reference to a writable scalar.  The Leopard book
(_Advanced Perl Programming_ page 11) has an example
that uses a lexical variable to create an anonymous, read/write scalar.

{
  my $temp_scalar = "foo";
  $scalarref = \$temp_scalar;
}

The $temp_scalar goes out of scope as soon as the block is
exited, but the ref count to the string "foo" doesn't.
You could also write a function to handle this:

sub mk_scalar_ref
{
  my ($scalar) = @_;
  return \$scalar;
}

$scalarref = mk_scalar_ref( "foo" );

Better?
Tramm
-- 
  o   hudson@cs.tulane.edu            tbhudso@cs.sandia.gov   O___|   
 /|\  http://www.cs.tulane.edu/~hudson/     H 505.266.59.96   /\  \_  
 <<   KC5RNF @ N5YYF.NM.AMPR.ORG            W 505.284.24.32   \ \/\_\  
  0                                                            U \_  | 


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

Date: 18 Aug 1998 22:47:31 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: regular expression. Help !!!!
Message-Id: <6rd0a3$c1s$1@nswpull.telstra.net>

In article <6rcr5o$5up$1@nnrp1.dejanews.com>,
	nguyen.van@imvi.bls.com writes:

> For instance, in a file I have the following lines:
> 
> xxxxxxxxxx&crno=1111222&xxxxxxxxx xxxxxxx xxxxxx AOL 3.0
> /?crno=1111111xxxxxxxxx xxxxxxxx xxxxxxxxxx AOL 3.1

As long as these xxxxx behind the 1111 are not digits...
 
> xxxxxxxxxxxxx xxxxxxxx&crno=8757555 xxxxxxx AOL 2.0

> want to do is to pull out from the line only "crno=number" (i.e crno=1111222,
> etc) and AOL X.X (i.e AOL 3.0, etc). Your help is highly appreciated.


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

use strict;

while (<DATA>)
{
	chomp;
	my ($crno, $aol) = m|crno=(\d+).*AOL (.*)|;

	print "$crno - $aol\n";

	my ($crno_full, $aol_full) = m|(crno=\d+).*(AOL .*)|;

	print "$crno_full - $aol_full\n";
}

__DATA__
xxxxxxxxxx&crno=1111222&xxxxxxxxx xxxxxxx xxxxxx AOL 3.0
/?crno=1111111xxxxxxxxx xxxxxxxx xxxxxxxxxx AOL 3.1
xxxxxxxxxxxxx xxxxxxxx&crno=8757555 xxxxxxx AOL 2.0

OUTPUT:
1111222 - 3.0
crno=1111222 - AOL 3.0
1111111 - 3.1
crno=1111111 - AOL 3.1
8757555 - 2.0
crno=8757555 - AOL 2.0

Please, read the following documentation:

# perldoc perlre
# perldoc perlop

Martien
-- 
Martien Verbruggen                      |
Webmaster www.tradingpost.com.au        | "In a world without fences,
Commercial Dynamics Pty. Ltd.           |  who needs Gates?"
NSW, Australia                          |


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

Date: Tue, 18 Aug 1998 23:13:38 GMT
From: rcook@pcug.org.au (Owen Cook)
Subject: Re: Why dont people read the FAQs
Message-Id: <35db0173.1744952@newshost.pcug.org.au>

On Mon, 17 Aug 1998 20:23:08 +0100, Richard Proctor
<Richard@waveney.demon.co.uk> wrote:

>3) The FAQs and Man pages are large, it is sometimes possible
>to miss somthing esoteric (This should be acceptable - I did it once)

Add 3a  The FAQ and Camel book are unintelligible to the uninitiated

The Perl Book, which is copied verbatim in parts, in the perldocs , is
written for people with probably some formal education in computing. I
have no objection to that.

As a person whose life does not depend on perl, I can afford the
luxury of dabbling aroung till I get something to work

Take this from perlre, also the Camel book

{n}    Match exactly n times

{n,m}  Match at least n but not more than m times

{n,m}? Match at least n but not more than m times

The word 'exactly' tends to throw you.

I thought I could use one of the above to check if a Credit card had
16 digits, not 17 or 15, just exactly 16. No matter what combination
of m,n or ? I used, it either found 17 numbers valid, or gave me an
error message.

Reading the Perl book a bit more, the Rules, or how regular
expressions work gives an inkling that exactly meant 'only the first
match need to be exact, but there may be lots of others').

After a couple of hours of non instructive stuffing around, I gave up
and used;

unless((length($CCNumber) == 16) && ($CCNumber=~ /\d{16}/))

Which works fine.

I once sat at a help desk and came to the conclusion that people
didn't read manuals or FAQs because of either,
Impatience developed through the brave new world of instant
gratification, or
The vocabulary was totally alien to the person asking the question
= should never have bought a computer in the first place



Owen

who never should have started dabbling in perl in the first place



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

Date: Tue, 18 Aug 1998 17:08:18 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Why dont people read the FAQs
Message-Id: <MPG.1043b749a70bec7f98976c@nntp.hpl.hp.com>

[Posted to comp.lang.perl.misc and a copy mailed.]

In article <35db0173.1744952@newshost.pcug.org.au> on Tue, 18 Aug 1998 
23:13:38 GMT, Owen Cook <rcook@pcug.org.au> says...
 ...
> unless((length($CCNumber) == 16) && ($CCNumber=~ /\d{16}/))

  unless ($CCNumber =~ /^\d{16}$/)

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


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

Date: 19 Aug 1998 00:26:33 GMT
From: gebis@fee.ecn.purdue.edu (Michael J Gebis)
Subject: Re: Why dont people read the FAQs
Message-Id: <6rd63p$gaf@mozo.cc.purdue.edu>

rcook@pcug.org.au (Owen Cook) writes:

}Take this from perlre, also the Camel book
}{n}    Match exactly n times
}{n,m}  Match at least n but not more than m times
}{n,m}? Match at least n but not more than m times

}The word 'exactly' tends to throw you.

}I thought I could use one of the above to check if a Credit card had
}16 digits, not 17 or 15, just exactly 16. No matter what combination
}of m,n or ? I used, it either found 17 numbers valid, or gave me an
}error message.

}Reading the Perl book a bit more, the Rules, or how regular
}expressions work gives an inkling that exactly meant 'only the first
}match need to be exact, but there may be lots of others').

}After a couple of hours of non instructive stuffing around, I gave up
}and used;

}unless((length($CCNumber) == 16) && ($CCNumber=~ /\d{16}/))

Yup, that works.  But as always, there is another way to do it:
unless($CCNumber =~ /^\d{16}$/)

Which sorta translates to "Start at the beginning of the table, eat
16 cookies, and you must now be at the end of the table."

"$CCNumber =~ /\d{16}/\" sorta translates to "Somewhere on the table,
find and eat exactly 16 cookies."  It did that, and if you would
examine the matched text, you would see that it contained exactly 16
digits--16 cookies were eaten.  Unfortunately, there are still cookies
on the table.

I don't know if I've confused you, but I swear, I was just trying to
give some insight as to why things didn't work as expected.  Hope I
didn't fail.


-- 
Mike Gebis  gebis@ecn.purdue.edu  mgebis@eternal.net


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

Date: 18 Aug 1998 20:47:07 -0500
From: Jonathan Feinberg <jdf@pobox.com>
To: rcook@pcug.org.au
Subject: Re: Why dont people read the FAQs
Message-Id: <af519204.fsf@mailhost.panix.com>

rcook@pcug.org.au (Owen Cook) writes:

> The Perl Book, which is copied verbatim in parts, in the perldocs

No: the perl docs are copied in the Camel book.

-- 
Jonathan Feinberg   jdf@pobox.com   Sunny Brooklyn, NY
http://pobox.com/~jdf/


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

Date: 18 Aug 1998 23:21:27 GMT
From: "Ron Savage" <Savage.Ron.RS@bhp.com.au>
Subject: Re: Win32 Perl rm -rf Equivalent?
Message-Id: <01bdcb00$33954120$8aeb1286@steelres-pcm657.resmel.bhp.com.au>

File::Path's rmtree.
-- 
Ron Savage
Home (preferred): rpsavage@ozemail.com.au
Office: Savage.Ron.RS@bhp.com.au
http://www.ozemail.com.au/~rpsavage




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

Date: 12 Jul 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Special: Digest Administrivia (Last modified: 12 Mar 98)
Message-Id: <null>


Administrivia:

Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.

If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu. 


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". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". 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". It appears twice
weekly in the group, but is not distributed in the digest.

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 V8 Issue 3478
**************************************

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