[11791] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5391 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Apr 15 13:07:23 1999

Date: Thu, 15 Apr 99 10:00:20 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Thu, 15 Apr 1999     Volume: 8 Number: 5391

Today's topics:
        [help] - please <x30407@wrek1.mar.lmco.com>
    Re: Can I write a #!-style interpreter with Perl ? (Randal L. Schwartz)
    Re: Can I write a #!-style interpreter with Perl ? (Randal L. Schwartz)
    Re: Can I write a #!-style interpreter with Perl ? <tchrist@mox.perl.com>
    Re: compare form input with log file (Larry Rosler)
        Dos version of Perl2exe <mwest@ovid.com>
    Re: Examples of slow regexes? (Kai Henningsen)
    Re: FAQ 1.1: What is Perl? (John Stanley)
        globbing doesn't work - (kind of) SOLVED (Uli Zappe)
    Re: how can i send perl -c output to a file instead of  <mis@sparc.spb.su>
        How to split a large data file into smaller files ? <cooperagent@my-dejanews.com>
        HTTP Cookies and Netscape Browser padhu@yahoo.com
    Re: HTTP Cookies and Netscape Browser <vvb@ibm.net>
    Re: Newbie Question: String Manipulation <cassell@mail.cor.epa.gov>
        Out of Order <bkennedy@one.net.au>
    Re: Perl Regex Q? (Larry Rosler)
    Re: Perl Regex Q? <uri@home.sysarch.com>
    Re: Perl Regex Q? <uri@home.sysarch.com>
    Re: Perl Regex Q? (Tad McClellan)
    Re: Perl Regex Q? (Larry Rosler)
    Re: position in s///g? (Ilya Zakharevich)
    Re: Question about variables, and Perl in general <aidan@salvador.blackstar.co.uk>
        Quick Questions WIN32 Extensions. mclaughlinj@leaders.ccl.org
        Recursion not working properly <mrizzo@ismd.ups.com>
    Re: SimVirus Program beta99 (Matthew Bafford)
    Re: SQL using the ODBC module chatswood@my-dejanews.com
        TZ not used in winnt Date/Time routines <gury@interaccess.com>
        TZ settings in WinNT ignored <gury@interaccess.com>
    Re: Using CGI with NT <cassell@mail.cor.epa.gov>
    Re: want regex to set a value in place of a procedure (Larry Rosler)
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: Thu, 15 Apr 1999 12:39:30 -0400
From: Adam Dittmer <x30407@wrek1.mar.lmco.com>
Subject: [help] - please
Message-Id: <37161641.F0B50F0D@wrek1.mar.lmco.com>

i am getting a error message when i try to use my guestbook type script
and i am not sure wht it means if anyone could please tells me what my
pro gram is doing wrong i would aprcieate it

Error: HTTPd: malformed header from script
/usr/local/etc/httpd/htdocs/cgi-bin/tplogbook.cgi



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

Date: 15 Apr 1999 09:10:07 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Can I write a #!-style interpreter with Perl ?
Message-Id: <m1k8vdvp9c.fsf@halfdome.holdit.com>

>>>>> "Jorma" == Jorma Laaksonen <jorma.laaksonen@hut.fi> writes:

Jorma> But, what I now would like to be able to do is to write the input
Jorma> to the script as a script like:

Jorma> *** #! /my-perl-script-dir/parser
Jorma> *** 
Jorma> *** here are the input lines...
Jorma> *** ...

Jorma> I have "chmod +x"'d this file and tried to run it.  It seems to me that
Jorma> the lines end up to be processed by /bin/csh, not by my Perl script.

Jorma> The parser script /my-script-dir/parser simply begins like:

Jorma> *** #! /usr/bin/perl 

Jorma> Is this a FAQ? Any advise? Is there a general solution to this
Jorma> problem?  I'm using Linux 2.0.36 on an i686.

>From what I recall in my kernel hacking days, the "#!" mechanism is
*not* recursive.  The "interpreter" after the #! must be a real
executable, not another "#!" file.

Sorry, you're outta luck.  However, you could do this:

	#!/usr/bin/perl

	use MyInterpreter;
	__END__
	Rest of your code here

and have MyInterpreter.pm get its stuff from <DATA>.

print "Just another Perl hacker,"

-- 
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@teleport.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me


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

Date: 15 Apr 1999 09:10:28 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Can I write a #!-style interpreter with Perl ?
Message-Id: <m1g161vp8r.fsf@halfdome.holdit.com>

