[8535] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2152 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Mar 21 15:07:41 1998

Date: Sat, 21 Mar 98 12:00:34 -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           Sat, 21 Mar 1998     Volume: 8 Number: 2152

Today's topics:
    Re: A Perl version of Crypt <cortez@tfn.com>
    Re: Assign lines of a text file into an array <rjk@coos.dartmouth.edu>
    Re: Assign lines of a text file into an array <rjk@coos.dartmouth.edu>
    Re: Backreference problem <rjk@coos.dartmouth.edu>
    Re: Cacheproblems with cgi-generated html tim@maroney.org
    Re: Changing Substr's into RegEx... <chasecreek.systemhouse@usa.net>
    Re: Changing Substr's into RegEx... <bholzman@mail.earthlink.net>
    Re: Data Storage Strategies? <zenin@archive.rhps.org>
    Re: DBM files... (Mark Schmick)
    Re: Evaluate expression inside print "" <bholzman@mail.earthlink.net>
        for ($x,$y) ([0,0]..[5,5]) revisited <jefpin@bergen.org>
        Help with NT4 Wks <netxu@tin.it>
    Re: Help with Perl code <rjk@coos.dartmouth.edu>
        How do I do this? (newbie questions) <digital_puer@hotmail.com>
    Re: How do I do this? (newbie questions) <chasecreek.systemhouse@usa.net>
        inplace search and replace ( Mark Kucera)
    Re: Large programs: is Perl up to it? <zenin@archive.rhps.org>
    Re: List a directory command?? pleez help! (A. Deckers)
    Re: Perl Daemons <rjk@coos.dartmouth.edu>
    Re: Please help with regexp problem <rjk@coos.dartmouth.edu>
        R.E. (Chico)
        R.E. (Chico)
        reset a array? <shockman@telefragged.com>
    Re: reset a array? <chasecreek.systemhouse@usa.net>
    Re: reset a array? <shockman@telefragged.com>
        Sockets <ctrotto@trotto.com>
    Re: what is wrong with being a novice ?? tim@maroney.org
    Re: Wierd redirection problem with Location: (brian d foy)
        Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Sat, 21 Mar 1998 13:00:15 -0500
From: Frank Cortez <cortez@tfn.com>
To: "Richard W. Koehler" <rkoehler@osmre.gov>
Subject: Re: A Perl version of Crypt
Message-Id: <3514002F.6659@tfn.com>

<Headers and prevs snipped>

> But, as mentioned elsewhere, you can get Crypt.pm and Crypt:DES etc from
> CPAN.  Good luck.
> 
> Rick Koehler, JAPH, or should I say JA-pilgrim-on-the-road-to-Perldom
> (JAPOTRTP)

Uh-- actually, I tried grabbing both Crypt::DES and Crypt::IDEA off
of CPAN and installing them on my version of Perl (the Gurusamy
Sarathy version 5.004_02), and *both* returned the same error
during "make":

------- begin inclusion -------
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 11.00.7022 for
80x86
Copyright (C) Microsoft Corp 1984-1997. All rights reserved.

des.c
des.h(1) : fatal error C1083: Cannot open include file:
'machine/types.h': No su
ch file or directory
NMAKE : fatal error U1077: 'cl' : return code '0x2'
Stop.
-------  end inclusion  -------

Is it possibly due to the "Unix-type" directory specs (being as I'm
running on a machine w/ DOS-type directories)?  All the file
contains is:

------- begin inclusion -------
#include <machine/types.h>

typedef u_int8_t  des_user_key[8];
typedef u_int32_t des_cblock[2];
typedef u_int32_t des_ks[32];

void des_crypt(des_cblock in, des_cblock out, des_ks key, int encrypt);
void des_expand_key(des_user_key userKey, des_ks key);
-------  end inclusion  -------

Of course, I've never heard of a 'u_int8_t' type, and a comprehensive
search for it in my VC++ directories (ALL of them, just to be safe)
didn't produce any matches.  Is this a special low-level type?

Any help, suggestions, etc., would be appreciated.  I'm trying to
write some password authentication programs for my web-site and a
lot of sample-code I've been working with requires crypt().

-Frank


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

Date: Sat, 21 Mar 1998 13:34:35 -0500
From: Ronald J Kimball <rjk@coos.dartmouth.edu>
Subject: Re: Assign lines of a text file into an array
Message-Id: <3514083D.FA41A446@coos.dartmouth.edu>

