[8509] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2127 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Mar 18 14:17:21 1998

Date: Wed, 18 Mar 98 11:02:12 -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, 18 Mar 1998     Volume: 8 Number: 2127

Today's topics:
        pattern matching dilemma <mlepine@bellsouth.net>
    Re: pattern matching dilemma <quentin@jihad.amd.com>
    Re: Posting to UseNet groups from Perl? (Michael J Gebis)
        Problem with CGI script <mlinde@atpco.com>
    Re: Qui sera assez fort pour repondre a ca ?? <tchrist@mox.perl.com>
    Re: regexp not working:help <barnett@houston.Geco-Prakla.slb.com>
    Re: searching a file in Perl (tony)
    Re: stripping "special" characters from string <cberry@cinenet.net>
    Re: stripping "special" characters from string <tchrist@mox.perl.com>
    Re: ts: using "my" inside a loop? <dboorstein@shopcfn.com>
        Using odbc to get to access 97 database on IIS <guldner@cs.fsu.edu>
    Re: VERY URGENT !!! (Craig Berry)
    Re: Wanted: email address gleaner <jp@glpbooks.BADMAIL.com>
        WinNT + Comm ports + Port Settings <james.bateman@mail.com>
        Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Wed, 18 Mar 1998 17:21:54 GMT
From: Michael Lepine <mlepine@bellsouth.net>
Subject: pattern matching dilemma
Message-Id: <35100426.31F61A2E@bellsouth.net>

I am using the following code to limit an archive web site so that it
only contains the ten most recent feature entries.

 while($_ = <IN>) {
   if ($entry_area_flag) {
        /^.*<li>.*?/i && do {  # count list items in archive
                                $archive_entries++;
                                if ($archive_entries >= 10) {
                                        next; # if 10 list items, don't
print
                                }
                         }
        /^.*</ul>.*?/i && do {  # end of archive list entries
                                undef $entry_area_flag;
                                print "Entries: $archive_entries\n" if
$DEBUG;
                          }
   }
    print FILE $_;
    /^.*NEW_ARCHIVE_ENTRIES.*/ && do {
                                     print FILE $New_Entry;
                                     $archive_entries++;
                                     $entry_area_flag = 1;
                                  }
 }

For some reason I get a syntax error with the second pattern matching
sequence in the code ( /^.*</ul>.*?/ ). No matter what I replace the
search pattern with, I get an error. Can someone please help me figure
out a way around this?

Mike



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

Date: 18 Mar 1998 12:09:14 -0600
From: Quentin  Fennessy <quentin@jihad.amd.com>
Subject: Re: pattern matching dilemma
Message-Id: <ximd8fjc1md.fsf@jihad.amd.com>

>>>>> "ML" == Michael Lepine <mlepine@bellsouth.net> writes:

    ML> For some reason I get a syntax error with the second pattern
    ML> matching sequence in the code

