[10306] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3899 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Oct 6 06:07:09 1998

Date: Tue, 6 Oct 98 03:00:24 -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, 6 Oct 1998     Volume: 8 Number: 3899

Today's topics:
    Re: Accessing Access97 using ADO DB... (Paul Murray)
        CGI outputs to DOS not browser (Abdul Ali)
    Re: CGI outputs to DOS not browser <daniel.vesma@thewebtree.com>
    Re: Common prefix for an array of strings <garethr@cre.canon.co.uk>
    Re: Execute perl on win32 with no console? (Paul Murray)
        How do I 'su' to in a perl script (when password is kno (Gerard Hammond)
    Re: How do I 'su' to in a perl script (when password is <rra@stanford.edu>
        How to install a local copy of perl? (Tianxiong)
        How to pass an array in AND out of a subroutine? (Tianxiong)
    Re: How to pass an array in AND out of a subroutine? <labrache@gaulois.cad.cea.fr>
    Re: How to pass an array in AND out of a subroutine? <howel88@cyberway.com.sg>
    Re: Image format conversion, resizing <erhmiru@erh.ericsson.se>
    Re: Keeping a running list of the top n values retrieve <garethr@cre.canon.co.uk>
    Re: Keeping a running list of the top n values retrieve (Sam Holden)
    Re: Need IP Address Sort Subroutine <erhmiru@erh.ericsson.se>
    Re: Need IP Address Sort Subroutine <erhmiru@erh.ericsson.se>
    Re: NEEDED: A good perl programer to... <erhmiru@erh.ericsson.se>
    Re: Omaha Perl Mongers - First Meeting ! (David Adler)
    Re: Owning Your Own Adult Interent Business Is Easy (Steve Watt)
    Re: Page Break in a report (Stefaan A Eeckels)
    Re: please check my CGI.pm/Perl Syntax <mp@mkt2mkt.com>
        Q: Speed up a regular expression tilman@spp.hpc.fujitsu.co.jp
    Re: Run cgi scripts ar regular intervals <erhmiru@erh.ericsson.se>
        Search string for "pe*l" *=any no of any chars (Anders Blockmar)
    Re: send geroge reese (was Re: Call for Participation:  <zenin@bawdycaste.org>
        Shuffling of array content <hauk@forumnett.no>
    Re: Shuffling of array content (Sam Holden)
    Re: Split question - retain the pattern? (A.J. Norman)
    Re: Too late for "-T" option ? <sugalskd@netserve.ous.edu>
    Re: Too late for "-T" option ? (Marc Haber)
        Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)

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

Date: 6 Oct 1998 08:04:56 GMT
From: murray-paul@usa.net (Paul Murray)
Subject: Re: Accessing Access97 using ADO DB...
Message-Id: <slrn71jjp8.h3l.murray-paul@unix3.netaxs.com>

On Mon, 05 Oct 1998 16:25:03 +0200, haller <haller@broadnet.ascom.ch> wrote:
>2. I made a query and would like to see, if it found something.
>So, I tried '$rs->RecordCount' but this returns always -1, but there
>should be 4 records found.. If I use '$rs->MoveNext' and
>'$rs->Fields->Value;' the right values are displayed.
>what could I've done wrong.. or am I calling a wrong function?

Assuming this is the same basic code as MFCs database access classes,
then from their help:

"[RecordCount] does not indicate how many records are contained in a
dynaset-type or snapshot-type recordset until all records have been
accessed. [...] To force the last record to be accessed, call the
MoveLast [function]."

Generally your best bet is to assume that the Perl interface is pretty
similar to the C++/VB/whatever interfaces, and ask in the Microsoft
newsgroups for details of them.

HTH.

-Paul Murray


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

Date: Tue, 06 Oct 1998 08:48:37 GMT
From: aali@ix.netcom.com (Abdul Ali)
Subject: CGI outputs to DOS not browser
Message-Id: <361ad729.8184970@nntp.ix.netcom.com>

Hi Everyone,

I installed a Sambar Server on my Win98 machine so I could practice
writing CGI Perl scripts. When I call the script from Netscape using
file:///E|samvar/cgi-bin/scriptname.pl, instead of getting output to
my browser an MSDOS window opens receives the output and then closes.

I tried to find this problem in the faq but didn't see it. I think I
once saw something about this on the http://www.perl.com site where
they had an "idiots" link page but this web site is undergoing updates
and the links are broken.

Does anyone know how to fix this problem?

Thanks,
Abdul


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

Date: Tue, 6 Oct 1998 10:20:09 +0100
From: "Daniel Vesma" <daniel.vesma@thewebtree.com>
Subject: Re: CGI outputs to DOS not browser
Message-Id: <3619e11f.0@news.thefree.net>

Hi.

If you find the answer, would you please e-mail it to me?

Daniel Vesma
www.thewebtree.com/daniel-vesma





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

Date: Tue, 6 Oct 1998 07:41:43 GMT
From: Gareth Rees <garethr@cre.canon.co.uk>
Subject: Re: Common prefix for an array of strings
Message-Id: <si7lye5e88.fsf@cre.canon.co.uk>

Bart Lateur <bart.mediamind@ping.be> wrote:
> Here's a nice puzzle for you. How do you extract a common prefix of a
> number of strings?

Join the strings together and use Perl's regular expression engine to do
the search for you.


    # Doesn't work on strings already containing \0, alas

    sub longest_common_prefix {
      local $_ = join "\0", @_;
      /^([^\0]*)[^\0]*(\0\1[^\0]*)*\Z(?!\n)/;
      return $1;
    }

    my @test = ('Fabriqui en Belgique.', 'Fabriqui en France.', 
                'Fabriqui en Belgique et en France.');
    print longest_common_prefix(@test), "\n";


(This was inspired by the indentation-removing code in 1.11 of
Christiansen and Torkington's "Perl Cookbook".)

-- 
Gareth Rees


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

Date: 6 Oct 1998 08:46:52 GMT
From: murray-paul@usa.net (Paul Murray)
Subject: Re: Execute perl on win32 with no console?
Message-Id: <slrn71jm7r.h3l.murray-paul@unix3.netaxs.com>

On Wed, 30 Sep 1998 05:11:31 GMT, Martin Oakley <martin.oakley@usa.net> wrote:
>Can perl scripts be executed without a console process?

A while ago someone gave me this solution:

use strict;
use Win32;
use Win32::Process;

Win32::Process::Create($Win32::Process::Create::ProcessObj,
	"d:\\perl\\bin\\perl.exe",
	"perl OtherScript.pl",
	0,
	DETACHED_PROCESS,
	".") ||
	die &print_error;

sub print_error {
	print Win32::FormatMessage( Win32::GetLastError() );
}

Essentially rather than starting your normal perl script you start
this wrapper, which runs your perl script as a detached process then
goes away. The console windows still pop on, but only very briefly. Is
this of any use to you?


-Paul Murray






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

Date: Tue, 06 Oct 1998 15:28:07 +1000
From: g.hammond@garvan.unsw.edu.au (Gerard Hammond)
Subject: How do I 'su' to in a perl script (when password is known)
Message-Id: <g.hammond-0610981528070001@power.garvan.unsw.edu.au>

I want to write a .forward and .vacation.msg file for any user on the
system using a web browser.  Basically I am trying to put a web front end
onto unix 'vacation' and I am using perl as the cgi language that will
handle the writing of these files.

I am stuck at the point when I need the perl script to setuid to the
person who entered the data from the web page.  The person will have
entered their user name and passwd from the web page. Yes I understand
there are a lot of security issues with this whole idea!)  

So how do I set the perl script to write files in their directory. Is
there some call that temporarily runs the script as the web user.

Please give a small example. I have been searching the net for hours on
this little problem.

Thanks in advance

Dr Gerard Hammond
g.hammond@garvan.unsw.edu.au


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

Date: 05 Oct 1998 23:14:21 -0700
From: Russ Allbery <rra@stanford.edu>
Subject: Re: How do I 'su' to in a perl script (when password is known)
Message-Id: <ylemsmnrnm.fsf@windlord.stanford.edu>

Gerard Hammond <g.hammond@garvan.unsw.edu.au> writes:

> I am stuck at the point when I need the perl script to setuid to the
> person who entered the data from the web page.  The person will have
> entered their user name and passwd from the web page. Yes I understand
> there are a lot of security issues with this whole idea!)

> So how do I set the perl script to write files in their directory. Is
> there some call that temporarily runs the script as the web user.

See man perlvar under $> and $<.  Basically, all you have to do is figure
out what UID you want to switch to and then set $> to it:

        $> = $uid;

Note that you have never completely successfully dropped permissions under
Unix (at least so far as my understanding of it goes) until you've set the
real and effective UIDs ($< and $>) to the new UID and then exec'd
something.  Until then, it's always possible for code to regain your
original UID.

-- 
#!/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: 6 Oct 1998 05:05:56 GMT
From: tianxiong@aol.com (Tianxiong)
Subject: How to install a local copy of perl?
Message-Id: <19981006010556.01129.00001069@ng137.aol.com>


As the version of perl installed in my company is very old (not sure how old),
I can not even use 'use strict;' 'abs(-20)', etc..  I'd like to install a local
copy of the latest perl on my node (DEC machine).  What should I do? and how
should I set the env so that I can use it anywhere within my account? any other
related issures ... I tried to download and then install today, but just
couldn't figure out how to use it.  Please help.

BTW, is there any help in the FAQ?  Where can I get the FAQ?

Thanks again.



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

Date: 6 Oct 1998 05:19:56 GMT
From: tianxiong@aol.com (Tianxiong)
Subject: How to pass an array in AND out of a subroutine?
Message-Id: <19981006011956.01129.00001070@ng137.aol.com>


For example, I want to read data from two data files using a subroutine.  If
there are 5 and 10 items in those two files, and I would expect that $num_items
= 15 and @items contains 15 items after the folling routine is executed.  I
know how to do it in C but not in perl.  Thanks in advance for your help.

############
$num_items = 0;
&read_data ($file1, $num_items, @items);
print "num_items = ",$num_items, "\n";
&read_data ($file2, $num_items, @items);
print "num_items = ",$num_items, "\n";

sub read_data{
 # ???? how ????
}

###########


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

Date: Tue, 06 Oct 1998 09:38:25 +0200
From: Laurent LABRACHERIE <labrache@gaulois.cad.cea.fr>
Subject: Re: How to pass an array in AND out of a subroutine?
Message-Id: <3619C8F1.7F77214B@gaulois.cad.cea.fr>

Tianxiong wrote:

> For example, I want to read data from two data files using a subroutine.  If
> there are 5 and 10 items in those two files, and I would expect that $num_items
> = 15 and @items contains 15 items after the folling routine is executed.  I
> know how to do it in C but not in perl.  Thanks in advance for your help.
>
> ############
> $num_items = 0;
> &read_data ($file1, $num_items, @items);
> print "num_items = ",$num_items, "\n";
> &read_data ($file2, $num_items, @items);
> print "num_items = ",$num_items, "\n";
>
> sub read_data{
>  # ???? how ????
> }
>
> ###########

sub read_data{    local($file,*tab)=@_;
    open(DATA, "$file") || die "Cannot open $file!";
    while(<DATA>){
      push (@tab,$_) ;
    }
}

&read_data ("file.dat", *items);
print "num_items = ",scalar(@items), "\n";

laurent




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

Date: Tue, 06 Oct 1998 17:12:44 +0730
From: Hongwei <howel88@cyberway.com.sg>
Subject: Re: How to pass an array in AND out of a subroutine?
Message-Id: <3619E613.D3DC0599@cyberway.com.sg>

Tianxiong wrote:

> For example, I want to read data from two data files using a subroutine.  If
> there are 5 and 10 items in those two files, and I would expect that $num_items
> = 15 and @items contains 15 items after the folling routine is executed.  I
> know how to do it in C but not in perl.  Thanks in advance for your help.
>
> ############
> $num_items = 0;
> &read_data ($file1, $num_items, @items);
> print "num_items = ",$num_items, "\n";
> &read_data ($file2, $num_items, @items);
> print "num_items = ",$num_items, "\n";
>
> sub read_data{
>  # ???? how ????
> }
>
> ###########

  open(F1, $file1);
open(F2, $file2);
@items = (<F1>, <F2>);
$num_items = @items;
close(F1);
close(F2);



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

Date: 06 Oct 1998 10:40:57 +0200
From: Michal Rutka <erhmiru@erh.ericsson.se>
To: admin@hatsoft.com
Subject: Re: Image format conversion, resizing
Message-Id: <lavhlyrskm.fsf@erh.ericsson.se>

"Henry Wolff" <admin@hatsoft.com> writes:
> Does anyone know of a perl 5 routine/module that will for instance, take a
> gif file and convert it to jpeg and viseversa, or one that will resize both
> or one format?  (The image will be a local)

Yes. Try Image::Magick. It is marvelous. Can convert everything into
anything, and much more.

> If not, does someone want to earn some money writing such?

Wait! how much do you offer?

[...]

Michal


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

Date: Tue, 6 Oct 1998 07:59:00 GMT
From: Gareth Rees <garethr@cre.canon.co.uk>
Subject: Re: Keeping a running list of the top n values retrieved
Message-Id: <si67dy5dff.fsf@cre.canon.co.uk>

Nick Tonkin <nick@valueclick.com> wrote:
> Is there a standard way to keep a running list of the top 20 scoring
> variables?

Yes.  It's a data structure called a "heap".  Look in any algorithms
book (for example, "Introduction to Algorithms" by Cormen, Leiserson and
Rivest, chapter 7).

-- 
Gareth Rees


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

Date: 6 Oct 1998 09:00:44 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: Keeping a running list of the top n values retrieved
Message-Id: <slrn71jn1r.7c5.sholden@pgrad.cs.usyd.edu.au>

On Tue, 6 Oct 1998 07:59:00 GMT, Gareth Rees <garethr@cre.canon.co.uk> wrote:
>Nick Tonkin <nick@valueclick.com> wrote:
>> Is there a standard way to keep a running list of the top 20 scoring
>> variables?
>
>Yes.  It's a data structure called a "heap".  Look in any algorithms
>book (for example, "Introduction to Algorithms" by Cormen, Leiserson and
>Rivest, chapter 7).

How does a heap help... good for priority queues I admit... but for keeping 
track of the top n values surely a bit excessive... especially since perl
does arrays for you...and sorting for that matter...

If you have numbers being retrieved and you just want the to record the
top n values at any given time then why not :

@top_20 = (sort {$b <=> $a} @top_20,$new_value)[0..19];

If they you are counting occurances of something and want the top twenty, then
I would use a hash to keep track of them and then sort that each time I wanted
the top twenty using a ST probably...

Anyway I would not implement a heap when perl has perfectly good arrays and
hashes. I might consider inserting the new value at the appropriate place
in the array instead of sorting the whole thing each time, but not before I
noticed it was too slow.

-- 

Sam

Can you sum up plan 9 in layman's terms? It does everything Unix does
only less reliably.
	--Ken Thompson


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

Date: 06 Oct 1998 09:14:46 +0200
From: Michal Rutka <erhmiru@erh.ericsson.se>
Subject: Re: Need IP Address Sort Subroutine
Message-Id: <lazpbarwk9.fsf@erh.ericsson.se>

Hi John,

John Porter <jdporter@min.net> writes:
[...]
> >      return udef unless $_[0] =~ /.*: ([\d.]+)#/;
> >      return inet_aton($1);
> >  }
> 
> Thank you for noting the difference.
> 
> Hey, what's 'udef'?  I suppose you didn't actually run this code?

