[7730] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1356 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Nov 21 17:28:13 1997

Date: Fri, 21 Nov 97 14:00:24 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Fri, 21 Nov 1997     Volume: 8 Number: 1356

Today's topics:
     Re: -w flag (Faust Gertz)
     [Q] Why does this behave this way? lm@binary9.net
     Re: analysing a html-document <eryq@zeegee.com>
     Re: analysing a html-document (Bart Lateur)
     Re: analysing a html-document (Tad McClellan)
     Re: Authenticate a user and log him an NT identity <vcuya@mindspring.com>
     Re: Authenticate a user and log him an NT identity (Jeremy D. Zawodny)
     Base64 Encoding Code Snippett? (Thomas Munn)
     Re: Base64 Encoding Code Snippett? <zenin@best.com>
     Re: Base64 Encoding Code Snippett? (Jeremy D. Zawodny)
     Exiting in MSQL thru Perl (Wong Dai)
     Re: Exiting in MSQL thru Perl <zenin@best.com>
     Re: Fehler in timelocal()??? (Andreas Karrer)
     Re: function parameters (Andrew M. Langmead)
     Re: giving up on flock <markm@nortel.ca>
     Re: New to perl.   What's wrong with this script? (Faust Gertz)
     Re: open(), seek() and email monitoring (Neil Briscoe)
     Re: Perl and Sybase <rjk@fprsdev3.fmr.com>
     Re: Perl Source Formatter <rjk@fprsdev3.fmr.com>
     Proxy Client <peter.storm@its.cna.com>
     Re: Proxy Client (Jason Gloudon)
     Re: Reading single lines from a file . . . ()
     Re: Regex for three equal characters (Ilya Zakharevich)
     Re: Regex for three equal characters <merlyn@stonehenge.com>
     Re: Regex for three equal characters (Abigail)
     regexp for selectively stripping html (Neil Edmondson)
     Re: Sorting an array lm@binary9.net
     Re: stdout and stdin of ` ` coming to screen (Jason Gloudon)
     Re: Working with just part of an array. <zenin@best.com>
     Re: Working with just part of an array. <ludlow@us.ibm.com>
     Re: Working with just part of an array. (Bart Lateur)
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Fri, 21 Nov 1997 19:06:38 GMT
From: faust@wwa.com (Faust Gertz)
Subject: Re: -w flag
Message-Id: <3475db7b.1301447@news.wwa.com>

On 21 Nov 1997 14:36:29 GMT, Zenin <zenin@best.com> wrote:

>Tad McClellan <tadmc@flash.net> wrote:
>: The very first bug listed there is:
>:    "The -w switch is not mandatory."
>: So, it has already been thought of (and, apparently, rejected ;-)
>	>snip<
>
>	Actually, I think this is bug in the documentation.  It should
>	really read:
>
>	"The -w switch and 'use strict' are not mandatory"

I think perl poets would strongly disagree.  :-)


Streben nach Wahrheit

Faust Gertz
Philosopher at Large


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

Date: Fri, 21 Nov 1997 21:23:44 GMT
From: lm@binary9.net
Subject: [Q] Why does this behave this way?
Message-Id: <3475fa95.196730996@client.news.psi.net>

I'm confused about the behavior of something (in Perl5.004_04). I was
trying to do something like this:

sub LOG {
	$ERROR=sprintf @_;
	print STDERR "[err] ";
	printf STDERR @_;
	print STDERR "\n";
}

To 1) retain a copy of the error message,
  and
     2) output the error

Strange thing is, $ERROR gets set to the number of elements in @_.
I've reduced it down to this example:

#!/usr/bin/perl

@a=qw ( Hello );
$a=sprintf @a;

print "sprintf: $a\n";
print "printf : "; printf @a; print "\n";

Now, when I run this, I get:

sprintf: 1
print : Hello

Shouldn't they produce the same result? Am I missing something
incredibly stupid and easy?



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

