[12864] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 274 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jul 27 19:07:27 1999

Date: Tue, 27 Jul 1999 16:05:12 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Tue, 27 Jul 1999     Volume: 9 Number: 274

Today's topics:
        -w and line numbers <jbc@shell2.la.best.com>
    Re: 3 dimensional array <sariq@texas.net>
    Re: Another host_addr question (Vicki Surratt)
    Re: Another host_addr question (Vicki Surratt)
    Re: Beginner-friendly group as cultural adaptation? <dgris@moiraine.dimensional.com>
    Re: cgi HTTP header information (brian d foy)
    Re: converting net address... (Tramm Hudson)
    Re: converting net address... <laurens@bsquare.com>
    Re: Custom HTML functions - I could use some direction, (brian d foy)
    Re: ebcdic packed numbers (Bart Lateur)
    Re: FormMail Year 2000 problem (Alan Curry)
        Help removing special characters from a string ryan7879@my-deja.com
    Re: Korn Shell or Perl? (brian d foy)
    Re: Korn Shell or Perl? (Michael Wang)
    Re: module for Oracle? <cassell@mail.cor.epa.gov>
    Re: module for Oracle? (Larry Rosler)
        negated compiled regexp <ltl@rgsun5.viasystems.com>
    Re: negated compiled regexp <tchrist@mox.perl.com>
    Re: Net::LDAP help <ltl@rgsun5.viasystems.com>
    Re: Net::LDAP help <ltl@rgsun5.viasystems.com>
    Re: newby rename problem (help) <cassell@mail.cor.epa.gov>
    Re: platform independent perl advice <cassell@mail.cor.epa.gov>
    Re: Pretty prompt creation from info in a file... (Tad McClellan)
        Removing special characters in perl ryan7879@my-deja.com
    Re: Removing special characters in perl <arnej@fc.hp.com>
        Digest Administrivia (Last modified: 1 Jul 99) (Perl-Users-Digest Admin)

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

Date: 27 Jul 1999 22:20:17 GMT
From: John Callender <jbc@shell2.la.best.com>
Subject: -w and line numbers
Message-Id: <379e30a1$0$8462@nntp1.ba.best.com>

When running under -w, if I try to use an uninitialized variable inside
an if block, the warning is reported as being at the line number on
which the block started, not the line where the variable is used. If I
use a foreach block, the warning reports the actual line number where
the variable is used.

Examples:

1: #!/usr/bin/perl -w
2:
3: if (1) {
4:     print $walnuts;
5: }

gives me:

[jbc@xena jbc]$ ./test.pl
Name "main::walnuts" used only once: possible typo at ./test.pl line 4.
Use of uninitialized value at ./test.pl line 3.

while this:

1: #!/usr/bin/perl -w
2: 
3: foreach (1..4) {
4:     print $walnuts;
5: }

gives me:

[jbc@xena jbc]$ ./test.pl
Name "main::walnuts" used only once: possible typo at ./test.pl line 4.
Use of uninitialized value at ./test.pl line 4.
Use of uninitialized value at ./test.pl line 4.
Use of uninitialized value at ./test.pl line 4.
Use of uninitialized value at ./test.pl line 4.

Why is that? I mean, why is the first one reporting the error at line
3? I was expecting it to report the error at line 4.

-- 
John Callender
jbc@west.net
http://www.west.net/~jbc/


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

Date: Tue, 27 Jul 1999 17:03:36 -0500
From: Tom Briles <sariq@texas.net>
Subject: Re: 3 dimensional array
Message-Id: <379E2CB8.2EC7592@texas.net>

Arnabnil Bhattacharjee wrote:
>         I am a perl novice and need some urgent help.

You shouldn't come to Usenet for urgent help.  You might get an answer
in 10 minutes, in 10 hours, in 10 days, or never.

> I need to create a 3
> dimensional array in perl 5 . constraints the ranges of the dimensions are
> not known ( but of course begin from 0 ) and the elements are not inserted
> in any kind of order. Could somebody write me some sample code please...

<snipped 14, *14*, yes *fourteen* line sig - I'm trying to make a point
here, Arnabnil>

This is not the group to come to for help with your homework
assignments.

If you make an effort, and just can't figure it out, post what you've
written so far.  You may get some helpful responses.

