[7825] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1450 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Dec 10 19:18:05 1997

Date: Wed, 10 Dec 97 16:00:23 -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           Wed, 10 Dec 1997     Volume: 8 Number: 1450

Today's topics:
     Re: ? Determining the directory of an executing script  <zenin@best.com>
     Re: [Q] Several misc. questions <rootbeer@teleport.com>
     autoflush on/off g.e.kohr@gats.hampton.va.us
     Re: Checking if integer/real (Bart Lateur)
     Re: Checking the instance of a class <tchrist@mox.perl.com>
     Re: CPAN on CD is not evil (was Re: Resource Kit Anomal <dformosa@st.nepean.uws.edu.au>
     Re: Fileupload <erikdj@cyberjunkie.com>
     Re: Filtering out unneeded header files (Kevin D. Clark)
     Re: Help! Formating numeric print statement output rhardin@planethollywood.com
     Re: Kanji Perl plambert$1@plambert.org
     Re: Local Array initialized to a constant <npatel@rsn.hp.com>
     need help with regexp (Jeroen van Gorkum)
     Re: need the skinny on my() vs local() <dformosa@st.nepean.uws.edu.au>
     newbie: compact an array <xah@best.com>
     Re: Please advise. Fastest way to line-count files <rootbeer@teleport.com>
     Re: print buffer flush rhardin@planethollywood.com
     Re: Returning information from an nslookup ?? (Burt Lewis)
     simple array problem parsing a cookie <dbaker@dkburnap.com>
     Taking document in directories and replacing them dynam (Steve)
     Re: There's More Than One Way? (Faust Gertz)
     UML and Perl (dave)
     WANTED: "generic" logfile parse/report <eak@detroit.sgi.com>
     Re: WANTED: "generic" logfile parse/report <eryq@zeegee.com>
     Re: Wanted: Perl5 script to scan+kill POP3 mailbox (Dirk Vleugels)
     Re: Writing fixed-length records to file speed@racer.cartoon.spam.address
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: 10 Dec 1997 21:01:59 GMT
From: Zenin <zenin@best.com>
Subject: Re: ? Determining the directory of an executing script ?
Message-Id: <881787936.615684@thrush.omix.com>

jeff stanier <stanier@neuma.com> wrote:
: I am calling a perl script (addvars.pl)  from another application.  The
: script "requires " another file containing sub-routines (commonsub.pl).
: addvars.pl and commonsub.pl are in the same directory.   Since I am calling
: the addvars.pl from  another directory "." does not equal the location of
: the addvars.pl or commonsub.pl.  Can I determine the location of the
: addvars.pl script as it is executing and unshift or push it into @INC.
	
	Here's a trick I like to use:

	use File::Basename;
	use lib dirname $0;
	require "commonsub.pl";

	This puts the dirname of $0 (Your currently running perl script)
	into @INC.  This works %99.9 of the time.  It still can fail
	however, if you or someone else has messed with your process's
	argv[0] ($0 in perl).  If you or someone else has changed your
	argv[0] then you have no way (that I've ever known) to locate
	the path of your process's executable (script).

	But like I said, %99.9 of the time it's fine, and if you must
	adjust $0 you can just do it after the above require call.

-- 
-Zenin
 zenin@best.com


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

Date: Wed, 10 Dec 1997 13:03:46 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: nicholas@neko.binary9.net
Subject: Re: [Q] Several misc. questions
Message-Id: <Pine.GSO.3.96.971210125402.15679R-100000@user2.teleport.com>

On 10 Dec 1997 nicholas@neko.binary9.net wrote:

> Hi folks, I have several unrelated questions I would like to ask.

Generally on Usenet, it's better to post unrelated questions separately,
each with appropriate subject lines.

> 1. Usage of *{}
> 
> In my quest to improve my 'perl' programming cleanliness, I decided 
> I wanted an 'enum' package similiar to the 'constant' one. I thought
> the syntax of
> 
> use enum qw(
> 	ERR_NOERROR
> 	ERR_WARNING
> 	ERR_CRITICAL
> 	ERR_BROKEN
>         );
> 
> (so that $ERR_NOERROR==0, $ERR_WARNING==1, etc...)
> 
> would be just hunky dory. So I looked at constant.pm 

Since this is similar to what constant.pm does, and since I'm the author
of constant.pm :-)  I'll be glad to work with you on this via private
email. Let's talk.

> 2. Timing out from an operation
> Is there a better way to do timeouts other than:
> 
> eval {
>    local $SIG{ALRM}=sub{ die };
>    alarm(5);
>    $_=<STDIN>;
>    alarm(0);
> };

We're working on making signals work reliably in a future version of Perl. 
But you can try using non-blocking input, using the four-arg form of
select. 

> 3.
> I recently wanted to try the new perl5.004_54, 

To everyone reading along at home: That's an _experimental_ version, not
recommended for production use.

> so I brought it down and compiled it. Well, it fails MANY MANY of the
> tests.

That's one reason why it's not recommended. :-)

