[10333] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3926 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Oct 8 04:07:11 1998

Date: Thu, 8 Oct 98 01: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           Thu, 8 Oct 1998     Volume: 8 Number: 3926

Today's topics:
    Re: "Many Jars" Mystery (David Adler)
    Re: "Many Jars" Mystery (Tye McQueen)
    Re: "restoring" hard references pcbel@my-dejanews.com
    Re: A numbering issue (David A. Black)
    Re: Are there any "perl.newbie" group or forum? <jeff@vpservices.com>
        Back Button in Perl - oops (Marc Bissonnette)
    Re: Back button in Perl? <Tony.Curtis+usenet@vcpc.univie.ac.at>
    Re: Can't generate HTML! Why??? (David Adler)
    Re: cat reese > /dev/null (was Re: Perl & Java - differ (David Adler)
    Re: Compile <nguyend7@msu.edu>
        cross-platform module installation <aravind@genome.wi.mit.edu>
    Re: cross-platform module installation <zenin@bawdycaste.org>
        grep //, 'abc' somethings returns empty array <stuart@dtm.com.au>
    Re: grep //, 'abc' somethings returns empty array <rra@stanford.edu>
        Help!  What's wrong with $string =~ s/$pattern/$replace (Ian Underwood)
    Re: Help!  What's wrong with $string =~ s/$pattern/$rep <zenin@bawdycaste.org>
        HELP <csqy65@postoffice.pacbell.net>
        high level (UNIX) system summary <bruce.w.mohler@saic.com>
    Re: high level (UNIX) system summary <rra@stanford.edu>
    Re: How to match exactly x occurrences of a character (Leslie Mikesell)
    Re: Http post and SSL (brian d foy)
    Re: Need help refining this <ebohlman@netcom.com>
        Perl's OO design / name space / stuff like that (was: R <zenin@bawdycaste.org>
        Please HELP!!!! Database search output  format <sroque@man.amis.com>
    Re: Problem passing values to represent arrays names. (David A. Black)
    Re: reg-exp: "Buy!!!" -> "Buy!" ? (Bart Lateur)
    Re: Searching a string.... (Mike)
        stat() return of mode is wierd... kevin@zippy.tnet.com
    Re: stat() return of mode is wierd... <rra@stanford.edu>
    Re: What perl modules do I have??????? <qdtcall@esb.ericsson.se>
        Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)

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

Date: 8 Oct 1998 05:20:24 GMT
From: dha@panix.com (David Adler)
Subject: Re: "Many Jars" Mystery
Message-Id: <6vhi2o$63g@news1.panix.com>

On 7 Oct 1998 20:21:06 +0100, Jonathan Stowe <gellyfish@btinternet.com> wrote:
>To bring this back somewhere into orbit around Planet Perl - The venue of
>the recent London.pm meet had a damn fine pint of bitter at a very reasonable
>#1.50 .

Ah, but you leave out the *important* info - which pub???

dave, who is planning on being in london in the next couple of months...

-- 
David H. Adler - <dha@panix.com> - http://www.panix.com/~dha/
The Teletubbies are coming to America.
They must be stopped!


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

Date: 8 Oct 1998 01:19:05 -0500
From: tye@fumnix.metronet.com (Tye McQueen)
Subject: Re: "Many Jars" Mystery
Message-Id: <6vhlgp$bru@fumnix.metronet.com>

lr@hpl.hp.com (Larry Rosler) writes:
) John "Many Jars" Porter
) baby mother hospital scissors creature judgment butcher engineer

Oh, I _like_ that song.  Toy piano and everything!

But I don't know what "Many Jars" refers to.  Though as
written it sounds like something from Planet 10.  His
Organization: header doesn't say Yoyodyne, does it?
-- 
Tye McQueen    Nothing is obvious unless you are overlooking something
         http://www.metronet.com/~tye/ (scripts, links, nothing fancy)


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

Date: Thu, 08 Oct 1998 06:49:08 GMT
From: pcbel@my-dejanews.com
Subject: Re: "restoring" hard references
Message-Id: <6vhn94$hgi$1@nnrp1.dejanews.com>


> When the script runs, you can use `local' to alias %somehash to the
> language you want.   Let's say that on a particular run, you happen to
> want the current language to be Dutch:
>
> 	$cur_language = 'dutch';
> 	local *somehash = $lang_hash{$cur_language};
>
> 	$somehash{'foo'}; # Gets `foo' item from db_dutch.

Thanks, that works just great!

Thanks to all who have helped, either by posting here, or emailing me
directly.

Peter *somehash Bel

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Wed,  7 Oct 1998 09:28:51 EDT
From: dblack@saturn.superlink.net (David A. Black)
Subject: Re: A numbering issue
Message-Id: <6vfqaj$cav$1@earth.superlink.net>

Hello -

"Chavez" <isafold@worldnet.att.net> writes:

>I am fairly new to Perl and would appreciate any help the list has to
>offer.  