Alternatively, you can hire a programmer to complete your assignment. 
It won't be cheap, though, and your professor might just ask you some
questions about it.

- Tom


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

Date: Tue, 27 Jul 1999 17:40:38 -0600
From: vicki@vickishome.com (Vicki Surratt)
Subject: Re: Another host_addr question
Message-Id: <1dvm3co.29l9hy20dccbN@ip159.houston13.tx.pub-ip.psi.net>

Cancel that request for help.  I ended up stumbling into a *very* nice
man named Lincoln Stein who has written a few books about the web.  He
came up with a script I can call through the ssi exec command.

I'll post it here so others can use it as well:

In your .shtml file, simply execute the perl script (called mytest.pl)
with the following command:

<!--#exec cgi="/cgi-local/mytest.pl" -->

Now the script itself:

#!/usr/local/bin/perl
use Socket;
my $addr = $ENV{REMOTE_HOST};
print "Content-type: text/html\n\n";
print resolve_name($addr);

sub resolve_name {
  my $addr = shift;
  die "$addr: Not a valid address" unless $addr=~/^\d+\.\d+\.\d+\.\d+$/;
  my $name = gethostbyaddr(inet_aton($addr),AF_INET);
  return $name;
}

That's it!  I hope this helps others.

Take Care!

Vicki Surratt
vicki@vickishome.com
Visit my website!  http://www.vickishome.com

Vicki Surratt <vicki@vickishome.com> wrote:

> I've read all the messages I could find about this subject, but I'm
> still stumped.
> 
> I am trying to display the host_addr variable on the screen.  It appears
> my webhost has dns lookup turned off on the server.  I have tried a
> simple ssi echoing host_addr, and I've tried an ssi exec in which a perl
> script is executed to get $ENV{'REMOTE_HOST'}.  In both cases, all I get
> is the IP address.  I tried updating my .htaccess file (which I can
> usually update), but it errors out when I tried to turn dns lookup on.
> 
> I'm wanting the host_addr to display automatically when the visitor goes
> to that particular page rather than expecting them to type in their IP
> address.
> 
> So what's next?  Is there another way to have the information displayed?
> Is there any way to use the IP address to automatically lookup the host
> address in a perl script?
> 
> Take Care!
> 
> Vicki Surratt
> vicki@vickishome.com
> Visit my website!  http://www.vickishome.com



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

Date: Tue, 27 Jul 1999 17:40:37 -0600
From: vicki@vickishome.com (Vicki Surratt)
Subject: Re: Another host_addr question
Message-Id: <1dvm35m.rclzb41ilohslN@ip159.houston13.tx.pub-ip.psi.net>

Thanks for the help.  For some reason, it didn't work for me, but I got
the problem solved.

Take Care!

Vicki Surratt
vicki@vickishome.com
Visit my website!  http://www.vickishome.com

Jonathan Stowe <gellyfish@gellyfish.com> wrote:

> Vicki Surratt <vicki@vickishome.com> wrote:
> > 
> >                  Is there another way to have the information displayed?
> > Is there any way to use the IP address to automatically lookup the host
> > address in a perl script?
> > 
> 
> See for instance : 
> 
> <http://www.deja.com/[ST_rn=ps]/getdoc.xp?AN=489776960&fmt=text>
> 
> /J\



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

Date: 27 Jul 1999 15:57:26 -0600
From: Daniel Grisinger <dgris@moiraine.dimensional.com>
Subject: Re: Beginner-friendly group as cultural adaptation?
Message-Id: <m3yag14uyh.fsf@moiraine.dimensional.com>

John Callender <jbc@shell2.la.best.com> writes:

<snip>

Wouldn't it be easier to create a mailing list that we
can redirect people to?

dgris
-- 
A hacker is a machine that turns caffeine into code.


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

Date: Tue, 27 Jul 1999 18:28:56 -0400
From: brian@pm.org (brian d foy)
Subject: Re: cgi HTTP header information
Message-Id: <brian-ya02408000R2707991828560001@news.panix.com>

In article <vQjn3.19477$nW3.1783@newreader.ukcore.bt.net>, "Richard Garside" <richard.garside@zen.co.uk> posted:

> I have a cgi script that will be used by several users. It is a
> sitesearching tool. It works fine but the problem is that at present anyone
> using it can search through the directories of other people hosted on our
> server. I want to find the path location of the pge that calls my script so
> I can check they aren't trying to access other users sites.


you should fix the problem - the misdesigned script.

something like Glimpse (find it through Yahoo!) would be much better
for you.

-- 
brian d foy                    
CGI Meta FAQ <URL:http://www.smithrenaud.com/public/CGI_MetaFAQ.html>
Perl Monger Hats! <URL:http://www.pm.org/clothing.shtml>


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

Date: 27 Jul 1999 15:00:05 -0600
From: hudson@swcp.com (Tramm Hudson)
Subject: Re: converting net address...
Message-Id: <7nl6kl$fl@llama.swcp.com>
Keywords: HTML design rant

[posted and cc'd to cited author]

In article <379E160C.9DFAE6F8@dk.net>, Henrik Gemal  <gemal@dk.net> wrote:
> Actually after I looked at txt2html I came up with this:
>  .... <A HREF=\"$&\" > TARGET=\"_blank\">$&<\/A>/ig ...

Please do -not- use this attribute.  Yes, it is defined in HTML 4.0c:

	http://www.w3.org/TR/REC-html40/types.html#type-frame-target

but most everyone finds it very, very obnoxious when someone else
tries to control their browsing experience.  I wish w3 had advised
against the use of this attribute.

Why is it that every brain dead HTML author seems to think that they
must open new windows for the user?  With most client software it
is easy enough for the viewer to create a new window if desired.
As far as I can tell, however, there is no way to instruct Netscape
to ignore the target=_blank attribute.  So I strip it out in my
proxy instead.  Luckily lynx ignores such bogus designs.

[snip way too many lines of ugly regular expressions]

> I the only thing I miss is to convert the following type of addresses:
> www.gemal.dk/test

But that is not a valid URI.  So how would you convert it?

Pedantic Luddites unite!
Tramm
-- 
  o   hudson@swcp.com                 tbhudso@cs.sandia.gov   O___|   
 /|\  http://www.swcp.com/~hudson/          H 505.323.38.81   /\  \_  
 <<   KC5RNF @ N5YYF.NM.AMPR.ORG            W 505.284.24.32   \ \/\_\  
  0                                                            U \_  | 


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

Date: Tue, 27 Jul 1999 14:37:53 -0700
From: "Lauren Smith" <laurens@bsquare.com>
Subject: Re: converting net address...
Message-Id: <7nl8rt$dri$1@brokaw.wa.com>

AUGH!!!   I'm Blind!

;-)

Lauren - whose programs sometimes look just like Henrik's...




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

Date: Tue, 27 Jul 1999 18:14:48 -0400
From: brian@pm.org (brian d foy)
Subject: Re: Custom HTML functions - I could use some direction, hints, help!  :-)
Message-Id: <brian-ya02408000R2707991814480001@news.panix.com>

In article <37a43e0a.9740708@news.gte.net>, cnlsilva@gte.net posted:

> I am attempting to modify a script to allow a HTML page to be updated
> dynamically.  I want to use a custom tag <poll> and </poll> to allow
> ew information to be updated to the page in a easy to use manner.

i would be inclined to use HTML::Parser in that case, but i would
avoid that case by using some other template method.  you might look
at some of the modules in Text::*

-- 
brian d foy                    
CGI Meta FAQ <URL:http://www.smithrenaud.com/public/CGI_MetaFAQ.html>
Perl Monger Hats! <URL:http://www.pm.org/clothing.shtml>


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

Date: Tue, 27 Jul 1999 21:26:05 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: ebcdic packed numbers
Message-Id: <37a322f4.14328174@news.skynet.be>

John G Dobnick wrote:

> "Packed" numbers (which I presume really means "packed decimal" numbers)
> are not EBCDIC, ASCII, or any other character code.  They are
> binary coded decimal digits arranged in a specific manner.
>
> Each "byte" (8-bit byte in the IBM case) contains two 4-bit binary coded 
> decimal digits.

The name is "BCD", or Binary Coded Decimal (I guess).

> The rightmost "nibble" (a "nibble" is a 4-bit quantity)
> contains the sign of the value.  

Huh?

Anyway, in order to decode BCD data, you could first convert this data
to a hex string, e.g. using sprintf(), and treat the result as a decimal
number. Basically, that should cut it.

	Bart.


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