Eric Bohlman wrote:
> 
> You're right and I was wrong.  That'll teach me not to propose
> cutesy-tricky solutions.

I hope not!  Cutesy-tricky solutions are fun, and they aren't necessarily
wrong.  Straightforward solutions can have mistakes too.

-- 
 _ / '  _      /         - aka -             rjk@coos.dartmouth.edu
( /)//)//)(//)/(    Ronald J. Kimball           chipmunk@m-net.arbornet.org
    /                                   http://www.ziplink.net/~rjk/
        "It's funny 'cause it's true ... and vice versa."


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

Date: Sat, 21 Mar 1998 13:38:36 -0500
From: Ronald J Kimball <rjk@coos.dartmouth.edu>
Subject: Re: Assign lines of a text file into an array
Message-Id: <3514092F.35C68560@coos.dartmouth.edu>

Tony Curtis wrote:
> 
> Re: Assign lines of a text file into an array, C
> <csml1@ukc.ac.uk> said:
> 
> C> Is it possible to assign each line of a text file into an
> C> associative array where the key will be the line number
> C> and the value will be a string variable containing the
> C> whole line?
> 
> Yes.
> 
> But what has this got to do with perl per se?

Sheesh.  He's asking if it's possible to do it in Perl.  Duh.

-- 
 _ / '  _      /         - aka -             rjk@coos.dartmouth.edu
( /)//)//)(//)/(    Ronald J. Kimball           chipmunk@m-net.arbornet.org
    /                                   http://www.ziplink.net/~rjk/
        "It's funny 'cause it's true ... and vice versa."


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

Date: Sat, 21 Mar 1998 14:03:58 -0500
From: Ronald J Kimball <rjk@coos.dartmouth.edu>
Subject: Re: Backreference problem
Message-Id: <35140F22.F03FB827@coos.dartmouth.edu>

Dan Boorstein wrote:
> 
> Craig Berry wrote:
> >
> > Frederic RIVOALLON (frederic@xilinx.com) wrote:
> > :   I would like to insert the string '01' before an underscore in a
> > : string so I wrote:
> > :
> > : $StringToBeChanged =~ s/(.*)_/$101_/;
> > :
> > : But this does not work perl must be looking for $101 instead of $1 and
> > : then 01.
> >
> > Yes.
> 
> i think it is actually looking for '$101_'.

Nope.  It's looking for $101.

  DB<1> $_ = "foo"

  DB<2> s/(f)/$101_/

  DB<3> x $_
0  '_oo'


Which is what I'd expect, as '101' does not start with a letter or underscore.

-- 
 _ / '  _      /         - aka -             rjk@coos.dartmouth.edu
( /)//)//)(//)/(    Ronald J. Kimball           chipmunk@m-net.arbornet.org
    /                                   http://www.ziplink.net/~rjk/
        "It's funny 'cause it's true ... and vice versa."


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

Date: Sat, 21 Mar 1998 12:18:20 -0600
From: tim@maroney.org
Subject: Re: Cacheproblems with cgi-generated html
Message-Id: <6f105m$f44$1@nnrp1.dejanews.com>

In article <35138CED.17EE3ECC@hrz1.hrz.tu-darmstadt.de>,
  Raphael Breiting <totalrel@hrz1.hrz.tu-darmstadt.de> wrote:
> Can cgi-generated html-documents be cached by proxy servers?

Yes. Not to mention browsers.

> If they can be cached, what can i do to prevent the proxys from caching
> these pages?

They aren't guaranteed to pay attention to anything you do, but you can try
putting this out as your HTTP header:

print STDOUT "Content-type: text/html\n";
print STDOUT "Pragma: no-cache\n";
print STDOUT "Cache-Control: no-cache\n";
print STDOUT "Expires: Fri, 13 Feb 1998 00:00:01 GMT\n"; # the past
print STDOUT "\n";

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/   Now offering spam-free web-based newsreading


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

Date: Sat, 21 Mar 1998 17:10:12 GMT
From: Sneex <chasecreek.systemhouse@usa.net>
Subject: Re: Changing Substr's into RegEx...
Message-Id: <3513F319.7050D211@usa.net>

Thank you, I appreciate you responding so
quickly and plainly :-)  I have tried out
some combinations below -

Benjamin Holzman wrote:

>     remote_addr =~ /^((?:\d+\.??){3})/;
>     if (my $domain_info = $fccjDomains{$1}) {

If I understand what is happening here -
the ?: and ?? group the addr string in groups of  '.' and
the {3} determines from which '.' to stop the match at?

So, the above would match 24.129.0 out of 24.129.0.61  and
 remote_addr =~ /^((?:\d+\.??){2})/;  would match
24.129 out of 24.129.0.61  -  right?  Therefore -
$a_Class = 1;  # NET.HOST.HOST.HOST
$b_Class = 2;  # NET.NET.HOST.HOST
$c_Class = 3;  # NET.NET.NET.HOST
$d_Class = 4;  # Entire address required...
remote_addr =~ /^((?:\d+\.??){$d_Class})/;
would match the whole addr of 24.129.0.61 !?!

I see other possibilties here, as well...

Very nice - Thank you!
Bill :-)




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

Date: Sat, 21 Mar 1998 12:19:06 -0500
From: Benjamin Holzman <bholzman@mail.earthlink.net>
To: sneaker@earthling.net
Subject: Re: Changing Substr's into RegEx...
Message-Id: <3513F68A.594560B3@mail.earthlink.net>

Sneex wrote:
> 
> Thank you, I appreciate you responding so
> quickly and plainly :-)  I have tried out
> some combinations below -
> 
> Benjamin Holzman wrote:
> 
> >     remote_addr =~ /^((?:\d+\.??){3})/;
> >     if (my $domain_info = $fccjDomains{$1}) {
> 
> If I understand what is happening here -
> the ?: and ?? group the addr string in groups of  '.' and
> the {3} determines from which '.' to stop the match at?
Almost, but not quite.  The (?: ... ) is just a grouping mechanism, like
( ... ), except that it doesn't save what it groups into a $n variable. 
What it groups is one or more numbers optionally followed by a period. 
The reason there's a non-greedy optional quantifier (??) on the period
is so the last octet doesn't have a trailing period.  So, for instance,
if the pattern was a) /^((?:\d+\.){3})/ or b) /^((?:\d+\.?){3})/ and you
matched against '24.129.0.61', $1 would contain '24.129.0.' either
because a) it didn't have a choice or b) it had a choice but it _could_
match, so it did. To understand this, it really helps to have a mental
picture of the NFA at work. There's a great article by Jeffrey Friedl in
the September 1996 issue of "The Perl Journal" about this.  He's also
written a book "Mastering Regular Expressions", published by O'Reilly. 
I haven't read it personally, but I've heard great things about it. 
Good luck!

Benjamin Holzman
> 
> So, the above would match 24.129.0 out of 24.129.0.61  and
>  remote_addr =~ /^((?:\d+\.??){2})/;  would match
> 24.129 out of 24.129.0.61  -  right?  Therefore -
> $a_Class = 1;  # NET.HOST.HOST.HOST
> $b_Class = 2;  # NET.NET.HOST.HOST
> $c_Class = 3;  # NET.NET.NET.HOST
> $d_Class = 4;  # Entire address required...
> remote_addr =~ /^((?:\d+\.??){$d_Class})/;
> would match the whole addr of 24.129.0.61 !?!
> 
> I see other possibilties here, as well...
> 
> Very nice - Thank you!
> Bill :-)


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

Date: 21 Mar 1998 18:44:58 GMT
From: Zenin <zenin@archive.rhps.org>
Subject: Re: Data Storage Strategies?
Message-Id: <890506278.510946@thrush.omix.com>

[ posted & mailed ]

Wade Williams wwilliam@cisco.com> wrote:
: I'd like to hear the strategies some of you experts have used for storing
: complex data structures in files.

	Check out any or all of these at your local CPAN:

	Data::Dumper
	Storable
	MLDBM

-- 
-Zenin
 zenin@archive.rhps.org


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

Date: Sat, 21 Mar 1998 18:39:43 GMT
From: mark@webz.com (Mark Schmick)
Subject: Re: DBM files...
Message-Id: <3513efb4.83945371@news.flash.net>

On Fri, 20 Mar 1998 22:28:40 GMT, Bill Lewis <Bill.Lewis@mci.com>
wrote:

>I am looking to implement a simple online web maintenance log for
>machines.  I have a form to fill out and right now am writing the data
>via a perl script to a flatfile.  What I want to do is write it to a
>database type file.
>
>Is DBM a viable way to store this data for later retrieval?  I am trying
>to make it as painless as possible to move this code to different
>platforms after I am finished.
>
>Is it possible to get perl to write to the DBM file?  I have read the
>man pages on  tie and untie, but I havent seen any examples of changing
>the data and writing it.  Once I do a tie to the hash is any data
>changed contained in the file after I untie it?