Date: Fri, 21 Nov 1997 12:46:14 -0500
From: Eryq <eryq@zeegee.com>
To: "Ronald G\"oggel" <r.goeggel@atos-group.de>
Subject: Re: analysing a html-document
Message-Id: <3475C8E6.642A@zeegee.com>

Ronald G"oggel wrote:

> Is there a general method to analyse a html document?
> 
> In CPAN I found a lot of modules that generate html syntax; but how about
> analysing?

Try HTML::Parse.  It's excellent, and easy to subclass.


> What about including this question to the FAQ?

Not really necessary, if you have a copy of the Perl5 Module
List.

-- 
   ___  _ _ _   _  ___ _   Eryq (eryq@zeegee.com)
  / _ \| '_| | | |/ _ ' /  President, Zero G Inc.
 |  __/| | | |_| | |_| |   
  \___||_|  \__, |\__, |___/\  Visit STREETWISE, Chicago's newspaper by/
            |___/    |______/ of the homeless: http://www.streetwise.org


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

Date: Fri, 21 Nov 1997 18:49:39 GMT
From: bart.mediamind@tornado.be (Bart Lateur)
Subject: Re: analysing a html-document
Message-Id: <3476d6f0.1013860@news.tornado.be>

tadmc@flash.net (Tad McClellan) wrote:

>You could build something using the HTML::Parser module maybe?

I've looked all over CPAN for it. I can't find it. Neither under "html",
nor under "parsing". It's not in the standard distribution, either.

So where is it?

	Bart.


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

Date: Fri, 21 Nov 1997 14:07:10 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: analysing a html-document
Message-Id: <elp456.ke2.ln@localhost>

Bart Lateur (bart.mediamind@tornado.be) wrote:
: tadmc@flash.net (Tad McClellan) wrote:
: >You could build something using the HTML::Parser module maybe?

: I've looked all over CPAN for it. I can't find it. Neither under "html",
: nor under "parsing". It's not in the standard distribution, either.

: So where is it?


   http://www.perl.com/CPAN/modules/by-module/HTML


part of the libwww bundle.


--
    Tad McClellan                          SGML Consulting
    tadmc@flash.net                        Perl programming
    Fort Worth, Texas


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

Date: Fri, 21 Nov 1997 15:23:06 -0500
From: "Victor A. Cuya" <vcuya@mindspring.com>
Subject: Re: Authenticate a user and log him an NT identity
Message-Id: <654qpi$qu9@camel15.mindspring.com>