>sub descend { $b <=> $a};
>@actual = sort descend keys %data;
>foreach $count (0..6) {
>	$list = $count + 1;
>	$first = $data{$actual{$count]} [0];
>	($one,$two) = split / /,$first;
>	print $list\t$actual[$count]\t$names{$one}\t$names{$two}\n";
>	$place=1;
>	while ($wreh = $data{$actual[$count]}[$place]) {
>		($foo,$bar) = split / /,$wreh;
>		print "=\t$actual[$count]\t$names{$foo}\t$names{$bar}\n";
>		$place++;
>	}
>}

>What this part of the script does is read the keys from %data and print
>them out in descending order.  If some of the keys are of equal value the
>script will print out an equal sign instead of the next number
>ie..1,2,3,=,=,=,4,5....  What I would like to happen is for each individual
>key to get a number ie..1,2,3,4,5,6,...and so on.


I'd say what this code does is to trigger a fatal error message.
But anyway....  I'm not at all sure what you're trying to do.  A hash's
keys are unique; no two keys of %data can be equal to each other.

Could you explain a little more, or perhaps post a complete, working
example (including the kind of data you are using)?

David Black
dblack@saturn.superlink.net


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

Date: 8 Oct 1998 07:02:36 GMT
From: Jeff Zucker <jeff@vpservices.com>
To: madame philosophe <mp@mkt2mkt.com>
Subject: Re: Are there any "perl.newbie" group or forum?
Message-Id: <361C62CA.65EF53C7@vpservices.com>

My $0.02 is no, there probably shouldn't be a separate newbie group, and
no, seasoned posters should not be required to answer the same old
questions again and again. But ...

Let's look at this as a signal to noise ratio: for every "clueless"
posting on clpm, there are two or three flame resposnes to it, which
makes three or four worthless messages on the group.  What about the
value of resounding silence?  I ask a stupid question and no one bothers
to reply, hmm, maybe I should rephrase it more intelligently or try
somewhere else.  

Heck, I enjoy a good flame as much as the next person, but I don't
really enjoy the endless, pointless flames on the same RTFM topic - it
sours the tone of the group and multiples the number of messages I scan
and wish I hadn't.  I don't really think the perl community is made up
of 12 year old boys (of all genders and ages) but some days it sure
sounds like that.

- Jeff Zucker


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

Date: 8 Oct 1998 04:28:08 GMT
From: dragnet@internalysis.com (Marc Bissonnette)
Subject: Back Button in Perl - oops
Message-Id: <6vhf0o$5s7$1@news.interlog.com>

Damn, my ISP's news server hasn't caught up with my response to Abigail yet, so 
I'm posting my "oops" as a new article. 

Just realized the flaw in my logic regarding embedding the originating document 
name within the page to be linked "back" to: It'll only work one level back, 
then it's an endless loop, as Abigail's page indeed points out. 

I suppose it *could* be done by saving the path of docs viewed in a DB, server 
side, but that's turning a simple "back" idea into a huge project. 

Shoulda thought about it more before posting.

I'll line my clothes with asbestos now.

-- 
Marc Bissonnette
InternAlysis
Corporate Internet Research and Results!
http://www.internalysis.com



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

Date: 08 Oct 1998 09:54:47 +0200
From: Tony Curtis <Tony.Curtis+usenet@vcpc.univie.ac.at>
Subject: Re: Back button in Perl?
Message-Id: <83emsjsd2w.fsf@vcpc.univie.ac.at>

Re: Back button in Perl?, Abigail <abigail@fnx.com>
said:

Abigail> It will hopelessly confuse a reader, specially if
Abigail> he uses both your "back button" and his readers
Abigail> back button.

All too true.  Especially when you consider that "back"
buttons often end up being "forward" buttons.  If I jump
into lesson 5 of a tutorial, selecting "back to 4" is
actually going forward because lesson 4 is certainly not in
my browser's history.

-- 
Tony Curtis, Systems Manager, VCPC,    | Tel +43 1 310 93 96 - 12; Fax - 13
Liechtensteinstrasse 22, A-1090 Wien,  | <URI:http://www.vcpc.univie.ac.at/>
"You see? You see? Your stupid minds!  | private email:
    Stupid! Stupid!" ~ Eros, Plan9 fOS.| <URI:mailto:tony_curtis32@hotmail.com>


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

Date: 8 Oct 1998 05:40:24 GMT
From: dha@panix.com (David Adler)
Subject: Re: Can't generate HTML! Why???
Message-Id: <6vhj88$63g@news1.panix.com>

On Thu, 01 Oct 1998 08:13:41 -0700, Kenneth Hunt <kchunt@mail.hac.com> wrote:
>Also, the server at my job is set up for Perl4. Although the SysAd says
>I can invoke Perl5 at the initial command line: #/usr/local/bin/Perl5.

Hopefully he also advised you that this is in fact what you should do
in just about all circumstances.  Perl 4 is dead, it wouldn't voomf if
you put 4000 volts through it, If you hadn't nailed it to the perch
It'd be pushing up the daisies.  This is an ex-perl.