>>>>> "Jonathan" == Jonathan Feinberg <jdf@pobox.com> writes:

Jonathan> Jorma Laaksonen <jorma.laaksonen@hut.fi> writes:
>> *** #! /my-perl-script-dir/parser

Jonathan> You'll probably get better help on a newsgroup that deals with
Jonathan> whatever shell you're using.  HTH.

It's not a shell issue.  It's a Kernel issue.  See my other post.

-- 
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@teleport.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me


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

Date: 15 Apr 1999 10:58:28 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Can I write a #!-style interpreter with Perl ?
Message-Id: <37161ab4@cs.colorado.edu>

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

In comp.lang.perl.misc, 
    Jorma.Laaksonen@hut.fi writes:
:I have "chmod +x"'d this file and tried to run it.  It seems to me that
:the lines end up to be processed by /bin/csh, not by my Perl script.

Sure, it's easy.  Just run it through env.

Here's /tmp/testit (indented):
    #!/usr/bin/env /tmp/catenv
    Hey, there Mr %%USER%%, are you 
    really at %%HOME%% right now?

Here's /tmp/catenv (indented):
    #!/usr/bin/perl 
    # catenv program
    while (<>) {
	next if /^\s*#/;
	s/%%(\w+)%%/$ENV{$1}/g;
	print;
    }

And here's the run of testit (indented):
    Hey, there Mr tchrist, are you 
    really at /home/tchrist right now?

--tom
-- 
"OSI: Same day service in a nanosecond world" Van Jacobsen.
T-shirt he produced for an Interop, a few years ago.


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

Date: Thu, 15 Apr 1999 08:18:46 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: compare form input with log file
Message-Id: <MPG.117fa330ae00ee979898be@nntp.hpl.hp.com>