Jeremy D. Zawodny wrote in message <3477ce7a.246868387@woody.wcnet.org>...
>[original author automagically cc'd via e-mail]
>
>On Wed, 19 Nov 1997 18:08:45 -0800, Debasish Biswas <dbiswas@nc.com>
>wrote:
>
>>I am writing a web-based admin tool on NT using Perl. I have to
>>authenticate the client not only to the admin application but also to
>>the operating system, so that the client can get the right
>>administrative privileges. In other words I want the scripts to 'run as'
>>a privileged user and be able to add users, create directories etc. to
>>the NT machine.
>>
>>How do I do this ? Any help will be appreciated.
>
>Install a second copy of perl.exe. Setup a new file extension which
>you want to use on scripts that are run by this second perl.exe (let's
>call it admin-perl.exe for fun).
>
>Set the permissions on your scripts (and maybe on the admin-perl.exe,
>I can't recall which worked) such that only admins can run them.
>
>Make some sense?
>
>Jeremy
>--
>Jeremy D. Zawodny                 jzawodn@wcnet.org
>Web Server Administrator          www@wcnet.org
>Wood County Free Net (Ohio)       http://www.wcnet.org/

You can use the Win32::AdminMisc extension for user authentication on NT
security, and also to 'impersonate' another user, all without launching a
second perl instance.

Good luck

Victor A. Cuya
vcuya@mindspring.com
victor_cuya@ccmail.prusec.com





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

Date: Fri, 21 Nov 1997 21:05:29 GMT
From: jzawodn@wcnet.org (Jeremy D. Zawodny)
Subject: Re: Authenticate a user and log him an NT identity
Message-Id: <3475f762.107024653@igate.hst.moc.com>

[original author automagically cc'd via e-mail]

On Fri, 21 Nov 1997 15:23:06 -0500, "Victor A. Cuya"
<vcuya@mindspring.com> wrote:

>You can use the Win32::AdminMisc extension for user authentication on NT
>security, and also to 'impersonate' another user, all without launching a
>second perl instance.

Yes.

However, the method I suggested will use NT Challenge/Response and
make the authentication "transparent" to the end user.

It's just a question of whether or not that's what the original poster
is/was looking for.

Jeremy
-- 
Jeremy D. Zawodny                 jzawodn@wcnet.org
Web Server Administrator          www@wcnet.org
Wood County Free Net (Ohio)       http://www.wcnet.org/


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

Date: Thu, 20 Nov 1997 02:22:48 GMT
From: munn@bigfoot.com (Thomas Munn)
Subject: Base64 Encoding Code Snippett?
Message-Id: <650718$kko$1@nu-informer.alliance.net>

Has anyone authored a bit of PERL that will convert plaintext to base64 
encoding?  I need it for a program that I am writing.

Thanks

Thomas
munn@bigfoot.com


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

Date: 21 Nov 1997 21:02:47 GMT
From: Zenin <zenin@best.com>
Subject: Re: Base64 Encoding Code Snippett?
Message-Id: <880146314.521814@thrush.omix.com>

Thomas Munn <munn@bigfoot.com> wrote:
: Has anyone authored a bit of PERL that will convert plaintext to base64 
: encoding?  I need it for a program that I am writing.

	Check out MIME::Base64 at your local CPAN.

-- 
-Zenin
 zenin@best.com


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

Date: Fri, 21 Nov 1997 21:05:56 GMT
From: jzawodn@wcnet.org (Jeremy D. Zawodny)
Subject: Re: Base64 Encoding Code Snippett?
Message-Id: <3476f7a2.107088455@igate.hst.moc.com>

[original author automagically cc'd via e-mail]

On Thu, 20 Nov 1997 02:22:48 GMT, munn@bigfoot.com (Thomas Munn)
wrote:

>Has anyone authored a bit of PERL that will convert plaintext to base64 
>encoding?  I need it for a program that I am writing.

I believe there's a module on CPAN for this...

Jeremy
-- 
Jeremy D. Zawodny                 jzawodn@wcnet.org
Web Server Administrator          www@wcnet.org
Wood County Free Net (Ohio)       http://www.wcnet.org/


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

Date: 21 Nov 1997 19:59:58 GMT
From: mpuscar@thunder.temple.edu (Wong Dai)
Subject: Exiting in MSQL thru Perl
Message-Id: <654p7u$4b6$1@cronkite.ocis.temple.edu>

A question for anyone else out there using mSQL and the Perl modules that
can access it ...

 ... is there a command in the API you need to issue to terminate your
connection with the database?  After I have completed a query, the 
mSQL instances seem to be hanging around for quite awhile (over an hour).
1) Is there an command I can issue from Perl to let mSQL know I am done
or 2) Is there a timeout limit I can set somewhere?  I didn't see it in
the config file.

Any help is appreciated!

Thanks,

-- 
Mike
mpuscar@technologist.com
My SR Homepage: http://thunder.temple.edu/~mpuscar/sr


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

Date: 21 Nov 1997 20:29:07 GMT
From: Zenin <zenin@best.com>
Subject: Re: Exiting in MSQL thru Perl
Message-Id: <880144294.869937@thrush.omix.com>

Wong Dai <mpuscar@thunder.temple.edu> wrote:
: ... is there a command in the API you need to issue to terminate your
: connection with the database?

	RFTM: perldoc DBI

	$dbh->disconnect
	    or die $DBI::errstr;

-- 
-Zenin
 zenin@best.com


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

Date: 21 Nov 1997 18:47:35 GMT
From: karrer@ife.ee.ethz.ch (Andreas Karrer)
Subject: Re: Fehler in timelocal()???
Message-Id: <slrn67blqj.idt.karrer@kuru.ee.ethz.ch>

In article <01bcf698$bf440860$c65bbe8a@gd2yld>, Christian Broennimann wrote:

>print "", (timelocal(0,0,0,10,3,98) - timelocal(0,0,0,10,2,97)) / 86400,

Now, we just switched from winter- to summertime in Europe, and an
estimated 80% of the non-Unix-computers around here did not get it
right, because the rules had changed. Already forgotten?

Assuming MEZ/CET: 

           timelocal(0,0,0,10,3,98)      timelocal(0,0,0,10,2,97)
Localtime  Fri Apr 10 00:00:00 1998      Mon Mar 10 00:00:00 1997
UTC        Thu Apr  9 22:00:00 1998      Sun Mar  9 23:00:00 1997

Use gmtime/timegm, or round to the nearest integer.

Don't crosspost in comp.lang.perl.misc (english) and de.comp.lang.perl (german).

 - Andi


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

Date: Fri, 21 Nov 1997 18:58:52 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: function parameters
Message-Id: <EK0FE4.2tM@world.std.com>

bsa@void.apk.net (Brandon S. Allbery KF8NH; to reply, change "void" to "kf8nh") writes:

>In <EJt3wE.CzG@world.std.com>, on 11/17/97 at 08:07 PM,
>   aml@world.std.com (Andrew M. Langmead) said:
>+-----
>| Its just without the assignment you end up having to deal with the
>| identifier-that-looks-like-line-noise "$_[0]".
>+--->8

>...the question arises:  how does that differ from the rest of Perl?  ;-}

Perl code does has a natural tendency to looking like line noise. The
programmer just has to decide whether they want to vainly try to fight
this tendency and fail, or to just give up and let perl win.

-- 
Andrew Langmead


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

Date: 21 Nov 1997 15:10:52 -0500
From: Mark Mielke <markm@nortel.ca>
Subject: Re: giving up on flock
Message-Id: <lq1ra8a57oz.fsf@bmers2e5.nortel.ca>

tadmc@flash.net (Tad McClellan) writes:
> Here's the canonical "update" model with flocking:
> 
>         open FILE, "+>>in-duh-vidual";
>         flock FILE, 2;
>         seek FILE, 0, 0;
>         @contents = <FILE>;
>         ## process @contents to the new contents
>         seek FILE, 0, 0;
>         truncate FILE, 0;
>         print FILE @contents;
>         close FILE;
> 
> Do *not* release the flock before you close.  Bad bad bad.  This *is*
> the way.  Yes, *all* of these steps are necessary.  Any deviation will
> break down somewhere.  You have been warned.

Again, i quote from the manpage on perlfunc:

     flock FILEHANDLE,OPERATION
             ...

             To avoid the possibility of mis-coordination, Perl
             flushes FILEHANDLE before (un)locking it.

             ...

If your logs are going to continue to grow... i suggest retaining the open
filehandle for your program's efficiency's sake. Also, it seems that on
Solaris the flock() operation takes quite a bit of time. My Log class
that i'm using that adds 1000+ records to a file ran 20+ times faster
when i buffered the log. (i.e. my log class kept a buffer of lines "to-log"
and when it's sync() or DESTROY() method was called it would do the
flock(on),seek(),print(),flock(off). Imagine how many times slower it
would have run if i had put open(),close() around it too :-)

mark
 
--                                                  _________________________
 .  .  _  ._  . .   .__    .  . ._. .__ .   . . .__  | Northern Telecom Ltd. |
|\/| |_| |_| |/    |_     |\/|  |  |_  |   |/  |_   | Box 3511, Station 'C' |
|  | | | | \ | \   |__ .  |  | .|. |__ |__ | \ |__  | Ottawa, ON    K1Y 4H7 |
  markm@nortel.ca  /  al278@freenet.carleton.ca     |_______________________|


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

Date: Fri, 21 Nov 1997 19:09:51 GMT
From: faust@wwa.com (Faust Gertz)
Subject: Re: New to perl.   What's wrong with this script?
Message-Id: <3476dc21.1467211@news.wwa.com>

On Thu, 20 Nov 1997 22:48:49 -0500, Jeremy Zifchock <jz32@cornell.edu>
wrote:

>I am trying to have a page that can give directions to events in my area
>that can be updated by another page.  here's my script, but it doesn't
>work.  Can anyone help?  Thanks in advance

[code snipped]

Perhaps it would help if you commented your code so we could see what
you think the code is supposed to do.  :-)  Then we might be able to
tell you where you went wrong.