Your fragment:

        /^.*</ul>.*?/i && do {  # end of archive list entries

You are using too many slashes '/'.  There are three in your
example, rendering the syntax ambigous.

Try this

       m|^.*</ul>.*?|i && do { 


It would be helpful if you posted your error messages 
along with your code sample.

-- 
Quentin Fennessy			AMD, Austin Texas
Secret hacker rule #11 - hackers read manuals


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

Date: 18 Mar 1998 18:39:53 GMT
From: gebis@albrecht.ecn.purdue.edu (Michael J Gebis)
Subject: Re: Posting to UseNet groups from Perl?
Message-Id: <6ep4dp$lhp@mozo.cc.purdue.edu>

mknutson@websolution.com (Mick Knutson) writes:

}How would this be done?

Start looking in CPAN (which can itself be found via www.perl.com).

However, you should realize that if you use perl to post spam,
you'll face the curse of the two-headed monkey-god Tiko.  Ice cream
won't taste as sweet.  You'll constantly fail to make the green light
an intersections.  Telemarketers will be more agressive.  Hanson will
release another song.  Your cats will get lazier.  You'll never properly
refold a map again.  You will feel "stickier." Your rollerblades will
start to itch.  Your "L" key will get jammed on your keyboard.  Forget
about getting a fair deal on your next car.  Your dreams will all
feature the characters of "Gimme A Break" and "Charles in Charge."
Your voice will have more static when heard over a speaker-phone.
If you thought that fingernails on a chalkboard was annoying, it will
be 10% worse.  You'll get a coffee stain on your favorite shirt.
Feeling constipated and bloated?  You will.   "Whitening" toothpaste
will fail to work.  And a gigantic glowing apparition of a two-headed
monkey-god will be always hovering just outside your field of view.

It's really not worth it.

-- 
Mike Gebis  gebis@ecn.purdue.edu  mgebis@eternal.net


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

Date: Wed, 18 Mar 1998 13:49:46 -0500
From: Marcos Lindekugel <mlinde@atpco.com>
Subject: Problem with CGI script
Message-Id: <35101749.61020FFC@atpco.com>

If someone could please help me with this problem, I would appreciate it
very much. My script basically is a "change of address" program that
reads a form, checks for info someone wants to change, then writes the
old info and new info into a file. Everything works fine until it's time
to write the info. I'm getting an Internal Server Error, and my error
log says it's hit a Premature end of script headers. The problem
probably is obvious, but I can't seem to figure it out. I'm including
the script below. Any help would be much appreciated. Thanks in advance
for your time.

#!/usr/local/bin/perl

$dataFile = '/app/dbpwd/changes.txt';
@oldName = ('edition', 'prefix', 'First_Name', 'Last_Name', 'Job_Title',
'Company', 'Address', 'Address_2', 'City', 'State', 'ZipPostalCode',
'Country', 'email', 'Telephone', 'Fax', 'account');
@newName = ('nedition', 'nprefix', 'nFirst_Name', 'nLast_Name',
'nJob_Title', 'nCompany', 'nAddress', 'nAddress_2', 'nCity', 'nState',
'nZipPostalCode', 'nCountry', 'nemail', 'nTelephone', 'nFax');
@fieldName = ('Edition', 'Title', 'First Name', 'Last Name', 'Job
Title', 'Company', 'Address', 'Address (continued)', 'City', 'State',
'Zip/Postal Code', 'Country', 'E-mail', 'Telephone', 'Fax');

&initialize;
&parseForm;
&verifyRequired;
&getChanges;
&outputIt;

sub initialize{
 foreach $entry(@oldName){
  $FORM{$entry} = "";
 }
 foreach $entry(@newName){
  $FORM{$entry} = "";
 }
}

sub verifyRequired{
 if (($FORM{'Last_Name'} eq "") || ($FORM{'First_Name'} eq "")){
  &printTop;
  print qq!\n<font face=arial size=3><b>In order to identify your
account, you must enter your name</b></font><p>!;
  print qq!\n<form action="/cgi-bin/sdchange.pl" method=POST>!;
  foreach $field(@oldName){
   if ($FORM{$field} ne ""){
    $qChange = "n$field";
    print qq!\n<input type=hidden name=$field value=$FORM{$field}>!;
    print qq!\n<input type=hidden name=n$field value=$FORM{$qChange}>!;
   }
  } print qq!\n<font face=arial size=2><b>First Name: <input type=text
name="First_Name" value="$FORM{'First_Name'}"><br>!;
  print qq!\nLast Name: <input type=text name="Last_Name"
value="$FORM{'Last_Name'}">!;
  print qq!\n<p><input type=submit value="Submit"></form>!;
  &printBottom;
  die;
 } if ($FORM{'nLast_Name'} eq ""){
  $FORM{'nLast_Name'} = $FORM{'Last_Name'};
 } if ($FORM{'nFirst_Name'} eq ""){
  $FORM{'nFirst_Name'} = $FORM{'First_Name'};
 }
}

sub outputIt{
 open (DATA, '>>'.$dataFile) || die "Failed to open $dataFile: $!";
 $line = "";
 foreach $field(@oldName){
  $qField = "n$field";
  if ($FORM{$field} eq ""){
   $line .= 'na;na:';
  } else{
   $line .= $FORM{$field}.';'.$FORM{$qField}.':';
  }
 }
 print DATA "$line\n";
 close DATA;
}

sub getChanges{
 $count = 0;
 $count2 = 0;
 $inputCount = 0;
 foreach $name(@newName){
  $realField{$name} = $fieldName[$count];
  $count++;
 } $count = 0;
 foreach $name(@oldName){
  if ($FORM{$name} ne ""){
   $changingField[$count] = $name;
   $count++;
  }
 } foreach $change(@changingField){
  $qChange = "n$change";
  if ($FORM{$qChange} eq ""){
   $inputCount++;
  }
 } if ($inputCount > 0){
  &printTop;
  print qq!\n<font face=arial size=3><b>The following fields were
selected to be changed,!;
  print qq!\nbut no new information was found.</font><p>!;
  print qq!\n<form action="/cgi-bin/sdchange.pl" method=POST>!;
  for ($count2=0; $count2<$count; $count2++){
   $oChange = "$changingField[$count2]";
   $qChange = "n$changingField[$count2]";
   if ($FORM{$qChange} eq ""){
    print qq!\n<p><font face=arial size=3><b>$realField{$qChange}:
<input type=text name="$qChange" value="$FORM{$oChange}"></b></font>!;
   } else{
    print qq!\n<input type=hidden name=$qChange
value="$FORM{$qChange}">!;
   }
  } for ($count2 = 0; $count2<$count; $count2++){
   print qq!\n<input type=hidden name="$changingField[$count2]"
value="$FORM{$changingField[$count2]}">!;
  } print qq!\n<input type=submit value="Submit"></form>!;
  &printBottom;
  die;
 }
}

sub printTop{
 print "Content-type: text/html\n\n";
 print qq!<html><head><title>Change of address</title></head>!;
 print qq!\n<body
background="http://www.spacenews.com/simages/bground.gif">!;
 print qq!\n<table width=590 cellpadding=0 cellspacing=0 border=0><tr
valign=top><td width=590>!;
}

sub printBottom{
 print qq!\n<P>) Copyright 1998 Army Times Publishing
Co.</P></td></tr></table></body></html>!;
}