In article <3715C6FF.C87E5471@hotmail.com> on Thu, 15 Apr 1999 12:01:19 
+0100, Richard H <rhardicr@hotmail.com> says...
> > while ($line = <PEOPLE>) {
> >         @data = split(/\:/, $line);
> >         #stopped here because it's not getting any better :-)
> 
> Not sure what the question is exactly?? but,
> 
> shift @data;
> $passes{"$data[0]"} = "$data[1]";

  $passes{$data[1]} = $data[2];

The shift is unnecessary and the double-quotes are misleading.

One could write the split more efficiently as:

          my @data = split /:/, $line, 4;

because the trailing fields aren't used.

-- 
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Thu, 15 Apr 1999 15:57:47 GMT
From: Michael West <mwest@ovid.com>
Subject: Dos version of Perl2exe
Message-Id: <7f529l$mm5$1@nnrp1.dejanews.com>

I know this has probably been asked many times before, but a DejaNews search
didn't help much.

Quite simply, I want to create a Dos executable out of a Perl script that I
can send to customers who are literally running Dos (not Win32).  I don't
care if the code is visible or not, I only care that the customer does need
to have Perl installed on their PC.  In essence, I would like a Dos version
of Perl2exe, which does not appear to exist.  Are there any alternatives at
this point?

Thanks,
Michael

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


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

Date: 15 Apr 1999 09:34:00 +0200
From: kaih=7EuaUq7Xw-B@khms.westfalen.de (Kai Henningsen)
Subject: Re: Examples of slow regexes?
Message-Id: <7EuaUq7Xw-B@khms.westfalen.de>

bart.lateur@skynet.be (Bart Lateur)  wrote on 14.04.99 in <371763d6.1690756@news.skynet.be>:

> Kai Henningsen wrote:
>
> >> Slightly more complicated examples, such as /[ab]*[ac]*[ab]*[ac]*/ come
> >> to mind. /[ab]*[ac]*/ must be equivalent to /[ab]*(?:c[ac]*)?/, which
> >> *looks* like it should be more efficient, but it isn't. In fact, it's a
> >> bit slower.
> >
> >That doesn't seem right - your second one fails to accept "cb", does it
> >not?
>
> I can't see how /[ab]*[ac]*/ could ever match "cb", either. :-)
>
> You must have confused it with the first regex, the one the four
> subpatterns. This one is nothing but twice the second regex.

Ah. Somehow I only saw two, not three expressions there. Obviously, I was  
a little too tired.

Kai
-- 
http://www.westfalen.de/private/khms/
"... by God I *KNOW* what this network is for, and you can't have it."
  - Russ Allbery (rra@stanford.edu)


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

Date: 15 Apr 1999 16:56:09 GMT
From: stanley@skyking.OCE.ORST.EDU (John Stanley)
Subject: Re: FAQ 1.1: What is Perl?
Message-Id: <7f55n9$md6$1@news.NERO.NET>

In article <3715e427.6381689@news.erols.com>,
David Turley <dturley@pobox.com> wrote:
>The FAQs are already avaialble in numerous places "whole." 

Yes, and when they were posted to this group, my server was one of
them. 

>I like these postings. I've read the FAQs but like the opportunity to
>review them quickly with no effort on my part. 

I give up. It is obviously easier to manage 180 pieces than 9. It's too
bad that there doesn't seem to be an index so you can tell if you are
missing any, though. 



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

Date: 15 Apr 1999 15:14:08 GMT
From: uli@tallowcross.uni-frankfurt.de (Uli Zappe)
Subject: globbing doesn't work - (kind of) SOLVED
Message-Id: <7f4vo0$4kc$1@tallowcross.tallowcross.uni-frankfurt.de>

I wrote:
> I have written a C program which (via execv) executes a Perl script. The 
> Perl script uses globbing:
> 
> 	@files = </foo/bar/*>;
> 
> The Perl script works fine if started from the commandline (sh, csh, 
> whatever...). However, when it's executed by my C program, @files is always 
> empty.

It turned out the problem is that my program runs suid root.

A
   setgid(getegid());
before execv solved the problem. (I did a setuid(seteuid()), but that wasn't 
enough for glob...)

Heaven knows why glob depends on this (sh's ls doesn't...).

                Bye
                        Uli
-- 
_____________________________________________________________________

Uli Zappe               E-Mail: uli@tallowcross.uni-frankfurt.de
                                (NeXTMail,Mime,ASCII) PGP on request
Lorscher Strasse 5      WWW:    -
D-60489 Frankfurt       Fon:    +49 (69) 9784 0007
Germany                 Fax:    +49 (69) 9784 0042
_____________________________________________________________________


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

Date: Thu, 15 Apr 1999 19:27:31 +0400
From: Manida Ivan <mis@sparc.spb.su>
Subject: Re: how can i send perl -c output to a file instead of STDERR
Message-Id: <Pine.GSO.4.02.9904151925340.10773-100000@minerva.sparc.spb.su>

ROTFL.
Abigail, that's a great one :)
Did you ever thought about publishing a Perl tips book? I'd buy it :) 

//-- PiRaMidA aka Ivan S. Manida		    <piramida@agsm.net>
aGSM webmaster : http://agsm.gagames.com : multiplayer games on your PC


On 12 Apr 1999, Abigail wrote:

> William Smith (smith.will@epa.gov) wrote on MML September MCMXCIII in
> <URL:news:7etj4d$hue1@valley.rtpnc.epa.gov>:
> && When perl finds syntax errors they are sent to STDERR. I want to send them
> && to a file.
> 
> STDERR *is* a file. Everything is a file. Your are a file too.



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

Date: Thu, 15 Apr 1999 16:46:39 +0100
From: "David Phillips" <cooperagent@my-dejanews.com>
Subject: How to split a large data file into smaller files ?
Message-Id: <7f51l0$o1o$1@newsreader1.core.theplanet.net>

folks

I'm sure this can be done quite simply in perl ????

I have a large (50MB) flat text file arranged in alpha order, starting at
AA... and ending in ZZ.... and I need to split that file into smaller files,
each containing data for that pair of leading letters only. Fields within
the records are tab delimited.

For example all the records starting with AA end up in a file named AA.TXT,
all the AB records go into AB.TXT and so on.

hmmm. some pointers as to how this might be done in perl would be very
welcome here.

thanks
dave p





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

Date: Thu, 15 Apr 1999 15:35:48 GMT
From: padhu@yahoo.com
Subject: HTTP Cookies and Netscape Browser
Message-Id: <7f510j$lhi$1@nnrp1.dejanews.com>

Hi,

I wrote a script to set the HTTP cookies. It seems to work fine in IE. When i
go to the Windows/Cookies folder, i see the cookie being set correctly and
properly. Even when i close and reopen the IE browser, the cookies are still
present. When I try to set the cookie using Netscape (Netscape 4.5), due to
some reason the cookies expire as soon as i close the browser. When i open
the cookie.txt file, i see that the cookies are not set even when i don't
close the browser.

Following is the code.
The code is saved in a file called test1.pl

Any help would be appreciated.
Thanks,
Prabha.


#!/usr/bin/perl
use CGI qw(:standard);

print "Content-Type: text/html\n";

if(param())
{
	$username = param("username");
	$email = param("email");
	$result = param("result");
}

$path = '/';
$exp_date = "Thursday,01-Jan-2099 23:00:00 GMT";
$domainname = "secure.tek-tools.com";

if(! defined $ENV{'HTTP_COOKIE'})
{
	if ($result eq "valueok")
	{
	   print "Set-Cookie: user=$username; expires=$exp_date; path=$path;
domain=$domain\n";
	   print "Set-Cookie: email=$email; expires=$exp_date; path=$path;
domain=$domain\n\n";

	   print "<HTML>\n";
	   print "<BODY>\n";

	   print "<BR>Cookie is set<BR>\n";
	}
	else
	{
	  print "\n\n";
	  print "<HTML><BODY>\n";
	  print "<FORM METHOD=POST ACTION=\"test1.pl\">\n";
	  print "Enter your name:\n";
	  print "<INPUT TYPE=TEXT NAME=\"username\">\n";
	  print "<BR><BR>Enter email address:\n";
	  print "<INPUT NAME=\"email\">\n";
	  print "<INPUT TYPE=SUBMIT>\n";
	  print "<INPUT TYPE=HIDDEN NAME=\"result\" VALUE=\"valueok\">\n";
	  print "</FORM>\n";
	}
}

print "</BODY></HTML>\n";


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


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

Date: Thu, 15 Apr 1999 18:05:12 +0200
From: "Vincent Vanbiervliet" <vvb@ibm.net>
Subject: Re: HTTP Cookies and Netscape Browser
Message-Id: <37160da1@news.uk.ibm.net>

Everything looks correct to me.
It is normal though that you don't see the cookie when you don't close the
browser, as it is only written to the file when you close Netscape.
The only thing I can think of, is that you have set your Netscape settings
to 'not accept cookies'...
Are you sure you pass the tests, and the code actually tries to set the
cookie?

But since it's working on MSIE, I don't think this is a real Perl question,
but rather a netcape one...

Vincent Vanbiervliet
http://learn.ibm.be

<padhu@yahoo.com> wrote in message news:7f510j$lhi$1@nnrp1.dejanews.com...
> Hi,
>
> I wrote a script to set the HTTP cookies. It seems to work fine in IE.
When i
> go to the Windows/Cookies folder, i see the cookie being set correctly and
> properly. Even when i close and reopen the IE browser, the cookies are
still
> present. When I try to set the cookie using Netscape (Netscape 4.5), due
to
> some reason the cookies expire as soon as i close the browser. When i open
> the cookie.txt file, i see that the cookies are not set even when i don't
> close the browser.
>
> Following is the code.
> The code is saved in a file called test1.pl
>
> Any help would be appreciated.
> Thanks,
> Prabha.
>
>
> #!/usr/bin/perl
> use CGI qw(:standard);
>
> print "Content-Type: text/html\n";
>
> if(param())
> {
> $username = param("username");
> $email = param("email");
> $result = param("result");
> }
>
> $path = '/';
> $exp_date = "Thursday,01-Jan-2099 23:00:00 GMT";
> $domainname = "secure.tek-tools.com";
>
> if(! defined $ENV{'HTTP_COOKIE'})
> {
> if ($result eq "valueok")
> {
>    print "Set-Cookie: user=$username; expires=$exp_date; path=$path;
> domain=$domain\n";
>    print "Set-Cookie: email=$email; expires=$exp_date; path=$path;
> domain=$domain\n\n";
>
>    print "<HTML>\n";
>    print "<BODY>\n";
>
>    print "<BR>Cookie is set<BR>\n";
> }
> else
> {
>   print "\n\n";
>   print "<HTML><BODY>\n";
>   print "<FORM METHOD=POST ACTION=\"test1.pl\">\n";
>   print "Enter your name:\n";
>   print "<INPUT TYPE=TEXT NAME=\"username\">\n";
>   print "<BR><BR>Enter email address:\n";
>   print "<INPUT NAME=\"email\">\n";
>   print "<INPUT TYPE=SUBMIT>\n";
>   print "<INPUT TYPE=HIDDEN NAME=\"result\" VALUE=\"valueok\">\n";
>   print "</FORM>\n";
> }
> }
>
> print "</BODY></HTML>\n";
>
>
> -----------== Posted via Deja News, The Discussion Network ==----------
> http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own




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

Date: Thu, 15 Apr 1999 09:45:37 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Newbie Question: String Manipulation
Message-Id: <371617B1.DC82BDE9@mail.cor.epa.gov>

Eric Bohlman wrote:
> 
> David Cassell <cassell@mail.cor.epa.gov> wrote:
> : Ummm, I think you made a braino there, Tim.  Your regex is going to
> : match 'xxxxx' instead.  Try it.  Perhaps
> 
> : $cgi1 =~ s#.*/(.*?)\?.*#$1#;
> 
> : is more what he had in mind.  {Match everything to last `/', non-greedy
> : grab up to next `?' in case there are more `?' following, and eat the
> : rest.}
> 
> : However, IMHO, for general parsing of html, you're better off going to
> : HTML::Parser and letting the module do the dirty work.
> 
> True, but what the original poster has was an HTTP request line, not a

Agreed.  That's why I gave an answer.

> piece of HTML.  It is true, though, that URI::URL has methods for
> splitting up and putting together URLs, and those should be used, if
> applicable, instead of trying to wing it with regexen.

Right.  I should have mentioned URI::URL too, but I forgot.  My point
[which obviously was not clear] was that it appeared to me that the 
poster was going to be moving into parsing/regexing of html pages
next, and that there was a better solution than trying to do the 
analogous techniques on html.

I'll try to be clearer in future.  Or at least drink plenty of coke
before posting.  :-)

