[15914] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3327 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jun 12 09:05:21 2000

Date: Mon, 12 Jun 2000 06:05:10 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <960815110-v9-i3327@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Mon, 12 Jun 2000     Volume: 9 Number: 3327

Today's topics:
    Re: ANSI Perl: No Way !!! <you.will.always.find.him.in.the.kitchen@parties>
    Re: ANSI Perl: No Way !!! <thoren@southern-division.com>
        Compling Blowfish Decryption Code <wrightjg@nospam.hotmail.com>
    Re: DBD-ODBC connect gives runtime exception <tfbiv@SPAMMENOTerols.com>
    Re: dividing a string into array..? (Bart Lateur)
    Re: Help with writing to other program <gellyfish@gellyfish.com>
    Re: Help wtih Regular Expression <abuse@localhost>
    Re: Help wtih Regular Expression amitr@w-o-i.com
    Re: how to check for integer? <thoren@southern-division.com>
    Re: how to check for integer? <thoren@southern-division.com>
    Re: how to check for integer? <abuse@localhost>
    Re: Is it possible: Dumping Package Method Names (Bart Lateur)
    Re: Larry Rosler interview on perl.com! (Bart Lateur)
    Re: Larry Rosler interview on perl.com! <htp@mac.com>
        Looking for modules for form processing <kenneth.lee@alfacomtech.com>
    Re: now this is strange... <abuse@localhost>
        Perl Bus Error alanrkiernan@my-deja.com
    Re: perl CGI on an Linux based apache webserver (Bart Lateur)
        perl script for replacing delimiters in WEB logs anuragmenon@my-deja.com
    Re: perl script for replacing delimiters in WEB logs (jason)
    Re: perl script for replacing delimiters in WEB logs <renenyffenegger@my-deja.com>
    Re: Perl script to create users, directories, permissio (jason)
        Problem using only Global Variables? <ryanc@nci1.net>
    Re: Problem using only Global Variables? (jason)
    Re: Shebang line -- What exactly does Perl do? (Bart Lateur)
    Re: Simple Question ~ How to perform a directory recurs (Neil Kandalgaonkar)
    Re: Stopping perl CGI <ryanc@nci1.net>
    Re: Why /\b\+\b\ matches "x+y" but not "++" or "+"? <sweeheng@usa.net>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Mon, 12 Jun 2000 20:06:18 +1200
From: "Tintin" <you.will.always.find.him.in.the.kitchen@parties>
Subject: Re: ANSI Perl: No Way !!!
Message-Id: <960797090.135873@shelley.paradise.net.nz>


"Godzilla!" <godzilla@stomp.stomp.tokyo> wrote in message
news:3943BEC7.53008CD6@stomp.stomp.tokyo...
> I need no credentials. I never critique scripts
> of others. I know my part and play it well. This
> is to say, I mind my own business lest I make a
> fool of myself by stepping beyond the limits of
> my knowledge and dubious authority.

I think this paragraph should be set in stone and hung on a wall.  It's a
classic!




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

Date: Mon, 12 Jun 2000 10:52:59 +0200
From: "Thoren Johne" <thoren@southern-division.com>
Subject: Re: ANSI Perl: No Way !!!
Message-Id: <8i29jg$3es$13$1@news.t-online.com>

Jonathan Stowe <gellyfish@gellyfish.com> wrote in message
news:8i14jg$s29$1@orpheus.gellyfish.com...
> On Sun, 11 Jun 2000 18:12:54 +0200 Thoren Johne wrote:
> > Elaine Ashton <elaine@chaos.wustl.edu> wrote in message
> > news:B5692989.5F04%elaine@chaos.wustl.edu...
> >
> >> What I am beginning to find interesting is the number of men who
> >> take on female names and characters around the Perl community. It's
> >> interesting as I've not seen it anywhere else though admittedly I've
> >> not looked that hard.  I wonder what Freud would have to say...
> >
> > perhaps that female perl trolls prefer to use male names? ;)
> >
>
> Er, sorry ?  This is precisely opposite to the point Elaine was making.