sub parseForm{
   read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
   @pairs = split(/&/, $buffer);
   foreach $pair (@pairs)
   {
      ($name, $value) = split(/=/, $pair);
      $value =~ tr/+/ /;
      $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
      $value =~ s/<!--(.|\n)*-->//g;
      $FORM{$name} = $value;
   }
}





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

Date: 18 Mar 1998 16:18:22 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Qui sera assez fort pour repondre a ca ??
Message-Id: <6eos4e$47k$1@csnews.cs.colorado.edu>

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

In comp.lang.perl.misc, cfockeu@atos-group.com (ATOS) writes:
:Je cherche (desesperement ?) comment faire pour retrouver une cle
:dans un tableau associatif grace a la valeur qui y est associee.
:Je m'explique : 
:$tab1{"cle1"} = "valeur1"
:... etc
:
:Maintenant j'ai "valeur1" je voudrais savoir quelle cle correspond
:a cette valeur dans %tab.

"Qui sera assez fort pour repondre a ca?", tu preguntas.  Moi, bien s{r,
y te espero tanta suerte en leerlo como has esperado de los demas. :-)

Ocurre que lo que buscas si trova nel famosmsimo FAQ di Perl, lo cual
viene incluido mjme con il tuo propio sistema de Perl.  ?Nco lo has visto
jamas?  ?Csmo que no?  De hecho, il me semble que si tu l'avais dij` lu,
lo hubieras visto dans la cuarta parte, al principio de este documento
quasi nunca leido, cuyo tercer entrado de esto se trata.   Ademas,
a moins que tu ne puisses pas leggere inglese ni en absoluto, ego te
suggiero que la proxima vez que nos pongas une question comme cette-l`,
que la escribas d'une manihre que quepa esperar que otra gente que yo
te pudiere ripondre.  Hai capito?  Mais si ga n'est pas possible, tal
vez existen grupos dans lesquels se suele piy auf franzvsisch schrieben,
such as perchance fr.comp.lang.perl, n'est-ce pas?

Ciao,

--tom

# por si las moscas... YANETUT
package Tie::RevHash;
use strict;
use Tie::Hash;
use Carp;
use vars qw(@ISA);
@ISA = qw(Tie::StdHash);
sub STORE($$$) {
    my ($self, $key, $value) = @_;
    for ($key, $value) { 
	if ($^W && ref($_) && !UNIVERSAL::isa($_, "Tie::RefHash")) {
	    carp "refness of $_ used as key destroyed!\n";
	} 
    }
    $self->{$value} = $key;
    $self->{$key}   = $value;
} 
1;
__DATA__
-- 
	Tom Christiansen	tchrist@jhereg.perl.com

        ``Imagination is more important than knowledge.''
				(A. Einstein)


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

Date: Wed, 18 Mar 1998 11:22:09 -0600
From: Dave Barnett <barnett@houston.Geco-Prakla.slb.com>
Subject: Re: regexp not working:help
Message-Id: <351002C1.E89EB2C9@houston.Geco-Prakla.slb.com>

parv wrote:
> 
> - my actual address is hyphen free -
> 
> why doesn't the following code prints the year w/o 19?
> 
>   local $time = localtime ;
>   $time =~s?\s[a-z][sd]t\s[12][90]? ? ; # should remove, e.g., ' EST 19'
>   print "\n $time \n" ;
> 
> it always prints the year as 1998.  what am i doing wrong? i know that i
> can use substring function, but i want to know why the above
> substitution doesn't work.
> 
> - anu
Well, have you tried doing 

print scalar(localtime(time)), "\n";

to see what you get?

I think you might be surprised.

I get:
Wed Mar 18 11:20:24 1998


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: Thu, 19 Mar 1998 03:29:32 +1000
From: td@lavalink.com.au (tony)
Subject: Re: searching a file in Perl
Message-Id: <td-1903980329320001@mtterror.lavalink.com.au>

Hi,
I was wondering how would it be done if you wanted to search two or more
files at the same time? ie: filename1 filename2 ...

Tony Delov

 
> Pretty simple to do, although this can be a slow way especially if
> you're searching a big file:
> 
> $foo = "whatever you're searching for";
> open(FILEH,"<filename");
> while (<FILEH>) {
>         if (/$foo/) {
>                 print;
>         }
> }
> close(FILEH);
> 
> Paul.


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

Date: Wed, 18 Mar 1998 09:29:58 -0800
From: Craig Berry <cberry@cinenet.net>
To: Randal Schwartz <merlyn@stonehenge.com>
Subject: Re: stripping "special" characters from string
Message-Id: <Pine.GSO.3.95.980318092715.8894A-100000@hollywood.cinenet.net>

[posted and mailed]
 
On 18 Mar 1998, Randal Schwartz wrote:

> >>>>> "Craig" == Craig Berry <cberry@cinenet.net> writes:
> 
> Craig> Might suggest this instead:
> Craig>   my $mday = localtime(time)[3];
> 
> You could suggest it, but it wouldn't work. :-)

Ouch.  I'm, ah, using invisible parentheses -- yeah, that's the ticket,
invisible parentheses!

---------------------------------------------------------------------
   |   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: 18 Mar 1998 16:31:19 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: stripping "special" characters from string
Message-Id: <6eossn$47k$2@csnews.cs.colorado.edu>

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

In comp.lang.perl.misc, Randal Schwartz <merlyn@stonehenge.com> writes:
:Syntax for list-splice is:

ENOPEE

:	(LIST)[LIST_OF_INDICIES]

--tom
-- 
	Tom Christiansen	tchrist@jhereg.perl.com
"The reason you subscribe to a mailing list is you don't get all 
 the crap you get on netnews. "
	    --Dennis Ritchie


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

Date: Wed, 18 Mar 1998 11:31:14 -0500
From: Dan Boorstein <dboorstein@shopcfn.com>
To: Jason Gloudon <jgloudon@manitoba.bbn.com>
Subject: Re: ts: using "my" inside a loop?
Message-Id: <350FF6D2.136C620E@shopcfn.com>

Jason Gloudon wrote:
> 
> There really should be no substantial difference as the work associated
> with the maintenance of the lexical variables is the same in both examples.
> The lexical variables within a block are "created" only when execution enters
> that block.  The for(each) loop enters and exits the { my () = split  } block
> once, so the lexicals are still only "created" once.

that being the case how is the difference explained? if i replace the
'split' with a simple assignment, the difference is increased as i
expected.

in addition i moved the bulk of the iterations into the 'for' loops,
thinking that this would more closely resemble a real application.

timethese('5', {
  'myin',  '       for (my $i = 0; $i <= 800000; $i++) { my $j = 1; }',
  'myout', 'my $k; for (my $l = 0; $l <= 800000; $l++) {    $k = 1; }',
});

Benchmark: timing 5 iterations of myin, myout...
      myin: 11 secs (10.90 usr  0.00 sys = 10.90 cpu)
     myout:  9 secs ( 9.17 usr  0.00 sys =  9.17 cpu)

again, i would let the scoping issues rule my decision on where to
declare my 'my's, but i *am* curious still.

thanks for any insight,

-- 
# dan boorstein <dboorstein@shopcfn.com>
seek DATA,0,0;print scalar<DATA>,__END__
Just another Perl hacker,


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

Date: Wed, 18 Mar 1998 13:07:21 -0500
From: "Claus Gueldner" <guldner@cs.fsu.edu>
Subject: Using odbc to get to access 97 database on IIS
Message-Id: <6ep2b2$60q$1@news.fsu.edu>

I have a server running Nt Server 4.0 with service pack 3 and option pack,
running Internet Information Server 4.0.  I have created a system DSN for
the database I want to access.   Basically it works fine if I am at the
server at a dos prompt but when I move it to the web and try and run it from
there it fails.  From the web I can see the odbc source, but if I try and
open a connection the script does nothing.  I will also get a error on the
server which says:
"The instruction at "0x001400c5" referenced memory at "0x002800e0". The
memory could not be "written".

The window's title is "OleMainThreadWndName: perl.exe -Application Error"

If anyone has any idea what is causing this please respond and email the
response to me.

Thanks

Claus Guldner
guldner@cs.fsu.edu




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

Date: 18 Mar 1998 17:47:22 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: VERY URGENT !!!
Message-Id: <6ep1bb$k83$1@marina.cinenet.net>

Jim Britain (jbritain@home.com) wrote:
: On Wed, 18 Mar 1998 01:14:22 -0000, "PORTUGAL SYSTEMS"
: <webmaster@portugalsystems.pt> wrote:
: 
: >I need to calculate two field on real time, inside a Perl Script. This two
: >fields are inserted through a Form.
: >How can I do that ? Adding variable 1 to variable 2 and give a result x ?
: 
: $resultx = form{'variable1'} + form{'variable2'};
: 
: Or am I missing something?

Nothing but the dollar signs before each occurrence of 'form'. :-)

---------------------------------------------------------------------
   |   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: Wed, 18 Mar 1998 13:38:09 +0000
From: Jeff Potter <jp@glpbooks.BADMAIL.com>
Subject: Re: Wanted: email address gleaner
Message-Id: <350FCE41.5636@glpbooks.BADMAIL.com>

John Callender wrote:
> 
> Jeff Potter wrote:
> >
> > I've heard there are programs that search webpages on the internet
> > as well as newsgroup posts for email addresses. That's how spam
> > is done, right? Well, there are obviously good uses for such progs,
> > too.
> 
> Personally, I can't think of one. But maybe that's just because I'm so
> damn tired of being spammed.

As I posted, I have a big archive of newsgroup posts that I'd like to autoreply 
to all email addresses within. I need to ask permission to reprint their
posts. (The request would also auto-include their post text.) I want to publish 
a book that makes the very helpful info of this newsgroup more widely 
available. Sounds like a good use for a 'gleaner' to me! :)

-- 

Jeff Potter   jp@glpbooks.BADMAIL.com   delete '.BADMAIL' to reply
***"Out Your Backdoor": Friendly Magazine of DIY Adventure and Culture
       http://www.glpbooks.com/oyb ... with new bookstore & bulletin board


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

Date: Wed, 18 Mar 1998 18:17:32 GMT
From: James Bateman <james.bateman@mail.com>
Subject: WinNT + Comm ports + Port Settings
Message-Id: <35100FBB.C5467B7F@mail.com>

I would like to send out a simple sequence of characters to a comms
port, but first I would like to set it to a particular settings (baud
rate etc).

While I can do this by first calling the 'mode.com' command via the
system function, this isn't very neat. Is it possible to change the port
settings via the register, ie modifying
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Ports,
if so how).

Selection from current program being :-

    $commport="COM1";
    system("mode.com $commport: baud=9600 parity=n data=8 stop=1 to=on
dtr=off rts=off");
    ...
      open(PORT,"+>$commport") or die "Can't open $commport: $!";
    ...
james.bateman@isltd.insignia.com



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

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

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