When tie'ing DBM files, you'll want to use the bundled AnyDBM_File
module, whose man page is slightly more helpful than the tie pages
you looked at; it lists a handy table comparing the various DBM
implementations, and suggests that for tie'ing DBM files you need to
'use' a pair of modules:

AnyDBM_File -- plumbing classes for various DBM implementations
Fcntl       -- defines O_* flags needed in tie'ing syntax.

Here's a *simple* DBM example that updates a record:

use AnyDBM_File;
use Fcntl;
tie( %hash, AnyDBM_File, 'disk_hash', O_CREAT|O_RDWR, 0644 );
	$hash{this} = 'that';	updates or creates record in disk_hash
untie %hash;

YIP,
Mark

>any help is appreciated.  If there is a site where I can find or read
>more about this, drop it to me.
>
>thanks,
>-- 
>Bill Lewis, Senior Unix System Administrator
>MCI Telecommunications Corp.
>email: Bill.Lewis@mci.com



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

Date: Sat, 21 Mar 1998 13:04:49 -0500
From: Benjamin Holzman <bholzman@mail.earthlink.net>
To: Gary Trachier <trachier@crrel.usace.army.mil>
Subject: Re: Evaluate expression inside print ""
Message-Id: <35140141.13E4CBFE@mail.earthlink.net>

For the neatest way to do this, check out:

http://www.plover.com/~mjd/perl/Identity/

Gary Trachier wrote:
> 
> Hi Everyone,
> 
> I've been scratching my head over this one, and it is time to ask for help.
>  I want to evaluate an expression inside double-quotes of a print
> statement.  How can it be done?
> 
> Here is an example:
> 
> {
>         my      $var = 5;
> 
>         print "N plus one is ($var + 1)\n";
> }
> It should print out
> N plus one is 6
> 
> Simple, right?
> 
> Thanks for your help.
> 
> -Gary


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

Date: Sat, 21 Mar 1998 13:12:40 -0800
From: Je ne care pas! <jefpin@bergen.org>
To: perl5-porters@perl.org
Subject: for ($x,$y) ([0,0]..[5,5]) revisited
Message-Id: <Pine.PCW.3.96.980321130447.13198A-100000@techmaster.bergen.org>

I am currently making (or trying to make) Iterate.pm, which would allow
for something like the
	for ($x,$y) ([0,0]..[5,5]){ ... }

Now... the thing is, I'm having major difficulty in making it work for any
size ($a,$b,$c..$var) thing.

Here is how it would be called:

use Iterate;

iterate([$a,$b,$c],[[0..4],[0..10],[0..2]],{BLOCK});

Granted, it isn't very glamorous... :)  But the trouble is, in the module
itself, I'm stuck with not being able to C<my> variables, and I don't want
to make global ones (not good coding, I think)...

package Iterate;
use strict vars;

BEGIN {
	use Exporter();
	use vars qw( @ISA @EXPORT );

	@ISA = qw( Exporter );
	@EXPORT = qw( &iterate );
}

sub iterate(\@\@\&){
	my ($vars,$vals,$sub) = @_;
	my $tmp;
	for $tmp (0..@$vars-1){
		my ${"a$tmp"} = $vars->[$tmp];
		# here's where I'm stuck... the C<my> vars don't work
		# outside the for loop, and I'm not sure how to make
		# them ONLY in the subroutine WITHOUT making them
		# global... and I'm not sure how to do THAT either,
		# because this is supposed to take any number of vars.
	}
}

I'm not sure if the P5P mailing-list is where I should have sent this, but
I am curious if anyone else has tried to make an Iterate module.

Until the next hack,
Jeff Pinyan




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

Date: Sat, 21 Mar 1998 17:06:48 +0100
From: Marcello Veggiotti <netxu@tin.it>
Subject: Help with NT4 Wks
Message-Id: <3513E598.2667539D@arese.com>

Hi all, can someone help me configuring Perl and IIS4 (using the one in
NT option pack).
I have perl working on my PC, but when I call a perl file from the
browser, it askes me to open it. I have set permissions in the
configuration pannel so to have my cgi-local dir allowed to excecute
programs and scripts ... files .exe work, but .pl not.
how can I solve it?