Hym... I did run the code but without -w, so I didn't notice this bug, but 
after all the behaviur is almost the same because 'udef' is in anyway 
undefined ;-).

Michal


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

Date: 06 Oct 1998 09:28:37 +0200
From: Michal Rutka <erhmiru@erh.ericsson.se>
Subject: Re: Need IP Address Sort Subroutine
Message-Id: <layaqurvx6.fsf@erh.ericsson.se>

John Porter <jdporter@min.net> writes:
> Michal Rutka wrote:
> > 
> > And therefore, when you run this code at home then start a dialup
> > even when you
> > know that your addresses are in a cannonical form? No thanks.
> > BTW invention the
> > wheel, or even an arc takes more effort than writing a few lines of
> > Perl code.
> 
> Not sure what your point is.
> inet_aton() is not only at least as portable, but MORE correct
> than your solution.  

Eh, nothing. There was a bug in Socket implementation for Win32 platform
(probably you dont use this platform, and dont do this unless you must).
It causes that when you called inet_* function, it was trying to connect
to the network (via dialing a modem). It was quite annoing, but the
problem seems to be solved now so there is no excuse to not use inet_*
functions anymore... unless... somebody has a client with an old version.

Some guy pointed out how it is marvelous to keep the software up-to-date,
with all newest library. In practice it is impossible! There are big
companies which sell own software with bundled Perl (e.g. Mentor Graphic).
The bad practice is that you cannot update the shipped Perl version
because the software which uses it will not run anymore. It is not
always possible to update original software. Moreover I am talking about
a software which costs > 100k$ per package, pobablly more that that bright
guy makes in a year...