on a more serious note, there are an overwhelming number of reasons
not to use perl 4 (unless you're just fooling around) - this was
discussed to death here, probably more than once (surprise!)... check
dejanews.

What your admin should probably do is make 5 'perl' and set up
#u/l/b/perl4 for those who want it... :-)

-- 
David H. Adler - <dha@panix.com> - http://www.panix.com/~dha/
"Well, sure, being a ruthless godless dictator is fun, but it's all
about the fans!"


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

Date: 8 Oct 1998 05:43:11 GMT
From: dha@panix.com (David Adler)
Subject: Re: cat reese > /dev/null (was Re: Perl & Java - differences and uses)
Message-Id: <6vhjdf$63g@news1.panix.com>

On 7 Oct 1998 20:32:00 GMT, Walter Tice USG <tice@hunch.zk3.dec.com> wrote:

>In article <360C4E84.4621A333@bbnplanet.com> Elaine -HappyFunBall-
Ashton <eashton@bbnplanet.com> writes:

>>Adam Turoff wrote:
>
>>> With all due respect, John, I think George is playing the
>>> 'if 6 turned out to be 9' game.
>
>>Well, darling, men do seem to have an knack for exaggeration ;)
>>*mwaahahaa*
>
>Exaggeration? Or Hendrix tune?

Both!  It's a floor wax *and* a dessert topping!

>'If six turned out to be nine, I don't care!'

Hmm... I actually know Todd Rundgren's cover better, but isn't that q/I
don't mind/ ?

-- 
David H. Adler - <dha@panix.com> - http://www.panix.com/~dha/
"...for all you know we're a bunch of malcontents who couldn't get
sci.corned-beef, and are going to reject all the submitted articles
that aren't about corned beef." - Mark-Jason Dominus


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

Date: 8 Oct 1998 05:20:43 GMT
From: Dan Nguyen <nguyend7@msu.edu>
Subject: Re: Compile
Message-Id: <6vhi3b$5rb$1@msunews.cl.msu.edu>

Commitman <commitman@digitalnet.com.br> wrote:
: How can I compile some perl program ??
Why?

Isn't perl fast enough for you?  If it's not try doing a rewrite of
the code.  If it's not that.  Could it be because you don't want other
people looking at your code.  Try chmoding to 000 and let no one read
it (including yourself).

: Is it possible ?

So you still might wonder if you can compile perl.  Yes you can.  In
version 5.005 and above has a perlcc command.  And the compiler is
also available through CPAN.  However here's the catch.  The compiler
doesn't work very well.  Try compiling your script.  It might
compile.  It might run.  But even if it does both, it won't be faster
than your current perl code.

-dan

-- 
           Dan Nguyen            | There is only one happiness in
        nguyend7@msu.edu         |   life, to love and be loved.
http://www.cse.msu.edu/~nguyend7 |                   -George Sand



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

Date: Wed, 07 Oct 1998 14:56:13 -0400
From: Aravind Subramanian <aravind@genome.wi.mit.edu>
Subject: cross-platform module installation
Message-Id: <361BB94C.17BCD068@genome.wi.mit.edu>


I would like to place CPAN modules that we use on a single machine under

a *custom lib* directory specified using the PREFIX switch when running
perl MakeFile.pl. However, perl *scripts* that use these modules may
live on different machines (and OS). These scripts will access lib on
the
central module repository by including (through a mounted NFS based
path) the central
lib directory in their @INC.

Will such a scheme work? The module may have to be built on all
platforms that scripts will run from to generate the platform dependent
binaries (?)  - and then these directories copied over to the cental lib
area.

Having a central install location would make maintenance easier.

I would appreciate your comments on this problem and on the general
issue of using a central platform independent module repository.

Thank you,

aravind




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

Date: 8 Oct 1998 05:57:54 GMT
From: Zenin <zenin@bawdycaste.org>
Subject: Re: cross-platform module installation
Message-Id: <907826084.462049@thrush.omix.com>

[posted & mailed]

Aravind Subramanian <aravind@genome.wi.mit.edu> wrote:
: I would like to place CPAN modules that we use on a single machine under
: a *custom lib* directory specified using the PREFIX switch when running
: perl MakeFile.pl. However, perl *scripts* that use these modules may
: live on different machines (and OS). These scripts will access lib on
: the
: central module repository by including (through a mounted NFS based
: path) the central
: lib directory in their @INC.

	Just make sure you do *not* use:

	BEGIN { unshift @INC, "/my/lib" }

	As it won't set @INC correctly for OS dependent sub directories.
	Instead, use this:

	use lib '/my/lib';

: Will such a scheme work?

	Yes.

: The module may have to be built on all
: platforms that scripts will run from to generate the platform dependent
: binaries (?)

	Yes.