David
-- 
David Cassell, OAO                               
cassell@mail.cor.epa.gov
Senior Computing Specialist                          phone: (541)
754-4468
mathematical statistician                              fax: (541)
754-4716


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

Date: Fri, 16 Apr 1999 01:15:03 +1000
From: "Bill and Rowena Kennedy" <bkennedy@one.net.au>
Subject: Out of Order
Message-Id: <3716036f.0@pink.one.net.au>

We have this script that contains the following code.

# rename the file to the calculated name
writemsg((("Attempting to rename ".($srcdir.$srcfile)).(" to
".($srcdir.$newfile))));
rename(($srcdir.$srcfile),($srcdir.$newfile)) or die "Can't rename $srcfile
to $newfile\n";


sub writemsg
{
my $messg = shift(@_);
my $sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst;

 ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)=localtime(time);
 print  $mday,"/",($mon+=1),"/",$year," ",$hour,":",$min,":",$sec,"
",$messg,"\n";
}

If we call it at a DOS prompt in NT like this:
perl Z:\pbapps\scripts\swf52xout.pl c:\projects\swift\ dsmsg.csv  > test.log
2>&1

then if there is an error on the "rename" line the error message "Can't
rename ..." prints out before the "writemsg" line.

Of course I'm sure we can come up with a work around but does anyone know
why this happens.





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

Date: Thu, 15 Apr 1999 08:33:11 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Perl Regex Q?
Message-Id: <MPG.117fa688bff2b75e9898bf@nntp.hpl.hp.com>

In article <ohm4f7.7p7.ln@magna.metronet.com> on Thu, 15 Apr 1999 
08:37:12 -0400, Tad McClellan <tadmc@metronet.com> says...
 ... 
> :   last if ($Line =~ m{\w:/});
> 
>    And if you want to allow more than a single word character
>    before the colon, then you need to say so  :-)
> 
>      last if ($Line =~ m{\w+:/});

Why?  I don't see any start anchor there, so the two regexes would match 
identically.

-- 
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: 15 Apr 1999 11:46:32 -0400
From: Uri Guttman <uri@home.sysarch.com>
Subject: Re: Perl Regex Q?
Message-Id: <x77lrdopif.fsf@home.sysarch.com>

>>>>> "TM" == Tad McClellan <tadmc@metronet.com> writes:

  TM> Ronald J Kimball (rjk@linguist.dartmouth.edu) wrote:
  TM> : <andrewg6969@my-dejanews.com> wrote:

  TM> : > catbert:/export/home  192800   13224  177648     7%    /mnt

  TM> :   last if ($Line =~ m{\w:/});


  TM>    And if you want to allow more than a single word character
  TM>    before the colon, then you need to say so  :-)

  TM>      last if ($Line =~ m{\w+:/});
  TM>                            ^