Maybe this explain a little my point of view.

> And takes less typing besides.

This is a good point ;-).

> 
> -- 
> John "Many Jars" Porter
> baby mother hospital scissors creature judgment butcher engineer

Michal


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

Date: 06 Oct 1998 10:44:13 +0200
From: Michal Rutka <erhmiru@erh.ericsson.se>
To: mtnbike151@aol.com
Subject: Re: NEEDED: A good perl programer to...
Message-Id: <lasoh2rsf6.fsf@erh.ericsson.se>

mtnbike151@aol.com (MTNBIKE151) writes:

> Hello,
> 
> I am in need of a good perl/cgi programmer to write a script to search a
> flat-file database containing 4 fields (2 of which need to be searchable i.e.
> Part No. & Description Of Part... and the other 2 fields are Prices) 
[...]

You forgot to mention a price which you are willing to pay. Therefore
dont expect any serious offer.

Regards,

Michal


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

Date: 6 Oct 1998 07:37:58 GMT
From: dha@panix.com (David Adler)
Subject: Re: Omaha Perl Mongers - First Meeting !
Message-Id: <6vchcm$d4d@news1.panix.com>

On Fri, 02 Oct 1998 06:58:46 GMT, Patrick Timmins
<ptimmins@netserv.unmc.edu> wrote:

>The first meeting of the Omaha Perl Mongers will be next week:

Yay!  Congratulations!

>( follow the 'Omaha, the Beautiful' link to see the top 10 reasons
> why Omaha should host the year 2000 Perl Conference! )

Hey, watch it buddy.  We East Coasters called dibs on that one at the
1998 conference...

Attempting to scowl menacingly and probably failing, I remain...

dave

-- 
David H. Adler - <dha@panix.com> - http://www.panix.com/~dha/
"You don't understand.  He *had* to murder the nun and harvest her
organs" - overheard at some convention


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

Date: Tue, 6 Oct 1998 05:51:38 GMT
From: steve@Watt.COM (Steve Watt)
Subject: Re: Owning Your Own Adult Interent Business Is Easy
Message-Id: <F0E5M3.93u@Watt.COM>

In article <MPG.108317265d73e7269896c7@news.south-carolina.net>,
Matthew Bafford <dragons@scescape.net> wrote:
[ a followup to a spam ]

[ From here down is a recording. ]

Please do not follow up to spam postings.  The spammer does not read your
newsgroup, and it makes locating real spam for cancellation, while avoiding
followups, slightly more difficult.

This particular spam has been cancelled by me.  See message ID
<199810052006.AA16123@wattres.Watt.COM> in news.admin.net-abuse.bulletins.