: - and then these directories copied over to the cental lib
: area.

	Hmm, no.  Not "copied" at least.

	On each target system type (arch + OS), you'll need to do
	a clean:

		perl Makefile.PL PREFIX=/prefix/on/this/exact/system
		make
		make test
		make install
		make realclean

	That make clean is important.  Don't reuse makefiles between
	systems.

	This prefix of course, is the NFS mounted central perl lib
	filesystem.  On each system, you'll get a different path
	like these:

		$PREFIX/lib/perl5/site_perl/i386-freebsd
		$PREFIX/lib/perl5/site_perl/sun4-solaris

	For the OS dependent pieces only.

: Having a central install location would make maintenance easier.

	Oh yes. :-)
-- 
-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: Thu, 08 Oct 1998 17:19:07 +1000
From: Stuart Cunningham <stuart@dtm.com.au>
Subject: grep //, 'abc' somethings returns empty array
Message-Id: <361C676B.C0565B5@dtm.com.au>

When debugging a large and complex perlTk app, was startled
when I used:
  grep //, 'abc'
and the empty array was returned.  I know that the pattern //
will always match any string, so I could not see how this
strange behaviour could come about.  Is it possible that there
is some built-in variable which controls grep or regexes, which
could cause this behaviour?

I'm running  5.004_04 on an HP-UX 10.20 PA-RISC2.0 system,
with Tk version 402.002.



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

Date: 08 Oct 1998 00:38:13 -0700
From: Russ Allbery <rra@stanford.edu>
Subject: Re: grep //, 'abc' somethings returns empty array
Message-Id: <yl3e8zcxlm.fsf@windlord.stanford.edu>

Stuart Cunningham <stuart@dtm.com.au> writes:

> When debugging a large and complex perlTk app, was startled when I used:

>   grep //, 'abc'

> and the empty array was returned.  I know that the pattern // will
> always match any string, so I could not see how this strange behaviour
> could come about.  Is it possible that there is some built-in variable
> which controls grep or regexes, which could cause this behaviour?

// doesn't actually always match any string.  // is a magic regex that is
doing something that you're not expecting.  From man perlop under m//:

             If the PATTERN evaluates to the empty string, the
             last successfully matched regular expression is used
             instead.