Please, send a copy directly to me:
net4u@arese.com



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

Date: Sat, 21 Mar 1998 14:40:46 -0500
From: Ronald J Kimball <rjk@coos.dartmouth.edu>
Subject: Re: Help with Perl code
Message-Id: <351417C4.B5A78E35@coos.dartmouth.edu>

Ravi C. Kumar wrote:
> 
> Mark,
> 
> First split the fields, then it is real easy with regex
> try s/(.)\1/(\1\1)/g on the first split variable, this may not
> the most efficient, but a good start.  Also, note that this
> will parenthesize an expression with three same chars such
> as 'trrr xttt' to 't(rr)r x(tt)t' etc.,

Note: $1 instead of \1 is preferred on the RHS of a subsitution.

Good point about triple letters.  A possible solution:

s/((\w)\2+)/length $1 == 2 ? "($1)" : $1/eg;

> MARK AMBROSE wrote:
> 
> > With the use of Regular Expressions, how do I code it so that in a
> > particular line of text, it recognises instances of double letters, or
> > double characters, and makes them appear in parentheses.

-- 
 _ / '  _      /         - aka -             rjk@coos.dartmouth.edu
( /)//)//)(//)/(    Ronald J. Kimball           chipmunk@m-net.arbornet.org
    /                                   http://www.ziplink.net/~rjk/
        "It's funny 'cause it's true ... and vice versa."


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

Date: Sat, 21 Mar 1998 09:51:05 -0800
From: Digital Puer <digital_puer@hotmail.com>
Subject: How do I do this? (newbie questions)
Message-Id: <3513FE09.53AEDEB2@hotmail.com>

I'm a newbie who wants to migrate slowly from using
shell scripts to perl. Please tell me how I can do
this construct (which I use the most):

foreach file (*.whatever)
	blah
end


Also, is there a built-in way to get the length of
a file, besides $filelength = `wc -l file` ?
And also the number of files in a directory besides
`ls | wc -l` ?



Don't have the money to buy the camel book, but will
later for sure.


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

Date: Sat, 21 Mar 1998 18:37:24 GMT
From: Sneex <chasecreek.systemhouse@usa.net>
Subject: Re: How do I do this? (newbie questions)
Message-Id: <35140789.E793E766@usa.net>

I could have sworn wc -l counted the
number of lines in a file?

The other stuff is -

use diagnostics;
foreach (<>) {
#do stuff...
}

where the above is called via command line as
perl -w script.pl filename1.fil filename2.fil ...

HTH,
Sneex :-)
PS - $40 or $50 is a good investment - get a book :-)

Digital Puer wrote:

> I'm a newbie who wants to migrate slowly from using
> shell scripts to perl. Please tell me how I can do
> this construct (which I use the most):
>
> foreach file (*.whatever)
>         blah
> end
>
> Also, is there a built-in way to get the length of
> a file, besides $filelength = `wc -l file` ?
> And also the number of files in a directory besides
> `ls | wc -l` ?
>
> Don't have the money to buy the camel book, but will
> later for sure.





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

Date: Sat, 21 Mar 1998 05:58:03 GMT
From: kucera@mindsrping.com ( Mark Kucera)
Subject: inplace search and replace
Message-Id: <3513553f.12018471@news.mindspring.com>

ok so far the help from this group has been above par, so i come again
with a delima...  btw i have consorted the camel book, and man pages
and still can't find an answer to my problem


here is the problem.  i have two data files  with one record per line
in each file.

lets call file one the master data file, and file two the test data
which is created dynamically from some tests.

we want to walk through the master file, line by line, and see if it
is in the test file  (we can do this )  if it is in the test file  we
want to be able to flag that entry in the master file in its location
(by adding a * to one of the fileds.)  we want to update in place, we
DON't want to rewrite the file each time this case occurs.  isnt there
some sort of search replace feature in perl??

please help if you have any information that would prove useful..

thanks so much once again.

mark kucera  kucera@mindspring.com
jay posey jposey@isis.unc.edu






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

Date: 21 Mar 1998 18:58:11 GMT
From: Zenin <zenin@archive.rhps.org>
Subject: Re: Large programs: is Perl up to it?
Message-Id: <890507070.894615@thrush.omix.com>