Thank you for your help.
-- 
Steve Watt KD6GGD  PP-ASEL-IA         Packet: KD6GGD @ N0ARY.#NOCAL.CA.USA.NA
  ICBM: 121W 56' 58.1" / 37N 20' 14.2"          Internet: steve @ Watt.COM
   Free time?  There's no such thing.  It just comes in varying prices...


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

Date: 6 Oct 1998 07:14:12 GMT
From: Stefaan.Eeckels@ecc.lu (Stefaan A Eeckels)
Subject: Re: Page Break in a report
Message-Id: <6vcg04$ht$1@justus.ecc.lu>

In article <6vc5f8$rqp@newsops.execpc.com>,
	Deva Seetharam <psdspss@execpc.com> writes:
> I need to produce a report using Perl.
> 
> In the header portion of the report, there is a variable
> information(Dept No).
> Whenever the Dept No changes, a page break(new page) should be induced.
> 
> How to do this ?
Elementary, my dear Watson - introduce a variable called
Old_dept_no, set it to zero. Whenever you read a record,
compare its Dept_no to Old_dept_no, and print a header
when its different. Don't skip a page when Old_dept_no is
zero, and don't forget to set Old_dept_no to Dept_no after
printing the header.

After uttering these profound words, Holmes resumed his
violin practice...

