[8187] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1805 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Feb 4 10:08:01 1998

Date: Wed, 4 Feb 98 07:00:31 -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, 4 Feb 1998     Volume: 8 Number: 1805

Today's topics:
    Re: A Scoping Related Question <jdporter@min.net>
        Accessing WinNT Service Information Remotely from a Web <pdore@nortel.com>
        AIX, perl and syscall.h ? <Andreas.Kutschera@bln.sni.de>
    Re: can variables be generated on the fly <jdporter@min.net>
    Re: Debuggin w/o shell <administrator@actioninternet.net>
    Re: Email Perl script on NT alpha server <administrator@actioninternet.net>
        Filtering Problem <Joergen.Lang@schwaben.de>
        Global variable names <kar@webline.dk>
    Re: Help Wanted: Parsing data from oddly formatted file (Bart Lateur)
    Re: I am female, blonde and stupid! <jdporter@min.net>
    Re: Inverse of a regex <rootbeer@teleport.com>
    Re: Inverse of a regex <rootbeer@teleport.com>
    Re: Is Perl 5 year 2000 compliant? <lamber45@EGR.msu.edu>
    Re: Is Perl 5 year 2000 compliant? (I R A Aggie)
        Java Perl Integration <ophiry@agentsoft.com>
    Re: Matching one line, then another <bill.weaver@lexis-nexis.com>
    Re: New core dump on long-working troff2html <jspath@mail.bcpl.lib.md.us>
        NPH question <jim.blackwell@gsfc.nasa.gov>
    Re: Pattern Match Question <barnett@houston.Geco-Prakla.slb.com>
    Re: Quickie: regexp for valid e-mail addresses (Bart Lateur)
    Re: Quickie: regexp for valid e-mail addresses (Clay Irving)
        replacing things i perl <marthy@feskar.net>
    Re: searching by file creation/modification date? (Clay Irving)
    Re: solution for multiline comments??? (Bart Lateur)
    Re: Survival Of perl (Chris Nandor)
    Re: unix command <monte@ispi.net>
    Re: Using Bcc header in perl mail script (Clay Irving)
    Re: Variable passing with an URL <monte@ispi.net>
        Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Wed, 04 Feb 1998 09:14:44 -0500
From: John Porter <jdporter@min.net>
Subject: Re: A Scoping Related Question
Message-Id: <34D877D4.55EF@min.net>

V. Chandrasekhar wrote:
> 
> My 'main' sets several variables. It calls several subroutines.
> Even though main's variables are global, in each subroutine call,

Every package variable, not just the ones in package 'main', is
global, in the sense that it can accessed by giving the fully
qualified name.  This is just for info, though; it's a Good Idea
to avoid reaching into other packages' data.