Date: Tue, 27 Jul 1999 21:36:18 GMT
From: pacman@defiant.cqc.com (Alan Curry)
Subject: Re: FormMail Year 2000 problem
Message-Id: <mDpn3.6506$cO4.169180@news12.ispnews.com>

In article <slrn7prtm4.bvm.fl_aggie@thepentagon.com>,
I R A Darth Aggie <fl_aggie@thepentagon.com> wrote:
>On Tue, 27 Jul 1999 17:16:05 GMT, Alan Curry <pacman@defiant.cqc.com>, in
><pPln3.1230$c17.22291@news15.ispnews.com> wrote:
>
>+ >That's a configuration issue. Besides, how difficult will it be to
>+ >hack what you plan to do and turn it into an anonymous relay?
>
>+ I'll have users subscribe to receive their form mail. With ezmlm-style
>+ confirmation. This will guarantee that only those who actually asked for
>+ nearly-untraceable mail from a CGI will get it.
>
>Ah, so you won't be releasing your code to the general public. That
>pretty much puts the kibosh on the user modifying the code.

I misread your question. Of course if someone deliberately removes sanity
checks from an automatic mail-sending program, they can turn it into
something very ugly. FormMail.pl doesn't have any sanity checks to start
with, so everybody who runs it is a relay for mail from anyone to anyone.
-- 
Alan Curry    |Declaration of   | _../\. ./\.._     ____.    ____.
pacman@cqc.com|bigotries (should| [    | |    ]    /    _>  /    _>
--------------+save some time): |  \__/   \__/     \___:    \___:
 Linux,vim,trn,GPL,zsh,qmail,^H | "Screw you guys, I'm going home" -- Cartman


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

Date: Tue, 27 Jul 1999 22:02:00 GMT
From: ryan7879@my-deja.com
Subject: Help removing special characters from a string
Message-Id: <7nla8j$pos$1@nnrp1.deja.com>

I'm new to Perl and I am having trouble removing
a "+" character from a string.  The plus exists
because the string has it's value submitted from
one web page to another, therefor the blank
spaces are url encoded.  The following works for
letters or combinations of letters, but fails on
the s/+/ /g; line when a plus sign is involved.
Does anyone know how to get around this?

Thanks.

for ($a = 0; $a <= $#userwords; $a++) {
    @userwords[$a] = substr(@userwords[$a], 6);
    $_ = @userwords[$a];
    s/+/ /g;
    @userwords[$a] = $_;
  }



Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: Tue, 27 Jul 1999 18:00:24 -0400
From: brian@pm.org (brian d foy)
Subject: Re: Korn Shell or Perl?
Message-Id: <brian-ya02408000R2707991800240001@news.panix.com>

In article <7nl19f$13ss$1@nntp6.u.washington.edu>, donn@u.washington.edu (Donn Cave) posted:


> Another thing that seems to be going on here - I've seen a couple of
> these ``why can't Perl do this'' articles from the original poster,
> and it seems to me that he feels he needs parallel filter threads,
> because a serial processing model would gag on the bulk.  This is
> something that can be done with the utmost ease on UNIX, using the
> shell, and for practical purposes it's the only way to do it.  The
> same solution can be engineered in Perl, C, Python or what have you,
> using pipe() and fork(), but the shell does it easier and better.
> This is not a defect of Perl, just a fact of life.

if you want to play with pipelines, you can do it with Perl and you
only have to use one process to do it.  (see below code).

i just re-read "The Psychology of Computer Programming" which has
been re-printed for it's 25th aniversary.  there's a chapter devoted
to learning a new language when you already know one.  it seems most
people, instead of learning the new language, just squeeze the syntax
of the new language to fit their old ideas.   thus, any new language
will not be useful because one doesn't benefit from it differences
with the previous langauge.  such is the case of the original
poster, it seems.



#!/usr/bin/perl

use builtin qw(sum);

 ....

my $status = 
sum(
   map  { ( get_pin(0, 1, 0, $opt_b, $_) )[0] }
   grep { ! /^YP_/ }
      ( $opt_d ne 'all' ? split(/,\s*/, $opt_d) :
         map 
            { 
            if    ( /local/ )  { keys %beeper_name } 
            elsif ( /yp/ )     { map {/(\w+)/} `ypcat -k beeper.byname` }
            else               { () }
            } split  /,/, $opt_b

      )
   );

 ....