that's not needed. the previous regex will match any hostname word char
followed by a :.

yours works too but it won't work for a hostname of length 1.

in fact assuming a clean df with only nfs mounted lines with a :, then
just 

next if /:/ ;

will do fine. and if you are skipping nfs lines, you should do a next
because you could have hard mounted file systems after nfs systems in df.

uri


-- 
Uri Guttman  -----------------  SYStems ARCHitecture and Software Engineering
uri@sysarch.com  ---------------------------  Perl, Internet, UNIX Consulting
Have Perl, Will Travel  -----------------------------  http://www.sysarch.com
The Best Search Engine on the Net -------------  http://www.northernlight.com


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

Date: 15 Apr 1999 12:16:02 -0400
From: Uri Guttman <uri@home.sysarch.com>
Subject: Re: Perl Regex Q?
Message-Id: <x74smhoo59.fsf@home.sysarch.com>

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

  LR> In article <ohm4f7.7p7.ln@magna.metronet.com> on Thu, 15 Apr 1999 
  LR> 08:37:12 -0400, Tad McClellan <tadmc@metronet.com> says...
  LR> ... 
  >> :   last if ($Line =~ m{\w:/});
  >> 
  >> And if you want to allow more than a single word character
  >> before the colon, then you need to say so  :-)
  >> 
  >> last if ($Line =~ m{\w+:/});

  LR> Why?  I don't see any start anchor there, so the two regexes would match 
  LR> identically.