> Since I'm using glibc under Linux, I'm sure its related to that. Where
> is there an appropriate place (mailling list,newsgroup) to ask for help?

If you need help, you probably shouldn't be running an experimental
version. :-)  But you could ask for help on the mailing list for the Perl
developers. If you're not sure where that is, I can tell you in private
email. Let me know.

Hope this helps!

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/
              Ask me about Perl trainings!



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

Date: Wed, 10 Dec 1997 15:02:29 -0600
From: g.e.kohr@gats.hampton.va.us
Subject: autoflush on/off
Message-Id: <881787422.374669313@dejanews.com>

I have a server push piece of code where I would like to be able to
enable/disable perls autoflush.  Essentially the code looks like this:

#!/usr/bin/perl
#
# ------------- cut out the meaningless parts ---------------

$|= 1;	# Force a flush on every print # implement server push print
"Content-type: multipart/x-mixed-replace;boundary=ThisRandomString\n";
&print_header(); # put up initial wait screen print "<br><IMG
SRC=\'/images/PrettyPicture.gif\'><br>"; print "\n--ThisRandomString\n";
# # >>>>>> This does not work!? <<<<<<<<<<<< # $|=0;  # Turn off flush on
every print # # # perform code outside my control which outputs messages
to STDOUT # this, of course, evils up my web output # system("$idl <
$idl_inpt 2> $idl_log") || print TRACE "Idl returned an Error: $!\n"; #
print "Content-type: text/html\n\n"; print "<Img src=$idlOutputGif>\n";
print "\n--ThisRandomString\n"; #


I'm thinking that this system call could have a filehandle assigned to it.
I've played with the line, BUT, I don't know  the syntax

-------------------==== Posted via Deja News ====-----------------------
      http://www.dejanews.com/     Search, Read, Post to Usenet


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

Date: Wed, 10 Dec 1997 21:44:25 GMT
From: bart.mediamind@tornado.be (Bart Lateur)
Subject: Re: Checking if integer/real
Message-Id: <34910919.3185595@news.tornado.be>

Jay Rogers <jay@rgrs.com> wrote:

>How about relying on the perl warning feature?  :-)
>
>    eval {
>        local $^W = 1;
>        local $SIG{'__WARN__'} = sub { die "non-numeric\n" };
>        $veld *= 1;
>    };
>    $response = !$@ ? "OK" : "NOT INTEGER/REAL";

Incredible, it works! Although I don't think you need eval and die:
setting a flag in the __WARN__ sub should be enough. 

But puzzles me, is this line:

	local($SIG{'__WARN__'})  = sub { ... };

I know about making whole variables/arrays/hashes local, but only one
hash element?

It's my understanding that probably the old value is put on some stack,
temporarily gets a new value in the block, and is restored at the end of
the block.

Is this correct?

Does this mechanism correctly differentiates between hash elements that
had undef as value, and elements that weren't in the hash? (See POD,
"exists" vs. "defined")

	Bart.


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

Date: 10 Dec 1997 21:49:39 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Checking the instance of a class
Message-Id: <66n2pj$o16$1@csnews.cs.colorado.edu>

 [courtesy cc of this posting sent to cited author via email]

In comp.lang.perl.misc, Allen Choy <achoy@us.oracle.com> writes:
:I'm just gotten into the Perl OOP craze recently.  I noticed that Perl
:doesn't have an operator to [BAD WRAP]
:check if an object is an instance of a class (like in java).  I suppose,
:however, that you can [BAD WRAP]
:test to see if object string is equal to a certain class, but how do you
:do check if a [BAD WRAP]
:derived class (subclass) is an instance of a super class?

You don't know about UNIVERSAL's isa() method, do you?

--tom
-- 
	Tom Christiansen	tchrist@jhereg.perl.com

    "No, I'm not going to explain it. If you can't figure it out, 
     you didn't want to know anyway..." --Larry Wall 


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

Date: 10 Dec 1997 22:17:14 GMT
From: ? the platypus {aka David Formosa} <dformosa@st.nepean.uws.edu.au>
Subject: Re: CPAN on CD is not evil (was Re: Resource Kit Anomaly)
Message-Id: <881792134.754772@cabal>