Streben nach Wahrheit

Faust Gertz
Philosopher at Large


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

Date: 21 Nov 1997 18:57:14 GMT
From: neilb@zetnet.co.uk (Neil Briscoe)
Subject: Re: open(), seek() and email monitoring
Message-Id: <memo.19971121185713.62477C@skep.compulink.co.uk.cix.co.uk>

In article <3475561B.F18CBAC7@technologyXchange.com>,
andrewe@technologyXchange.com (Andrew Ellerton) wrote:

> Hi all,
>
> I'm trying to write some code to monitor email spool files and do
> anything once new email is received.
>
> Although the approach may be wrong, I'm presently trying this code
> virtually straight out of Programming Perl:
>
> for (;;) {
>         while (<SPOOL>) {
>
>                 process_in_whatever_way();
>         }
>         sleep $for_a_while;
>         seek SPOOL, 0, 1; # reset end-of-file error
> }
>
> Is the sleep-then-seek method a reasonable way to handle this? If anyone
> has any suggestions on an alternative, and/or the use of Mail::Header to
> extract header information, I'd be most thankful.
>

Hmm, a couple of questions.  First - whats SPOOL?  Would I be right in
supposing you'd opened it with an opendir() - in which case you'd want
seekdir() - or is it a single mail drop point that you're seeking.