as my other post says, the + version will fail for hosts with name
length of 1.

uri

-- 
Uri Guttman  -----------------  SYStems ARCHitecture and Software Engineering
uri@sysarch.com  ---------------------------  Perl, Internet, UNIX Consulting
Have Perl, Will Travel  -----------------------------  http://www.sysarch.com
The Best Search Engine on the Net -------------  http://www.northernlight.com


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

Date: Thu, 15 Apr 1999 11:16:16 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Perl Regex Q?
Message-Id: <0sv4f7.u78.ln@magna.metronet.com>

Tad McClellan (tadmc@metronet.com) wrote:
: Ronald J Kimball (rjk@linguist.dartmouth.edu) wrote:
: : <andrewg6969@my-dejanews.com> wrote:

: : > catbert:/export/home  192800   13224  177648     7%    /mnt
: : > 
: : > What is wrong with this line that it doesn't pass over the line containing
: : > "catbert:" ?
: : > 
: : > last if ($Line !~ /\w:\//);         # ditch Local entries

: : If you want to break out of the loop on the catbert: line, you don't
: : want to negate the value of the match:

: :   last if ($Line =~ m{\w:/});


:    And if you want to allow more than a single word character
:    before the colon, then you need to say so  :-)

:      last if ($Line =~ m{\w+:/});
:                            ^
:                            ^


   Uhh. Nevermind.

   I somehow got it in my head that it was anchored to the
   beginning of the string.

   It isn't (but probably should be), so the plus is not needed.


--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Thu, 15 Apr 1999 09:48:21 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Perl Regex Q?
Message-Id: <MPG.117fb8305f44ad289898c0@nntp.hpl.hp.com>

In article <x74smhoo59.fsf@home.sysarch.com> on 15 Apr 1999 12:16:02 -
0400, Uri Guttman <uri@home.sysarch.com> says...
> >>>>> "LR" == Larry Rosler <lr@hpl.hp.com> writes:
>   LR> In article <ohm4f7.7p7.ln@magna.metronet.com> on Thu, 15 Apr 1999 
>   LR> 08:37:12 -0400, Tad McClellan <tadmc@metronet.com> says...
>   LR> ... 
>   >> :   last if ($Line =~ m{\w:/});
>   >> 
>   >> And if you want to allow more than a single word character
>   >> before the colon, then you need to say so  :-)
>   >> 
>   >> last if ($Line =~ m{\w+:/});
> 
>   LR> Why?  I don't see any start anchor there, so the two regexes
>   LR> would match identically.
> 
> as my other post says, the + version will fail for hosts with name
> length of 1.

Why is that?  'x:' matches either regex, doesn't it?

-- 
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: 15 Apr 1999 16:14:11 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: position in s///g?
Message-Id: <7f538j$a81$1@mathserv.mps.ohio-state.edu>

[A complimentary Cc of this posting was sent to Andrew Allen
<ada@fc.hp.com>],
who wrote in article <7f3aqk$eos$1@fcnews.fc.hp.com>:
> Is there a way to get the position in a substitution. pos() only
> works in m//g. I'm trying to do something like:
> 
> $a="0520001250025";
> $b="weasgnkweplhk";
> $a=~/0/substr($b,pos($a)-1,1)/ge;
> 
> which obviously doesn't work. 