In <19971204.165408.1w3.rnr.w164w_-_@locutus.ofB.ORG> Russell Schulz <Russell_Schulz@locutus.ofB.ORG> writes:

>pschon@baste.magibox.net (Peter J. Schoenster) writes:

>> "Would you really want to take Web publishing advice from someone who
>> had to burn a CD-ROM to distribute his software?
[...]
>I fail to see how him including a CD-ROM implies that he `had to burn a
>CD-ROM to distribute his software'.

Indeed,  sneekernet  while having high latency also has rather good
bandwidth.  When you are out in the sticks (network wise) a good CD-ROM is
a god send.

--
Please excuse my spelling as I suffer from agraphia see the url in my header. 
Never trust a country with more peaple then sheep. I do not reply to mungged 
Support NoCeM http://www.cm.org/                   addresses.  
I'm sorry but I just don't consider 'because its yucky' a convincing argument


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

Date: Wed, 10 Dec 1997 15:04:20 -0500
From: "Erik D. Jones" <erikdj@cyberjunkie.com>
To: bill@adcn.on.ca
Subject: Re: Fileupload
Message-Id: <348EF5C4.7A4E62F6@cyberjunkie.com>

Bill Davidson wrote:
> 
> I am also struggling with file uploads.  All of the examples I have seen
> for CGI.pm show how to take a text file as an upload and print it back
> to the user browser screen.  I want to receive binary files (*.gif) and
> move them to another directory with a new name (client_id.gif).
> 
> How can I get the file handle or copy the tempfile directly..?
> 
The form input field name is also a file handle when you use the CGI.pm
and create an object within PERL5.  Ensure that your coding type is set
properly within your form.  Within your script, saving the file is the
easy part.  You just need to extract the filename if you want to
preserve that.  Different systems will place different crap in the
filename part.  This sample script should handle all types:
UNIX/PC-DOS/MAC

<HTML>

	.. HTML crap
	<form enctype="multipart/form-data" method=POST action="<script name">
   	.. FORM crap

 	<input type=file size=30 name="file">
	</form>
</HTML>

The script should look something like:

	use CGI;

	$cgiobj = new CGI;

	$rawfilename=$cgiobj-param('file');

	for($rawfilename)		#similar to a switch statement in C
        {       /\\/    and do { @temp = split(/\\/,$rawfilename);		#PC
                                 $full_filename="/somedirectory/" . pop
(@temp);
                                 last; };
                /:/     and do { @temp = split(/:/,$rawfilename);		#MAC
                                 $full_filename="/somedirectory/" . pop
(@temp);
                                 last; };
                /\//     and do { @temp = split(/\//,$rawfilename);	
#UNIX
                                 $full_filename="/somedirectory/" . pop
(@temp);
                                 last; };
                $full_filename="/somedirectory/$rawfilename";			#PLAIN
        }
        
        open (RAWFILE,">$full_filename") or	## OUTPUT Stage
                die "Error writing file: $!";
        while ($bytesread=read($rawfilename,$buffer,1024))
        {       print RAWFILE $buffer;
                $totbytesread+=$bytesread;
        }

Erik Jones


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

Date: 10 Dec 1997 17:01:53 -0500
From: kclark@ctron.com (Kevin D. Clark)
Subject: Re: Filtering out unneeded header files
Message-Id: <k5btyon9gu.fsf@koan.ctron>


tphillipREMOVETHIS@rogers.wave.ca (Tom Phillips) writes:

> I've been given a large number of C files to maintain
> in which every .c file #includes basically EVERY .h file(!).
> There are _hundreds_ of .h files #included in each .c file but
> only a subset of the header files are really needed.
> Does anyone know of an easy (and quick) 
> way to figure out what this subset is that does not
> require compiling or linting the file? Can a preprocessor 
> be used to determine this perhaps? The platform is Unix (SOLARIS).

ROTFL.

I have three pieces of advice:

You're not going to be able to solve the general case of this problem
easily.  Not even with Perl.

It'd probably be easiest to figure out the general structure of the
code that you have and then by hand redo the #includes.

Please, please, please make sure that the person(s) who wrote this
code never ever write another program ever again.

--kevin
-- 
Kevin D. Clark (kclark@ctron.com)              Give me a decent UNIX
Cabletron Systems, Inc.                      and I can move the world
Durham, N.H. (USA)                     
                                       


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

Date: Wed, 10 Dec 1997 15:12:02 -0600
From: rhardin@planethollywood.com
To: webmaster@avsites.com
Subject: Re: Help! Formating numeric print statement output
Message-Id: <881787802.384565250@dejanews.com>

In article <01bd0398$2fb75be0$46203fce@avsites-2>,
  "Michael Volk" <webmaster@avsites.com> wrote:
>
> Hi -
>
> Trying to find info on formating numeric variables when using the print
> statement. Specifically, how to print a numeric variable (integer or
> otherwise) with two decimal places. Exhausted the books, can't find it on
> the net. Anyone have any ideas? Any leads would be greatly appreciated.
>

mike, you have to use printf ("print formatted"), not print.  There is a
man page for printf on development systems or in most any C compiler doc
-- the entry in the camel book refers to the man page.	For your specific
situation:  $val_a = 5;  $val_b = 2.03941;  printf ("%.2f\n%.2f\n",
$val_a, $val_b);

output:  5.00  2.04 For formatting without outputting, use sprintf: 
$formatted = sprintf("%.2f", $val);

-------------------==== Posted via Deja News ====-----------------------
      http://www.dejanews.com/     Search, Read, Post to Usenet


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

Date: 10 Dec 1997 22:25:53 GMT
From: plambert$1@plambert.org
Subject: Re: Kanji Perl
Message-Id: <66n4th$6bb$1@nntp1.ba.best.com>

Tom Phoenix <rootbeer@teleport.com> spewed:
> On 10 Dec 1997 plambert$1@plambert.org wrote:

> > tell me why there is no Kanji version of Perl?

> We've been waiting for you to send in the patches. :-)

Exactly.  Sorry about the ranting tone of that message--long day--but I 
still stand by my point.  Perl makes a lot of shortcuts available which
improve the most common case greatly, but as time goes on, that common
case is going to change!  What then?

--Paul L.



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

Date: Wed, 10 Dec 1997 17:01:22 -0600
From: Nehal Patel <npatel@rsn.hp.com>
To: Marc Page <PageMan@BigFoot.com>
Subject: Re: Local Array initialized to a constant
Message-Id: <348F1F42.D6F050FA@rsn.hp.com>

Try using parens instead of braces. like so:

local @code = ("7CE8C9A91D953C06E384D1351400",  #0
               "7E4607A94D0100",                #1
               "11996B2AB6166300951590100",     #2
               "1DD86B22B2A2D2444650500",       #3
               "9C786B26B9590169A1C0500",       #4
               "D194725EC3A65C7B934E8C41500",   #5
               "196AA1E55BB8951F2784D3D710500", #6
               "5DBB9AAD9022124580000",         #7
               "D18A2726DF68A214836A322190500", #8
               "E4A776149CBAEDF09AE2DAD1400"    #9
                );

Braces imply an anonymous hash as brackets imply an anonymous array


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

Date: Wed, 10 Dec 1997 23:38:43 GMT
From: jvgorkum@dds.nl (Jeroen van Gorkum)
Subject: need help with regexp
Message-Id: <349011c6.46237746@news.a1.nl>

I'm working on a big html document tree where I need to replace the
".html" extensions of all _local_ links with ".htm". I'm looking for
one regular expression to pass as a command line option to H.
Churchyard's html search & replace (perl) script. It accepts two
options:
old="..." where ... is a regular expression, 
new="..." where ... is a statement to be evaluated.
I'm looking for the regexp that goes in old="...".

To distinguish between local and external links that use a http, ftp,
gopher or other protocol I planned on matching a pattern that contains
".html", preceded by any characters that aren't colons. (like in
"http://", I'm not using "file://" - all local links are relative.)

When it contains a colon, I don't want a match, but when it doesn't
contain a colon, I'd like the ".html" part memorized to be able to
replace it by reference in new="...".

I can't seem to get this to work:

====

$_ = "A href=\"http://www.somewhere.com/directory/filename.html\"";
/[^:]+(\.html)/;

====

$` is now: A href="http:
$& is now: //www.somewhere.com/directory/filename.html
$' is now: "