-- 
brian d foy                    
CGI Meta FAQ <URL:http://www.smithrenaud.com/public/CGI_MetaFAQ.html>
Perl Monger Hats! <URL:http://www.pm.org/clothing.shtml>


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

Date: 27 Jul 1999 22:45:28 GMT
From: mwang@tech.cicg.ml.com (Michael Wang)
Subject: Re: Korn Shell or Perl?
Message-Id: <7nlcq8$g33$1@news.ml.com>

After I posted the awkward Perl code to simulate the shell pipeline,
I got a lot of criticism. I have some problem of newsfeed so I can not
see them all, so I take Randal L. Schwartz's post [also emailed to me]
as a typical response, as attached below. Basically they are saying that
I do not know how to write better Perl script, and showed me how it can
be better written. 

While I appreciate that Randal and others who took the time to teach me
how to write better code, please take a note that what I want to achieve
is not to use temporary variables such as @hits to store the data. So
what I did and Randal did are different. I would think if
keys(%::beeper_byname) or `ypcat -k beeper.byname` are large enough
and exceed the system memory, my "awkard" code will survive, and Randal's
better code will break. 

Is the following Randal's code awkard?
select((slect(SOCK),$|=1)[0])
Well it is, but I appreciate "the length that Randal will go to
in order to avoid creating temporary variables." (Joseph Hall/Randal Schwartz,
Effective Perl Programming, writting better programs with Perl, page 245). 

By following the very advice/example from Randal, I am going through
great length at the risk of awkwardness to avoid creating temporary variables. 
Please advise me how can I avoid awkwardness and at the same time
avoid temporary variables. I appreciate your help. Thanks. 

Michael>   foreach $j ( do {
Michael>                  if ( $opt_d eq "all" ) {
Michael>                    do { foreach ( split(/,/, $opt_b) ) {
Michael>                      if ( /local/ ) {
Michael>                        keys(%::beeper_byname);
Michael>                      } elsif ( /yp/ ) {
Michael>                        open(FH, "ypcat -k beeper.byname |")
Michael>                          or die("cannot fork: $!\n");  
Michael>                        map ( {
Michael>                          /(\w+)\s+\w+/ && $1
Michael>                        } <FH> );
Michael>                      }
Michael>                    }}
Michael>                  } else {
Michael>                    split(/,\s*/, $opt_d);
Michael>                  }
Michael>               }
Michael>   ) {
Michael>     unless ( $j eq "YP_LAST_MODIFIED" || $j eq "YP_MASTER_NAME" ) {
Michael>       ($k, @devnull)=get_pin("0", "1", "0", $opt_b, $j);
Michael>       $exit_status+=$k;
Michael>     }
Michael>   } 

Randal>    my @hits;
Randal>    if ($opt_d eq "all") {
Randal>      for ( split /,/, $opt_b ) {
Randal>        if (/local/) {
Randal>          push @hits, keys %::beeper_byname;
Randal>        } elsif (/yp/) {
Randal>          push @hits, map /(\w+)\s+\w+/, `ypcat -k beeper.byname`;
Randal>        }
Randal>      }
Randal>    } else {
Randal>      @hits = split /,\s*/, $opt_d;
Randal>    }
Randal>    for (@hits) {
Randal>      next if $_ eq "YP_LAST_MODIFIED";
Randal>      next if $_ eq "YP_MASTER_NAME";
Randal>      ($k) = get_pin(0, 1, 0, $opt_b, $_);
Randal>      $exit_status += $k;
Randal>    }
-- 
Michael Wang
http://www.mindspring.com/~mwang


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

Date: Tue, 27 Jul 1999 14:20:20 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: module for Oracle?
Message-Id: <379E2294.5E6E2D1E@mail.cor.epa.gov>

bing-du@tamu.edu wrote:
> 
> Hello there,
> 
> I am using Perl 5.005_02.  In this version, is there any
> embedded standard module that can be used to access Oracle database?
> What is the name of the module?  Thanks.

Get the DBI module, and DBD::Oracle if you don't already have 
tem on your system.  I *think* that 5.005_02 has DBI already,
but you should be able to check easily enough.  Just type:

perldoc DBI

and see if you get the manpage.  No manpage?  No DBI module
yet.

HTH,
David
-- 
David Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician


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

Date: Tue, 27 Jul 1999 14:31:19 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: module for Oracle?
Message-Id: <MPG.1207c4fc752b2b2a989d57@nntp.hpl.hp.com>

In article <379E0FD7.1404BCE5@lucent.com> on Tue, 27 Jul 1999 16:00:23 -
0400, Yvonne Li <yli15@lucent.com> says...
> There is a module called DBD and a DBI Oracle. You should install both to access
> Oracle. You can find them at 
> http://www.iru.missouri.edu/perldbi/dbiinstall.html

That page says it has not been changed since January 30, 1998, and the 
CPAN links there are out of date.  You should go directly to CPAN for 
links to the latest modules.

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


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

Date: 27 Jul 1999 22:06:15 GMT
From: lt lindley <ltl@rgsun5.viasystems.com>
Subject: negated compiled regexp
Message-Id: <7nlagn$ldk$1@rguxd.viasystems.com>

I wanted to store some compiled regular expressions in a data 
structure then loop through them and append to the structure
based on success of the match.  My problem came when I tried
to construct a "re" that was the opposite of another "re".

Normally, if you want to match anything that doesn't match
a re, you use 

$val !~ $re

But I wanted to use a loop that does:
foreach my $re (keys %xxx) {
	if ($val =~ $re) ...
}
and have it work for those that should match and others that shouldn't.

So, how to compose a re that is a negated re?  When I started I 
actually assumed that there was a negating re operator.  :-)
A perusal of perldoc perlre disabused me of that notion.  The
only thing I could come up with that worked was this:

my (%xxx) = (
  qr{^/       # match first char always just to have something match
      (?!     # negative assertion -- these shouldn't match
        (?:   # Grouping without saving.  Redundant in a lookahead?
            somedir/
            |anotherdir/
	    |athirddir/
	    |some_other_unwanted_dir/
        )
      )
    }x, 			# No => here -- don't want magic quoting
                       [],	# anon array for pushing into later
  qr{^/somedir/},
                       [],
  qr{^/anotherdir/},
  		       [],
);

what I really wanted was something like
  $re = qr{ <NOT> ^/(?:somedir/|anotherdir/
  			|athirddir/|some_other_unwanted_dir/)}x;

#############################################################
1) Am I missing a re operator/modifier that lets me compile a regular
expression that is a negated regular expression?  If one does not
exist, should there be one?

2) My solution won't work if I can't positively match part of the 
string.  I have to have something that matches before I can use
the netative lookahead assertion.  True?  My limited testing and
not so limited studying of the documentation seems to support
this, but I'm no regular expression stud.

3) Other than storing a switch in the data structure, can someone
see a better generalized way to do this?


-- 
// Lee.Lindley   /// Programmer shortage?  What programmer shortage?
// @bigfoot.com  ///  Only *cheap* programmers are in short supply.
////////////////////    50 cent beers are in short supply too.


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

Date: 27 Jul 1999 16:33:41 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: negated compiled regexp
Message-Id: <379e33c5@cs.colorado.edu>

     [courtesy cc of this posting mailed to cited author]

In comp.lang.perl.misc, 
    lee.lindley@viasystems.com writes:
:So, how to compose a re that is a negated re?  

I just posted this.  It's in the Cookbook.  Here's the short answer:

    /^(?:(?!PAT).)*$/s

--tom
-- 
 "Unix isn't fun anymore" --Rob Pike.


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

Date: 27 Jul 1999 21:35:18 GMT
From: lt lindley <ltl@rgsun5.viasystems.com>
Subject: Re: Net::LDAP help
Message-Id: <7nl8mm$k7a$1@rguxd.viasystems.com>

Davis Ford <forddavi@pilot.msu.edu> wrote:
:>I'm trying to write a script that will spit out an LDAP search, using the
:>Net::LDAP module.

:>I know the $entry->dump method will spit out all the information that the
:>search method comes up with, however, I want to specifically get only
:>certain attributes, and then print them in an HTML table.  For instance,

:>print "<TABLE...etc.,

:>..then print just the givenName attribute in one column
:>..then print the phone number attribute in another column