Adding to other suggestions, note that

  $a=~/0(?{pos})/substr($b,$^R-1,1)/ge;

should work with bleeding-edge Perls.

Ilya


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

Date: 15 Apr 1999 14:57:29 GMT
From: Aidan Rogers <aidan@salvador.blackstar.co.uk>
Subject: Re: Question about variables, and Perl in general
Message-Id: <7f4uop$3hk$1@nclient3-gui.server.ntli.net>

> You seem to be confused about what a scalar is and about how Perl
> handles data typing.  I think you need to read two things: _Learning
> Perl_ (published by O'Reilly), and the perldata man page (which comes
> with perl).

I do know what a scalar is. I read Learning Perl about two years ago, 
and I've read the Camel book several times. I program in Perl for a
living. It's maybe just the way I worded the post that makes me seem inept.

Anyhow, the scalar tries to treat the number as a number, and ends up giving
me incorrect data. If it treated it as a string, however, I know I wouldn't
get that problem. Hence, the post, because I'm unsure how to get Perl to
treat the value as a string in this instance.

You may be right, and I could be barking up the wrong tree entirely.

As for the Perl suggestions, they are from our programming team, not just from
me.

Aidan


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

Date: Thu, 15 Apr 1999 15:55:10 GMT
From: mclaughlinj@leaders.ccl.org
Subject: Quick Questions WIN32 Extensions.
Message-Id: <7f524o$mjn$1@nnrp1.dejanews.com>

I have some Perl questions that I can't solve or find info on.
Thanks for any help..

1) if i do Win32::AdminMisc::GetDriveSpace($uncpath) and the file is large,
it returns a negative number ?  My file is over 3 gig. My code works for all
other files.

2)if i do $gso_ports = (Win32::RasAdmin::GetPorts($RASServer,,)) over the
WAN (56k FR) i get Time(in msec) for CALLNAMEDPIPE to complete: 260 - and the
ports come back in error.

3)<non perl but i use o/p) if i use dumpel from the NT resource kit utilities
it works fine for system logs but I get Dr. Watson errors for application logs
I want to parse the logs from perl
               thanks,

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


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

Date: Thu, 15 Apr 1999 10:38:24 -0400
From: "Mike Rizzo" <mrizzo@ismd.ups.com>
Subject: Recursion not working properly
Message-Id: <7f4t9d$sns7@innsrv.ismd.ups.com>

I have a perl script in wihch a recursive call that I am attempting is not
executing properly.  The sub is called coparedirs(), when I call comparedirs
from inside
comparedirs, it does start exectuing compare dirs, but it seems as if the
original
call to comparedirs never completes running. Is there something I am missing
about recursion in Perl that I should know about before attempting this
execution.

thanks





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

Date: Thu, 15 Apr 1999 15:35:47 GMT
From: dragons@dragons.duesouth.net (Matthew Bafford)
Subject: Re: SimVirus Program beta99
Message-Id: <slrn7hc0tk.24m.dragons@dragons.duesouth.net>

Newsgroups: comp.lang.perl.misc
                      ^^^^
                      
On Thu, 15 Apr 1999 21:30:45 +0800, Patrick <dbs2pat@netvigator.com>
lucked upon a computer, and thus typed in the following:
[snip]
) begin 666 Virus1.pas
                   ^^^

I must say, that's the first time I've seen someone use _that_ extension
on a Perl program...

--Matthew                   


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

Date: Thu, 15 Apr 1999 15:15:23 GMT
From: chatswood@my-dejanews.com
Subject: Re: SQL using the ODBC module
Message-Id: <7f4vq3$kdr$1@nnrp1.dejanews.com>

Gus

> I suggest trying a fairly simple query first.  This should work:
>

tried it but it wouldn't work -
D:\apache\cgi-bin>d:\perl\bin\perl any.cgi
Can't locate object method "new" via package "CGI" at any.cgi line 7.

but see below anyway...

> >  spg@quokka.com (Gus) wrote:
> >> First guess is you have a problem with quotes, but without seeing
> >> sample code, it's just a wild guess.

Okay you were right. Turned out to be quoting.I was using the following line
for the query... $db->sql("INSERT INTO Transactions ( PatName, PatNo,
DateField, InfoPageNo, DispByRef, Notes ) SELECT '$patname', '$patno',
'$fulldate', '$pageno', '$initials', '$notes';");

