[10618] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4210 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Nov 12 22:07:44 1998

Date: Thu, 12 Nov 98 19:00:38 -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           Thu, 12 Nov 1998     Volume: 8 Number: 4210

Today's topics:
        a RE for email addresses? <nospam.gear4u@hotmail.com>
        access to web (open (IN,"<http://www.n.de/hal.htm")) (Jochen Staerk)
    Re: access to web (open (IN,"<http://www.n.de/hal.htm") <rootbeer@teleport.com>
        Allowing escaped characters in a split joseph@zieglerzone.com
    Re: Breathtakingly concise Perl code (Dan Carson)
    Re: Clear screen? (Paul Sisson)
    Re: Exit UNIX from within a perl program (courtesy)
    Re: Exit UNIX from within a perl program (courtesy)
    Re: Exit UNIX from within a perl program (John Stanley)
    Re: flock <rootbeer@teleport.com>
    Re: HELP!!!  Script needed to create a site index <rootbeer@teleport.com>
    Re: How to resolve sym links <rootbeer@teleport.com>
        How: Run Perl Script Within Perl Script !! shazad@my-dejanews.com
    Re: How: Run Perl Script Within Perl Script !! (Martien Verbruggen)
        Is __DIE__ a real signal? (with real signal limitations <b.d.low@unsw.edu.au>
    Re: Is __DIE__ a real signal? (with real signal limitat <rootbeer@teleport.com>
    Re: Is __DIE__ a real signal? (with real signal limitat <zenin@bawdycaste.org>
    Re: Is __DIE__ a real signal? (with real signal limitat <dgris@moiraine.dimensional.com>
    Re: Is __DIE__ a real signal? (with real signal limitat <zenin@bawdycaste.org>
    Re: Is it possible to pass ref of regular expression? (Damian Conway)
        MacPerl, Help, and Internet Config johnny99@sydney.dialix.oz.au
    Re: Occasional Perl Script Failure <campb@think.ucdavis.edu>
    Re: perl cgi script <rootbeer@teleport.com>
    Re: Q: are symbolic refs really needed (was Re: Modific <jim.gillespie@usa.net>
        Raw Sockets <carvdawg@patriot.net>
    Re: Regular Expressions in Java (Alan Barclay)
    Re: Search for a script! <rootbeer@teleport.com>
    Re: SMTP server on the Web <craig@patchett.com>
    Re: SMTP server on the Web (Alastair)
    Re: Suidperl? <rootbeer@teleport.com>
    Re: This is flocking tricky <rootbeer@teleport.com>
    Re: This is flocking tricky <zenin@bawdycaste.org>
        Trying to remove item from a list <kole@semp.net>
    Re: Trying to remove item from a list <rootbeer@teleport.com>
    Re: What's wrong with this perl program? -from a beginn <rootbeer@teleport.com>
        Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)

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

Date: Thu, 12 Nov 1998 21:11:06 -0500
From: sara starre <nospam.gear4u@hotmail.com>
Subject: a RE for email addresses?
Message-Id: <364B953A.C359E0BB@hotmail.com>

I tried to use the /.+\@.+\..+(\..+)*/ to find good email addresses, but
it let
"my mail@myplace.com" thru, so I modified it to:  /.+\@.+\..+(\..+)*/ &&
!/[\s]/

According to my camel book, /.+/ should be one or more characters- is
whitespace considered a character?

Does anyone have any better suggestions for RE's to validate email
addresses? This one seems pretty good:

good: mymail@mycompany.com
bad: mymail#myplace.com
bad: my mail@myplace.com
bad: mymail@myplace
good: m1ymail@my1place2.com3good:
good: m1ymail@my1place2.mystate.com3
bad: m1ymail@my1place2.mystate. com3

HUG!
S
PS: Thanks for the help with my assignment question.. :)




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

Date: 12 Nov 1998 21:13:04 GMT
From: BlackAnt@t-online.de (Jochen Staerk)
Subject: access to web (open (IN,"<http://www.n.de/hal.htm"))
Message-Id: <72fj10$ph$1@news00.btx.dtag.de>

how can i "read" an homepage from the net?
(please email back)





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

Date: Fri, 13 Nov 1998 01:05:27 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: access to web (open (IN,"<http://www.n.de/hal.htm"))
Message-Id: <Pine.GSO.4.02A.9811121705080.791-100000@user2.teleport.com>

On 12 Nov 1998, Jochen Staerk wrote:

> how can i "read" an homepage from the net?

Use the LWP module from CPAN. Hope this helps!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Fri, 13 Nov 1998 02:29:51 GMT
From: joseph@zieglerzone.com
Subject: Allowing escaped characters in a split
Message-Id: <72g5iv$31t$1@nnrp1.dejanews.com>

I'm trying to split on a comma, but I would like to allow people to escape the
original string to allow a comma to exist after the split.

Example:
cars, trucks, vans\,s, bikes
Should split into
cars
trucks
van,s
bikes

Any ideas?  Thanks!

-Joseph
joseph@zieglerzone.com

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


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

Date: 12 Nov 1998 16:38:50 -0800
From: dbc@tc.fluke.com (Dan Carson)
Subject: Re: Breathtakingly concise Perl code
Message-Id: <72fv2q$scc$1@chelan.tc.fluke.com>

In article <UDF22.6361$fS.20909691@news.itd.umich.edu>,
Sean McAfee <mcafee@waits.facilities.med.umich.edu> wrote:
>After a few code iterations, I was eventually able to populate my data
>structure with a single line:
>
>@spell{ /"(.+?)"/ } = [ /[A-Z]\d?(?=[,}])/g ] while <DATA>;
>
>Oooooooo!  *Fantastic!*  I was patting myself on the back for days.
>
>Anyone else care to share any wonderfully concise Perl code?

Well, I can't match that, but I do have one to share.  When I want a deep
copy of an arbitrary data structure, I use Data::Dumper or FreezeThaw.
But once I wanted to copy a specific structure: a square matrix of numbers
implemented as $matrix = [ [...], [...], [...], etc. ];  I usually avoid
the one-liner in favor of something that's really easy to read.  But
there's always an exception, right?

my $copy = [map {[@$_]} @$matrix];

-Dan


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

Date: Thu, 12 Nov 1998 17:08:26 -0800
From: admin@the-signal.com (Paul Sisson)
Subject: Re: Clear screen?
Message-Id: <admin-ya02408000R1211981708260001@news.smartlink.net>

In article <36424c00.30075048@news.algonet.se>, gustafl@algonet.se (Gustaf
Liljegren) wrote:

> I'm trying to make a text based configuration script wich consist of a
> few menus in a hierarchical system. The script will run in UNIX (I'm
> using the Perl interpreter of my ISP in Telnet). If it's not to hard,
> I would like to clear the screen between the menus. Like the UNIX
> command "clear" or DOS command "cls". If I remember correctly, there
> is a clear screen command in C/C++ also, but I can't find this
> function in Perl.

Use these subs:

sub CLS     { print "\e[;H\e[2J"; } # clear screen
sub INVERSE { print "\e[7m"; }      # inverse screen
sub NORMAL  { print "\e[0m"; }      # normal screen

They work for me...

-Paul Sisson


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

Date: 13 Nov 1998 00:18:28 GMT
From: Bob Shair (courtesy) <rmshair@delphi.itg.uiuc.edu>
Subject: Re: Exit UNIX from within a perl program
Message-Id: <72ftsk$h50$1@vixen.cso.uiuc.edu>

Zhengdong Zhang <zzhang@Bayou.UH.EDU> wrote:
> Suppose I want to exit the Unix system after executing my perl program.
> Can I include this step in my program? (system "exit" doesn't work.) 

You can always do $Array = `ps -fu $USER`, find your login process,
and kill it.  That should bring down all the children.

Yup.  works (OK, I tried it from the shell) 
   ps -fu $USER
     UID   PID  PPID  C    STIME TTY       TIME COMMAND
  bshair  7639 21366  7 18:16:39 ttyv1     0:00 ps -fu bshair
  bshair 21366 21365  1 13:52:41 ttyv1     0:00 -ksh
vortex:(bshair)/home2/bshair>
   kill -9 21366

(there's response to this command to display...
-- 

Bob Shair                          rmshair@delphi.itg.uiuc.edu
Open Systems Specialist    	   Champaign, Illinois		   
/*  Opinions expressed are mine... go get your own!       */


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

Date: 13 Nov 1998 00:19:21 GMT
From: Bob Shair (courtesy) <rmshair@delphi.itg.uiuc.edu>
Subject: Re: Exit UNIX from within a perl program
Message-Id: <72ftu9$h50$2@vixen.cso.uiuc.edu>

courtesy <rmshair@delphi.itg.uiuc.edu> wrote:
> Zhengdong Zhang <zzhang@Bayou.UH.EDU> wrote:
> > Suppose I want to exit the Unix system after executing my perl program.
> > Can I include this step in my program? (system "exit" doesn't work.) 

> You can always do $Array = `ps -fu $USER`, find your login process,
> and kill it.  That should bring down all the children.

Oh, close your files first!
-- 

Bob Shair                          rmshair@delphi.itg.uiuc.edu
Open Systems Specialist    	   Champaign, Illinois		   
/*  Opinions expressed are mine... go get your own!       */


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

Date: 13 Nov 1998 01:01:15 GMT
From: stanley@skyking.OCE.ORST.EDU (John Stanley)
Subject: Re: Exit UNIX from within a perl program
Message-Id: <72g0cr$9l0$1@news.NERO.NET>

In article <72ftsk$h50$1@vixen.cso.uiuc.edu>,
Bob Shair (courtesy)  <rmshair@delphi.itg.uiuc.edu> wrote:
>Zhengdong Zhang <zzhang@Bayou.UH.EDU> wrote:
>> Suppose I want to exit the Unix system after executing my perl program.
>> Can I include this step in my program? (system "exit" doesn't work.) 
>
>You can always do $Array = `ps -fu $USER`, find your login process,
>and kill it.  That should bring down all the children.

Overkill. man 2 kill. Pay attention to what happens when pid == 0.



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

Date: Fri, 13 Nov 1998 00:00:28 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: flock
Message-Id: <Pine.GSO.4.02A.9811121550100.791-100000@user2.teleport.com>

On Thu, 12 Nov 1998, Rory Matthews wrote:

> I have taken over some perl databasing routines that seem to be
> causing a problem which I think has to do with database contention. I
> suspect that this might have something to do with the flock routine
> not doing its stuff and indeed the perl documentation says that some
> systems may not implement flock.

Yes; calling flock() on such systems is a fatal error. But maybe you're
not using flock() properly. Are you, for example, releasing the lock
before you close the file? Don't release the lock unless you know all
about the underlying buffering issues.

> Can someone give me the low down on how good flock is at locking out a
> file or point me in the direction of successfully locking out files.

In general, if you're using flock() properly, that's the best you can do.  
If other processes don't use flock() and thereby stomp on your data,
that's wrong, and those processes should be stopped. See your system's
docs to find out more about fcntl(2) (or however Perl's flock() is
implemented on your machine).

Hope this helps!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Fri, 13 Nov 1998 00:22:14 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: HELP!!!  Script needed to create a site index
Message-Id: <Pine.GSO.4.02A.9811121621490.791-100000@user2.teleport.com>

On Thu, 12 Nov 1998, Alan McCoy wrote:

> Does anyone have (or know where I can find) a script 

If you're wishing merely to _find_ (as opposed to write) programs,
this newsgroup may not be the best resource for you. There are many
freeware and shareware archives which you can find by searching Yahoo
or a similar service. Hope this helps!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Fri, 13 Nov 1998 00:23:45 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: How to resolve sym links
Message-Id: <Pine.GSO.4.02A.9811121622420.791-100000@user2.teleport.com>

On Thu, 12 Nov 1998 johnvv@hotmail.com wrote:

> In my perl script I need to be able to identify the files that are
> pointed to by the links.

Could you be looking for Perl's readlink() function? Hope this helps!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Fri, 13 Nov 1998 01:35:09 GMT
From: shazad@my-dejanews.com
Subject: How: Run Perl Script Within Perl Script !!
Message-Id: <72g2cd$dd$1@nnrp1.dejanews.com>

Hi all...

I have a perl script which takes 2 files and creates a new file by extracting
the required information.  Now I need to run the same perl script within my
New perl script. (In simple english, run a perl script within a perl script).
I have tried to use the system command but don't seem to succeed.

$x #first file
$y #second file

system "/my/perl/script.pl",$x, $y, ">", "/tmp/final_output";

How can I manipulate the system command or something equivalent to the above
one liner.

I have tried all type of quotes but does not work!  AnybodY?
thanxs,
sm


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


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

Date: Fri, 13 Nov 1998 01:57:32 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: How: Run Perl Script Within Perl Script !!
Message-Id: <gmM22.27$q%.102@nsw.nnrp.telstra.net>

In article <72g2cd$dd$1@nnrp1.dejanews.com>,
	shazad@my-dejanews.com writes:

> system "/my/perl/script.pl",$x, $y, ">", "/tmp/final_output";

The ">" is a shell metacharacter, and not an argument to your perl
script. If you want that to happen, do something like

system "/my/perl/script.pl $x $y > /tmp/final_output"

which will pass that whole string to the shell, and let that do its
thing. Be careful that the contents of $x and $y don't include other
shell metacharacters.

Alternatively, you can use qx// or backticks, and capture the
output in a variable, after which you can write it to a file yourself.

Of course, you could also rewrite your perl script so that it can take
the name of an output file on its command line.

Maybe you should consider rewriting that external perl script into a
library or module, so you can just 'require' it, after which you can
call the perl subs directly. I normally find that that approach gives
me much more satisfaction :)

Martien
-- 
Martien Verbruggen                  | 
Webmaster www.tradingpost.com.au    | The number of the beast is not 666. Its
Commercial Dynamics Pty. Ltd.       | number is 95, and it's awake.
NSW, Australia                      | 


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

Date: Fri, 13 Nov 1998 11:03:23 +1100
From: Benjamin Low <b.d.low@unsw.edu.au>
Subject: Is __DIE__ a real signal? (with real signal limitations?)
Message-Id: <364B774A.DF8F8E6@unsw.edu.au>

Prog Perl and the Perl Cookbook state that __DIE__ is a "special"
signal, that it is an internal hook. Does this means that it's just a
simple function call and doesn't have the problems of real signals with
non-reentrant libraries?

i.e. how safe is this:
$SIG{__DIE__} = sub { print STDERR "erk..." };

Presumably perl just calls &{$SIG{__DIE__}} within the die handler and
no actual signals get called in?

Thanks,

Ben

-- 
 Benjamin Low, BEng (Elec)
 Communications Unit, University of New South Wales, Australia
 (02) 9385 1138  b.d.low@unsw.edu.au  b.d.low@ieee.org


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

Date: Fri, 13 Nov 1998 00:51:51 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Is __DIE__ a real signal? (with real signal limitations?)
Message-Id: <Pine.GSO.4.02A.9811121649210.791-100000@user2.teleport.com>

On Fri, 13 Nov 1998, Benjamin Low wrote:

> Prog Perl and the Perl Cookbook state that __DIE__ is a "special"
> signal, that it is an internal hook. Does this means that it's just a
> simple function call and doesn't have the problems of real signals
> with non-reentrant libraries?

Yes, you got that right; it's safe. Cheers!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: 13 Nov 1998 02:10:12 GMT
From: Zenin <zenin@bawdycaste.org>
Subject: Re: Is __DIE__ a real signal? (with real signal limitations?)
Message-Id: <910923015.47410@thrush.omix.com>

[posted & mailed]

Benjamin Low <b.d.low@unsw.edu.au> wrote:
: Prog Perl and the Perl Cookbook state that __DIE__ is a "special"
: signal, that it is an internal hook. Does this means that it's just a
: simple function call and doesn't have the problems of real signals with
: non-reentrant libraries?

	Yep, it's safe.

: i.e. how safe is this:
: $SIG{__DIE__} = sub { print STDERR "erk..." };

	Safe.  Just quote the '__DIE__' or use strict won't eat it. :-)

: Presumably perl just calls &{$SIG{__DIE__}} within the die handler and
: no actual signals get called in?

	Yep, that's pretty close to it.  However, I normally like to use
	something more interesting like this:

	$ cat foo.pl
	#!/usr/local/bin/perl -w
	use strict;

	$SIG{'__DIE__'} = sub {
	    require Carp;         ## Only load the 1k lines of Carp if/when called
	    local $Carp::CarpLevel = 1;
	          $Carp::CarpLevel = 1; ## Second time for -w
	    Carp::confess (@_);   ## Add a full stack trace to die()
	};

	sub foo { bar (@_) }
	sub bar { die (@_) }
	
	foo ("I went boom!");

	$ perl foo.pl
	I went boom! at foo.pl line 12.
	        main::bar('I went boom!') called at foo.pl line 11
	        main::foo('I went boom!') called at foo.pl line 14

-- 
-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: 12 Nov 1998 19:22:02 -0700
From: Daniel Grisinger <dgris@moiraine.dimensional.com>
Subject: Re: Is __DIE__ a real signal? (with real signal limitations?)
Message-Id: <m33e7o72np.fsf@moiraine.dimensional.com>

Zenin <zenin@bawdycaste.org> writes:

> 	    local $Carp::CarpLevel = 1;
> 	          $Carp::CarpLevel = 1; ## Second time for -w

It's because of silliness such as this that I never use -w in
production code.  When a construct that is supposed to be a 
programmer aid forces you to go through all sorts of bizarre
contortions, it's better to just not use the construct.

dgris
-- 
Daniel Grisinger          dgris@moiraine.dimensional.com
Supporter of grumpiness where grumpiness is due on clpm.
perl -Mre=eval -e'$_=shift;;@[=split//;;$,=qq;\n;;;print 
m;(.{$-}(?{$-++}));,q;;while$-<=@[;;' 'Just Another Perl Hacker'


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

Date: 13 Nov 1998 02:52:29 GMT
From: Zenin <zenin@bawdycaste.org>
Subject: Re: Is __DIE__ a real signal? (with real signal limitations?)
Message-Id: <910925551.582147@thrush.omix.com>

Daniel Grisinger <dgris@moiraine.dimensional.com> wrote:
: Zenin <zenin@bawdycaste.org> writes:

: > 	    local $Carp::CarpLevel = 1;
: > 	          $Carp::CarpLevel = 1; ## Second time for -w
:
: It's because of silliness such as this that I never use -w in
: production code.  When a construct that is supposed to be a 
: programmer aid forces you to go through all sorts of bizarre
: contortions, it's better to just not use the construct.

	This silliness is very rare in most code actually, and the
	benefits of -w far outweight any tiny effort to work around it
	when not needed.

	In fact, there are many times I run code under this:

	## Make all warnings fatal, with stack trace
	BEGIN {
	    $^W++; ## Force -w
	    $SIG{'__WARN__'} = sub {
	        require Carp;
	        local $Carp::CarpLevel = 1;
	        $Carp::CarpLevel = 1;
	        Carp::confess ("Fatal Warning: @_");
	    };
	}

	This turns all warnings into exceptions with stack trace.  I can
	of course try/catch these with simply eval{}/if($@).  There are
	many times when "Use of uninitialized value" and similar really
	means basically the same thing as a C SIGSEGV or Java's
	NullPointerException as far as the application is concerned.
	Basically, something very wrong happened if any value actually
	was null when it was referenced.

-- 
-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: 13 Nov 1998 02:48:01 GMT
From: damian@cs.monash.edu.au (Damian Conway)
Subject: Re: Is it possible to pass ref of regular expression?
Message-Id: <72g6l1$qrn$1@towncrier.cc.monash.edu.au>

bill_raty@my-dejanews.com writes:

>    @newlist = mygrep( m/^b/i, @list );

>and have the calling mechanism build a coderef for you (i.e. more condusive to
>laziness)?

You want the qr/.../ operator that was introduced in Perl 5.005.
See the perlop manpage for details.

Damian


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

Date: Fri, 13 Nov 1998 02:27:36 GMT
From: johnny99@sydney.dialix.oz.au
Subject: MacPerl, Help, and Internet Config
Message-Id: <72g5eo$312$1@nnrp1.dejanews.com>

I'm sure this question has been asked before, and I apologise like hell, but I
can't seem to find a fix for it, or a reference on DejaNews:

I can't get MacPerl's help menu to work. Every time I try it says:

Could not find helper for "pod". Do you want to create one?

"For "file" you should specifiy a WWW browser as the helper"

and then offers to open internet Config. I have done various things with
internet config, (like, oh, I don't know, specifying a WWW browser as the
helper for "file" for instance!) and nothing seems to work.

What the hell is going on?

TIA, please crosspost, redirect me, flame me, etc as appropriate,

jh

--
I'll have this thing looking like the Mac in no time!

Neil Kontzen, Windows Developer, 1984

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


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

Date: 13 Nov 1998 00:06:17 GMT
From: Blaise Camp <campb@think.ucdavis.edu>
Subject: Re: Occasional Perl Script Failure
Message-Id: <72ft5p$c45$2@mark.ucdavis.edu>

James Frogel <tory1@IDT.NET> wrote:
> However, after a few weeks it appears that the script fails during one
> of the sleeps and drops from the machine. I cant seem to find the error.
> Perhaps it is some sort of spurious kill signal? Anyway, I am on

My first thought would be to just trap all the signals you think might 
be sent to the process and log them somewhere.  Maybe it exceeds its CPU
limit or something.  Although it doesn't sound like it would.

-Blaise


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

Date: Fri, 13 Nov 1998 00:28:46 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: perl cgi script
Message-Id: <Pine.GSO.4.02A.9811121627200.791-100000@user2.teleport.com>

On Thu, 12 Nov 1998, Tri Tram wrote:

> how do you detect that the user has gone off the page?  

If it's possible at all (and I don't think it is) it's done with the same
technique in other languages as it is in Perl. See the docs, FAQs, and
newsgroups about CGI programming for more information. Good luck!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: 12 Nov 1998 11:57:25 +0000
From: James Gillespie <jim.gillespie@usa.net>
Subject: Re: Q: are symbolic refs really needed (was Re: Modification of a read-only??)
Message-Id: <biiemr9aztm.fsf@usa.net>

Larry Rosler <lr@hpl.hp.com> writes:

> Workaround: Don't use symbolic references.  Use a hash.  Any string
> can serve as a valid hash index.  (Does anyone have an example where
> symbolic references *must* be used, where a hash wouldn't do as
> well?)

    I was going to give an example of checking environment variables
dragged in with "use Env @vars", but this post has made me realise
that it's easier to work directly on the %ENV hash - we learn
something new every day!

                Jim
--
Jim.Gillespie@     ,'_            Just another spooky similarity between
   USA.net        / -.--.    ___  motor racing and golf                 
+44 171 721 2672 _\_x \__`--'_,-'
                / /\\    \--'_-\\
'94 BYO         \__/ `---'  \__/                          -- Adam Curtin


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

Date: Thu, 12 Nov 1998 19:37:34 +0000
From: Marquis de Carvdawg <carvdawg@patriot.net>
Subject: Raw Sockets
Message-Id: <364B38FE.A2D255B6@patriot.net>

Does anyone have links to code or information on
creating raw sockets in Perl?  I am trying to write a
script to do just that, in order to test firewalls, ID systems,
etc.

I posted my code to comp.lang.perl.misc and comp.protocols.tcpip,
with no responses....

Thanks

Carv



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

Date: 13 Nov 1998 00:15:22 GMT
From: gorilla@elaine.drink.com (Alan Barclay)
Subject: Re: Regular Expressions in Java
Message-Id: <910916121.74823@elaine.drink.com>

In article <72fe0p$ee9$1@nnrp1.dejanews.com>,  <chris@subtlety.com> wrote:
>  I was wondering if anyone thought it was a good idea to build a generic
>regular expressions package in Java.  I was thinking about something
>structured like the JDBC or security package, where different providers could

There are already classes to do regular expressions in Java, doing
a quick search with "java regular expressions" brings such pages
as http://javaregex.com, http://www.cacas.org/java/gnu/regexp and
http://home.woldcom.ch/~jmlugrin/RegExSummary.html

I've used the package on the second of those links, and it seemed capable
though I never really stressed it.

Having said all of this, what has this got to do with Perl?  Begone back
to the java group.


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

Date: Fri, 13 Nov 1998 00:19:01 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Search for a script!
Message-Id: <Pine.GSO.4.02A.9811121618340.791-100000@user2.teleport.com>

On Thu, 12 Nov 1998, Markus Robold wrote:

> I search for a script which must the following do:

If you're wishing merely to _find_ (as opposed to write) programs,
this newsgroup may not be the best resource for you. There are many
freeware and shareware archives which you can find by searching Yahoo
or a similar service. Hope this helps!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Thu, 12 Nov 1998 17:11:15 -0800
From: "Craig Patchett" <craig@patchett.com>
Subject: Re: SMTP server on the Web
Message-Id: <72g0m4$a6s@sjx-ixn8.ix.netcom.com>

Alastair wrote in message ...

>>I would like to test some of the Matt's Scripts that use smtp.
>
>Lots of people don't think much of those.

And lots of people do...different people, different needs. It's an amazing
concept.

Craig
craig@patchett.com




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

Date: Fri, 13 Nov 1998 02:01:01 GMT
From: alastair@calliope.demon.co.uk (Alastair)
Subject: Re: SMTP server on the Web
Message-Id: <slrn74n4la.7i.alastair@calliope.demon.co.uk>

Craig Patchett <craig@patchett.com> wrote:
>Alastair wrote in message ...
>
>>>I would like to test some of the Matt's Scripts that use smtp.
>>
>>Lots of people don't think much of those.
>
>And lots of people do...different people, different needs. It's an amazing
>concept.

OK - if that's sarcasm directed at me then you can skip it. Note I remained
neutral on who these 'people' are. I'm agnostic because I've never used or
looked at them.

-- 

Alastair
work  : alastair@psoft.co.uk
home  : alastair@calliope.demon.co.uk


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

Date: Fri, 13 Nov 1998 00:03:50 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Suidperl?
Message-Id: <Pine.GSO.4.02A.9811121602460.791-100000@user2.teleport.com>

On Thu, 12 Nov 1998, Matt Heusser wrote:

> If anyone could point me in the direction of some documentation on
> suidperl, it'd be appreciated.  I've checked the FAQ's, "Learning
> Perl", "Programming Perl" and "Programming Perl with CGI" to no avail.

See the perlsec manpage. But, generally, you don't need to know anything
about suidperl; it's all taken care of for you. You shouldn't be
explicitly running it, for example. Hope this helps!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Fri, 13 Nov 1998 00:14:15 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: This is flocking tricky
Message-Id: <Pine.GSO.4.02A.9811121605461.791-100000@user2.teleport.com>

On Thu, 12 Nov 1998, Clinton Gormley wrote:

> Scenario : new information is appended to the end of a flatfile
> sitting on a web server.  This file is regularly collected by FTP,
> then deleted and recreated.
> 
> Problem : If somebody writes to the file after FTP commences but
> before file is recreated, their data will be lost.

So, rotate the log file before FTPing it. That is, rename the file, FTP
it, and delete it. If some new data come in while this is happening, the
file should be automatically (re)created.

> So, I thought of writing a script to run before FTP which did the
> following
> (1) Locked File A (exclusive lock)
> (2) Renamed File A to File B

Of course, now there's no lock on any file called A, so that didn't work.
Darn.

> Would a better solution (which I've just thought of) be to
> (1) $^I='ftp';

I do not think that variable means what you think it means.

> (2) Open File A
> (3) Exclusively lock File A
> (4) Truncate File A

Now you've lost all of the data. Is that what you meant to do?

> (5) Close File A;
> (6) Unlock File A
> (7) Download FileA.ftp

No, but you're getting close to the idea I gave earlier. Something like
this.

    1. Rename file A to, say, "/tmp/A.$$.ftp"
    2. Download it
    3. Delete it

The $$ is the process-id. Hope this helps!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: 13 Nov 1998 02:39:30 GMT
From: Zenin <zenin@bawdycaste.org>
Subject: Re: This is flocking tricky
Message-Id: <910924772.289596@thrush.omix.com>

[posted & mailed]

Tom Phoenix <rootbeer@teleport.com> wrote:
	>snip<
: So, rotate the log file before FTPing it. That is, rename the file, FTP
: it, and delete it. If some new data come in while this is happening, the
: file should be automatically (re)created.

	It isn't quite that simple, not if any process already has a descriptor
	for it at least.

	Rename() changes the name of the file, not the inode (this is
	basically why rename() doen't work across file systems).  The descriptor
	doesn't care about the name, it only cares about the inode.  The other
	process (or the same process), if it has already open()ed the now renamed
	file will continue writing to the same file (now with a new name).  It
	won't recreate the original file unless it tries to open() it *after*
	the rename():

	open SESAME, ">foo.data" or die $!;
	print SESAME "line one\n";
	print SESAME "line two\n";
	
	rename "foo.data" => "foo.data.old" or die $!;
	
	print SESAME "line three\n" or die $!;
	close SESAME or die $!;
	
	open SESAME, "foo.data.old" or die $!; print while (<SESAME>);

	__END__

	Prints out:
	$ perl foo.pl
	line one
	line two
	line three
		
: > So, I thought of writing a script to run before FTP which did the
: > following
: > (1) Locked File A (exclusive lock)
: > (2) Renamed File A to File B
:
: Of course, now there's no lock on any file called A, so that didn't work.
: Darn.

	The lock holds, but is now (still, actually) attached to B.  Locks
	are on inodes, not file names (unless you're under SysV, in which
	case they are on descriptors, but the result is similar).  The
	flock() holds across the rename to the new file name.

: > (5) Close File A;
: > (6) Unlock File A
: > (7) Download FileA.ftp
:
: No, but you're getting close to the idea I gave earlier. Something like
: this.
:
:     1. Rename file A to, say, "/tmp/A.$$.ftp"
:     2. Download it
:     3. Delete it
:
: The $$ is the process-id. Hope this helps!

	You'll then have other processes writing first to "/tmp/A.$$.ftp",
	and then to an anonymous inode (Ever delete the log file out from
	under a web server for instance?).  Your disk will continue to
	fill up, but you'll have no filename to get at the data.  Not likely
	what you want.

	1. LOCK_EX file A (and make sure other processes respect it!)
	2. COPY A to, say, "/tmp/A.$$.ftp"
	3. Truncate A
	4. Call fsync() on A (use the File::Sync module).
	5. Unlock A

	This way, any processes still attached (have an open descriptor) to
	A can continue to stay that way. -This is often mandatory if a
	parent open()s the file under one UID (ie, root), but hands it to
	children that run under another UID (ie, nobody).  Nobody can't
	reopen the file if it wanted to (it is owned by root), but has
	no problem using a descriptor opened in a root UID process (through
	fork() or by passing a descriptor over local UDP).

	The fsync() is to insure that the truncate() on A is complete. -I
	remember someone saying once that some brain dead file systems
	(NTFS?) don't run truncate() as atomatic.

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


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

Date: Thu, 12 Nov 1998 16:32:52 -0800
From: Kole Dunn <kole@semp.net>
Subject: Trying to remove item from a list
Message-Id: <364B7E13.E821087E@semp.net>

Hi, Mr. Newbie here..
I have a text file with a list of items, and I need to remove one item
from the list.
How do I do this? I have read and looked for over a week and still
cannot find an answer. The list is in this format:

Item 1
Item 2
Item 3, etc..

I have tried to read the list into an array and then split it on \n.
among others..

Thanks for any help!



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

Date: Fri, 13 Nov 1998 00:53:31 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Trying to remove item from a list
Message-Id: <Pine.GSO.4.02A.9811121652420.791-100000@user2.teleport.com>

On Thu, 12 Nov 1998, Kole Dunn wrote:

> Subject: Trying to remove item from a list

Maybe you want splice().

> I have a text file with a list of items, and I need to remove one item
> from the list.

Maybe you want the FAQ's entry about working with line-oriented files.

Hope this helps!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Fri, 13 Nov 1998 00:27:11 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: What's wrong with this perl program? -from a beginner
Message-Id: <Pine.GSO.4.02A.9811121625410.791-100000@user2.teleport.com>

On Thu, 12 Nov 1998, Zhengdong Zhang wrote:

> Subject: What's wrong with this perl program? -from a beginner

Your posting seems to be over 70k bytes long. Please cut it down to the
smallest example which demonstrates the difficulty you're having. Ideally,
show just one line of code which isn't doing what you want. That'll
greatly improve your chances of getting a useful response. Good luck!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

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

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