yeah. did you ever read Freud?

> I dont believe anyones gender, or the gender that they portray themselves
> as, is important here; nor are any of the other things that might
> arbitrarily distinguish any individual from another except for the quality
> of their utterances here.

i agree

> Please dont engage in this nonsense, it doesnt serve the cause.

i wish you would tell that all the others here also.

gruß
thoren
8#X

--
----------------------------------------------------------------------
Thoren Johne - 8#X - thoren@southern-division.com
Southern Division Classic Bikes - www.southern-division.com




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

Date: Mon, 12 Jun 2000 11:23:42 +0100
From: "JG Wright" <wrightjg@nospam.hotmail.com>
Subject: Compling Blowfish Decryption Code
Message-Id: <8i2dfk$ci$1@gxsn.com>

I've never done any Perl programming but my colleague is encrypting
information using a Perl blowfish routine and I need a dll or something
which can decrypt it on a Win98 machine. I've heard you can compile Perl
code. Is it possible that I could just take my colleague's code and compile
it into a dll - exposing the 'encrypt' and 'decrypt' methods?

Thanks

Jon




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

Date: Mon, 12 Jun 2000 08:32:52 -0400
From: Tom Bates <tfbiv@SPAMMENOTerols.com>
Subject: Re: DBD-ODBC connect gives runtime exception
Message-Id: <bsl9kskbccee0f4g8l5ebt83pesjo4umv3@4ax.com>

On Mon, 12 Jun 2000 04:48:28 GMT, posting.account@lynxview.com
(William Herrera) wrote:

>On Sun, 11 Jun 2000 15:46:34 -0400, Tom Bates <tfbiv@SPAMMENOTerols.com> wrote:
>
>>Last week, the statement below worked perfectly well. This week, I get
>>the not very informative "Error: Runtime exception", with no script
>>changes. I am hosted on an NT 4.0 server. Anybody have any clues?
>>
>
>In my recent ODBC experience, this may be due to an exception generated within
>the (non-perl) ODBC driver code running on the Windows machine. This exact
>error happens here on occasion while doing an update of local Berkely DB files
>via an ODBC connection to a large Unix database when the database server gets
>backed up on requests and the driver times out. If you find a good way to keep
>the Windows ODBC driver trap from shutting down the Perl process, let me know.
>We could use a fix :/
>

My website was down for nearly a full week and the web hosting company
could not determine the cause of the problem. This weekend I found
that using a DSN-less connection avoids the problem.

Tom


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

Date: Mon, 12 Jun 2000 09:44:32 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: dividing a string into array..?
Message-Id: <3945ae68.1819061@news.skynet.be>

happyhippi@my-deja.com wrote:

>I've decided to make a game where a player guesses letters from some
>unknown word and after all tries to guess the whole word. Unfortunately
>it seems to be harder job than I first imagined cause I dunno how to
>show current situation to player; like this:
>
>the word is "detournement"
>First, the player can see: "____________"
>Player guesses letter "e"
>What she sees next would be: "_e_____e_e__"
>and so on..

That sounds like the "hangman" kid's game.

	http://www.freeperlcode.com/guide/Games/Hangman/

>I thought that tr/// -function should solve the problem but according to
>my handbook it doesn't support variables in it. (of course i tried it
>too..)

Indeed. But in general, you can emulate the functionality offered by
tr/// by s/[...]//g, which *does* allow variables.

For example, if the player guessed "e" and "t":

	$word = "detournement";
	$letters = "et";
	($masked = $word) =~ s/[^$letters]/_/g;
	print $masked;
-->
	_et____e_e_t

-- 
	Bart.


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

Date: 12 Jun 2000 09:05:48 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Help with writing to other program
Message-Id: <8i25ks$io0$1@orpheus.gellyfish.com>

On Wed, 07 Jun 2000 21:45:14 GMT gthorne777@my-deja.com wrote:
> Can anyone tell me why this program will not work without the "-i"
> switch in the first line?  

Beats me - the -i switch should only affect files opened by the <> construct.