-- 
Stefaan
-- 

PGP key available from PGP key servers (http://www.pgp.net/pgpnet/)
___________________________________________________________________
Perfection is reached, not when there is no longer anything to add,
but when there is no longer anything to take away. -- Saint-Exupiry



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

Date: Mon, 05 Oct 1998 23:55:35 -0800
From: madame philosophe <mp@mkt2mkt.com>
To: Eugene Sotirescu <eugene@vertical.net>
Subject: Re: please check my CGI.pm/Perl Syntax
Message-Id: <3619CCC2.13C92293@mkt2mkt.com>

Hi Eugene,

I wasn't sure if save() would know WHAT to save.  Especially since I don't
want to save all the values of the params to the $spy_entry object
(formerly $q).

Basically, I'm trying to save to a file a new object that is only part of
the main $q object.  Am I doing this correctly?

 (Sorry! Sometimes a question is just a question and sometimes it is two or
three.

But all are asked in earnest, rather than laziness. Thanks for your help.)

mp



Eugene Sotirescu wrote:

>  sysopen(LOG, "$activity_path", O_WRONLY|O_APPEND, 0660) ||
> log_error('LOGTRACK_ERR',$spy_entry);
>
>  flock(LOG, LOCK_EX);
>
>  $spy_entry->save($log_row);  #here you mean save->(LOG), no? (save only
> writes to filehandle)
>
>  close LOG;
>
>  flock(LOG, LOCK_UN);  #this is unnecessary: you've already unlocked the
> file when you closed it
>
> madame philosophe wrote:
>
> > Is this syntax correct?
> >
> > Thanks in advance!
> >
> > mp
> > --------
> >
> > sub spy {
> >
> >  local $q = shift;
> >  local $activity_path;
> >
> >  my $spy_entry = new CGI($q);
> >  my(@spy_set, $stuff, $log_row);
> >
> >  foreach ($spy_entry->param() =~
> > /^(person|action|contribution|email|date)$/) {
> >
> >   push(@spy_set, map{ $stuff = $spy_entry->param($_) });
> >
> >    $log_row = join( ' ][ ', @spy_set);
> >
> >   }
> >
> >  sysopen(LOG, "$activity_path", O_WRONLY|O_APPEND, 0660) ||
> > log_error('LOGTRACK_ERR',$spy_entry);
> >
> >  flock(LOG, LOCK_EX);
> >
> >  $spy_entry->save($log_row);
> >
> >  close LOG;
> >
> >  flock(LOG, LOCK_UN);
> >
> > }#end of spy()





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

Date: Tue, 06 Oct 1998 07:37:42 GMT
From: tilman@spp.hpc.fujitsu.co.jp
Subject: Q: Speed up a regular expression
Message-Id: <6vchc6$o23$1@nnrp1.dejanews.com>

Hello !

Is there a way to speed up this regular expression ?

if ($line =~ /(^$Search )|( $Search )/io)

I want to match a string $Search either in the beginning of $line or
within the string $line, but then with a leading SPACE.

Thanks Tilman

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


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

Date: 06 Oct 1998 10:30:28 +0200
From: Michal Rutka <erhmiru@erh.ericsson.se>
Subject: Re: Run cgi scripts ar regular intervals
Message-Id: <laww6ert23.fsf@erh.ericsson.se>

"Jay Scherberth" <jayss@sprintmail.com> writes:
[...]
> Is there a way to get the Perl script to run on it's own (atomically) at
> regular intervals, like, once an hour?

Add to your crontab a line like this:
0 * * * * your_script_here

> 
> Platform is NT IIS4.0.

Oops. I am not NT guru so I don't know if there is something similar to
crontab. On the win95 I saw something called SystemAgent which is something
like M$ 'enhanced' crontab ;-). 

The other solution will be to wrap your script
with the following loop:

while(1){
   eval{
      ... your script comes here
   }
   sleep 3600;
}

> Thanks in advance,

You are welcome.

> Jay Scherberth

Michal


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

Date: 6 Oct 1998 08:43:00 GMT
From: e98_abl@e.kth.se (Anders Blockmar)
Subject: Search string for "pe*l" *=any no of any chars
Message-Id: <6vcl6k$8ug$1@news.kth.se>