:>I've tried different variations of accessing the attrs method...
:>the dump method doesn't seem to take any parameters, in fact, it doesn't
:>care what you put in there, it just dumps.

:>Can anyone help me with the syntax.  I've read the perldoc on Net::LDAP, and
:>no luck there.

:>Thanks in advance,

:>Davis



-- 
// Lee.Lindley   /// Programmer shortage?  What programmer shortage?
// @bigfoot.com  ///  Only *cheap* programmers are in short supply.
////////////////////    50 cent beers are in short supply too.


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

Date: 27 Jul 1999 21:40:17 GMT
From: lt lindley <ltl@rgsun5.viasystems.com>
Subject: Re: Net::LDAP help
Message-Id: <7nl901$k7a$2@rguxd.viasystems.com>

Davis Ford <forddavi@pilot.msu.edu> wrote:
:>I'm trying to write a script that will spit out an LDAP search, using the
:>Net::LDAP module.

[snip]
Sorry about the double post; my fingers slipped.

I don't recall what led me down this road but last year when I wanted
to do some LDAP, something led me to Net::LDAPapi instead of Net::LDAP.


-- 
// Lee.Lindley   /// Programmer shortage?  What programmer shortage?
// @bigfoot.com  ///  Only *cheap* programmers are in short supply.
////////////////////    50 cent beers are in short supply too.


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

Date: Tue, 27 Jul 1999 14:09:03 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: newby rename problem (help)
Message-Id: <379E1FEE.BB8E0BC1@mail.cor.epa.gov>

stoli wrote:
> 
> I am needing to rename a file that has been uploaded using
> a script, however, I keep getting internal server errors.
>
> the filename that has been uploaded is stored as the
> variable %cgi_cfn{'upload'} which
> contains "c:\windows\desktop\file.exe"
> 
> the file is renamed on the server (someone else wrote this
> script) and the name is stored as %cgi_sfn{'upload'} which
> contains "/home/username/upload/upload.12343.3"
> 
> I need to retain the orignal name form the users computer
> (file.exe) but every iteration of rename gives me errors..

Well, you'll have to show us some code (not much, less than
30 lines, just enough to illustrate the problem), and show us
the error messages you're getting.  Are you checking the errors
from rename() ?  What do they tell you?

A few more points:
[1] this could be a server configuration issue, since web
    servers like to change the environment underneath you;
[2] if you want to keep the old name, you *have* it - it's
    %cgi_cfn{'upload'} and you can save it somewhere
    convenient;
[3] when you use rename(), be sure to print out the value 
    of $! so you can see what the OS is complaining about.

I can't be much more help, since you gave us so little
information in your post.

David
-- 
David Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician


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

Date: Tue, 27 Jul 1999 14:17:16 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: platform independent perl advice
Message-Id: <379E21DC.100323D9@mail.cor.epa.gov>

Marco Cecconi wrote:
> 
> >1) How and what do ya need for crossplatform perl cgi.
> 
> Perl is meant to be x-platform, and it is, except for a few "minor"
> glitches.
> The first that spring to mind are:
> 
> -Are you using file locking (flock())? It is not available on Windows.

Umm, it *is* available on some win32 systems.  WinNT has it.
Win9x does not.  There's a major difference between these
supposedly-similar OSes.

> -What about process spawning (fork())? It is not available on Windows,
> either.

Not yet, anyway.  But ActiveState is working on that one even
as we write.  Look for it Real Soon Now (as Jerry Pournelle
says).

> -What about some system calls like `ls -lR` have to be changed to `dir /s`
>  and also may imply changes in the source code.

Unless you have the Perl Power Tools, or the MKS toolkit, or
some other collection of Unix utilities.  Those still don't
handle the piping and redirection of a real shell, though.

> -Is your progam sending mail through sendmail? You'll need to change that,
>  possibly with a solution using Socket for platform independance.

Well, I wouldn't recommend Socket.pm for this.  There are lots
of modules for handling mail.  And there's even sendmail for NT,
if you want it badly enough.

> >2) are the CPAN modules available
> 
> AFAIK 99% of the CPAN modules work on both platforms, of course you'll need
> to
> compile them... Be warned that some features might be disabled on Windows...