>                          Where does the output go when you do an "open
> (| progname)"?  Eventually, I would like to parse the output of this and
> only show certain lines.  What's the best way of doing this?
> 

Any output from a program that you open to pipe into will go wherever it
went before - that is probably STDOUT.  If you need to write to and read
from a program you will probably want to use IPC::Open2.  I would check
out the perlipc manpage which has some examples.

/J\
-- 
** This space reserved for venue sponsor for yapc::Europe **
              <http://www.yapc.org/Europe/> 


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

Date: Mon, 12 Jun 2000 16:27:41 +0800
From: "multiplexor" <abuse@localhost>
Subject: Re: Help wtih Regular Expression
Message-Id: <8i26fl$1kd29@imsp212.netvigator.com>


<kittycspot@my-deja.com> wrote
> OK heres the deal...
>
> lets say ive got the string "<!--ThisStays-->"
> i need to replace the beginning part of the HTML comment (<!--) and the
> ending (-->) with different strings (lets say we make it into a named
> anchor tag) so it looks like <A NAME="ThisStays">
>
> Also, The string that stays is made of variable length alphanumeric
> characters.
>
> ive dug around for hours and im sure that im just looking too deep, by
> now i couldve written a loop to do it but i want to do it with pattern
> matching...can anyone out there help me?
>
> Thank you in advance,
> Cheyenne
>


Example:

###
$html =<<EOF;
<!--ThisStays--><!--ThisStays1-->
<!---->

EOF

print $html;
$html =~ s/<!--(\w*)-->/<A NAME="$1">/g;
print $html;
###

Done...




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

Date: Mon, 12 Jun 2000 11:44:20 GMT
From: amitr@w-o-i.com
Subject: Re: Help wtih Regular Expression
Message-Id: <8i2iej$vbd$1@nnrp1.deja.com>

dear Cheyenne,

actually the solution to ur problem is pretty simple. no jokes. I can
suggest u to read man page for 'perlre' ie perl regex.

so, here is the solution,
the following code would do what u want to. see it is really easy.
in Perl  this (.*?) make magic. :)


#!/usr/bin/perl -w
use strict;

my $string = "<!--ThisStays-->";

$string =~ s!<\!--(.*?)-->!<A NAME=\"$1\">!gi;
print $string;

exit 0;





I think u got ur answer.

happy coding.
bye

> OK heres the deal...
>
> lets say ive got the string "<!--ThisStays-->"
> i need to replace the beginning part of the HTML comment (<!--) and
the
> ending (-->) with different strings (lets say we make it into a named
> anchor tag) so it looks like <A NAME="ThisStays">
>
> Also, The string that stays is made of variable length alphanumeric
> characters.
>
> ive dug around for hours and im sure that im just looking too deep, by
> now i couldve written a loop to do it but i want to do it with pattern
> matching...can anyone out there help me?
>
> Thank you in advance,
> Cheyenne


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Mon, 12 Jun 2000 10:21:13 +0200
From: "Thoren Johne" <thoren@southern-division.com>
Subject: Re: how to check for integer?
Message-Id: <8i26p0$27g$13$1@news.t-online.com>

Tad McClellan <tadmc@metronet.com> wrote in message
news:slrn8k870l.5m3.tadmc@magna.metronet.com...
> On Sun, 11 Jun 2000 18:07:58 +0200, Thoren Johne
<thoren@southern-division.com> wrote:
> >Jonathan Stowe <gellyfish@gellyfish.com> wrote in message
> >news:8i00ji$o8h$1@orpheus.gellyfish.com...
> >> On Sun, 11 Jun 2000 09:25:56 +0200 Mariska wrote:
>
> >> > I don't know how to check if a number is an integer.
>                                ^^^^^^^^^^^^^^^^^^^^^^^^^
       ^^^^^^^^^^^^^^^^^^^^^^^^^
> >> > I need to do something when a number is even.
> >> > i divide a number by 2 and i want to check if the result is an
integer
> >or
> >> > not.
> >> >
> >>
> >> You dont need to do that :
> >>
> >>    if ( $number % 2 )
> >>    {
> >>      print "Odd";
> >>    }
>
> >so, given 2.5 as $number it returns "Even"
> >
> >do you think 2.5 is an even number? ;>
>
>
> do you think 2.5 is an integer?
>
> :-)