If the latter, then I wouldn't do it like that.  I'd get rid of the outer
for() loop and call the script every so often with cron or at.

More information please, and I might be able to give you a better answer -
although I'm away most of next week.  Still, the rest of the group may
provide you with an answer.

Regards
Neil



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

Date: Fri, 21 Nov 1997 13:01:46 -0500
From: Rick Meldrum <rjk@fprsdev3.fmr.com>
Subject: Re: Perl and Sybase
Message-Id: <3475CC8A.2107@fprsdev3.fmr.com>

Greg Stanfield wrote:
> 
> I am relatively new to combining Perl and Sybase, and could use some
> help, if anyone has the time.
> 
> I am trying to connect to a Sybase database from a Perl script.  I have
> the isql statement ready to go, but cannot figure out the right/best way
> to connect to the database to pass the isql statement. 

[.....]

I have had relatively good luck with variations of...

$cmds = "$my_password\n exec $myproc $params\n go\n exit\n";
system "isql -Umy_id<<EOF\n$cmds";

Sometimes I add:

@tmp_array = system "isql -Umy_id<<EOF\n$cmds";

and my results are now in hand...


This is a very primitive example, you'll want to do a lot of 
error checking (and debugging!)

Slight modifications make it work with Oracle too...

HTH
Rick


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

Date: Fri, 21 Nov 1997 13:19:49 -0500
From: Rick Meldrum <rjk@fprsdev3.fmr.com>
Subject: Re: Perl Source Formatter
Message-Id: <3475D0C5.25B2@fprsdev3.fmr.com>

Clay Irving wrote:
> 
> In <34742AFB.CCE1A299@lanl.gov> Bill Dorin <bill@lanl.gov> writes:
> 
> >Anyone point me to a perl source formatter similar to lint?  Sorry if this
> >has been a previous topic.
> 
> From the "style guides" section of Perl Reference <http://reference.perl.com>:
> 
>   pb -- Freeware
>   http://www.arachnoid.com/lutusp/ftp/cgi/pb.txt
>   Perl Beautifier -- This script processes Perl scripts, cleans up and
>   indents, like cb does for C
> 
> --
> Clay Irving <clay@panix.com>                   <http://www.panix.com/~clay/