And the percentage is probably well under 99% .  Anything using
fork(), alarm(), the four-variable version of select(), syscall(),
chroot(), link() and symlink(), and a couple dozen (unix-
specific) others will break.

I've found that ActiveState's repository of Perl modules
works extremely well for win32 systems.  Use their ppm
program to check their site first before even considering
building your own.  Why re-invent the wheel if your wheel
isn't going to be an improvement?

David
-- 
David Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician


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

Date: Tue, 27 Jul 1999 13:46:03 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Pretty prompt creation from info in a file...
Message-Id: <r8rkn7.4vl.ln@magna.metronet.com>

Joan Richards (richj@home.com) wrote:

: I've got a question that I'm not exactly sure how it can be solved.


   Just like every other post here.

   That sentence is content-free.


: Here's the problem...let's say that I have a file filled with data that
: might look like this:

: property 222 76 89

: Now, if I want to see the entries that have the "property" tag (first
: portion of the entry in the file).  I will do something like this:

: sub property_info {
:         &show("Available property settings are:\n");
:         open(FL, "$FILE") && do {
:                 while(<FL>) {
:                         &show($_) if /^property/i;
:                 }
:         };
:         close(CNF);
                ^^^
                ^^^ what is that filehandle? ...

: }

: I know I know, i didn't check the return from open.  


   Yes you did (the while loop does not execute if the file could
   not be opened).

   But you didn't output any helpful diagnostic information.


: anyway, this will list all the lines that start with property.  This is
: great, however, when I prompt the user to delete a "property" entry, I
: just run my little function and then have the user type in that entire
: line, and then call a routine that will appropriate remove the line from
: the file.  As you can tell, it is a bit of a pain to type in the entire
: "property" entry in full.  So, I'd like to have an output that looks
: like this:

: (1) property 222 76 89
: (2) property 333 23 11

: and then just hvae the user enter "1" or "2", and then have my routine
: that will appropriate remove this line called and do it's necessary
: work.  Now, understand that hte # of "property" entries will grow and
: shrink, so I need something that is dynamic in figuring out this
: information.

: Does anyone have some ideas on how to do this, or even better some
: sample code/scripts that will help me in doing this?


# UNTESTED
open(FL, "$FILE") || die "could not open '$FILE'  $!";
while (<FL>) {
   push @list, $_ if /^property/i;
}

foreach my $i ( 0..$#list) {
   print "($i) $list[$i]";
}

chomp($ans = <STDIN>);
remove_this_record($list[$ans]);


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


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

Date: Tue, 27 Jul 1999 22:05:42 GMT
From: ryan7879@my-deja.com
Subject: Removing special characters in perl
Message-Id: <7nlafh$q2a$1@nnrp1.deja.com>

I'm new to Perl and I am having trouble removing a "+" character from a
string.  The plus exists because the string has it's value submitted
from one web page to another, so the blank spaces are url encoded.  The
following works for letters or combinations of letters, but fails on the
s/+/ /g; line when a plus sign is involved.  Does anyone know how to get
around this?

Thanks.

for ($a = 0; $a <= $#userwords; $a++) {
    @userwords[$a] = substr(@userwords[$a], 6);
    $_ = @userwords[$a];    s/+/ /g;
    @userwords[$a] = $_;
  }


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: Tue, 27 Jul 1999 17:00:47 -0600
From: Arne Jamtgaard <arnej@fc.hp.com>
To: ryan7879@my-deja.com
Subject: Re: Removing special characters in perl
Message-Id: <379E3A1F.1DAC@fc.hp.com>

ryan7879@my-deja.com wrote:

> I'm new to Perl and I am having trouble removing a "+" character 
> from a string.  The plus exists because the string has it's value
> submitted from one web page to another, so the blank spaces are url
> encoded.  The following works for letters or combinations of letters,
> but fails on the s/+/ /g; line when a plus sign is involved.  Does
> anyone know how to get around this?

Ryan-

	First, to address your problem, you should read up more 
on regular expressions, _particularly_ special characters and 
how to handle them in a literal context.

	Second, read up on the "foreach" statement and you'll
probably find a more perlish, less c-like way of writing your
code.

foreach (@userwords) {
      $_ = substr($_, 6);
      s/\+/ /g;
      }

Arne


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

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


Administrivia:

The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

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


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