While I need the string as a whole in $` or $' or not matched at all
in this case.

Any suggestions?

--JvG


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

Date: 10 Dec 1997 23:00:32 GMT
From: ? the platypus {aka David Formosa} <dformosa@st.nepean.uws.edu.au>
Subject: Re: need the skinny on my() vs local()
Message-Id: <881794732.965588@cabal>

In <666ula$jir@world6.bellatlantic.net> "Dave Kaufman" <davidk@nospam.cnct.com> writes:

[...]

>I'm afeared.  What is the difference between my() and local() ?

my()'s keep a verable scoped within a block, outside this block the
verable is not advalable.

sub foo {
  my($bar)=shift;
  &moo;  
  print "In foo \$bar is $bar\n"; 
}

Here $bar is only acceable by lines in foo.  So 

sub moo {
  print "In moo \$bar is $bar\n";
  $bar="Test2";
}

will cause an error if you have strict vars.

However if you have

sub foo {
  local($bar)=shift;
  &moo;
  print "In foo \$bar is $bar\n";
}

$bar will be in scope within the subroutean and all subrouteans called
from this.  So &foo("Pink") so will generate

In moo $bar is pink
in foo $bar is test2

--
Please excuse my spelling as I suffer from agraphia see the url in my header. 
Never trust a country with more peaple then sheep. I do not reply to mungged 
Support NoCeM http://www.cm.org/                   addresses.  
I'm sorry but I just don't consider 'because its yucky' a convincing argument


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

Date: Wed, 10 Dec 1997 14:07:47 -0800
From: "Xah" <xah@best.com>
Subject: newbie: compact an array
Message-Id: <66n3jh$617$1@nntp1.ba.best.com>

Suppose @a is an array of integers. I want to compact @a, so that elements
that are 0 get deleted. How can I do this without declaring another array @b
such as:

# compact array
$j=0;
foreach $i (@a) {if ($i) {@b[$j] = $i; $j++;};};

Thanks.
PS I'm new to the Perl language.

 Xah, xah@best.com
 http://www.best.com/~xah/SpecialPlaneCurves_dir/specialPlaneCurves.html




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

Date: Wed, 10 Dec 1997 12:53:32 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Ravi Kumar <ravi@centtech.com>
Subject: Re: Please advise. Fastest way to line-count files
Message-Id: <Pine.GSO.3.96.971210124044.15679Q-100000@user2.teleport.com>

On Wed, 10 Dec 1997, Ravi Kumar wrote:

> 	I have 2 sets of files. The first set is a bunch of 
> small (<10K lines) files. The second set is a bunch of large
> (> 200K lines ) files. I need to line-count these. 

> 1. I have found that perl is faster than wc(1)

That's sad, really, when you think about it. Here, somebody has coded a C
program to do "just one thing, and do it right", and you can still outpace
it in Perl. At least, on your system. :-)

> 2. In perl I can do it in two ways.

[methods snipped]

> Here are the nebulosities.

> 1. Which approach is faster for small/large files.

The one that finishes first. :-)  Use Benchmark, or a similar method to
time your code.

> 2. For large files, @jj will be massive. How do we deallocate 
>    @jj when done (in other words, does @jj=() work instantly???)

Pretty close to that. I wouldn't worry about deallocation times. But worry
about _allocation_ times: There's no good reason to store data you don't
need. (Hint.)

> 3. The file sizes are significant (small files: 3M , large files: 60M
>    and all reside on a single server. If I split this job on multiple
>    machines, I create congestion and dont gain any time. So looks like
>     I have to run this on a single fast machine. 

Okay.  :-)

That said, here's my linecounting code.

    open FILE, $filename
	or die "Can't open $filename: $!";
    my $count = 0;
    $count += tr/\n// while read FILE, $_, 1024;
    close FILE;

Arguing about whether this is correct and benchmarking this against other
methods are left as exercises. :-) 

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/
              Ask me about Perl trainings!



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

Date: Wed, 10 Dec 1997 15:01:56 -0600
From: rhardin@planethollywood.com
To: mxu@eecs.ukans.edu
Subject: Re: print buffer flush
Message-Id: <881787141.356974596@dejanews.com>

In article <348ECCB7.167E@eecs.ukans.edu>,
  Mousheng Xu <mxu@eecs.ukans.edu> wrote:
>
> Dear Experts and Semi-experts:
>
> 	I am dealing with very large files, the problem is that the "print"
> doesn't follow the order implemented in file. For example,
>
>         if(...) {
> 		......
> 		<do a lot of things>
> 		print FILEA, "abc\n";
> 	}
> 	print FILEB, "123\n";
>
> You would expect FILEA is written first and FILEB is wrtten second. But
> in my program, FILEB is written first, even in the case of true of the
> if statement -- just trust me. :)
>
> 	The delay could be hours or days!
> 	So, if I do want the order of printing, what can I do? I am trying to
> flush the printing buffer everytime it prints, but there is not a
> "fflush" function in Perl.

There is a way to switch between buffered and unbuffered output, by
setting the special variable $| to a non-zero value (applies to the
currently 'select'ed filehandle.  In your example,  open (FILEA,
">somefilea");	open (FILEB, ">somefileb");  select FILEA;  $| = 1; 
select FILEB;  $| = 1;	select STDOUT;

Now, the output buffers for these two filehandles will be flushed on
every print or write.  Absolutely necessary if you write to a file, then
immediately go back and read it ("hey, where's my output?").  Hope this
helps.	Good luck.

-------------------==== Posted via Deja News ====-----------------------
      http://www.dejanews.com/     Search, Read, Post to Usenet


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

Date: 10 Dec 1997 23:34:41 GMT
From: burt@ici.net (Burt Lewis)
Subject: Re: Returning information from an nslookup ??
Message-Id: <66n8uh$jqn$1@bashir.ici.net>

As the original poster of this, I want to thank everyone who responded.

I also am happy that it has been resolved for several weeks and the answer is 
below:

@numbers = split(/\./, $ENV{'REMOTE_ADDR'}); # make 4-element array out of IP
     $ip_number = pack("C4", @numbers);           # mangle
     ($i) = (gethostbyaddr($ip_number, 3))[0];    # and look up


Burt Lewis
www.eastonmass.com





In article <Pine.GSO.3.96.971210123039.15679L-100000@user2.teleport.com>, 
rootbeer@teleport.com says...
>
>On Wed, 10 Dec 1997, Carsten Posingies wrote:
>
>> are you on a Unix machine? If, you should start your favorite editor,
>> hack in some C-lines that do the gethostbyaddr() system call to STDOUT
>> and use this in your perl script. 
>
>That seems like a lot of work, since gethostbyaddr is already a builtin.
>And there's a module to do any other kind of DNS. Hope this helps!
>
>-- 
>Tom Phoenix           http://www.teleport.com/~rootbeer/
>rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
>Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/
>              Ask me about Perl trainings!
>



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

Date: 10 Dec 1997 21:06:47 GMT
From: "David Baker" <dbaker@dkburnap.com>
Subject: simple array problem parsing a cookie
Message-Id: <01bd05af$c0204d40$180cdece@dbaker>

Running PERL 5.003 build 306 on Intel NT 4.0 SP3
-------------------------------------------------------------------------


What I am doing is a few steps.  The are:

1.  Determine if the user has a cookie
2.  Take the cookie and split it on the ; seperator (multiple name/value
pair cookie)
3.  Then split it on the = for name/value pairs

The code below "looks" like it works fine.  It is splitting and populating
the array and showing me the data on-screen.  

The script is failing to truly go through the population of the final array
($aname, $avalue) = split (/=/); .  It looks OK on-screen while in the for
loop, but is not placing anything in the array after the first pass.

Please fill me in on why this is failing.  I'm not seeing my error...




Here is the code:

print "1. cookie as I got it: $cookie\n <br><br>";	

	(@variables) = $cookie;

	print "2. After assignment to array: @variables\n";
	

	#SPLIT ON ; TO SEPERATE THE COOKIES
	for $a_variables (@variables){
		(@value) = split (/;/,$a_variables);
	}#END for

print "<br><br> 3. After split on ; and value array assignment <br> value:
@value <br> \n";

	#TAKE @value FROM ABOVE AND SPLIT ON =
	for (@value) {
	($aname, $avalue) = split (/=/);
		print "<br><br> 4.$test split on = for name/value assignment----- <br>
name: $aname  <br> value: $avalue <br> \n";
		$thecookie{$aname} = $avalue; #POPULATE ASSOCIATIVE ARRAY
		$test++; #INCREMENT COUNTER
	} #end for

	print "<br> <b> Step 4 </b> made $test passes populating the
array.<br><br> \n";
	

	print "<br><br> 5. cookie after the array: <br> <b> asp:</b>
$thecookie{'ASPSESSIONID'} <br> <b>id:</b> $thecookie{'id'} <br> \n ";




Thanks,

David
dbaker@dkburnap.com


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

Date: Wed, 10 Dec 1997 22:12:52 GMT
From: syarbrou@ais.net (Steve)
Subject: Taking document in directories and replacing them dynamically
Message-Id: <348f12f4.21370550@news.ais.net>

Ok, here we go.  I have a web site(no this isn't a CGI) with multiple
levels of subdirectories.  Say the URL of the site is changing, but
the content structure will stay the same.  I want an easy way where a
preson hits any of the old pages on the old URL, it will redirect them
directly to the new location of that document.  Is there some way to
have a perl script parse through the directories and say ok, this file
is called joe.htm and it's located under /joe/main/ and so I need to
create an html with a meta tag that redirects the files to new
URL/joe/main/joe.htm?  Thanks.

Any other suggestions would be appreciated as well for this concept.

Steve


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

Date: Wed, 10 Dec 1997 23:04:47 GMT
From: faust@wwa.com (Faust Gertz)
Subject: Re: There's More Than One Way?
Message-Id: <348f1dca.12638606@news.wwa.com>

On Wed, 10 Dec 1997 13:07:28 -0500, John Porter <jdporter@min.net>
wrote:

>Quoth Larry, "There's more than one way to do it", as we are all aware.

Okay, I'll grant you that.

>This is interesting, philosophically, because it means that 
>For every problem in the universe of problems,
>the number of solutions (in Perl) is >= 1.

That is assuming that TIMTOWTDI has to do wth coming up with solutions
to problems.  It is unclear to me that Larry limits TIMTOWTDI to
problem solving.  Also, I think the universe of which you speak is
limited to the set of all problems solvable with Perl.

>That is, there are no problems which can not be solved in Perl.

Unless I am to allow language to go on holiday, I think all I would
allow you to say is that there are no problems which are solvable with
Perl which can not be solved with Perl.  I will leave the
philosophical interest of such a claim to the reader.


Streben nach Wahrheit

Faust Gertz
Philosopher at Large


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

Date: Wed, 10 Dec 1997 22:39:34 GMT
From: bark@the.moon (dave)
Subject: UML and Perl
Message-Id: <348f19ba.799817@news.one.net>

The Universal Modeling Language is being evaluated around where I work along
with tools that generate code.  Are/will there be tie-ins to Perl?  What are
they?

Thanks,
Dave


~~~~~~~~~~~~~~~~~~~~~~~~~~~~
http://w3.one.net/~dlripber
ten.eno@rebpirld


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

Date: Wed, 10 Dec 1997 16:03:07 -0500
From: Eric Kimminau <eak@detroit.sgi.com>
Subject: WANTED: "generic" logfile parse/report
Message-Id: <348F038B.C55D2EBA@detroit.sgi.com>

Ive been asked to grab the logfile output from our Legato Networker
backup server and attempt to determine the amount of tape storage space
being used by each user. Every night the log file generates multiple
lines for each client but Im only interested in lines whose last string
contain a directory tree structure, something similar to:

dlt_00         somehost.somedomain.com 12/06/97 802 MB full /
dlt_00         somehost.somedomain.com 12/06/97 236 MB full /usr/people
dlt_00         somehost.somedomain.com 12/06/97 163 MB full /usr/share
dlt_00         legato-serv.somedomain.com 12/06/97 47 MB full
/released/nsr/index/somehost.somedomain.com

I want to track, by day, how much data is stored for each client,
regardless of partition, including its index on the legato server, and
then generate reports by host (or the entire server), for daily, weekly,
monthly, quarterly, etc. storage use. Parsing the entire logfile, for
now, is an option. Version 2 will probably parse a much smaller daily
logfile and keep track of things in some kind of database.

I have a limited knowledge of perl but everything Ive heard tells me its
the right language to do this kind thing in. And Im sure that someone,
somewhere has probably already done something similar.

I started looking for web server logfile parsers but everything Ive
found seems to go into a whole lot more detail than Im looking for and
none of the sample sources to "inherit" seem to be very well documented
to make fore easy adaption.

Im probably going to start with the "cronsort" example just because it
seems to lend itself to a good starting place but I thought I would ask
if the wheel had already been invented and where I might look for it, if
it had.

BTW, anyone interested in doing this should get in touch with Legato and
sell them the resulting application. Its functionality that seems to be
missing from most networked archival products Ive come in contact with.

-- 
Eric Kimminau                             System Engineer
eak@detroit.sgi.com                       Silicon Graphics, Inc
Vox:(810) 848-4455                        39001 West 12mile Road
Fax:(810)848-5600                         Farmington, MI 48331-2903
            "I speak my mind and no one else's."
    http://www.dcs.ex.ac.uk/~aba/rsa/perl-rsa-sig.html

-----END PGP PUBLIC KEY BLOCK-----
http://bs.mit.edu:11371/pks/lookup?op=vindex&search=Eric+A.+Kimminau&fingerprint=on


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

Date: Wed, 10 Dec 1997 17:15:56 -0500
From: Eryq <eryq@zeegee.com>
To: eak@detroit.sgi.com
Subject: Re: WANTED: "generic" logfile parse/report
Message-Id: <348F149C.3CF@zeegee.com>

Eric Kimminau wrote:

> lines for each client but Im only interested in lines whose last string
> contain a directory tree structure, something similar to:
> 
> dlt_00         somehost.somedomain.com 12/06/97 802 MB full /
> dlt_00         somehost.somedomain.com 12/06/97 236 MB full /usr/people
> dlt_00         somehost.somedomain.com 12/06/97 163 MB full /usr/share
> dlt_00         legato-serv.somedomain.com 12/06/97 47 MB full
> /released/nsr/index/somehost.somedomain.com

That "last string" is a slightly difficult problem, since you can have
weird directory names which include spaces; e.g., "/usr/local/whoa there/kid".
If you're content to assume no whitespace in paths, then the solution below
can start you off.  Otherwise, you'll have to give more information as to
the syntax of these logs, and how we can distinguish lines you want from 
lines you don't (example: if you were to say, "all lines are of the form 
'device host date size units status directory', we could proceed).

Try running this from the command line, with the log filename(s) as the
argument(s); or else, just pipe stuff into stdin... 

    #!/usr/bin/perl -w
    use strict;
    while (<>) {
	chomp;
	m{\s/\S*$} or next;	# skip if not ending in " /anything-but/white:space"
	my @vals = split;
	print "client $vals[1]: $vals[3] MB\n";	
    }

I didn't check it but I don't think my typing is far off...


> I have a limited knowledge of perl but everything Ive heard tells me its
> the right language to do this kind thing in. 

I violently agree.  :-)


> And Im sure that someone,
> somewhere has probably already done something similar.

Yup.  Many folks write log file parsers in Perl.  They tend to be so driven
by the syntax of the individual files that inheriting from some generic
log file parser class is probably more trouble than rolling your own 
parser each time.


> Im probably going to start with the "cronsort" example just because it
> seems to lend itself to a good starting place but I thought I would ask
> if the wheel had already been invented and where I might look for it, if
> it had.

If it has, it's in the CPAN.  (www.perl.com/CPAN, I think).


> BTW, anyone interested in doing this should get in touch with Legato and
> sell them the resulting application. Its functionality that seems to be
> missing from most networked archival products Ive come in contact with.

Ah, too much bother.  I'd just give it away.  :-)

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


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

Date: 10 Dec 1997 22:22:40 GMT
From: vleugels@do.isst.fhg.de (Dirk Vleugels)
Subject: Re: Wanted: Perl5 script to scan+kill POP3 mailbox
Message-Id: <881792130.641553@firewall.do.isst.fhg.de>

A.M. Basman (amb26@ponder.demon.co.uk) wrote:
: I would like a nice script that, given username, password,
: POP3 server, and a file full of regexps, will run through
: the mailbox and trash any message whose From address
: matches any of the expressions.

: Yes, a spam filter.

: Does anyone have anything like this?

: No, I do not have the time/expertise to write one myself,
: at least, not one that I'd trust :)

: Antranig.

Something like this?

--cut

use Net::POP3;

$num = 0;
$x = 0;

$pop = new Net::POP3 ("$ARGV[0]");
$pop->login("$ARGV[1]", "$ARGV[2]");

($num,$size) = $pop->popstat();

print "$num messages on server. Mailbox size: $size bytes\n";

exit(0) if ($num == 0);

for ($i=1; $i <= $num; $i++) {
    $lr_message = $pop->top ($i,1);
    foreach $l (@{ $lr_message}) {
	if ($l =~ m/^Subject:\s+MONEY.*FAST/) {
	    $pop->delete($i);
	    $x++;
	    last;
	}
    }
    print "$x messages deleted.\n";
}
$pop->quit;


--cut

Use with care! No warranty for nothing ;)

Dirk


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

Date: 10 Dec 1997 16:19:03 -0700
From: speed@racer.cartoon.spam.address
Subject: Re: Writing fixed-length records to file
Message-Id: <yz23ek0lrbs.fsf@advtech.uswest.com>

### "Dave" == Dave Barnett <barnett@houston.Geco-Prakla.slb.com> writes:
Dave> #!/usr/local/bin/perl -w
Dave> #
Dave> $a = "junk";
Dave> $b = "12345";
Dave> $c = "123456";
Dave> $d = "1234567";
Dave> $e = pack("A5A6A7A10",$a,$b,$c,$d);
Dave> print "<$e>\n";
Dave> 
Dave> __END__
Dave> 
Dave> Creates these results:
Dave> <junk 12345 123456 1234567   >
Dave>  1234512345612345671234567890
Dave> 
Dave> As you can see, I got a field of 5, 6, 7 & 10 characters in length, space
Dave> padded.  I think that is what you wanted, no?
Dave> 
Dave> HTH.
Dave> 
Dave> Dave
Dave> 

This is in fact the functionality I was looking for.  Thank you for your 
time.

Peace.

-- 
  Bruce W. Hoylman (303/541-6557) -- bhoylma@advtech.USWest.COM ._ 0  
   -     __0    Speaking for myself...        /\/\    /\       /  //\.
-  - - _-\<,_   "Please saw my legs off".    /~/~~\/\/~~\     '  \>> |
 -  __(_)/_(_)_____________________________/\ /    \ \/\ \________\\ `_


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

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

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