Jean-Louis Leroy <jll@skynet.be> wrote:
: 1) Whether it *could* have been done in Perl + Tk, at least in 
: principle.
	>snip<

	To general of a question.  Perl/Tk is vary useful, but a little
	limited.  -It has to be, or it would be Motif, or (gasp) xlib.	:-)
	If you don't need anything really fancy (As far as the GUI is
	concerned), Perl/Tk would probably be fine.  However, you really
	should look at the Tk widget set a little deeper before making any
	large decisions.  -Eg, I wouldn't ever suggest trying to write
	Netscape or Word in Perl/Tk, but an interface like WinZip or WS_FTP
	uses would be pretty straightforward.

: 2) More realistically (client demanded app in C++), whether I could 
: write admin apps in Perl.

	Again, it depends.  Most admin style apps don't need a really
	fancy GUI, so it's probably a good choice.

: I've heard of the dump'n'retstart feature, but it seems extremely 
: OS-dependant.

	Yep.  SunOS only (and maybe HPUX?), if I remember correctly...

: Also heard rumors of (portbale?) ways of saving the
: opcodes after compilation, thus skipping the parser at startup time...

	There is work being done on a Perl compiler with a few backends, one
	of which would store perl opcodes (Perl bytecode) that could be
	eval()ed later.  Check out CPAN.  I don't know the link off hand.

-- 
-Zenin
 zenin@archive.rhps.org


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

Date: 21 Mar 1998 17:00:25 GMT
From: Alain.Deckers@man.ac.uk (A. Deckers)
Subject: Re: List a directory command?? pleez help!
Message-Id: <slrn6h7sh8.sos.Alain.Deckers@bashful.rediris.es>

In <6f0nu3$2ae$1@viper.america.net>,
	Mark Polakow <mark@imp.net> wrote:
>I know this is a supremely NEWBEE question, but that's what I am!

How does being a newbee prevent you from reading the FAQ and the
documentation provided with Perl?

And there's no need to multipost your question here and in ciwac.

=item readdir DIRHANDLE

Returns the next directory entry for a directory opened by opendir().
If used in a list context, returns all the rest of the entries in the
directory.  If there are no more entries, returns an undefined value in
a scalar context or a null list in a list context.

If you're planning to filetest the return values out of a readdir(), you'd
better prepend the directory in question.  Otherwise, because we didn't
chdir() there, it would have been testing the wrong file.

    opendir(DIR, $some_dir) || die "can't opendir $some_dir: $!";
    @dots = grep { /^\./ && -f "$some_dir/$_" } readdir(DIR);
    closedir DIR;

Alain
-- 
Perl reference: <URL:http://reference.perl.com/>
 Perl language: <URL:http://language.perl.com/>
  Perl archive: <URL:http://www.perl.com/CPAN/>
      Perl FAQ: <URL:http://www.perl.com/CPAN/doc/FAQs/FAQ/>


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

Date: Sat, 21 Mar 1998 14:34:37 -0500
From: Ronald J Kimball <rjk@coos.dartmouth.edu>
Subject: Re: Perl Daemons
Message-Id: <35141653.42C301CC@coos.dartmouth.edu>

Mark Kucera wrote:
> 
> hi, i have a perl script that i want to make into a daemon.  how would
> i go about doing it?

On the evening of a full moon, draw a pentagram on the floor with chalk.  At
each of the five points of the pentagram, place an unlit black candle in a
silver candlestick.  Place your Perl script in the exact center of the
pentagram.  Light four of the candles, starting with any one candle, and then
proceeding along the lines of the pentagram to light three more.  Using a
knife forged during a solar eclipse, slice the palm of your left hand.  Allow
three drops of blood to fall from your hand onto the Perl script.  Quickly
light the fifth candle and then invoke the name of the daemon whose spirit you
wish to imbue into your Perl script.

-- 
 _ / '  _      /         - aka -             rjk@coos.dartmouth.edu
( /)//)//)(//)/(    Ronald J. Kimball           chipmunk@m-net.arbornet.org
    /                                   http://www.ziplink.net/~rjk/
        "It's funny 'cause it's true ... and vice versa."


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

Date: Sat, 21 Mar 1998 13:50:32 -0500
From: Ronald J Kimball <rjk@coos.dartmouth.edu>
Subject: Re: Please help with regexp problem
Message-Id: <35140BFB.2D8DCC1E@coos.dartmouth.edu>

[posted but not mailed - munged addresses are annoying]