The pattern // is special in the context of split(), where it splits
between every character position, but in many other contexts it acts like
the description above.  Note:

        $_ = "foo";
        /foo/;
        print (grep (//, 'abc'), "\n");
        print "---\n";
        print (grep (//, 'foobar'), "\n");
        print "---\n";
        $_ = "bar";
        /ar/;
        print (grep (//, 'foo'), "\n");
        print "---\n";
        print (grep (//, 'bar'), "\n");

produces as output:

        
        ---
        foobar
        ---
        
        ---
        bar

-- 
#!/usr/bin/perl -- Russ Allbery, Just Another Perl Hacker
$^=q;@!>~|{>krw>yn{u<$$<[~||<Juukn{=,<S~|}<Jwx}qn{<Yn{u<Qjltn{ > 0gFzD gD,
 00Fz, 0,,( 0hF 0g)F/=, 0> "L$/GEIFewe{,$/ 0C$~> "@=,m,|,(e 0.), 01,pnn,y{
rw} >;,$0=q,$,,($_=$^)=~y,$/ C-~><@=\n\r,-~$:-u/ #y,d,s,(\$.),$1,gee,print


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

Date: Thu, 08 Oct 1998 04:20:37 GMT
From: science@home.com (Ian Underwood)
Subject: Help!  What's wrong with $string =~ s/$pattern/$replacement/?
Message-Id: <361c3ab6.204784741@news>


I hope this isn't too stupid a questions, but I'm new to Perl, and I'm
having trouble understanding why the following program:

	use strict;

	my $text = "<u><b>Title here</b></u>";
	my $pattern = '<u><b>(.*)</b></u>';
	my $replacement = '<b><u>$1</u></b>';

	my $text1 = $text;
	$text1 =~ s|$pattern|$replacement|;
	print "With variables: ", $text1, "\n";

	my $text2 = $text;
	$text2 =~ s|<u><b>(.*)</b></u>|<b><u>$1</u></b>|;
	print "Without variables: ", $text2, "\n";

prints the following output:

	With variables: <b><u>$1</u></b>
	Without variables: <b><u>Title here</u></b>

How can I define $pattern and $replacement so that the first
substitution has the same effect as the second?  




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

Date: 8 Oct 1998 05:22:28 GMT
From: Zenin <zenin@bawdycaste.org>
Subject: Re: Help!  What's wrong with $string =~ s/$pattern/$replacement/?
Message-Id: <907823961.227518@thrush.omix.com>

[posted & mailed]

Ian Underwood <science@home.com> wrote:
: I hope this isn't too stupid a questions, but I'm new to Perl, and I'm
: having trouble understanding why the following program:
	>snip<
: 	my $replacement = '<b><u>$1</u></b>';

	You'll note that you've got the string '$1' here, which
	will not be evaluated in the replacement pattern:

	>snip<
: 	$text1 =~ s|$pattern|$replacement|;

	As you can see by the output you got:

	>snip<
: 	With variables: <b><u>$1</u></b>
: 	Without variables: <b><u>Title here</u></b>
:
: How can I define $pattern and $replacement so that the first
: substitution has the same effect as the second?  

	You need to eval()uate the string $replacement in the context
	of the replacement, which is a bit ugly to do.  One way is
	like this:

	$text1 =~ s|$pattern|eval "qq($replacement)"|e;

	Warning however: String eval()s can be hazardous to your
	health.  Also, /e is really slow, and tied to an eval() is
	far slower then that.  It's almost like doing:

		eval qq(eval qq($string));

	which is scary to think about... :-/

	If you're not doing this on huge amounts of data though, this
	shouldn't be too bad speed wise, but I wouldn't want to do this
	on an entire web site unless I've got some time to kill. :-)

-- 
-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: Wed, 07 Oct 1998 23:44:35 -0700
From: Jane Vermont <csqy65@postoffice.pacbell.net>
Subject: HELP
Message-Id: <361C5F53.C0D21F50@postoffice.pacbell.net>

How to use perl to remove <!-- html  comment -->  and  <tags>
            thank



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

Date: Wed, 07 Oct 1998 15:50:57 -0700
From: Bruce Mohler <bruce.w.mohler@saic.com>
Subject: high level (UNIX) system summary
Message-Id: <361BF051.C8E10EC8@saic.com>

Has anyone written a Perl script to perform a high level system
summary: hardware (vendor, model, amount of memory, disks,
CD-ROMs, tapes, etc.), software (OS version, patches installed,
common utilities installed, NFS?, NIS?, DNS?, etc.), general
configuration (survey of syslog, password/group files, local
printers configured, backups, etc.).

Nothing ambitious or anything.  :-)  I intend to use the script
(whether I can stand on the shoulders of giants or write it myself)
to create configuration information to generate web pages that
"profile" each of our UNIX boxes.  Having a Perl script means
that I can run it once a month and just e-mail to the web server
to process.

Thanks, in advance.

Bruce

--
Bruce W. Mohler                619-458-2675 (voice)
SAIC/ITS/Server Support        619-535-7806 (fax)
Sr UNIX system administrator   888-781-5697 (pager)
                               mailto:bruce.w.mohler@saic.com
Of course my password is the same as my pet's name.
My dog's name is Q47pY!3, but I change it every 90 days.




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

Date: 08 Oct 1998 00:47:09 -0700
From: Russ Allbery <rra@stanford.edu>
Subject: Re: high level (UNIX) system summary
Message-Id: <ylww6bbima.fsf@windlord.stanford.edu>

Bruce Mohler <bruce.w.mohler@saic.com> writes:

> Has anyone written a Perl script to perform a high level system summary:
> hardware (vendor, model, amount of memory, disks, CD-ROMs, tapes, etc.),
> software (OS version, patches installed, common utilities installed,
> NFS?, NIS?, DNS?, etc.), general configuration (survey of syslog,
> password/group files, local printers configured, backups, etc.).

<URL:http://www.magnicomp.com/sysinfo/sysinfo.shtml>

This won't do everything that you're looking at doing above, but it's a
good place to get started (and better than trying to do it all in Perl,
since a lot of that information requires fairly low-level interfaces to
obtain).

-- 
#!/usr/bin/perl -- Russ Allbery, Just Another Perl Hacker
$^=q;@!>~|{>krw>yn{u<$$<[~||<Juukn{=,<S~|}<Jwx}qn{<Yn{u<Qjltn{ > 0gFzD gD,
 00Fz, 0,,( 0hF 0g)F/=, 0> "L$/GEIFewe{,$/ 0C$~> "@=,m,|,(e 0.), 01,pnn,y{
rw} >;,$0=q,$,,($_=$^)=~y,$/ C-~><@=\n\r,-~$:-u/ #y,d,s,(\$.),$1,gee,print


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

Date: 7 Oct 1998 23:21:15 -0500
From: les@MCS.COM (Leslie Mikesell)
Subject: Re: How to match exactly x occurrences of a character
Message-Id: <6vhejr$44p$1@Jupiter.Mcs.Net>

In article <6vdsnm$1dk$1@client3.news.psi.net>,
Abigail <abigail@fnx.com> wrote:

>++ You almost had it. You just need to move the parense: [^a](aa)[^a]
>
>
>But that fails to match "aafoo" and "fooaa". It will also set pos off
>one position.
>
>Use:   /(?:^|[^a])a{2}(?!a)/    (5.004)
> or:   /(?<!a)a{2}(?!a)/        (5.005)

Would this run faster than adding extra lines for the special cases?
 /^(aa)([^a])/
 /([^a])(aa)$/
 /([^a])(aa)([^a])/

I'd recognize what they mean a lot faster than the combined version.

 Les Mikesell
   les@mcs.com


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

Date: Thu, 08 Oct 1998 02:35:21 -0400
From: comdog@computerdog.com (brian d foy)
Subject: Re: Http post and SSL
Message-Id: <comdog-ya02408000R0810980235210001@news.panix.com>
Keywords: from just another new york perl hacker

In article <6vhb3i$uae$1@nnrp1.dejanews.com>, factor@imports.com posted:

>I apologize if this problem has already been discussed here.  I'm sure it is a
>common problem...

it is common.

>-----------== Posted via Deja News, The Discussion Network ==----------
>http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own   

and that's the place that should have the archives of the past answers!

-- 
brian d foy                                  <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
Comprehensive Perl Archive Network (CPAN) <URL:http://www.perl.com>
Perl Mongers needs volunteers! <URL:http://www.pm.org/to-do.html>


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

Date: Thu, 8 Oct 1998 06:00:17 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: Need help refining this
Message-Id: <ebohlmanF0HvCH.4p0@netcom.com>

baillie@my-dejanews.com wrote:
: Basically, this is my first perl program, and I'd like to have it more compact
: (in the tradition of perl), as well as optimize it some.  Any help would be
: appreciated!


: #!/usr/bin/perl -w

Using -w is always a good sign.  Next, I'd suggest that you

use Strict;

and explicitly declare all your variables.  This will eventually save you 
hours chasing down seemingly impossible-to-find bugs.

:   # figure out what host we're acting on and
:   # run the command to an output file from that host
: if(defined($ARGV[0])) {
:         $host=$ARGV[0];
:         system "rsh $host alex-sched -LP 0 > /tmp/opck.cache";

It's usually *not* a good idea to take input from outside your program
(such as a command-line argument) and pass it to system() without first
checking it to make sure it won't do something nasty.  You might want to
take a look at the perlsec manpage.  If you're the only person who's ever
going to be invoking this script, no harm will come, but you don't want to
get into bad habits. 

: } else {
:         $host='localhost';
:         system "alex-sched -LP 0 > /tmp/opck.cache";
: }

You need to go to the perlop man page and look at the backtick (``) 
operator, which lets you execute a command and get its standard output 
back directly without having to redirect it to a temporary file.  If you 
use it in a list context (such as assigning to an array variable) it will 
return a list of lines.  This will come in handy if you need to search 
the output backwards, as you need to do.

So your second system() call should be replaced with:

@results=`alex-sched -LP 0`;

You'll want to put:

my @results;

before your if statement (since we're declaring all our variables), and 
you'll also need to change the first system() call.  BTW, the same 
considerations about passing external data to system() also apply to 
backticks.

: open(FILE, "/tmp/opck.cache")
:                 or die "Can't access file: $!";

Good to see you testing the return value of an open().  However, we can 
get rid of this because we're no longer dealing with a file; we already 
have the results in an array.

: $i=0;

Let's get rid of this and put

my $store_found=0;

instead.

:   # Find the only instance of Total..Backup and
:   # the last (can someone tell me how to get only
:   # the last without saving an @ and referencing
:   # the final value) instance of Current..Stored

: while(<FILE>) {

Replace the above with:

for (my $i=$#results; $i>=0; --$i) {
  $_=$results[$i];

:         if(/^Total Bytes to Backup/) {
:                 chomp($to_store=$_);
:                 $to_store=~tr/[a-z A-Z:]//d;
:                 $to_store/=1024;
:         }

Take a look at the perlre manpage to learn how a regex can "remember" 
part of a matched pattern and make it available.  You could replace that 
entire if block with:

$to_store=$1/1024 if /^Total Bytes to Backup.*(\d+)/;

Take a look at the perlsyn manpage to learn about this "trailing if" 
which is a very common Perl idiom.

:         if(/^Current KBytes Stored/) {
:                 chomp($store_array[$i]=$_);
:                 $i++;
:         }

Replace this with:

         if (!$store_found && /^Current KBytes Stored.*(\d+)/) {
           $amount_stored=$1;
           $store_found=1;
         }
: }

See how the $store_found flag eliminates the need to save up all the amounts?

Get rid of everything from here:

:close(FILE) or warn "Couldn't close file: $!";

:   # Use the last value of the array for the current
:   # amount of data that's been stored
: $amount_stored=$store_array[$#store_array];
:   # Is this (below) right?..to grep out only the numbers
: $amount_stored=~tr/[a-z A-Z:]//d;
: undef(@store_array);
: undef($i);

to here.

: $cntr=2;

And get rid of the above, because you set $cntr and then set it again 
later without using it in the meantime.

: $screen_width=`tput cols`;
: $percentage=($amount_stored/$to_store)*100;

Probably a good idea to check that $to_store isn't zero before doing this.

: $vis_disp=($amount_stored/$to_store)*$screen_width;

: printf "\t$host amount to store\t=\t%.0f\n", $to_store;
: print "\t\tamount stored\t\t=\t$amount_stored\n";

: for($cntr=0; $cntr<=$vis_disp; $cntr++) {
:           # A little system curses-based output
: 	  # How can I do this in perl

The Perl idiom for this would be:

foreach (0..$vis_disp) {

: 	system "tput smso";
:         print "=";
: }

 : print ">\n";
: system "tput rmso";
: system "tput bold";
: printf "\t\t\t\t\tOpcard is%2d", $percentage;
: system "tput rmso";
: print  "% complete\n\n";

Go over to CPAN and see what sort of modules they have for using curses 
directly rather than firing off external programs.



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

Date: 8 Oct 1998 04:11:33 GMT
From: Zenin <zenin@bawdycaste.org>
Subject: Perl's OO design / name space / stuff like that (was: Re: send geroge reese)
Message-Id: <907819710.667181@thrush.omix.com>

[posted & mailed]

CCed because I'm changing the subject line.

Abigail <abigail@fnx.com> wrote:
: Zenin (zenin@bawdycaste.org) wrote on MDCCCLXIII September MCMXCIII in
	>snip<
: ++ 	As software gets to the level of "huge", how would a redesign help
: ++ 	fight name collision problems?
:
: If those subroutines are used outside of the package, they are clearly
: part of the interface. If you get name collision in your interface,
: you have designed your interface wrong.

	This sounds like you feel that at any point in your code, you should
	only be using one external package?  Please tell me I miss
	understand you here.

	I'm not talking about name collisions within a single package or its
	single interface.  I'm talking about name collisions between
	multiple packages being used at the same time.  No single package
	should ever have to worry about interfaces other then its own.  To
	say that Foo's interface is wrong because it clashes with Bar's
	interface is incorrect thinking.

: Packages help you avoid name collision; but if you're making an interface
: that has name collisions, you're on your own.

	Packages only help you avoid name collision if you fully qualify
	all access to them.  Once you start importing there symbols into
	your name space	you're asking for name collisions again.

: [Having said that, it would be nice if Exporter was a bit friendlier to
:  module importing symbols, instead of having the exporting module
:  define how the symbols will be named in the importing package.
:
:  Exporter.pm should allow aliasing
:  'Exporting_package::symbol_choosen_by_exporter' to
:  'Importing_package::symbol_choosen_by_importer' instead of aliasing to
:  'Importing_package::symbol_choosen_by_exporter'. ]

	Agreed, but IMHO this is still a kluge.

	1k lines deep into a piece of code I don't want to be searching
	for where kitty() was imported as an alias to Dog::dog() simply to
	avoid name clashes.  It's bad enough when I start having to
	call CORE::connect() to be sure I'm doing what I think I'm doing.

-- 
-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: 8 Oct 1998 06:48:11 GMT
From: "AMIP" <sroque@man.amis.com>
Subject: Please HELP!!!! Database search output  format
Message-Id: <01bdf287$8b953480$2bbe10ac@amipnet>

Hi!
	I made a perl script that will search a flat file database. My problem is
configuring the output. I don't want to use tables. I have four fields as
result to searching but these are so close together (no space at all). But
when I select View Source, they are properly justified. What do you think
shal I do. I used FORMAT statement. Please help!!!



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

Date: Wed,  7 Oct 1998 12:04:22 EDT
From: dblack@saturn.superlink.net (David A. Black)
Subject: Re: Problem passing values to represent arrays names.
Message-Id: <6vg3e6$1lq$1@earth.superlink.net>

Sanjay Joshi <joshi@ee.tamu.edu> writes:

>I have a matrix like this:
>  | a   b   c
>--------------
>x | 1   2   3
>y | 4   5   6 
>z | 7   8   9

[snip]

>I am able to pass the values of the row and column to the cgi.  Inside the
>cgi script, there is a loop which reads the numbers. The arrays work in
>both directions *inside* the loop i.e x(a) and a(x).  But when I use a
>value passed from the HTML file (as a scalar, $row) and try to access
>$row{$column}, it doesnt work. It doesn't recognize the array name but
>recognizes the subscript. Can someone help me with this? 

Not without seeing some (non-working) code and perhaps a clearer explanation.
(How does an HTML pass values?  If this is a CGI project, what is the
distinction between what's "inside" the script and what isn't?  What
aspects of the syntax of CGI.pm are confusing you?)

David Black
dblack@saturn.superlink.net


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

Date: Thu, 08 Oct 1998 08:21:57 GMT
From: bart.mediamind@ping.be (Bart Lateur)
Subject: Re: reg-exp: "Buy!!!" -> "Buy!" ?
Message-Id: <361e75d5.2048757@news.ping.be>

Alex Farber wrote:

>here is a regular expression quiz for you:
>How do you change the annoying repeating "!!!"
>(in a web board ;-)  to a single "!" ?

Just to be annoying, I'm not using a regexp: ;-)

	tr/!//s;

It's the 's' modifier that does the trick.

	Bart.


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

Date: 8 Oct 1998 03:07:42 GMT
From: schutzmd@SPAMFREEjmu.edu (Mike)
Subject: Re: Searching a string....
Message-Id: <6vha9u$3kl$1@lark.jmu.edu>

Styles (jstyles@hubcap.clemson.edu) wrote:
> Hello,

> Is there a way to search a string starting from right to left instead of
> left to right? 

rindex (STRING, SUBSTRING, [POSITION])

- mike -


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

Date: Thu, 08 Oct 1998 07:11:27 GMT
From: kevin@zippy.tnet.com
Subject: stat() return of mode is wierd...
Message-Id: <6vhoiv$k1t$1@nnrp1.dejanews.com>

Gots a question about stat() in Perl.

Using Perl 5.004_04 on an SCO Unix 3.2v4.2 platform...

I've got a small script that I want to report to me the permissions of
a file, ownership, group and size...  This should be pretty simple...

>From the man pages, I came up with...

    if ( ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,
        $size,$atime,$ctime,$blksize,$blocks) = stat($checkfile) );

However,  What I am getting back for the $mode is not what the files
are, OR, I am misunderstanding what it should be and can't figure out
how to make sense of it.

Given the following files...

-rwsr-sr-x   1 bbs  bbs  411031 Oct 05 00:12 /bbs/bbsfiles/ts2
---s--s--x   1 bbs  bbs  137932 Oct 05 10:04 /bbs/bbsfiles/ts2auth
-r-sr-sr-x   1 bbs  bbs  191364 Sep 13 09:28 /bbs/bbsfiles/ts2util

It get the results from stat for all values as follows:

 ./bbs/bbsfiles/ts2
272,2948,36333,1,203,53,0,411031,907778325,907571546,907571546,
 ./bbs/bbsfiles/ts2util
272,46,36205,1,203,53,0,191364,907768078,905704132,907547457,
 ./bbs/bbsfiles/ts2auth
272,3660,35913,1,203,53,0,137932,907768832,907607087,907786054,

The $mode entries are the third ones of each list.   The
corresponding results to what is actually set doesn't seem to match
at all...

Permissions      Results of
of file          stat $mode
-rwsr-sr-x       36333
---s--s--x       36205
-r-sr-sr-x       35913

The man pages say to refer to mknod but even there I can't figure out
how to get a number of 36333 which is anything close to what the real
permissions are for that file.

Any clues as to what I am missing???

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: 08 Oct 1998 00:43:24 -0700
From: Russ Allbery <rra@stanford.edu>
Subject: Re: stat() return of mode is wierd...
Message-Id: <ylzpb7bisj.fsf@windlord.stanford.edu>

kevin <kevin@zippy.tnet.com> writes:

> The $mode entries are the third ones of each list.  The corresponding
> results to what is actually set doesn't seem to match at all...

> Permissions      Results of
> of file          stat $mode
> -rwsr-sr-x       36333
> ---s--s--x       36205
> -r-sr-sr-x       35913

> The man pages say to refer to mknod but even there I can't figure out
> how to get a number of 36333 which is anything close to what the real
> permissions are for that file.

You've got two separate problems happening here at once.  First of all,
you're printing out the mode in decimal, since it's just a number.  It
isn't looking at all familiar to you because you're used to seeing modes
in octal.  Notice:

windlord:~> perl -e 'printf ("%o\n", 36333)'
106755

looks considerably more familiar and contains the 6755 that you'd expect
to see in a file that's setuid and setgid.

The second problem you're running into is that Perl's stat function
returns exactly the same sort of data that the system's stat(2) call
returns.  In particular, the mode is as defined in mknod(2), which
includes all the permission bits that you're used to and some extra bits
that identify the type of file system object (regular file, directory,
symbolic link, named pipe, etc.).

In general, you'll get what you want if you do ($mode & 07777) before
using it.

-- 
#!/usr/bin/perl -- Russ Allbery, Just Another Perl Hacker
$^=q;@!>~|{>krw>yn{u<$$<[~||<Juukn{=,<S~|}<Jwx}qn{<Yn{u<Qjltn{ > 0gFzD gD,
 00Fz, 0,,( 0hF 0g)F/=, 0> "L$/GEIFewe{,$/ 0C$~> "@=,m,|,(e 0.), 01,pnn,y{
rw} >;,$0=q,$,,($_=$^)=~y,$/ C-~><@=\n\r,-~$:-u/ #y,d,s,(\$.),$1,gee,print


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

Date: 08 Oct 1998 09:39:56 +0200
From: Calle Dybedahl <qdtcall@esb.ericsson.se>
Subject: Re: What perl modules do I have???????
Message-Id: <is1zojsdrn.fsf@godzilla.kiere.ericsson.se>

tekkin@hotmail.com (Ken Williams) writes:

> How do I find out what perl modules I have installed?  

perldoc perllocal
-- 
   Calle Dybedahl, qdtcall@esavionics.se, http://www.lysator.liu.se/~calle/
                         Mediocre minds think alike.


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

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

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