did you and jonathan read the question?

:)

--
----------------------------------------------------------------------
Thoren Johne - 8#X - thoren@southern-division.com
Southern Division Classic Bikes - www.southern-division.com




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

Date: Mon, 12 Jun 2000 10:24:00 +0200
From: "Thoren Johne" <thoren@southern-division.com>
Subject: Re: how to check for integer?
Message-Id: <8i26p2$27g$13$2@news.t-online.com>

Jonathan Stowe <gellyfish@gellyfish.com> wrote in message
news:8i13a3$s0m$1@orpheus.gellyfish.com...
> On Sun, 11 Jun 2000 18:07:58 +0200 Thoren Johne wrote:
> > Jonathan Stowe <gellyfish@gellyfish.com> wrote in message
> > news:8i00ji$o8h$1@orpheus.gellyfish.com...
> >> On Sun, 11 Jun 2000 09:25:56 +0200 Mariska wrote:
> >> > Hi all
> >> > I don't know how to check if a number is an integer.
> >> > I need to do something when a number is even.
> >> > i divide a number by 2 and i want to check if the result is an
integer
> > or
> >> > not.
> >> >
> >>
> >> You dont need to do that :
> >>
> >>    if ( $number % 2 )
> >>    {
> >>      print "Odd";
> >>    }
> >>    else
> >>    {
> >>      print "Even";
> >>    }
> >
> > so, given 2.5 as $number it returns "Even"
> >
> > do you think 2.5 is an even number? ;>
> >
>
> I dunno I'm not a mathematician :) Of course it thinks 3.5 is 'Odd' ...

ok... are you the guy writing the programms for nasa's mars landers?

;)

--
----------------------------------------------------------------------
Thoren Johne - 8#X - thoren@southern-division.com
Southern Division Classic Bikes - www.southern-division.com




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

Date: Mon, 12 Jun 2000 17:23:43 +0800
From: "multiplexor" <abuse@localhost>
Subject: Re: how to check for integer?
Message-Id: <8i29on$ner4@imsp212.netvigator.com>


"jason" <elephant@squirrelgroup.com> wrote
> Mariska writes ..
> >I don't know how to check if a number is an integer.
> >I need to do something when a number is even.
> >i divide a number by 2 and i want to check if the result is an integer or
> >not.
>
> if your end goal is just to determine whether an integer is even or not
> then the following Perlistic method is hard to beat
>
>   $var =~ /[02468]$/;
>
> if you don't know whether it'll be an integer or not then a small change
> to
>
>   $var =~ /^\d*[02468]$/;
>
> will make sure it's an integer also (of course - it doesn't distinguish
> between odd and non-integer - but your spec didn't seem to care about
> that)
>
> --
>  jason - elephant@squirrelgroup.com


Are there any method to check whether a string is an even integer?

Thanks




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

Date: Mon, 12 Jun 2000 10:46:20 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Is it possible: Dumping Package Method Names
Message-Id: <3948b86d.4383838@news.skynet.be>

Josiah Bryan wrote:

>    my $object = new myPackage();
>
>Is it possible to dump just the method names from that object?

>Any help would be IMMENSLY appreciated!!

You can go through the myPackage stash, and test each name found with
can(). Notice that methods not yet loaded when using AUTOLOAD, will not
(yet) appear.

Example:

	my $package = 'myPackage';
	{
	    no strict refs;
	    my $stash = *{$package.'::'};
	    foreach my $name (sort keys %$stash) {
	        print "method: $name\n"  if $package->can($name);
	    }
	}

-- 
	Bart.


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

Date: Mon, 12 Jun 2000 09:24:54 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Larry Rosler interview on perl.com!
Message-Id: <3944abe3.1173582@news.skynet.be>

Henry wrote:

>That said, it would be a great idea to have URLs like the one above 
>featured on a website somewhere, along with some sort of complexity 
>rating so the visiting newbie can jump into the pool at the _shallow_ 
>end rather than accidentally plunging into the deep end.

>...but preferably hosted on a dedicated Perl site, without all the ads, 
>and with more room for descriptors.
>
>"The one and only URL a Perl newbie would ever need."
>
>Or does such a beast already exist?

<www.perl.com> is going in that direction. It has a few pointers to
tutorials, but this particular site isn't listed (yet).

I'm not sure about the entry level of the pointers. All sites listed
have been screened, though.

-- 
	Bart.


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

Date: Mon, 12 Jun 2000 20:07:03 +0930
From: Henry <htp@mac.com>
Subject: Re: Larry Rosler interview on perl.com!
Message-Id: <htp-0917B0.20070312062000@news.metropolis.net.au>

In article <MPG.13adccc338b0f24298ab60@nntp.hpl.hp.com>, Larry Rosler 
<lr@hpl.hp.com> wrote:

< useful stuff >

Larry, I think I understand your 'angle' now.  Just to make sure, I've 
tried to summarise the important bits below.  If you could give them the 
once-over and let me know if I've missed the mark with any of them, that 
would be great.


_I_ think that _you_ believe:

Perl has untapped potential.

This potential should be realised.

Corporate (used broadly) acceptance is critical to such realisation.

Perl's "rough edges" are unacceptable to the corporate customer.  (Lack 
of a language definition is one of them.  Anarchistic behaviour is 
another.)

These rough edges need to be smoothed (eliminated/tempered) in order to 
make Perl an easier pill for the corporate customer to swallow.

Corporate acceptance will result in greater prestige for the language 
and its proponents, and more respect and remuneration for its 
programmers.

These benefits (which will flow on to the majority of members of the 
Perl community) far outweigh the costs associated with making the 
transition.

Such a move is, in the long term, for the greater good.


How'd I do?

Henry.


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

Date: Mon, 12 Jun 2000 18:17:11 +0800
From: Kenneth Lee <kenneth.lee@alfacomtech.com>
Subject: Looking for modules for form processing
Message-Id: <3944B8A7.79D329F0@alfacomtech.com>

Is there any modules already available to validate form 
fields in a consistent, at least reusable manner?

In my experience this was a copy-and-paste works for many 
scripts I wrote, which almost always use pages-long if's on 
every form variables. Then they adds error messages for 
each invalid value.

I imaginate my code can be written like this,

  $q = new CGI;
  $v = new MyValidator;

  unless ($v->validate($q)) {
    print "Error in form:\n";
    for my $e ($v->errors) {
      print "- $e\n";
    }
  } else {
    ...process the form
  }

Where MyValidator is some subclass of a abstract Validator class.
Validator provides the framework and MyValidator implements the 
actual validation rules.

Any suggestion are also welcome.

Thanks.
Kenneth



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

Date: Mon, 12 Jun 2000 16:13:15 +0800
From: "multiplexor" <abuse@localhost>
Subject: Re: now this is strange...
Message-Id: <8i25kk$1kd27@imsp212.netvigator.com>


"Ala Qumsieh" <aqumsieh@hyperchip.com> wrote
>
> "multiplexor" <abuse@localhost> writes:
> > "Raphael Pirker" <raphaelp@nr1webresource.com> wrote
>
> ...
>
> > > > >foreach $key (keys(%FORM)) {
> > > > >$key = $FORM{$key};
> > > > >}
>
> ...
>
> > I Don't know whether using "eval" is a bad idea.
> >
> > Example:
> >
> > ###
> > %hash = (
> >  a => '10',
> >  b => '20'
> > );
> >
> > print "a=$a ; b=$b\n";
> >
> > foreach (keys %hash) {
> >  $st = "\$$_ = \$hash{$_}";
> >  print "$st\n";
> >  eval $st;
> > }
> >
> > print "a=$a ; b=$b\n";
> > ###
> >
> > I also use this code for convenience.
>
> Very very bad idea. It seems to me that the contents of %FORM are
> supplied by a user in some web page. If the user enters something like:
>
> system "\rm -rf /";
>
> then disaster will strike! Taint-checking will help prevent that,
> though.
>