Alan Silver wrote:
> 
> while (<>) {
>   s@(src|SRC)=\"(/.*)\"@$1=\"$host$2\"@ig;
      ^^^^^^^^^   ^^^^^

1. Makes using /i kind of a waste, doesn't it?

2. You'd better hope there are no other quotes on that line.  Your subsitution
will screw up with:
<IMG SRC="foo.gif"> <IMG SRC="bar.gif">

s,(src)=\"(/[^"]*)\",$1=\"$host$2\",ig;

> }
> 
> Now, by the time the substitution above has taken place, all references
> will be either full (ie start with "http://etc") or will be relative (ie
> don't start with http or /). How do I tell ?

Either way, the reference will not start with a /.  So why are you requiring a
slash in the above regex?

Or did you mean that *after* the above substitution has taken place,
references will be either full or relative, and you want a second subsitution
to deal with relative references?

> Please explain what your regexp does as I would like to understand them
> (as well as have code that works).

s,(src)=\"(?!http:)(.*)\",$1=\"$host$base$2\",ig;
          ^^^^^^^^^                 ^^^^^

1. Negative lookahead assertion: string does not match 'http' at this point

2. Like earlier substitution, only add path to base too.

-- 
 _ / '  _      /         - aka -             rjk@coos.dartmouth.edu
( /)//)//)(//)/(    Ronald J. Kimball           chipmunk@m-net.arbornet.org
    /                                   http://www.ziplink.net/~rjk/
        "It's funny 'cause it's true ... and vice versa."


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

Date: Sat, 21 Mar 1998 18:20:58 GMT
From: ffgs@minerva.del.ufrj.br (Chico)
Subject: R.E.
Message-Id: <6f10g0$9pi@news.iis.com.br>

hello...

can anyone help me with one regular expression?

for example,
i have one string> '  "hello here" hi there  '
and i want to put it in an array like this:
arr[0] = hello here
arr[1] = hi
arr[2] = there

i tried something even in more than one line... but i'm not really
good at this...

and i'd like also, if possible, an URL with something about regular
expressions!

thank you



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

Date: Sat, 21 Mar 1998 18:25:25 GMT
From: ffgs@minerva.del.ufrj.br (Chico)
Subject: R.E.
Message-Id: <6f10oa$9qj@news.iis.com.br>

hello...

can anyone help me with one regular expression?

for example,
i have one string> '  "hello here" hi there  '
and i want to put it in an array like this:
arr[0] = hello here
arr[1] = hi
arr[2] = there

i tried something even in more than one line... but i'm not really
good at this...

and i'd like also, if possible, an URL with something about regular
expressions!

thank you



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

Date: Sat, 21 Mar 1998 19:08:05 +0100
From: "Magnus \"ShockMan\" Blikstad" <shockman@telefragged.com>
Subject: reset a array?
Message-Id: <35140205.C72B8DA2@telefragged.com>

how do i reset a array, i need to do this in one of my CGI scripts... i
looked through the perl documents but i cant find anything... any ideas?

-Magnus "ShockMan" Blikstad



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

Date: Sat, 21 Mar 1998 18:39:21 GMT
From: Sneex <chasecreek.systemhouse@usa.net>
Subject: Re: reset a array?
Message-Id: <351407FE.1ADBE3EC@usa.net>

Try either -
undef @array;
@array = '"";

HTH,
Sneex  :-)


Magnus "ShockMan" Blikstad wrote:

> how do i reset a array, i need to do this in one of my CGI scripts... i
> looked through the perl documents but i cant find anything... any ideas?
>
> -Magnus "ShockMan" Blikstad





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

Date: Sat, 21 Mar 1998 20:31:54 +0100
From: "Magnus \"ShockMan\" Blikstad" <shockman@telefragged.com>
Subject: Re: reset a array?
Message-Id: <351415AA.23C25E90@telefragged.com>

@array = "";
wont work, thats how i had it before... well, it kinda works but it wont
remove the array it will just put nothing in it... but it will still be there.

undef @array; works fine though! thanx alot...

Sneex wrote:

> Try either -
> undef @array;
> @array = '"";
>
> HTH,
> Sneex  :-)
>
> Magnus "ShockMan" Blikstad wrote:
>
> > how do i reset a array, i need to do this in one of my CGI scripts... i
> > looked through the perl documents but i cant find anything... any ideas?
> >
> > -Magnus "ShockMan" Blikstad



--
##########################
# Magnus "ShockMan" Blikstad #
#  shockman@telefragged.com   #
#    chemical.telefragged.com      #
#  www.quake2.com/converted  #
#         UIN:1017564                 #
##########################




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