>   &writeHeaderLines(
>        $testNumber, $kmh, $mph, $testDescription,
> ...
>        $obs
>        ) ;
> 
> The subroutine looks like this:
> 
> sub writeHeaderLines
> {
>   local(
>    $testNumber, $kmh, $mph, $testDescription,
> ...
>    $obs ) = @_ ;

For starters, change that 'local' to 'my'.  This may be
one of the most important changes in perl5.  In general,
use 'my' where you used to use 'local'.  When and if you
need 'local', you'll know it.


That's a mightly long argument list you have there.
I would suggest replacing it with a single hash, passed by
reference, that contains all these fields.  I.e.:

  my %args;
  $args{'testNumber'} = $tn; # however you get these values
  . . .
  $args{'obs'} = $obs;
  &writeHeaderLines( \%args );

Or even:

  &writeHeaderLines( { # passing an anonymous hash ref
    testNumber => $tn,
    . . .
    obs => $obs
  } );

Then:

  sub writeHeaderLines {
    my( $args_hr ) = @_;
    # use $args_hr->{testNumber} as you used to use
    # $testNumber, etc.
    . . .
  }

Hth,
John Porter


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

Date: Wed, 04 Feb 1998 13:21:27 +0000
From: Philip Dore <pdore@nortel.com>
Subject: Accessing WinNT Service Information Remotely from a Web Page
Message-Id: <34D86B57.4AAE9176@nortel.com>

I am trying to create a script which will from a web page query the
status of the services running on a remote WinNT system. the script
works if I use the name of the localhost on which the web server is
running, but if I use the name of a remote system the script fails and
returns the error, no such file or directory - HELP.

print <<END_of_Multiline_Text;
Content-type: text/html

<HTML>
<HEAD>
<TITLE>WinNT Services Check</TITLE>
</HEAD>
<BODY>
END_of_Multiline_Text
use Win32::Service;
${HOSTNAME}="host1";
 print "<H1>Running Services Check on ${HOSTNAME}</H1>";
$!="";
Win32::Service::GetServices(${HOSTNAME}, \%list) || warn $!;
print "Error - $! <P>";
print "Display Name = Service Name\n<P>";
foreach $key (keys %list)
        {
        print "<H2>",$key, "</H2>";
       Win32::Service::GetStatus(${HOSTNAME}, $list{$key}, \%status) ||
warn $!;
       if ($status{CurrentState} == "1") {
             print "<I>Current State = " , Stopped, "</I><P>\n";
       } elsif ($status{CurrentState} == "4"){
              print "<I>Current State = " , Running, "</I><P>\n";
       }else {
              print "<I>Current State = " , $status{CurrentState},
"</I><P>\n";
       }
}

print <<END_of_Multiline_Text;
<H3>End of List</H3>
</BODY>
</HTML>
END_of_Multiline_Text



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

Date: 4 Feb 1998 12:47:01 GMT
From: Andreas Kutschera <Andreas.Kutschera@bln.sni.de>
Subject: AIX, perl and syscall.h ?
Message-Id: <6b9o05$ru4$1@horus.mch.sni.de>

Hi,
I've gotten a precompiled version of Perl 5.4.4.0 from frec.bull.com, installed
it on AIX 4.2 and now I cannot call "SYS_statfs", because there is no
syscall.h on AIX (and thus no syscall.ph).

I've searched the FAQ (both Perl and AIX) and everywhere else I could think of,
but I've only found solutions for specific syscalls, but no generic solution.

All I've found out is that on AIX syscalls seem to be assigned dynamically and
so they don't have a specific number that would work with h2ph.

My question is this:
Is there a generic solution that allows me to use syscalls on AIX or do I have
to rewrite all modules and programs that (seem to) work everywhere else?

Any help is much appreciated.
--
Andreas Kutschera,Siemens Nixdorf AG ASW BA DMS 4,     Tel. 030/386-27939
Nonnendammallee 101, D-13629 Berlin                    Fax  030/386-24946
email: Andreas.Kutschera@bln.sni.com (actually it's "de" instead of "com")


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

Date: Wed, 04 Feb 1998 09:25:43 -0500
From: John Porter <jdporter@min.net>
Subject: Re: can variables be generated on the fly
Message-Id: <34D87A67.773F@min.net>

Andrew M. Langmead wrote:
> 
> chip@mail.atlantic.net (Chip Salzenberg) writes:
> 
> >And obtaining hard references is difficult exactly when?
> 
> Well, its a little easier to turn input into a soft reference than a
> hard reference. To get the hard reference, you have to set some sort
> of mapping between string and the reference.
> 
> %hash = (sub_a => \&sub_a, sub_b => \&sub_b);

yahbut, perl already provides that mapping.  To get a hardsubref
from a softsubroll^H^H^Hef (i.e. sub name ),
  $hsref = \&{$subname};

> But on the other hand, I'm not sure if I'd want a syntax error in the
> input to call any arbitrary subroutine of my program as in:
> 
>      &{shift @ARGV};

Yahbut, your hash mapping at least restricts the possible calls
to those you allow.

More generally (relaxedly), you can prevent attempts to call
undefined subroutines:

  $hsref = defined &{$subname} ? \&{$subname} : \&no_such_sub;

John porter


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

Date: Wed, 4 Feb 1998 09:14:23 -0500
From: "Shane Newberg" <administrator@actioninternet.net>
Subject: Re: Debuggin w/o shell
Message-Id: <34d87813.0@209.4.95.130>


Paul Mone wrote in message <6b87vk$dv8@bgtnsc03.worldnet.att.net>...
>Due to the elitest nature of the body of programmers who reside here, I
>am forced to both use a proper subject and be as specific as I can.
>I have a script, written in Perl, no problems with the code, no problems
>with the file attributes/permissions...so don't send me any emails.
>My dilemma is that, of course "it doesn't work", but I am curious as to
>the best ways to go about debugging when you don't have shell/telnet
>access...I can ftp or http to the domain I'm working on, no more, no
>less.  I am getting the vaguest of the vague error messages in return
>for my hard work...one of the latest is:
>CGIwrap Error: System Error: execv() failed
>
>Error: No such file or directory (2)
>
>but this is nonsense...there is such file or directory.  Basically, I
>want to find out more specific information about whats gone
>wrong...where did it reach this error, which file is it trying to
>access?  Why the hell does my Web-hosting service not give me telnet
>access to my "virtual" server?
> Yours,
>    Paul

Probably because your web hosting service on  NT.
As a suggestion only, make the script work on your local system before
uploading it to the server where you can get debugging information from your
local box.





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

Date: Wed, 4 Feb 1998 09:28:38 -0500
From: "Shane Newberg" <administrator@actioninternet.net>
Subject: Re: Email Perl script on NT alpha server
Message-Id: <34d87b64.0@209.4.95.130>


d2dcleh@fre.fsu.umd.edu wrote in message <6b7gan$9ht$1@hecate.umd.edu>...
>I currently created a form through html and I am using a perl script to
email
>the form.  The problem is when I send the form nothing happens, I just get
the
>reponse back through the netscape browser saying that the form was sent.
>Everyone I have talked to so far has been running forms from a unix server.
We
>have a NT alpha server and I was wondering if maybe the perl script is
>different on a Unix server compared to a NT alpha server.  I would greatly
>appreciate any suggestions on how to email the form, or maybe something
that
>may need configured on the NT server.   Thanks...

Yeah, most of the Form to email scripts out there use sendmail as there
method of opening up the socket to send the mail. On NT you can either use
your own command line mailer, the smtp.pl script, or Front Page 98 which has
a built in Form to email generator.

You can get the smtp.pl script from
http://www.seattlelab.com/slmail/xtras.asp and then modify it to output the
form.






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

Date: Wed, 04 Feb 1998 15:21:30 +0000
From: Joergen Lang <Joergen.Lang@schwaben.de>
Subject: Filtering Problem
Message-Id: <34D8877A.586E@schwaben.de>

Dear Wizards of Perl,

I'm pretty new to the Perl language and now I'm stuck in the middle of a
Senior-Level task (at least as it seems to me...).
After scavenging the CPAN/FAQ's, etc. I couldn't find anything that
matches my problem, so maybe one of you Gurus can help me.

Here's the problem:

I have a database of tourdates to deal with. It's in simple ASCII and
has the following form:

"date";"town";"venue";"time";"artist"\n
"date";"town";"venue";"time";"artist"\n
"date";"town";"venue";"time";"artist"\n
(...etc...)

I have wrecked my head with trying to write something that compares the
database against itself so I can print out a tour schedule for each
artist with the artistname as a header and then lists the appropriate
dates.
Like this:

ARTIST

date town venue time
date town venue time

NEXT ARTIST

(as above...)

The actual problem I have lies in filtering out each individual artist
so it gets printed only once. 
Is there any algorithm that does these things for me ?

As an extension I think of something like passing variables for a
limited search to it via a WWW form, so maybe I have two variables
$sort_by and $range where one could specify the modes / limit the
search. Maybe I need something like default variables that cover the
whole database which.

I suppose the easiest thing would be some simple routine from which I
could then work my way up to more complex structures.

Has anyone of you done something similar or knows of a location/URL
where to obtain the appropriate tools ?

Big thanks for your patience and time,

Joergen
-- 
____________________________________________________________

    '&`      Joergen Lang:
     #       
     #       <mailto:Joergen.Lang@schwaben.de>
    _#_      <mailto:Joergen_Lang@magicvillage.de>
   ( # )     
   / O \     HOELDERLIN EXPRESS Management:
  ( === )    <mailto:music.contact@p-net.de>
   `---'     

HOELDERLIN EXPRESS Website:
<http://www.musiccontact.com/hx>

             --- Electric Body Folk ---

_____________________________________________________________


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

Date: Wed, 04 Feb 1998 12:52:57 +0100
From: Kaare Rasmussen <kar@webline.dk>
Subject: Global variable names
Message-Id: <34D85699.9DBB03CF@webline.dk>

I have a construct like this

$fname="varname";
for $j (0..$result->ntuples - 1) {
   $fval=$some_value
   @$fname[$j]=$fval;
}

in a subroutine in a module. The idea is that there should be a global
array called $varname, but if the subroutine is called, the variable
lives only inside there.

How can I export or declare a variable outside a module - when I don't
know the name in advance?


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

Date: Wed, 04 Feb 1998 12:40:22 GMT
From: bart.mediamind@tornado.be (Bart Lateur)
Subject: Re: Help Wanted: Parsing data from oddly formatted files
Message-Id: <34e25920.5295044@news.tornado.be>

riddler@atmnet.net (Terry Bunch) wrote:

>I have around 300 small ascii files that I need to parse some data out of
>and I am not quite sure how to go about this. The files do not all
>contain the same fields, but they need to populate the same html
>template. The other problem I have is that the field names and data
>fields are on seperate lines with a blank line seperating them.
>
>What I need is the the parsing section of the code to be able to do the
>following:
>
>1. Find the field names if they exist and match the data on the line
>below the field name in the pair.
>
>2. Report null as the data for the fields missing input
>
>3. Process this on each file, one after the other.
>
>example of file:
>
>field name
>data
>
>field name
>data
>data
>The data portion on some of the fields is multiple lines.

Here's one for your toolbox.

Maintain a "state" (aka a "mode"). This means: keep track of the
situation you're in when reading the next line. Change the state when
the data on the line says so.

This is an approach I use a lot, for all sorts of situations. I have
succesfully used it in processing DXF files, by keeping multilevel
states. Your problem is pretty simple compared to that.

Here's the scenario for collecting the data:

   while(defined($file = shift)) {	#next file
	open(IN, $file) or (warn "Can't open file $file, $!"), next;
	$mode = 'NAME'; undef %hash;	# fresh start for each file
	while (<IN>) {
		if (/^$/) {	#empty line
			$mode = 'NAME';
		} elsif ($mode eq 'NAME') {
			chomp; $key = $_;
			$mode = 'DATA';
			# I just clear the field
			# you may want to warn for doubly defined names
			$hash{$key} = ""; 	
		} elsif ($mode eq "DATA") {
			#more data, append to what was there
			$hash{$mode} .= $_;
		}
	}
	# file end. Now fill in the template
	# you probably need this printed to a different file each time
	print &interpolate($htmltemplate, \%hash);
    }

Note that all variable values end in "\n". You'll probably want these
chomped.

Now, do you need help on filling in the template too? There are several
script snippets available that do this. It's even been used in some of
the modules. Note that not all of them expect the "variable" encoded in
the same way. Anyway, it's amazingly simple, once you get the hang of
it.

This one expects "variable names" between curly braces. If you DO want
an opening curly brace, precede it with a backslash. If you want a
backlash, use two.

Note that I'm posting this without testing.

     sub interpolate {
	my ($template, \*hash) = @_;
	local($^W);	#suppress those bloody warnings
	$template =~ s/\\(\W)|\{(\w+)\}/$1 || $hash{$2}/ge;
	return $template;
     }

HTH,
Bart.


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

Date: Wed, 04 Feb 1998 09:37:00 -0500
From: John Porter <jdporter@min.net>
Subject: Re: I am female, blonde and stupid!
Message-Id: <34D87D0C.1FD2@min.net>

Chip Salzenberg wrote:
> 
> JavaScript and Perl don't mix.  (Thank goodness.)

Well, actually, they can, in the sense that Kati is
talking about.  She wants to use perl to read/write
javascript files.  What better language to modify
javascript files?

Eventually the distribution will include a js2p script,
presumably. (Right?)

John Porter


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

Date: Wed, 4 Feb 1998 05:34:33 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Peter Wahl <wahl@lts.sel.alcatel.de>
Subject: Re: Inverse of a regex
Message-Id: <Pine.GSO.3.96.980204052636.464G-100000@user1.teleport.com>

On Tue, 3 Feb 1998, Peter Wahl wrote:

> I would propose 
> $line =~ s/.*(\<.*\>).*/$1/g;

Or you could wirte to my friends at the address below. For some reason,
that code displeases them. :-)

    "Fred>&<Barney" <"fred>&<barney"@redcat.com>

Cheers!

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



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

Date: Wed, 4 Feb 1998 05:36:00 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: peter.edlund@capgemini.se
Subject: Re: Inverse of a regex
Message-Id: <Pine.GSO.3.96.980204053504.464H-100000@user1.teleport.com>

On 3 Feb 1998 peter.edlund@capgemini.se wrote:

> ($line) = ($line =~ /(\<.*?\>)/);

Have you written to my friends at this valid email address? :-)

    "Fred>&<Barney" <"fred>&<barney"@redcat.com>

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



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

Date: Wed, 4 Feb 1998 08:55:24 -0500
From: David Lee Lambert <lamber45@EGR.msu.edu>
Subject: Re: Is Perl 5 year 2000 compliant?
Message-Id: <Pine.GSO.3.96.980204083422.25250D-100000@area51>

On Wed, 4 Feb 1998, Matthew Rock wrote:

> Does anyone know of any problems with Perl 5 and Y2K?

Perl itself is date-independent.  RTFM, and you'll see that the only way
to get a date is with `date` (i.e., spawn an external program that returns
text) or via POSIX::strftime(), which is Year 2000 compliant on all UNIX
systems and most others.  (The C analogue allows flexible printing of
year, month, timezone, etc., depending on the time and locale.) 

David Lee Lambert   MHm 16x20   Hack Programmer and Student
Admin of lmert.dyn.ml.org           http://lmert.dyn.ml.org
My web pages are at http://web.egr.msu.edu/~lamber45



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

Date: Wed, 04 Feb 1998 09:34:30 -0500
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: Is Perl 5 year 2000 compliant?
Message-Id: <fl_aggie-0402980934310001@aggie.coaps.fsu.edu>

In article <Pine.GSO.3.96.980204083422.25250D-100000@area51>, David Lee
Lambert <lamber45@EGR.msu.edu> wrote:

+ RTFM, and you'll see that the only way to get a date is with `date` 
+ (i.e., spawn an external program that returns text) or via 
+ POSIX::strftime(),

RTFM yerself...unless I mis-read things, there are entries for
gmtime() and localtime():

$date_string=localtime();
print "$date_string\n";

Wed Feb  4 09:33:23 1998

Hmmmm...this of course is dependent upon the underlying C libraries on
any given system.

James

-- 
Consulting Minister for Consultants, DNRC
The Bill of Rights is paid in Responsibilities - Jean McGuire
To cure your perl CGI problems, please look at:
<url:http://www.perl.com/perl/faq/idiots-guide.html>


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

Date: Wed, 04 Feb 1998 15:02:05 +0200
From: Ophir Yoktan <ophiry@agentsoft.com>
Subject: Java Perl Integration
Message-Id: <34D866CC.26A0020C@agentsoft.com>

Is it available whitout the perl resource kit?

--
-----------------------------
Ophir Yoktan
ophiry@agentsoft.com
http://www.huji.ac.il/~ophiry

"It's not a bug, It's a feature"
 (old Microsoftian proverb)




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

Date: Wed, 4 Feb 1998 09:48:22 -0500
From: "Bill Weaver" <bill.weaver@lexis-nexis.com>
Subject: Re: Matching one line, then another
Message-Id: <6b9v3s$bqv@mailgate.lexis-nexis.com>
Keywords: perl, sql, regex

Thanks Craig, Tad McClellan, and Guy Decoux! The most obvious things I
learned were chomp, \S, and {n}. Guy used the range operator, which took me
a while to figure out but is very cool.

Guy's solution follows (with a couple modifications).

#!/usr/local/bin/perl5 -w
while (<>) {
    chomp;
    $succ = /^ {11}0/ .. /^\t(\S+)\s*$/;
    $found = $1;
    print "$found added successfully\n" if $succ =~ /E0/;
    $fail = /duplicate USERID/ .. /^\t(\S+)\s*$/;
    $found = $1;
    print "$found failed\n" if $fail =~ /E0/;
}

Thanks again, folks. -bill

Craig Berry wrote in message <6at42q$cki$1@marina.cinenet.net>...
>Bill Weaver (bill.weaver@lexis-nexis.com) wrote:
>: There are two SQL output files that I would like to scan for successful
>: operations and for errors. (The most common error is attempting adding
>: duplicate ids.) The output files are of slightly different formats, and I
>: have a perl solution for each, but I think my way is ugly and sophomoric.
>: Can someone please suggest some better ways to do this?
>:
>: Basically, I'm looking for ids that succeed and ids that fail. In the
sample
>: data at the end of this message, the failed userid is ABC1230 (with a "1"
>: tacked on by SQL), the successful adds are ids ABC1234, and ABC1236.
>:
>: #! /usr/local/bin/perl5
>
>You forgot the -w switch.
>
>: while (<>) {
>:  chop;
>
>chomp is often preferable, though it's a minor difference.
>
>:  if (/^           0/) {
>
>The regex might be better written as /^ {11}0/ since multiple
>spaces are hard to type/read accurately.
>
>:   while (<>) {
>:    if (/^\t([^\s]+)\s+$/) {
>
>[^\s] can be equivalently and more compactly written as \S.
>
>:     $last_good_id = $1;
>:     print "$last_good_id added successfully\n";
>:    }
>:    last;
>:   }
>:   next;
>
>Why put the while loop in, if you're going to unconditionally
>exit after reading one line via 'last'?  Why use 'next' to
>trigger the next cycle, when you can use 'elsif' below and
>get the same effect more clearly and with equal efficiency?
>
>:  }
>:  if (/duplicate USERID/) {
>
>Make this 'elsif'.
>
>:   while (<>) {
>:    if (/^\t([^\s]+)\s+$/) {
>
>See \S comment above.
>
>:     $failed_id = $1;
>:     print "$failed_id failed\n";
>:     last;
>:    }
>
>This makes me think you've misplaced your 'last' in the
>similar loop above.
>
>:   }
>:   next;
>:  }
>: }
>
>HTH!
>
>---------------------------------------------------------------------
>   |   Craig Berry - cberry@cinenet.net
> --*--    Home Page: http://www.cinenet.net/users/cberry/home.html
>   |      Member of The HTML Writers Guild: http://www.hwg.org/
>       "Every man and every woman is a star."




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

Date: 4 Feb 1998 14:47:55 GMT
From: "Jim Spath" <jspath@mail.bcpl.lib.md.us>
Subject: Re: New core dump on long-working troff2html
Message-Id: <6b9v2r$mrr$1@news.abs.net>

>   From: ilya@math.ohio-state.edu (Ilya Zakharevich)
>   Date: 3 Feb 1998 22:43:41 GMT
>   References:
>          <6b83jn$4kg$1@news.abs.net>
>I wrote in article <6b83jn$4kg$1@news.abs.net>:
>> >   From: chip@mail.atlantic.net (Chip Salzenberg)
>> >   Date: Tue, 03 Feb 1998 21:16:04 GMT
>> >   References:
>> >          <6b6tok$5jn$1@news.abs.net>
>> >According to Jim Spath <jspath@mail.bcpl.lib.md.us>:
>> >>A 400-line troff file core dumps under the current perl (5.004)
>> >The current perl is 5.004_04, not 5.004.  Maybe if you try that one it
>> I'm running 5.004_04 where the dumps occur.
>> >Or you may be overflowing your stack due to ill-behaved regexes.
>> Here's the line that seems to be the baddie:
>>     # records are a command, optional args, newline, optional text
>>     # This leaves $args with all extra 1st line spaces
>>     ($command, $args, $text) = /^(\S+)(.*)\n?((.|\n)*)$/;
>> I'm no regexpert, but that could probably misbehave.  Suggestions?
>If you have a very short stack (less than 4-6M) this may segfault on
>longer input.  The latter star can take eat up to 32K chars, taking
>100-200 bytes of stack per char.
>This will not happen with newer Perls (4_55 and later) since (.|\n)*
>is optimized to use no recursion.

I've just installed 5.004_57 and the core dump has vanished.
Thanks to all who replied.  Took me a little while to find the devel
version, but I'm happy now!


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

Date: Wed, 04 Feb 1998 08:01:12 -0500
From: "James H. Blackwell" <jim.blackwell@gsfc.nasa.gov>
Subject: NPH question
Message-Id: <34D86698.167E@gsfc.nasa.gov>

Hi all,

been trying to force the download of a file by setting the MIME type to
application/octet-stream then printing the file to be downloaded.  Goes
into opening the dialog box, but instead of containing the name of the
file to be downloaded, it uses the name of the script.

I'm using CGI.pm

Jim Blackwell


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

Date: Wed, 04 Feb 1998 08:24:39 -0600
From: Dave Barnett <barnett@houston.Geco-Prakla.slb.com>
Subject: Re: Pattern Match Question
Message-Id: <34D87A27.A28F587A@houston.Geco-Prakla.slb.com>

Curt Cranfield wrote:
> 
> This a pretty newbie question but it has bothered me for sometime.  How
> do I a pattern match without using $_ as the string being search.  I am
> tired of always have to set my searched string to $_ before I can do a
> pattern match on it.  I have looked through the perl book and can't find
> anything.
> 
> ie.
> $_ = "foo is for you";
> if (/foo/) {
>         # This works
> }
Of course.  :-)

> 
> But what I want to do is something like this - where I say what string I
> want to search on:
> $dog = "big brown";
> if (/big/$dog)  {
> }
How about:
#!/usr/local/bin/perl -w
$dog = "big narly brown";
if ($dog =~ /big/) {
	$dog =~ s/big/tiny/;
}
print $dog;
__END__

outputs:
tiny narly brown

That what you were after?  Note that is an equal sign (=) followed by a
tilde (~) character.  That tells Perl to look through the variable.  The
/big/ is equivalent to m// (but the m is not required, as long as you
use the / character as a delimiter), and tells perl to look for what is
inside the //'s in the variable specified.  $dog could be any variable
(including $_).

You should look up the:
s// operator
m// operator
=~  operator

and any others above that you don't understand.

"Learning Perl" by Randal Schwartz, and "Programming Perl" by Schwartz,
Larry Wall, and Tom Christiansen are good reference books.  Both of them
by O'Reilly and assosciates (http://www.ora.com).

HTH.

Dave

-- 
"Security through obscurity is no security at all."
		-comp.lang.perl.misc newsgroup posting

------------------------------------------------------------------------
* Dave Barnett               U.S.: barnett@houston.Geco-Prakla.slb.com *
* DAPD Software Support Eng  U.K.: barnett@gatwick.Geco-Prakla.slb.com *
* Schlumberger Geco-Prakla   (281) 596-1434 (Office Number)            *
* 1325 S. Dairy Ashford      (281) 596-1807 (Fax)                      *
* Houston, TX 77077                                                    *
------------------------------------------------------------------------


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

Date: Wed, 04 Feb 1998 12:40:19 GMT
From: bart.mediamind@tornado.be (Bart Lateur)
Subject: Re: Quickie: regexp for valid e-mail addresses
Message-Id: <34de518e.3357235@news.tornado.be>

cberry@cinenet.net (Craig Berry) wrote:

>Dan Sanderson (dsanders@u.washington.edu) wrote:
>: What's a good regexp that will only match valid e-mail addresses

>Short answer:
>
>  Don't bother.  There isn't a good one.  Give up.
>
>Longer answer:
>
>  Buy Freidl's _Mastering Regular Expressions_.  Read his brilliant
>  discussion on this very topic.  Marvel at his 4,000+ character
>  valid-email-matching regex which still doesn't handle every possible
>  case.  Give up.

My question: how do mailer programs process them?

My thoughts: If a mailer program can process them correctly, it must be
possible to write a Perl script that does the same.

My afterthought: *IF*

	Bart.


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

Date: 4 Feb 1998 09:23:40 -0500
From: clay@panix.com (Clay Irving)
Subject: Re: Quickie: regexp for valid e-mail addresses
Message-Id: <6b9tlc$pcc@panix.com>

In <34de518e.3357235@news.tornado.be> bart.mediamind@tornado.be (Bart Lateur) writes:

>cberry@cinenet.net (Craig Berry) wrote:

>>Dan Sanderson (dsanders@u.washington.edu) wrote:
>>: What's a good regexp that will only match valid e-mail addresses

>>Short answer:
>>
>>  Don't bother.  There isn't a good one.  Give up.
>>
>>Longer answer:
>>
>>  Buy Freidl's _Mastering Regular Expressions_.  Read his brilliant
>>  discussion on this very topic.  Marvel at his 4,000+ character
>>  valid-email-matching regex which still doesn't handle every possible
>>  case.  Give up.

>My question: how do mailer programs process them?

They attempted to deliver the message to the address specified.

>My thoughts: If a mailer program can process them correctly, it must be
>possible to write a Perl script that does the same.

Sure... Write a Perl program to send a message to the address specified.
But.... What have you accomplished? You still don't know if the address is
valid. For example, is president@whitehouse.gov a valid address? Or how
about dev-null@panix.com? :)

-- 
Clay Irving <clay@panix.com>                  I think, therefore I am. I think? 
http://www.panix.com/~clay/


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

Date: Thu, 5 Feb 1998 15:18:15 +0100
From: Martin Raknerud <marthy@feskar.net>
Subject: replacing things i perl
Message-Id: <Pine.LNX.3.95.980205151047.12950A-100000@torsk.feskar.net>



Hi,

Im trying to make a small perl script that will read true a textfile,
printing the "normal" text to the screen our an output until it comes to
some sort of keyword, in wich it will replace the keyword or the
keysentence with something else and continue on the next line.

I have been experimenting with this

      if (open(IN, $n)) {
               while ($line = <IN>) {
                       $data .= $line;
                        if ($data =~ /byline:\s*(.*)\s*/i) {
                            $byline = $1;
                               last;
                        }
                }

                close(IN);

As you see, this will search true $n until it finds the text "byline:",
then it inputs the text following the statement into $byline.

First of all this only allows me to find one keyword at a time. If I have
more than one "byline"-statements in the text i want to change it just
ignores all but the first.

Second thing is that it doesnt print anything to the screen _but_ the
things i especially tell it to, like print "bla bla bla :$byline\n".

Suggestions?

martin



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

Date: 4 Feb 1998 09:15:53 -0500
From: clay@panix.com (Clay Irving)
Subject: Re: searching by file creation/modification date?
Message-Id: <6b9t6p$ola@panix.com>

In <34D800E8.7D03@links.magenta.com> Jess Askey <jess@links.magenta.com> writes:

>  Im completely at a loss to find a way within perl to look at file
>creation dates and sort them out into an HTML file. Im trying to create 
>a perl program that will automatically create a "Whats New" section on a
>web page, based on date stamps of all files within a tree. Im a novice
>at this but have spent hours looking through books and searching
>dejanews for anything relating to this process but I can't seem to find
>anything.

You can find the modification date, but not the creation date. 

-- 
Clay Irving <clay@panix.com>                  I think, therefore I am. I think? 
http://www.panix.com/~clay/


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

Date: Wed, 04 Feb 1998 12:40:16 GMT
From: bart.mediamind@tornado.be (Bart Lateur)
Subject: Re: solution for multiline comments???
Message-Id: <34da4edb.2665894@news.tornado.be>

s93bni@csd.uu.se (Bjvrn Nilsson) wrote:

>It seems like I took the "lazyness" part in "Programming Perl" a bit too
>seriously. Quite a few of the answers suggested using POD, so I took a look
>at the documentation of that. Indeed it's the solution that I look for. But
>really, wouldn't a solution like:
>/******
>* This is a comment about what is to follow.
>* This class is a nonsense class that really does nothing but
>* serving as an example.
>*******/
>i.e. a notation like the /* C, C++, Java etc */ commenting be a nice
>feature in Perl as well?

But it DOES work! (GRIN)

#######
#  This is a comment about what is to follow.
# This class is a nonsense class that really does nothing but
# serving as an example.
#######

I just can't see why you dislike inserting the '#', and then you do
insert '*'

	Bart.


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

Date: Wed, 04 Feb 1998 07:42:41 -0500
From: pudge@pobox.com (Chris Nandor)
Subject: Re: Survival Of perl
Message-Id: <pudge-0402980742420001@ppp-29.ts-1.kin.idt.net>

In article <34D7E93C.6F47@earthling.net>, lovegod@earthling.net wrote:

# OK, Sorry. Nandor was the one dispensing personal insults.
# I see my mistake, can we stop the flame war?

It is insulting to speak what is true?  Hm.  Note to self: "lie to people
to make them feel better."

-- 
Chris Nandor          mailto:pudge@pobox.com         http://pudge.net/
%PGPKey=('B76E72AD',[1024,'0824 090B CE73 CA10  1FF7 7F13 8180 B6B6'])
#==       New Book: MacPerl:  Programming for the Rest of Us       ==#
#==    Publishing Date: Early 1998. http://www.ptf.com/macperl/    ==#


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

Date: Wed, 04 Feb 1998 08:23:48 -0600
From: Monte Ohrt <monte@ispi.net>
Subject: Re: unix command
Message-Id: <34D879F4.F0D0EED9@ispi.net>

Kelby Valenti wrote:
> 
> Is there any way to run a unix command from perl?  My problem is that i'm
> trying to set up an dbmm password protection.  The only way that I know how
> to set the passwords is by manually typing everything in at the shell.  This
> can be very time consuming.  I'm going to be get the variables from the web
> so i will have the username and password available.
> 
>     If anyone has any suggestion please let me know,
>         Thanks,
>             Kelby

you execute unix shell commands with back tics:

print "the current date is `date`\n";

There are perl scripts that dump data into dbm files as well.
Something like this might be on www.apache.org, or at
least point you to the place.

Monte

-- 
Monte Ohrt            monte@ispi.net         | 99 bugs in the code, 99 bugs, 
Chief Technologist    ispi of Lincoln        | fix one bug, compile it again,
                      voice: +1.402.441.3295 | 101 bugs in the code...
http://www.ispi.net   fax:   +1.402.483.5418 |


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

Date: 4 Feb 1998 09:13:57 -0500
From: clay@panix.com (Clay Irving)
Subject: Re: Using Bcc header in perl mail script
Message-Id: <6b9t35$oh0@panix.com>

In <6b8t6p$og1@panix.com> das@panix.com (David Staschover) writes:

>Is there a way to have a "Bcc" field in a perl mail script? (using
>sendmail as the program).. I've used:

Er? Why don't you stick the bcc in the header:

>From: name@domain
>To: name@domain
 Bcc: other_name@domain
>Subject: subject

-- 
Clay Irving <clay@panix.com>                  I think, therefore I am. I think? 
http://www.panix.com/~clay/


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

Date: Wed, 04 Feb 1998 08:29:01 -0600
From: Monte Ohrt <monte@ispi.net>
Subject: Re: Variable passing with an URL
Message-Id: <34D87B2D.A6F606F2@ispi.net>

Gil Brown wrote:
> 
> Hi everybody;
> 
> I am trying to pass a variable to a cgi script through an URL:
> 
> print "<LI li
> type=disc><ahref=\"http://chevy.cae.ca",$CGI,"/allo.cgi\"?allo>USER</a>\n";
> 

First of all, get rid of the quote after allo.cgi.
Then you need to pass a variable value for allo.

<a href = "http://www.domain.com/cgi-bin/allo.cgi?var1=value1&var2=value2>Click
me</a>

in your case:

print "<a href=\"http://chevy.cae.ca",$CGI,"/allo.cgi?allo=$allo\">USER<?a>\n";

This is assuming that $allo is URL-escaped.

> My problem is I can't get it back in the cgi. Does anybody know what's
> missing.
> 
> Thanks
> 
> --
> Gil Brown
> System Administrator Dept.80
> CAE Electronics Ltd
> gbrown@cae.ca
> 
>                         "It's not denial."
> "I'm just very selective about the reality I accept." --Calvin

-- 
Monte Ohrt            monte@ispi.net         | 99 bugs in the code, 99 bugs, 
Chief Technologist    ispi of Lincoln        | fix one bug, compile it again,
                      voice: +1.402.441.3295 | 101 bugs in the code...
http://www.ispi.net   fax:   +1.402.483.5418 |


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

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

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