I know  eval{system "\rm -rf /";}  is dangerous. Just curious about how
dangerous this is:

eval{$system "\rm -rf /"; = $hash{system "\rm -rf /";} }

Can you teach me more?

Thanks.





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

Date: Mon, 12 Jun 2000 09:25:23 GMT
From: alanrkiernan@my-deja.com
Subject: Perl Bus Error
Message-Id: <8i2a9t$qbn$1@nnrp1.deja.com>

Folks,
      There seems to be little info about this about what I've
encountered so far indicates the interpreter is attempting to free
memory from an arguement array whish has already been freed.

Heres the problem.
I'm making a system call as part of a script which is running an
application which takes its comand options from a file and redirects
the results to another file.

if(system("application < command_arguement_file > results_file")==0)
{
}

This ALWAYS causes a Bus error..
Given that I cant alter the mechanish in which the application takes
the input and output, has anyone any ideas on how to get around this ?

Cheers,
Alan Kiernan


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Mon, 12 Jun 2000 10:46:26 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: perl CGI on an Linux based apache webserver
Message-Id: <394abc38.5354473@news.skynet.be>

Michael.Siemens wrote:

>-rwxr-xr-x   1 root     root          201 Feb 28 20:28 mail-form.pl

>root@csg:/usr/local/httpd/cgi-bin > ./mailform.pl
>bash: ./mailform.pl: No such file or directory
>root@csg:/usr/local/httpd/cgi-bin >

It doesn't look to me like it's the same filename.

-- 
	Bart.


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

Date: Mon, 12 Jun 2000 07:19:33 GMT
From: anuragmenon@my-deja.com
Subject: perl script for replacing delimiters in WEB logs
Message-Id: <8i22u0$l4g$1@nnrp1.deja.com>

This is probably child's play for a lot of you..but I am a perl newbie
and the number of slashes and quotes that I am finding in the web logs
are leaving me with no choice but to post here!!

The web logs that I am dealing with are in the Extended Log format.  Its
a text file with the entries are delimited by one empty space and there
is a newline character at the end of each entire row (I think). I want
to replace the blanks with a pipe and the new lines with an ampersand
sign so that then I can use the bcp utility of sybase to import the text
data into a table for further manipulation.

If the file name is say log.txt, then this was the script I tried but it
kept throwing up stuff and never did work. Pardon my ignorance if this
approach is wrong.

#!/usr/local/bin/perl

open(NEWFILE, ">log.txt")
s/" "/"|"/g;
s/"/n"/"&"/g

thats it...there are tonnes of other double quotes in the text in the
entries..for example the referrer page is regitered as "http://www...."
and the double quotes are part of the string I think.

well..please help!

Vinod.


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Mon, 12 Jun 2000 09:51:10 GMT
From: elephant@squirrelgroup.com (jason)
Subject: Re: perl script for replacing delimiters in WEB logs
Message-Id: <MPG.13af4fc041d6a6d989731@news>

anuragmenon@my-deja.com writes ..
>If the file name is say log.txt, then this was the script I tried but it
>kept throwing up stuff and never did work. Pardon my ignorance if this
>approach is wrong.
>
>#!/usr/local/bin/perl
>
>open(NEWFILE, ">log.txt")

you've opened the file for write not read .. and you left the semi colon 
off the end of the line - this should cause a syntax error .. plus you 
never check to see whether the open() completed successfully or not

  perldoc perlopentut

>s/" "/"|"/g;
>s/"/n"/"&"/g

these need to be in some sort of loop (covered in perlopentut) .. plus 
you're missing another semicolon .. plus you don't need the "s in there 
 .. check out

  perldoc perlre

for more information on regular expressions

in case you don't know what perldoc is then at a command prompt type

  perldoc perldoc

-- 
 jason - elephant@squirrelgroup.com -


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