Date: Sat, 21 Mar 1998 12:30:47 -0600
From: "carl m. trotto jr." <ctrotto@trotto.com>
Subject: Sockets
Message-Id: <35140757.63F074C@trotto.com>


--------------6856DF20DCBC57BB05AAE6DD
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

for($fh = "fh00", $i = 0; $i != $MAXSOCKET; $i++, $fh++ ) {
   socket($fh, AF_INET, SOCK_DGRAM, $proto ) || die "socket: $!";
   $qsock[$i] = $fh;
   select(fileno($fh)); $| = 1;
}

Why doesn't the above code snippet work.  I think "socket" regards "$fh"
as a file.  How can open more than one socket.
I did try IO::Socket but I had other problems there.  Anyway the above
should work.

Perl  version 5.004_02 Win95 Standard not ActiveWare

Regards,
Carl

--------------6856DF20DCBC57BB05AAE6DD
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit

<HTML>
<TT>for($fh = "fh00", $i = 0; $i != $MAXSOCKET; $i++, $fh++ ) {</TT>
<BR><TT>&nbsp;&nbsp; socket($fh, AF_INET, SOCK_DGRAM, $proto ) || die "socket:
$!";</TT>
<BR><TT>&nbsp;&nbsp; $qsock[$i] = $fh;</TT>
<BR><TT>&nbsp;&nbsp; select(fileno($fh)); $| = 1;</TT>
<BR><TT>}</TT><TT></TT>

<P>Why doesn't the above code snippet work.&nbsp; I think "socket" regards
"$fh" as a file.&nbsp; How can open more than one socket.
<BR>I did try IO::Socket but I had other problems there.&nbsp; Anyway the
above should work.

<P>Perl&nbsp; version 5.004_02 Win95 Standard not ActiveWare

<P>Regards,
<BR>Carl</HTML>

--------------6856DF20DCBC57BB05AAE6DD--



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

Date: Sat, 21 Mar 1998 12:11:38 -0600
From: tim@maroney.org
Subject: Re: what is wrong with being a novice ??
Message-Id: <6f0vp4$e6j$1@nnrp1.dejanews.com>


>I'd be very surprised if many would claim that the bandwidth is a
>major concern.  The concern is the time.  The questions in question
>waste very precious time.

Uh, hello, time is bandwidth. When people refer to their news or mail reading
bandwidth they are referring to how much information they personally have to
sort through. This has been a standard idiom on USENET from the beginning, or
at least since I joined in 1982. You might want to reread my message in this
light. Pointless flames are bigger bandwidth wasters than sincere questions of
possible general interest.

>It's just not true.  The "flamers," as you call them, aren't wasting
>anyone's time except arguably their own at times.

Funny, I could swear they're wasting mine. I click on a message hoping to find
information and instead I find some stupid flame. If that's not a waste of
time, what is?

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/   Now offering spam-free web-based newsreading


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

Date: Sat, 21 Mar 1998 12:40:12 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: Wierd redirection problem with Location:
Message-Id: <comdog-ya02408000R2103981240120001@news.panix.com>
Keywords: from just another new york perl hacker

In article <3518e2e4.11613397@news.omen.net.au>, UCE-trap_synic@omen.net.au (Peter Caffin) posted:

>culrich@i2000.net did cunningly address to comp.lang.perl.misc..
>:             print "Content-type: text/html\n";
>:             print "Location: http://www.xyz.com/page1.htm\n\n";
>:
>:It merely puts a hyperlink on the screen.  It should do redirection to the
>:full URL.  Instead, it puts a hyperlink on the screen.  Is this a Perl issue?
>:Solaris?  Configuration of Solaris?  Thanks in avance.
>
>Use only: 'print "Location: http://www.xyz.com/page1.htm\n\n";'
>
>By using both, you're telling the web browsers with the first line that "print
>'Location: http://www.xyz.com/page1.htm\n\n";' should be interpreted as HTML
>rather than as a header.

thanks for trying, but you're wrong.

both of those lines are in the HTTP header which isn't terminated
until the first blank line.  if you read the HTTP specification [1], you 
will discover that it suggests that redirections include a short
hypertext note in the HTTP message body.  this means that the
Content-type header is not only valid in this situation, but
recommended.

[1] see the CGI Meta FAQ

-- 
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 <URL:http://www.pm.org>


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

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

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