I just grabbed this. I like it! 

I tweeked it to my liking, but it works fine as is.

My compliments to Author: P. Lutus Ashland, Oregon lutusp@arachnoid.com


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

Date: Fri, 21 Nov 1997 12:12:24 -0600
From: Pete Storm <peter.storm@its.cna.com>
Subject: Proxy Client
Message-Id: <3475CF06.68395BCE@its.cna.com>

Hello hello hello

I'm trying to program a little web client.  This is an exercise in
learning how to deal with headers and such.  I am not interested in
using the LWP modul e (because I know how to do it with that).

What I'm looking for is advice/pointers/help on how to authenticate with
a proxy.

Anyone have any ideas/maintenance/hints/tips/etc?

What I have so far is this

I connect to proxy
pass it the page request

it sends me back a 407 error asking for authentication, but then it
sends the error page and close the connection

aaron



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

Date: 21 Nov 1997 20:48:53 GMT
From: jgloudon@bbn.remove.com (Jason Gloudon)
Subject: Re: Proxy Client
Message-Id: <654s3l$6jd$1@daily.bbnplanet.com>

Pete Storm (peter.storm@its.cna.com) wrote:
: Hello hello hello

: I'm trying to program a little web client.  This is an exercise in
: learning how to deal with headers and such.  I am not interested in
: using the LWP modul e (because I know how to do it with that).

Ok you mentioned perl once.

: What I'm looking for is advice/pointers/help on how to authenticate with
: a proxy.

: Anyone have any ideas/maintenance/hints/tips/etc?

Try comp.infosystems.www.misc or another more appropriate group.

Jason Gloudon


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

Date: 21 Nov 1997 20:42:46 GMT
From: root@select.net ()
Subject: Re: Reading single lines from a file . . .
Message-Id: <654ro6$e0b@newshub.atmnet.net>

In article <Pine.GSO.3.96.971121080944.8884P-100000@usertest.teleport.com>,
	Tom Phoenix <rootbeer@teleport.com> writes:
> On Thu, 20 Nov 1997, Jon Turner wrote:
> 
>> I have found that it doesn't always read just 1 line at a time.  When I
>> step through it with the debugger I often get 5-6 lines in my variable
>> $line. 
> 

Have you set autoflush on the file handle?;

use IO::Handle;

open (FILEHANDLE, "blahblahblah");
FILEHANDLE->autoflush();

Otherwise, you won't see any printed output until ye olde buffer is full;

-- 
____________________________________________________________________________
Matthew Hempel			SelectNet Internet Services
Systems Administrator		Carlsbad, California
				(760) 438-9555


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

Date: 21 Nov 1997 18:37:20 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: Regex for three equal characters
Message-Id: <654kd0$m8t$1@agate.berkeley.edu>

In article <wvp7ma2bbmz.fsf@hobbes.ejoper.dmi.min.dk>,
Casper K. Clausen <ckc@hobbes.ejoper.dmi.min.dk> wrote:
> only such 'words' as 'ggg' or 'jjjjjj'. /(.)\1{2,}/ would be better,
> but for effeciency it can't compete with /(.)\1\1+/.

How so?  I would say that /(.)\1{2,}/ *should* be much quickier.

Hmm, maybe no, since /(.)\1\1+/ may reject a negative earlier, *before*
going into a loop.  Then

	/(.)\1\1\1*/s 

should be yet better candidate (if you have many doubled characters).

Ilya


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

Date: 21 Nov 1997 12:37:18 -0700
From: Randal Schwartz <merlyn@stonehenge.com>
To: Dean Jenkins <jenkinsrd@cf.ac.uk>
Subject: Re: Regex for three equal characters
Message-Id: <8coh3ekpht.fsf@gadget.cscaper.com>

>>>>> "Dean" == Dean Jenkins <jenkinsrd@cf.ac.uk> writes:

Dean> Markus Bubendorf wrote:
>> I'm looking for a regex which matches three or more consecutive equal
>> characters. Any ideas?

Dean> So how about /.{3,}/

Nope.  The key part of the phrase is "equal".  You didn't use memory,
so you can't get equal things.  Try this instead:

	/
		(.)	# grab one char
		\1{2,}	# give me two or more additional ones
	/xs

print "Just another Perl hacker," # but not what the media calls "hacker!" :-)
## legal fund: $20,990.69 collected, $186,159.85 spent; just 283 more days
## before I go to *prison* for 90 days; email fund@stonehenge.com for details
-- 
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@ora.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me


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

Date: 21 Nov 1997 21:37:29 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Regex for three equal characters
Message-Id: <slrn67bvsa.n1i.abigail@betelgeuse.wayne.fnx.com>

Dean Jenkins (jenkinsrd@cf.ac.uk) wrote on 1543 September 1993 in
<URL: news:3475FDC3.2727@cardiff.ac.uk>:
++ Markus Bubendorf wrote:
++ 
++ > I'm looking for a regex which matches three or more consecutive equal
++ > characters. Any ideas?
++ 
++ RTFM
++ 
++ "Any item of a regular expression may be followed with digits in curly 
++ brackets of the form {n,m}, where n gives the minimum number of times to 
++ match the item and m gives the maximum.  The form {n} is equivalent to 
++ {n,n} and matches exactly n times.  The form {n,} matches n or more 
++ times.  (If a curly bracket occurs in any other context, it is treated as 
++ a regular character.) The * modifier is equivalent to {0,}, the + 
++ modifier to {1,} and the ? modifier to {0,1}.  There is no limit to the 
++ size of n or m, but large numbers will chew up more memory." Perlman
++ 
++ So how about /.{3,}/

That matches any string with at least 3 characters. Not at
all what was asked.

/.\1{2,}/ or /.\1\1+/ will do.



Abigail
-- 
perl -wle 'print "Prime" if (1 x shift) !~ /^1?$|^(11+?)\1+$/'


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

Date: Fri, 21 Nov 1997 20:41:56 GMT
From: neil@weaveware.com (Neil Edmondson)
Subject: regexp for selectively stripping html
Message-Id: <3475f162.687579@news.enteract.com>

Let me try this again.....

Have a look at the following, it's an attempt to neutralize (not
remove) html tags with specific exclusions.

I did this 'cos I couldn't find anything that was already done.

Anyone got a better way?
-----------------------------------------

$inout = "string <b> </b> <i> </i> <u> </u> <p> </p> to <<<<scan>>>
and <<replace>>";
%ent = (
	'<' => 'lt',
	'>' => 'gt'
);
%allowed = (
	'&lt;b&gt;' => '<b>',
	'&lt;/b&gt;' => '</b>',
	'&lt;i&gt;' => '<i>',
	'&lt;/i&gt;' => '</i>',
	'&lt;u&gt;' => '<u>',
	'&lt;/u&gt;' => '</u>',
	'&lt;p&gt;' => '<p>',
	'&lt;/p&gt;' => '</p>'
);
print "Before substitute: $inout", "\n";
$inout =~ s/([<>])/&$ent{$1};/g;
$inout =~ s/(&lt;.{1,2}&gt;)/$allowed{$1}/g;
print "After substitute:  $inout", "\n";



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

Date: Fri, 21 Nov 1997 21:30:05 GMT
From: lm@binary9.net
Subject: Re: Sorting an array
Message-Id: <3475fcaa.197264213@client.news.psi.net>

On Fri, 21 Nov 1997 10:49:55 +0100, Yann <ycueff@club-internet.fr>
wrote:

>I've some problems to sort an array.
>Could someone help me ?
>For example I'd like to sort this array by the 3rd field.
>
>bcv64wd8:solaris:5.5:sun4m:SUN1.05:AGL
>bcv67wcb:solaris:5.5.1:sun4m:SUN0535:AGL
>bcv67w50:solaris:5.5.1:sun4c:SUN0424:AGL
>bcv67w5b:solaris:5.5:sun4m:SUN0535:AGL
>bcv66m14:AIX:3.2:::AGL
>bcv66w58:sun4:4.1.3_U1:sun4m:SUN1.05:AGL
>bcv95wc4:solaris:5.5.1:sun4c:SUN0424:AGL
>

Assuming this information is in @ARR ...

for (sort { (split(/:/,$a))[2] <=> (split(/:/,$b))[2] } @ARR) {
	print "$_\n";
}



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

Date: 21 Nov 1997 18:09:07 GMT
From: jgloudon@bbn.remove.com (Jason Gloudon)
Subject: Re: stdout and stdin of ` ` coming to screen
Message-Id: <654io3$11d$1@daily.bbnplanet.com>

Miten S Mehta (mehta@mama.indstate.edu) wrote:


: I have to do some sccs commands which need to loop through a list of files
: either as command line wildcards or by some other means.  I need to let
: the user type in the responses for the sccs commands.  I do not know how
: to let the looped shell command or script to interact so am currently
: rescued by csh scripts.  could you guide how do I go about using perl for
: this problem?  I would also love to know if there is some module for this.

You can try using the Comm.pl per module (or use expect).

Jason Gloudon


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

Date: 21 Nov 1997 18:37:36 GMT
From: Zenin <zenin@best.com>
Subject: Re: Working with just part of an array.
Message-Id: <880137604.212491@thrush.omix.com>

Kevin Cheramie <kevinc@mobiletel.com> wrote:
: I would like to extract, if you will, just the filename1 part and assign it
: to $y so that

	perldoc File::Basename

	Hope this helps!

-- 
-Zenin
 zenin@best.com


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

Date: Fri, 21 Nov 1997 12:40:16 -0600
From: James Ludlow <ludlow@us.ibm.com>
Subject: Re: Working with just part of an array.
Message-Id: <3475D590.40A5@us.ibm.com>

Kevin Cheramie wrote:
> 
> Say I have a variable @x where
> 
> @x = ("/dir1/dir2/filename1")
> 
> So that if I print @x, my output is
> 
> /dir1/dir2/filename1
> 
> I would like to extract, if you will, just the filename1 part and assign it
> to $y so that
> 
> $y = ("filename1")
> 
> Any help with this would be appreciated.

Well, you left a lot of detail out, but I think that I understand what
you're trying to do.  One way to do it would be like this:

#!/usr/bin/perl -w
@x = ("/dir1/dir2/foo_bar.txt");
$y = $x[0];
# This next line is where the "magic" happens.
$y =~ s/^.*?([a-zA-Z_.]*$)/$1/;
print "$y\n";


If the regex that I used is confusing to you, you should really check
the man pages, or if you really want to get into it check out "Mastering
Regular Expressions."  You can check out the publisher's page at:
www.ora.com.

--
James Ludlow (ludlow@us.ibm.com)
This isn't tech support, and all opinions are my own.


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

Date: Fri, 21 Nov 1997 22:05:47 GMT
From: bart.mediamind@tornado.be (Bart Lateur)
Subject: Re: Working with just part of an array.
Message-Id: <347604e4.1726347@news.tornado.be>

"Kevin Cheramie" <kevinc@mobiletel.com> wrote:

>@x = ("/dir1/dir2/filename1")
>
>So that if I print @x, my output is 
>
>/dir1/dir2/filename1
>
>I would like to extract, if you will, just the filename1 part and assign it
>to $y

Odd that you call this "part of an array". I can't see any array. I can
only see a string.

But anyway, try this:

	$_ = "dir1/dir2/filename1";
	($dir,$file) = /(.*)\/(.*)/;
	print $file;

This uses the "greedy nature" of regexps to it's advantage: $dir slurps
up as much as possible upto a slash, in this case: the very last slash.
$file gets everything following that last slash.


HTH,
Bart.


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

Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 8 Mar 97)
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". 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 1356
**************************************

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