Date: Mon, 12 Jun 2000 11:17:29 GMT
From: Rene Nyffenegger <renenyffenegger@my-deja.com>
Subject: Re: perl script for replacing delimiters in WEB logs
Message-Id: <8i2gs4$uj8$1@nnrp1.deja.com>


> This is probably child's play for a lot of you..but I am a perl newbie
> and the number of slashes and quotes that I am finding in the web logs
> are leaving me with no choice but to post here!!
>
> The web logs that I am dealing with are in the Extended Log format.  Its
> a text file with the entries are delimited by one empty space and there
> is a newline character at the end of each entire row (I think). I want
> to replace the blanks with a pipe and the new lines with an ampersand
> sign so that then I can use the bcp utility of sybase to import the text
> data into a table for further manipulation.
>
> If the file name is say log.txt, then this was the script I tried but it
> kept throwing up stuff and never did work. Pardon my ignorance if this
> approach is wrong.
>
> #!/usr/local/bin/perl
>
> open(NEWFILE, ">log.txt")
> s/" "/"|"/g;
> s/"/n"/"&"/g
>
> thats it...there are tonnes of other double quotes in the text in the
> entries..for example the referrer page is regitered as "http://www...."
> and the double quotes are part of the string I think.




$ perl -p -e 's/ /|/;s/\n/&/;' log.txt > log_out.txt

Notes:
1 newline is \n, not /n
2 in perl, you don't quote strings in REs, so, it's / / for
  a blank, not /" "/
3 Are you sure that your logfile doesn't contain blanks within
  strings (such as "word1 word2"). Off course, these blanks
  would be replaced with bars as well

hth

Rene





Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Mon, 12 Jun 2000 09:41:09 GMT
From: elephant@squirrelgroup.com (jason)
Subject: Re: Perl script to create users, directories, permissions for WinNT4
Message-Id: <MPG.13af4d68b8943cb8989730@news>

Ryan King writes ..
>Please excuse my ignorance (major newbie here!) but has anyone done
>something like this? Is it possible?

yes

>I am trying to find out if it will be possible to create an online form that
>will pass the necessary info to Win NT4 Server to create new users/groups,
>and create directories and set permissions etc. This would make my life a
>lot easier if this is possible.

check out the Win32::AdminMisc module on

  http://www.roth.net/perl/

although be careful about the permissions you give to the anonymous web 
user

-- 
 jason - elephant@squirrelgroup.com -


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

Date: Mon, 12 Jun 2000 07:46:44 -0400
From: "Ryan & Treena Carrier" <ryanc@nci1.net>
Subject: Problem using only Global Variables?
Message-Id: <3944cc95_2@news.cybertours.com>

Is there a problem using only global variables? I'm currently writing a
classified ads script. (I know, it's been done before - I need some kind of
project to learn, don't I?)




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

Date: Mon, 12 Jun 2000 12:11:23 GMT
From: elephant@squirrelgroup.com (jason)
Subject: Re: Problem using only Global Variables?
Message-Id: <MPG.13af709d6200a901989732@news>

Ryan & Treena Carrier writes ..
>Is there a problem using only global variables?

yes .. the same problem that exists when using them with any language .. 
for some Perl specific discussion see

  perldoc perlsub

and maybe even

  perldoc perldata

-- 
 jason - elephant@squirrelgroup.com -


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

Date: Mon, 12 Jun 2000 10:46:23 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Shebang line -- What exactly does Perl do?
Message-Id: <3949bad9.5004161@news.skynet.be>

Alan J. Flavell wrote:

>boggle> more foo.pl
>#!/bin/sh
>
>echo foo
>
>boggle> perl foo.pl
>foo
>boggle>

>I trust that Tom will be along any moment to correct any
>misinterpretation of his intentions, however ;-)

That is indeed the feature that Tom described. I find it extremely
amazing that it actually works.

This is bound to be a security hole. I just can't see how. Yet.

-- 
	Bart.


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

Date: 12 Jun 2000 07:22:53 GMT
From: nj_kanda@alcor.concordia.ca (Neil Kandalgaonkar)
Subject: Re: Simple Question ~ How to perform a directory recursive search ?
Message-Id: <8i234d$udl$1@newsflash.concordia.ca>