My line looks like this:

if(/<!--#exec cgi=\"(? *)\"-->/)

it is suppost to find a call for a exec cgi in a html file. The (? *) is
intended to be the name of the script. How do I type (* ?) in the correct way?

I also want this line to return the "name" of the script found with the match.

eg.

Fins line that looks like this:
<!--#exec cgi="myscript.cgi"-->

then I want it to return 'myscript.cgi' into the if.

Thankful for all tips (Please respond to my mail)

/Anders

-------
I'm not a nerd, I prefer to be called a hacker

                                  Lex, Jurassic Park


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

Date: 6 Oct 98 07:39:25 GMT
From: Zenin <zenin@bawdycaste.org>
Subject: Re: send geroge reese (was Re: Call for Participation: Python Conference)
Message-Id: <907659738.616445@thrush.omix.com>

Abigail <abigail@fnx.com> wrote:
	>snip<
: @{$self -> {_array}}  vs   @array;
:
: The fact your implementation depends on the implementation of your
: parent class. OO is implementation *hiding*, not being depended on it.

	Yes, but this is "old" Perl (ok, by a few months, but still:-).

: Yes, fields.pm makes it a little better.

	Personally, I think it makes it a *lot* better.

: It took only 5 years of OO Perl to come with it.
: Which means that 5 years worth of writing modules
: does *NOT* use fields.pm and suffers from name collision and not having
: data encapsulation.

	True, but it is here now.  As such, this should no longer be
	considered an issue for new, large scale projects that need
	inheritance.

	I'm not worried about CPAN.  Most of the CPAN modules are built
	on a "uses" vs an "is-a" (inheritance) relationship.

	IMHO, inheritance is highly overrated.  A uses relationship is
	much more useful and reusable in most cases.  There never was field
	name collision in a uses relationship.

: Constructors like:
:        sub new {
:            my $class = shift;
:            no strict 'refs';
:            my $self = bless [\%{"$class\::FIELDS"}], $class;
:            $self;
:        }
: only enforce that OO Perl is a hack.
:
: Making anon arrays magical is the first element is a reference to a
: hash is just a kludge.

	This type of constructor is only needed if you want/need to use
	untyped access.  If one is really trying to use these features
	to support large scale projects, it would be unlikely that
	untyped access would be used.

: [  Not to mention the following from perlref:
:
:        WARNING:  This section describes an experimental feature.
:        Details may change without notice in future versions.
:
:    Which means that one shouldn't use the new fluff in serious code,
:    because it might disappear in the future.

	This only affects untyped access, as typed access does not need
	to do this.  Direct Pseudo-hash construction should not be needed
	by most that simply want private/public fields.

-- 
-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, 06 Oct 1998 10:16:59 +0200
From: Hauk Langlo <hauk@forumnett.no>
Subject: Shuffling of array content
Message-Id: <3619D1FB.7330B89E@forumnett.no>

Hi there. I'm about to write a script that will have to shuffle the
content in an array so that the elements are placed in random order. The
arrays will contain a pretty high number of elements, but probably less
than 1000. My fist idea was to go through the array element for element
and exchange it with another random selected element within the same
array. After all elements have been exchanged in that way the result
should then be a well shuffled array. I'm just wondering though, if
there are any better (more effective) ways to do it and if there even is
a special way to acheive this in PERL (Have not found anything about
this in the boks and I have read them). If anyone else have developed a
good routine for doing this or know about a special PERL command, then I
would be very thankfull if you would share your wisdom with me.

Regards Hauk Langlo

PS: No flaming please. I'm a newbie allright, but I have learned (the
hard way) not to post lazyquestions etc. Hope you do not find this
question infuriating.

--

----------------------------------
 Hauk Langlo

 Hauk@forumnett.no
 http://www.forumnett.no/~hauk
 (+047) 93438940
----------------------------------




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

Date: 6 Oct 1998 09:05:01 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: Shuffling of array content
Message-Id: <slrn71jn9t.7c5.sholden@pgrad.cs.usyd.edu.au>

On Tue, 06 Oct 1998 10:16:59 +0200, Hauk Langlo <hauk@forumnett.no> wrote:
>Hi there. I'm about to write a script that will have to shuffle the
>content in an array so that the elements are placed in random order. The
>arrays will contain a pretty high number of elements, but probably less
>than 1000. My fist idea was to go through the array element for element
>and exchange it with another random selected element within the same
>array. After all elements have been exchanged in that way the result
>should then be a well shuffled array. I'm just wondering though, if
>there are any better (more effective) ways to do it and if there even is
>a special way to acheive this in PERL (Have not found anything about
>this in the boks and I have read them). If anyone else have developed a
>good routine for doing this or know about a special PERL command, then I
>would be very thankfull if you would share your wisdom with me.
>
>Regards Hauk Langlo
>
>PS: No flaming please. I'm a newbie allright, but I have learned (the
>hard way) not to post lazyquestions etc. Hope you do not find this
>question infuriating.