This now works on my Win95 system at home. Unfortunately it doesn't work on
the WinNT4 system I'm using in uni. I think t's a CGI problem - even for a
simple

SELECT * FROM tablename

I can get a result from the command line, but not through CGI. It seems to be
caused by the sql statement as the other cgi bits work okay.

I'm not too familiar with WinNT so I'm not sure if I can get it to work. At
the minute the machine doesn't have Access, so I downloaded the Data Access
Pack from Microsoft and installed the drivers. They all work for my own
command line stuff, the Win32ODBC Test.pl  script etc.

So it seems to be a problem between Apache 1.3.4 and the ODBC I guess!

Thanks for your help!

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


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

Date: Thu, 15 Apr 1999 11:19:03 -0500
From: "john gury" <gury@interaccess.com>
Subject: TZ not used in winnt Date/Time routines
Message-Id: <924193069.979.85@news.remarQ.com>

Does anyone know how to get the TZ var to work under winnt perl?
I'm showing that regardless of TZ settings the timezone used is the
unadjusted windows system timezone.  Is this another "use a real
OS to get it to work" issue?




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

Date: Thu, 15 Apr 1999 11:15:03 -0500
From: "john gury" <gury@interaccess.com>
Subject: TZ settings in WinNT ignored
Message-Id: <924192827.194.97@news.remarQ.com>

Does anyone know how to get the TZ var to work properly under Windows NT?
I'm seeing all Date/Time routines using the Windows system setting for
timezone and
ignoring any and all places to set TZ.   Further, the windows timezone
setting is
used without applying the daylight saving adjustment.   Is this another
"move to a real
OS to get it to work" issue?




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

Date: Thu, 15 Apr 1999 09:56:41 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Using CGI with NT
Message-Id: <37161A49.F1AAA1D3@mail.cor.epa.gov>

Nick lammers wrote:
> 
> I'm familar with Front Page and would like to use some CGI scripts on my web
> site. Most of the instructions I've found refer to UNIX servers. Does anyone
> know of a reference for placing CGI scripts on NT servers with Front Page
> extensions.

Excuse me, but why are you posting this in a newsgroup devoted to Perl?
A newsgroup that is not even focused on web questions?  You really
should 
be asking this in one of the dozens of relevant newsgroups.  Even if you
have some Perl code.  This is a question for one of the groups for web
servers, or win NT, or MS Office products, or CGI authoring, or...

Well, the list is pretty extensive.  And doesn't include this newsgroup.

Good luck with your search,
David
-- 
David Cassell, OAO                               
cassell@mail.cor.epa.gov
Senior Computing Specialist                          phone: (541)
754-4468
mathematical statistician                              fax: (541)
754-4716


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

Date: Thu, 15 Apr 1999 08:08:05 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: want regex to set a value in place of a procedure
Message-Id: <MPG.117fa0ade311d5029898bd@nntp.hpl.hp.com>

[Posted and a courtesy copy sent.]

In article <3715af87.169375173@news> on Thu, 15 Apr 1999 09:28:17 GMT, 
Jim Britain <jbritain@home.com> says...
> I got tired of trying to figure out the regular expression to
> accomplish what this does... but, this works to do what I want.
> 
> I want to clean up hand keyed input that may contain garbage
> characters.  The only valid results are: empty string, or return a
> single character in the set [0-5].
> 
> There's got to be a better way..  but again, this works..
> 
>  if ($value =~ s/.*([0-5]).*/$1/){}else{$value=''}

First, to clean up your punctuation glut:

  $value =~ s/.*([0-5]).*/$1/ or $value = '';

That could be written as:

  $value = $value =~ /.*([0-5]).*/ ? $1 : '';

If there is more than one digit [0-5], the last one will be the value 
returned.  If more than one digit would be an error:

  $value = $value =~ /^[^0-5]*([0-5])[^0-5]*$/ ? $1 : '';

But I would chuck the whole regex approach, and use 'tr' instead:

  $value =~ tr/0-5//cd;
  $value = '' if length $value > 1;

Based on benchmarks of similar problems, this is surely much faster.  
Read about it in perlop.

-- 
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: 12 Dec 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Special: Digest Administrivia (Last modified: 12 Dec 98)
Message-Id: <null>


Administrivia:

Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing. 

]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body.  Majordomo will then send you instructions on how to confirm your
]subscription.  This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.

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

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