In article <yBZ05.11109$907.272697@newsread2.prod.itd.earthlink.net>,
Kenny Lim <kennylim@techie.com> wrote:

>(a) Is there a method to perform a directory recursive search (including
>subdirectories) "without having to use the File::Find standard module" ?
>(Snippets of my code is enclosed below)

Why would you not want to use File::Find?

Anyway, of course the answer is yes; you could simply reinvent what
File::Find does, perhaps in a less generalized way.

Or simply get the results of a 'find', if you are on unix.


>(b) Is there a method to only change the name of the file only when a
>criteria is met.
>
>Eg.
>
>Search for a matching strings called "old" and replace it with "new" in a
>file with
>*cpp *dsp *rc extension.

I got confused. Are you trying to change the filename or alter the contents?
Your code opened a second filehandle. I didn't understand the comments you
added after your code.

Anyway, perl has a rename(). 

Here's one way of modifying file *contents* which leans on shell tools 
rather than File::Find. (n.b. this is GNU find 4.1)

$ find /my/dir -regex '.*\.\(cpp\|dsp\|rc\)' -print   \
  | xargs perl -pi.bak -e 's/search/replace/g' 

This has the advantage of simplicity and safety. You'd have to do a lot
of wheel-reinventing to get something safe like perl -pi.bak; it makes
backups while modifying the file "in-place".

If you just wanted to rename it:

$ find /my/dir -regex '.*\.\(cpp\|dsp\|rc\)' -print   \
  | perl -wlne '(my $new = $_) =~ s/search/replace/; rename $_, $new'

See man find, and man perlrun for further explanation.

Or, find a good intro to unix shell scripting if everything here is
totally baffling to you.

-- 
Neil Kandalgaonkar
neil@brevity.org


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

Date: Mon, 12 Jun 2000 06:34:07 -0400
From: "Ryan & Treena Carrier" <ryanc@nci1.net>
Subject: Re: Stopping perl CGI
Message-Id: <3944bb87_2@news.cybertours.com>

The only method I'm aware of is to use JavaScript. The OnUnload() event
handler is what you need to look at. This handler is used as a last ditch
opportunity to do something before the user leaves your page.

I don't know the ramifications of a user having JavaScript turned off in
their browser options. You could experiment, and use the javaEnabled method
to verify whether Java is turned on or not.
AyJay <ayjayr@my-deja.com> wrote in message
news:8heqec$usb$1@nnrp1.deja.com...
> G'day,
>
> I have a perl CGI that displays information from a log file, while that
> file is being appended to. The approach taken was to check the size of
> the log file and if it has increased send those lines to the browser.
> This all works fine and dandy, any improvement suggestions would be
> appreciated however.
>
> The problem is that if the user presses the 'Stop' or 'back' buttons on
> their browser or even closes their browser the perl keeps running until
> the log file size no longer changes. How can I tell when any of these
> events happen?
>
> ---
> TIA
> AJ
>
> AyJayR_at_Yahoo.com.au
>
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.




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

Date: Mon, 12 Jun 2000 19:26:16 +0800
From: "Swee Heng" <sweeheng@usa.net>
Subject: Re: Why /\b\+\b\ matches "x+y" but not "++" or "+"?
Message-Id: <8i2h1u$rfs$1@violet.singnet.com.sg>

Run "perldoc perlre".

FACT:
1.) 'x' and 'y' are in the class \w.
2.) '+' is in the class \W.
3.) The imaginary chars off the front and end of a string are in \W.
4.) \b indicates a word boundary, ie. the imaginary super-duper-ultra
    thin space between a \W and a \w, in either order.

Hence /\b\+\b/,
a.) matches 'x+y' where the first \b is that between 'x' and '+' and
    the second \b is between '+' and 'y'.
b.) does not match '++' or '+' because FACT 2 and FACT 3 implies that
    there are no word boundaries \b (FACT 4) in the two strings.

Please read "perldoc perlre".




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

Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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.  

| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

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.

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 V9 Issue 3327
**************************************


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