Well don't post lazyquestions then...

perldoc perlfaq4 => 'How do I shuffle an array randomly'

Read the description for why your suggested solution is shall we say _really_
bad...

There that wasn't a flame... though I'm sure someone else will get you...

Oh yeah what this really means is RTFM...

-- 
Sam

You can blame it all on the internet. I do...
	--Larry Wall


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

Date: 6 Oct 1998 10:08:05 +0100
From: nja@le.ac.uk (A.J. Norman)
Subject: Re: Split question - retain the pattern?
Message-Id: <6vcmll$b1o@owl.le.ac.uk>

 In article <lazpbb3v50.fsf@erh.ericsson.se>, Michal Rutka 
 <erhmiru@erh.ericsson.se> wrote: 
 > nja@le.ac.uk (A.J.  Norman) writes: 
 > > I'm writing a script to parse text, and want to be able to split 
 > > a block of text (an e-mail message for instance) into sentences.  
 > > I can do something like this: 
 > > 
 > > @Lines = <Infile>; 
 > > $text = Join(" ", @Lines); 
 >           ^-- should be join 

 And is, in the original message (@Lines is @lines, etc).

 Many thanks for all the various solutions (I had already looked at
 split's ability to return the patterns as alternate elements in the
 array, but wanted to avoid having to glue all the full stops back to
 the original sentences).

-- 
Andrew Norman, Leicester, England
nja@le.ac.uk || andrew.norman@le.ac.uk
http://www.le.ac.uk/engineering/nja/


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

Date: 6 Oct 1998 06:28:25 GMT
From: Dan Sugalski <sugalskd@netserve.ous.edu>
Subject: Re: Too late for "-T" option ?
Message-Id: <6vcda9$1eq$1@news.NERO.NET>

Liz Castro <liz@cookwood.com> wrote:
: Marc Haber wrote:
:> 
:> defike@nospam.ilstu.edu (Don) wrote:
:> >I have a program using;
:> >#!/usr/local/bin/perl -Tw
:> >Which returns when run;
:> >Too late for "-T" option at line 1
:> 
:> How is your skript being invoked?
:> 

: I have this same problem. It's the simplest of scripts and I'm invoking it
: from the command line. Still, I get this message. Any thoughts?

The -T switch must be specified on the command line if you invoke the
script.

perl -T foo.pl

will work, while

perl foo.pl

with -T in the shebang line won't work. With 5.004 and up, perl has to
know about tainting before it does very much parsing at all. By the time
perl gets to parsing the #! line for extra switches, it's way too late.

Chip goes into some of this, at least a little, in the latest Perl
Journal. (Ish #11)

					Dan


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

Date: Tue, 06 Oct 1998 09:17:31 GMT
From: Marc.Haber-usenet@gmx.de (Marc Haber)
Subject: Re: Too late for "-T" option ?
Message-Id: <6vcna3$bo9$3@nz12.rz.uni-karlsruhe.de>

Liz Castro <liz@cookwood.com> wrote:
>I have this same problem. It's the simplest of scripts and I'm invoking it
>from the command line. Still, I get this message. Any thoughts?

are you invoking it with perl myscript or myscript with relying on the
shebang magic?

Greetings
Marc

-- 
-------------------------------------- !! No courtesy copies, please !! -----
Marc Haber          |   " Questions are the         | Mailadresse im Header
Karlsruhe, Germany  |     Beginning of Wisdom "     | Fon: *49 721 966 32 15
Nordisch by Nature  | Lt. Worf, TNG "Rightful Heir" | Fax: *49 721 966 31 29


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

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

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