[16828] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4240 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Sep 6 18:15:49 2000

Date: Wed, 6 Sep 2000 15:15:31 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <968278531-v9-i4240@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Wed, 6 Sep 2000     Volume: 9 Number: 4240

Today's topics:
        How do I check the length of a scalar? <abatefamily@worldnet.att.net>
    Re: How do I check the length of a scalar? <matt.stoker@motorola.com>
    Re: How do I check the length of a scalar? (Malcolm Dew-Jones)
    Re: How do I check the length of a scalar? <christopher_j@uswest.net>
    Re: How do I check the length of a scalar? <undergronk@my-deja.com>
        how is everyone? <toyboy@toy.eyep.net>
        How to find new page character <np> using Perl <kilminjaroNOSPAM@hotmail.com>
    Re: How to find new page character <np> using Perl <arthur.haas@westgeo.com>
    Re: How to get my IP address as a string <christopher_j@uswest.net>
    Re: How to get my IP address as a string <christopher_j@uswest.net>
    Re: HTML::parse bug <art.13@ntlworld.com>
    Re: IPC::Shareable "Munged shared memory segment" error steinra@my-deja.com
    Re: Monitoring a network <christopher_j@uswest.net>
    Re: newbie: redirect problem <flavell@mail.cern.ch>
    Re: newbie: redirect problem <brian+usenet@smithrenaud.com>
    Re: object version ??? <gellyfish@gellyfish.com>
    Re: parsing an asterisk and bracket <stephenk@cc.gatech.edu>
    Re: parsing an asterisk and bracket <arthur.haas@westgeo.com>
    Re: parsing an asterisk and bracket <uri@sysarch.com>
    Re: parsing an asterisk and bracket <matt.stoker@motorola.com>
    Re: Q. relating to  perlfaq(4) / sort <lr@hpl.hp.com>
    Re: Re-learn Perl <bart.lateur@skynet.be>
    Re: Re-learn Perl <rob@needless.virtualave.net>
        Re:[OT]why does foreach iterate on an undef variable? <matt.stoker@motorola.com>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Wed, 06 Sep 2000 18:53:20 GMT
From: "Abate Family" <abatefamily@worldnet.att.net>
Subject: How do I check the length of a scalar?
Message-Id: <Aowt5.174$LS.8170@bgtnsc05-news.ops.worldnet.att.net>

I want to be able to recieve a username and password from a user through
CGI.  After I get it how do i check to see if the length (how many
characters) is correct?  Any help is very much appreciated.

thanks,
abada723@att.net





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

Date: Wed, 06 Sep 2000 12:19:55 -0700
From: Matthew Stoker <matt.stoker@motorola.com>
Subject: Re: How do I check the length of a scalar?
Message-Id: <39B698DB.6A628BCF@motorola.com>

Abate Family wrote:
> 
> I want to be able to recieve a username and password from a user through
> CGI.  After I get it how do i check to see if the length (how many
> characters) is correct?  Any help is very much appreciated.
> 
> thanks,
> abada723@att.net

perldoc -f length

-- 
/------------------------------------------------------------------\
| Matt Stoker                |     email: matt.stoker@motorola.com |
| Unit Process Modeling      | Mail Drop: M360                     |
| DigitalDNA(TM) Laboratories|     Phone: (480)655-3301            |
| Motorola, SPS              |       Fax: (480)655-5013            |
| 2200 W Broadway Road       |     Pager: (888)699-8803            |
| Mesa, AZ 85202             |                                     |
\------------------------------------------------------------------/


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

Date: 6 Sep 2000 12:39:52 -0800
From: yf110@vtn1.victoria.tc.ca (Malcolm Dew-Jones)
Subject: Re: How do I check the length of a scalar?
Message-Id: <39b69d88@news.victoria.tc.ca>

Abate Family (abatefamily@worldnet.att.net) wrote:
: I want to be able to recieve a username and password from a user through
: CGI.  After I get it how do i check to see if the length (how many
: characters) is correct?  Any help is very much appreciated.

perldoc perlfunc.pod

read the whole thing, its full of useful details,

the entry you want may be length(), though the data you get may have other
things to check - m//  (perldoc perlop)  may also help.



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

Date: Wed, 6 Sep 2000 12:50:22 -0700
From: "Christopher M. Jones" <christopher_j@uswest.net>
Subject: Re: How do I check the length of a scalar?
Message-Id: <Xdxt5.2826$Xq2.242229@news.uswest.net>


"Abate Family" <abatefamily@worldnet.att.net> wrote:
> I want to be able to recieve a username and password from a user through
> CGI.  After I get it how do i check to see if the length (how many
> characters) is correct?  Any help is very much appreciated.


You won't believe this, but, length($var)

For example:

if ( length($var) > 0 && length($var) < $maxlen )
    {
    # do the regular shtuff
    }
else
    {
    # reject username / passwd or whatever
    }





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

Date: Wed, 06 Sep 2000 19:51:07 GMT
From: Scott Kirk <undergronk@my-deja.com>
Subject: Re: How do I check the length of a scalar?
Message-Id: <8p6772$a81$1@nnrp1.deja.com>

In article <Aowt5.174$LS.8170@bgtnsc05-news.ops.worldnet.att.net>,
  "Abate Family" <abatefamily@worldnet.att.net> wrote:
> I want to be able to receive a username and password from a user
> through CGI.  After I get it how do i check to see if the length (how
> many characters) is correct?  Any help is very much appreciated.

You could use the length function ;-)

--
Scott Kirk
My deja.com mailbox is full of spam. Use this instead:
perl -e '$_ = "znvygb: haqretebax\@lnubb.pbz";
tr/A-Za-z/N-ZA-Mn-za-m/; print;'


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Wed, 06 Sep 2000 17:53:00 -0400
From: toy <toyboy@toy.eyep.net>
Subject: how is everyone?
Message-Id: <39B6BCBC.9ED2986B@toy.eyep.net>

long time no see all.  How is everyone?



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

Date: Wed, 06 Sep 2000 15:33:23 -0500
From: Adnan <kilminjaroNOSPAM@hotmail.com>
Subject: How to find new page character <np> using Perl
Message-Id: <39B6AA13.64A36D6F@hotmail.com>

Hello all,

 I have a plain text file with a new page character represented as <np>
I would like to use a perl script to replace or remove it.

I do not know how to represent this new page character in perl.
Coding it as  < n p and > does not work.

Please advice. I am on an HP-UX workstation.

Thanks in advance.

Adnan




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

Date: 06 Sep 2000 15:59:38 -0500
From: Art Haas <arthur.haas@westgeo.com>
Subject: Re: How to find new page character <np> using Perl
Message-Id: <lrog21kzid.fsf@h130p254.wg.waii.com>

Adnan <kilminjaroNOSPAM@hotmail.com> writes:

> Hello all,
> 
>  I have a plain text file with a new page character represented as <np>
> I would like to use a perl script to replace or remove it.
> 
> I do not know how to represent this new page character in perl.
> Coding it as  < n p and > does not work.
> 
> Please advice. I am on an HP-UX workstation.
> 
> Thanks in advance.
> 

If you post your code, we can help you fix it.

Nevertheless, here's something that MIGHT do what you want.

$ cat junk.pl
#!/usr/local/bin/perl
use strict;

my $file = '/your/file/here';
open(FILE,"<$file") || die "Can't open `$file'! $!\n";
while(<FILE>) {
	if (m!\<np\>!) {
		s/\<np\>//;
	}
	print;
}
$ perl junk.pl > junk.out

`junk.out' should have no `<np>' strings in it.

-- 
###############################
# Art Haas
# (713) 689-2417
###############################


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

Date: Wed, 6 Sep 2000 11:08:17 -0700
From: "Christopher M. Jones" <christopher_j@uswest.net>
Subject: Re: How to get my IP address as a string
Message-Id: <eKvt5.2328$Xq2.193168@news.uswest.net>


"Jonaskuh" <jonaskuh@tell-em-off.com> wrote:
> If you are talking about just retrieving it when using perl with a
> webserver, just do the following:
>
> $ipstring = $ENV{'REMOTE_ADDR'};
>
> That'll do it.

WRONG!!

That is the ip address of the client, what is needed is

$ENV{'SERVER_ADDR'};


and,
$ENV{'HTTP_HOST'};
will return the full host (+domain) name





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

Date: Wed, 6 Sep 2000 11:15:50 -0700
From: "Christopher M. Jones" <christopher_j@uswest.net>
Subject: Re: How to get my IP address as a string
Message-Id: <kRvt5.2366$Xq2.196739@news.uswest.net>


"Christopher M. Jones" <christopher_j@uswest.net> wrote:
> $ENV{'SERVER_ADDR'};

BTW, That is for if your script is running as a cgi program under
a webserver.

If you are running a plain old standalone perl script, you can
use gethostbyname(), but remember that the address is packed
(IOW it returns the 32-bit integer version of the ip).  Use

$addy = join '.', unpack('C4', gethostbyname());

For an address in a more familiar form.





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

Date: Wed, 06 Sep 2000 20:38:41 +0100
From: "art.13" <art.13@ntlworld.com>
Subject: Re: HTML::parse bug
Message-Id: <39B69D41.A83A03AC@ntlworld.com>


--------------7587B60D0C2EABF260FC1B5A
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Just thought this is small and will probable do the same.

I am at home though and have not tested it!

use diagnostics;
use HTML::TokeParser;
use POSIX qw(:sys_wait_h);

my $token;
my $i = 1;

while  ($i < 5) {

   $SIG{CHLD} = \&REAPER;
   next if $pid = fork;
   die "fork: $!" unless defined $pid;

   my $fileName = "menu$num.html";
   my $p = HTML::TokeParser->new($fileName);
   $token = $p->get_tag("a") while

   print "done $fileName\n";


   exit();

} continue {

   $i++;

}

sub REAPER {
    1 until (-1 == waitpid (-1, WNOHANG) );
    $SIG{CHLD} = \&REAPER;
}

Tim Cockle wrote:

> Here is some test code:
>
> use diagnostics;
> use IO::Socket;
> use HTML::TokeParser;
> use IO::File;
> use POSIX qw(:sys_wait_h);
>
> my $i = 1;
>
> while  ($i < 5) {
>
>    $SIG{CHLD} = \&REAPER;
>    next if $pid = fork;
>    die "fork: $!" unless defined $pid;
>
>    &DO_STUFF($i);
>
>    exit();
>
> } continue {
>
>    $i++;
>
> }
>
> sub DO_STUFF {
>
>    my $num = shift;
>    my %found;
>    my $token;
>    my $fileName = "menu$num.html";
>
>    open($FILE, $fileName) || die "Couldn't open $fileName\n";
>
>    my $p = HTML::TokeParser->new($FILE);
>
>    while ($token = $p->get_tag("a")) {
>
>       my $url = $token->[3] || "";
>
>       if ( (exists $token->[1]{href}) and ($token->[1]{href} !~ /^mailto/i)) {
>          if ( 1 ) {
>             $text = "\<img border=\"0\"
> src=\"http://www.soc.staffs.ac.uk/~cmrtc/tick.gif\"\>";
>             $text .= $url;
>             unless (exists ($found{$url}) ) {$found{$url} = $text;};
>          }
>       }
>    }
>
>    close($FILE) || die "I can't close $fileName";
>    print "done $fileName\n";
> }
>
> sub REAPER {
>     1 until (-1 == waitpid (-1, WNOHANG) );
>     $SIG{CHLD} = \&REAPER;
> }
>
> I use NT by the way so this may be a platform dependence issue.
>
> Perl Version Info:
> This is perl, v5.6.0 built for MSWin32-x86-multi-thread
> (with 1 registered patch, see perl -V for more detail)
>
> Copyright 1987-2000, Larry Wall
>
> Binary build 613 provided by ActiveState Tool Corp. http://www.ActiveState.com
> Built 12:36:25 Mar 24 2000
>
> Hope you can help!
>
> Tim
>
> Gisle Aas wrote:
>
> > Tim Cockle <T.Cockle@staffs.ac.uk> writes:
> >
> > > I don't use it directly there is a reference from HTML::TokeParser.
> > >
> > > But I have looked at the TokeParser (get_token) and the failure occurs in the
> > > HTML::Parse code.
> >
> > How does it crash?  Are you able to reduce it to a little test program
> > that you can share?
> >
> > > jason wrote:
> > >
> > > > Tim Cockle <T.Cockle@staffs.ac.uk> wrote ..
> > > > >I have found a bug somwwhere in HTML::parse. I have written a simple
> > > > >server wich works fine. However if I convert it into a forking server it
> > > > >crashes out.
> > > > >
> > > > >Does this sound fermular to anyone?
> > > > >
> > > > >If no one has seen this problem don't worry. I going to restart my
> > > > >investigation into the bug so will be able to proved a much better
> > > > >description shortly.
> > > >
> > > > before you start .. you should be aware that HTML::Parse is deprecated
> > > > .. you should be using HTML::Parser
> >
> > --
> > Gisle Aas
>
> --
>
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> Mr. T. P. Cockle M.Sc. B.Sc. (hons) Pg.D.                 Ph.D. Representative
>
> Research (Distributed Computer Systems)
> School of Computing,
> Staffordshire University,
> Stafford ST18 0DG.
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

--------------7587B60D0C2EABF260FC1B5A
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit

<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
Just thought this is small and will probable do the same.
<p>I am at home though and have not tested it!
<p>use diagnostics;
<br>use HTML::TokeParser;
<br>use POSIX qw(:sys_wait_h);
<p>my $token;
<br>my $i = 1;
<p>while&nbsp; ($i &lt; 5) {
<p>&nbsp;&nbsp; $SIG{CHLD} = \&amp;REAPER;
<br>&nbsp;&nbsp; next if $pid = fork;
<br>&nbsp;&nbsp; die "fork: $!" unless defined $pid;
<p>&nbsp;&nbsp; my $fileName = "menu$num.html";
<br>&nbsp;&nbsp; my $p = HTML::TokeParser->new($fileName);
<br>&nbsp;&nbsp; $token = $p->get_tag("a") while
<p>&nbsp;&nbsp; print "done $fileName\n";
<br>&nbsp;
<p>&nbsp;&nbsp; exit();
<p>} continue {
<p>&nbsp;&nbsp; $i++;
<p>}
<p>sub REAPER {
<br>&nbsp;&nbsp;&nbsp; 1 until (-1 == waitpid (-1, WNOHANG) );
<br>&nbsp;&nbsp;&nbsp; $SIG{CHLD} = \&amp;REAPER;
<br>}
<p>Tim Cockle wrote:
<blockquote TYPE=CITE>Here is some test code:
<p>use diagnostics;
<br>use IO::Socket;
<br>use HTML::TokeParser;
<br>use IO::File;
<br>use POSIX qw(:sys_wait_h);
<p>my $i = 1;
<p>while&nbsp; ($i &lt; 5) {
<p>&nbsp;&nbsp; $SIG{CHLD} = \&amp;REAPER;
<br>&nbsp;&nbsp; next if $pid = fork;
<br>&nbsp;&nbsp; die "fork: $!" unless defined $pid;
<p>&nbsp;&nbsp; &amp;DO_STUFF($i);
<p>&nbsp;&nbsp; exit();
<p>} continue {
<p>&nbsp;&nbsp; $i++;
<p>}
<p>sub DO_STUFF {
<p>&nbsp;&nbsp; my $num = shift;
<br>&nbsp;&nbsp; my %found;
<br>&nbsp;&nbsp; my $token;
<br>&nbsp;&nbsp; my $fileName = "menu$num.html";
<p>&nbsp;&nbsp; open($FILE, $fileName) || die "Couldn't open $fileName\n";
<p>&nbsp;&nbsp; my $p = HTML::TokeParser->new($FILE);
<p>&nbsp;&nbsp; while ($token = $p->get_tag("a")) {
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; my $url = $token->[3] || "";
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if ( (exists $token->[1]{href}) and ($token->[1]{href}
!~ /^mailto/i)) {
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if ( 1 ) {
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
$text = "\&lt;img border=\"0\"
<br>src=\"<a href="http://www.soc.staffs.ac.uk/~cmrtc/tick.gif\" \">http://www.soc.staffs.ac.uk/~cmrtc/tick.gif\"\</a>>";
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
$text .= $url;
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
unless (exists ($found{$url}) ) {$found{$url} = $text;};
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }
<br>&nbsp;&nbsp; }
<p>&nbsp;&nbsp; close($FILE) || die "I can't close $fileName";
<br>&nbsp;&nbsp; print "done $fileName\n";
<br>}
<p>sub REAPER {
<br>&nbsp;&nbsp;&nbsp; 1 until (-1 == waitpid (-1, WNOHANG) );
<br>&nbsp;&nbsp;&nbsp; $SIG{CHLD} = \&amp;REAPER;
<br>}
<p>I use NT by the way so this may be a platform dependence issue.
<p>Perl Version Info:
<br>This is perl, v5.6.0 built for MSWin32-x86-multi-thread
<br>(with 1 registered patch, see perl -V for more detail)
<p>Copyright 1987-2000, Larry Wall
<p>Binary build 613 provided by ActiveState Tool Corp. <a href="http://www.ActiveState.com">http://www.ActiveState.com</a>
<br>Built 12:36:25 Mar 24 2000
<p>Hope you can help!
<p>Tim
<p>Gisle Aas wrote:
<p>> Tim Cockle &lt;T.Cockle@staffs.ac.uk> writes:
<br>>
<br>> > I don't use it directly there is a reference from HTML::TokeParser.
<br>> >
<br>> > But I have looked at the TokeParser (get_token) and the failure
occurs in the
<br>> > HTML::Parse code.
<br>>
<br>> How does it crash?&nbsp; Are you able to reduce it to a little test
program
<br>> that you can share?
<br>>
<br>> > jason wrote:
<br>> >
<br>> > > Tim Cockle &lt;T.Cockle@staffs.ac.uk> wrote ..
<br>> > > >I have found a bug somwwhere in HTML::parse. I have written
a simple
<br>> > > >server wich works fine. However if I convert it into a forking
server it
<br>> > > >crashes out.
<br>> > > >
<br>> > > >Does this sound fermular to anyone?
<br>> > > >
<br>> > > >If no one has seen this problem don't worry. I going to restart
my
<br>> > > >investigation into the bug so will be able to proved a much
better
<br>> > > >description shortly.
<br>> > >
<br>> > > before you start .. you should be aware that HTML::Parse is deprecated
<br>> > > .. you should be using HTML::Parser
<br>>
<br>> --
<br>> Gisle Aas
<p>--
<p>~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<br>Mr. T. P. Cockle M.Sc. B.Sc. (hons) Pg.D.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
Ph.D. Representative
<p>Research (Distributed Computer Systems)
<br>School of Computing,
<br>Staffordshire University,
<br>Stafford ST18 0DG.
<br>~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~</blockquote>
</html>

--------------7587B60D0C2EABF260FC1B5A--



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

Date: Wed, 06 Sep 2000 20:16:11 GMT
From: steinra@my-deja.com
Subject: Re: IPC::Shareable "Munged shared memory segment" errors
Message-Id: <8p68ln$caf$1@nnrp1.deja.com>


> I've had no luck at all sharing hashes with IPC::Shareable.  When I
insert
> or delete to a hash in one process, the change isn't seen in other
processes
> that are sharing the hash.  When I posted about this last week (with
code
> showing the problem, reproduced here), I saw no responses.  Are you at
least
> getting farther than I am?
>
> Thanks,
> Joe

I am having a similar problem.  I think I have isolated it to the way
version .30 of Shareable handled hashes compared to .51.


In .30 Shareable here is the HASH STORE code

      if ($type eq 'HASH') {
          # --- If the user appears to be in the middle of some kind of
iteration
          # --- we update the local cache only and return immediately
          if ($Shm_Info{$$variable}{'hash_iterating'}) {
              $Shm_Info{$$variable}{'DATA'}{'user'}{$key} = $value;
          }

          # --- Now we make our change.  If $key was supplied, we assume
that we're
          # --- making an incremental change and our value is simply
merged with
          # --- any existing values.  If $key was not supplied, we
assume
          # --- that a wholesale change is being made and our (cached)
hash represents
          # --- the authoritative record.
          ($key, $value) = @args;
          if (defined $key) {
              debug "making incremental change to HASH" if ($Debug);
              # --- Incremental change: fetch the most recent public
version.
              FETCH($variable);
              $Shm_Info{$$variable}{'DATA'}{'user'}{$key} = $value;
          } else {
              debug "making wholesale change to HASH" if ($Debug);
              # --- Wholesale change; ignore any existing public
version.
              1;
          }
          last TYPE;
      }



In .51 the HASH STORE code

      if ($self->{_type} eq 'HASH') {
          my $key = shift;
          my $val = shift;
          _mg_tie($self => $val) if _need_tie($val);
          $self->{_data}->{$key} = $val;
          last TYPE;
      }


In .51 (unless I have missed something) this will cause the currently
cached hash value to be written back out.  So it will destroy changes
that other processes may have made to the hash.


In .30 it would actually sync the data in shared memory with the cached
values prior to making changes.

The test program I have works with the .30 Shareable on perl 5.005 and
fails with Shareable .51 on perl 5.6.

I was in the process of upgrading when I was hit with this problem.

There may be other syncronization problems that I am missing to when
releating to hashes.

Any thoughts?

Thanks!

Randy


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Wed, 6 Sep 2000 11:57:10 -0700
From: "Christopher M. Jones" <christopher_j@uswest.net>
Subject: Re: Monitoring a network
Message-Id: <7swt5.2581$Xq2.215741@news.uswest.net>


"Willy Wally" <paolo.ercy@tin.it> wrote:
> I'm writing a perl cgi for pinging hosts and checking unix daemons without
> using the "ps" unix command. Does anyone know if (and where) i can find
> something for doing this in perl??
>
> Thanks to everyone.

Use a raw socket connection to connect to the ports and see what
they spit out.




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

Date: Wed, 6 Sep 2000 20:03:24 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: newbie: redirect problem
Message-Id: <Pine.GHP.4.21.0009062001500.8800-100000@hpplus03.cern.ch>

On 6 Sep 2000, Anthony Peacock wrote:

> >print "Location: http://www.newlocation.com\n\n";

> Or even better:
> 
> print "Location: http://www.newlocation.com/\n\n";

Why do you suppose so?  

(not that this is a Perl language issue anyway; but if you're going to
offer off-topic contradictions, they need to be good ones).



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

Date: Wed, 06 Sep 2000 16:14:23 -0400
From: brian d foy <brian+usenet@smithrenaud.com>
Subject: Re: newbie: redirect problem
Message-Id: <brian+usenet-9EBCE5.16142306092000@news.panix.com>

In article <Pine.GHP.4.21.0009062001500.8800-100000@hpplus03.cern.ch>, 
"Alan J. Flavell" <flavell@mail.cern.ch> wrote:

> On 6 Sep 2000, Anthony Peacock wrote:
> 
> > >print "Location: http://www.newlocation.com\n\n";
> 
> > Or even better:
> > 
> > print "Location: http://www.newlocation.com/\n\n";
> 
> Why do you suppose so?  

of course, they are equivalent.  the HTTP request line
ends up looking the same, unless your user-agent makes
non-compliant request lines.

-- 
brian d foy
Perl Mongers <URL:http://www.perl.org>
CGI Meta FAQ <URL:http://www.smithrenaud.com/public/CGI_MetaFAQ.html>


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

Date: 6 Sep 2000 06:56:53 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: object version ???
Message-Id: <8p4mb5$qqv$1@orpheus.gellyfish.com>

On Tue, 05 Sep 2000 18:17:20 GMT thomaskoehn@my-deja.com wrote:
> Hi,
> 
> today I have compiled perl 5.6.0 with several modules
> (DBI,ExtUtils,Getopt) to be able to use a mysql Database with Perl.
> I was able to compile everything but now I always get a error message
> when I try to use the module.
> 
> install_driver(mysql) failed: DBD::mysql object version 2.0415 does not
> match bootstrap parameter 2.0414 at /usr/local/lib/perl5/5.6.0/sun4-
> solaris/DynaLoader.pm line 219.
> 

It appears you have bits of two versions of DBD::mysql mixed up - I would
attempt to reinstall the newer one - when you do 'make install' you will
probably told about the presence of any files you should delete. 

/J\

-- 
yapc::Europe in assocation with the Institute Of Contemporary Arts
   <http://www.yapc.org/Europe/>   <http://www.ica.org.uk>


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

Date: Wed, 06 Sep 2000 14:07:22 -0400
From: Stephen Kloder <stephenk@cc.gatech.edu>
Subject: Re: parsing an asterisk and bracket
Message-Id: <39B687D9.D568B9A6@cc.gatech.edu>

JakeRocket wrote:

> I am having probs on a search and replace in a file I am trying to
> modify.
>
> usng the following line in a while loop chokes
> $myline =~ s/\[\//g;
>
> I am trying to nuke the bracket, but the script retruns an error about
> the missing right bracket.
>

What's that second \ doing there?  Use s/\[//g .


> Also, I am having a hard time finding the proper way to remove an
> asterisk in the same manner.

For removing asterisks, replace the [ with a * in the above s///

perldoc perlre

--
Stephen Kloder               |   "I say what it occurs to me to say.
stephenk@cc.gatech.edu       |      More I cannot say."
Phone 404-874-6584           |   -- The Man in the Shack
ICQ #65153895                |            be :- think.




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

Date: 06 Sep 2000 13:06:28 -0500
From: Art Haas <arthur.haas@westgeo.com>
Subject: Re: parsing an asterisk and bracket
Message-Id: <lru2btl7iz.fsf@h130p254.wg.waii.com>

JakeRocket <rocket@acme.com> writes:

> I am having probs on a search and replace in a file I am trying to
> modify.
> 
> usng the following line in a while loop chokes 
> $myline =~ s/\[\//g;
> 

You're missing another `/' in the substitution above ...

$myline =~ s/\[\///g;

 ... but you probably want to do it like this ...

$myline =~ s/[\[\/]//g;

> I am trying to nuke the bracket, but the script retruns an error about
> the missing right bracket.
> 
> Also, I am having a hard time finding the proper way to remove an
> asterisk in the same manner.

It's sometimes easier to use another character than `/' ...

$myline =~ s![\[\/\*]!!g;

You should also check the documentation about the `tr' command.

-- 
###############################
# Art Haas
# (713) 689-2417
###############################


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

Date: Wed, 06 Sep 2000 18:13:43 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: parsing an asterisk and bracket
Message-Id: <x7ya15jsmh.fsf@home.sysarch.com>

>>>>> "AH" == Art Haas <arthur.haas@westgeo.com> writes:

  AH> It's sometimes easier to use another character than `/' ...

  AH> $myline =~ s![\[\/\*]!!g;

no need for any of the \ there. if the [ is the first or last char in
the class it doesn't need escaping. the / doesn't need it since you
changed the delimiters. * is not special in a char class. in fact very
few chars are special there unlike elsewhere in a regex. it is useful to
know the difference.

these both work fine:

	s|[[/*]||g
	s|[/*[]||g

and as you said tr is a faster solution for deleting individual
characters.

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page  -----------  http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net  ----------  http://www.northernlight.com


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

Date: Wed, 06 Sep 2000 11:21:13 -0700
From: Matthew Stoker <matt.stoker@motorola.com>
Subject: Re: parsing an asterisk and bracket
Message-Id: <39B68B19.E07D18E0@motorola.com>

JakeRocket wrote:
> 
> I am having probs on a search and replace in a file I am trying to
> modify.
> 
> usng the following line in a while loop chokes
> $myline =~ s/\[\//g;
                 ^
                 This is your problem.

You want:

$myline =~ s/\[//g;

You only need "\" before the character you are escaping, not after! Perl
thinks you are also escaping "/" which is the cause of the error.

> 
> I am trying to nuke the bracket, but the script retruns an error about
> the missing right bracket.
> 
> Also, I am having a hard time finding the proper way to remove an
> asterisk in the same manner.

-- 
/------------------------------------------------------------------\
| Matt Stoker                |     email: matt.stoker@motorola.com |
| Unit Process Modeling      | Mail Drop: M360                     |
| DigitalDNA(TM) Laboratories|     Phone: (480)655-3301            |
| Motorola, SPS              |       Fax: (480)655-5013            |
| 2200 W Broadway Road       |     Pager: (888)699-8803            |
| Mesa, AZ 85202             |                                     |
\------------------------------------------------------------------/


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

Date: Wed, 6 Sep 2000 11:07:04 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Q. relating to  perlfaq(4) / sort
Message-Id: <MPG.142027a0f2ec628198ad26@nntp.hpl.hp.com>

In article <lta2rsk6r0bn51vqnk78lhdtudft4j9kld@4ax.com> on Sat, 02 Sep 
2000 18:43:52 +0200, Abe Timmerman <abe@ztreet.demon.nl> says...
> On Sat, 02 Sep 2000 14:54:59 GMT, kcivey@cpcug.org (Keith Calvert Ivey)
> wrote:
> 
> > Abe Timmerman <abe@ztreet.demon.nl> wrote:
> > 
> > >This might not be the best way, but it does the job.

 ...

> > >#!/usr/bin/perl -w
> > >use strict;
> > >
> > >my @data = (
> > >    '123.342',
> > >    '-23234',
> > >    '2347872347878273878984527636598264368234',
> > >    '1234878234' x 100,
> > >    '-' . '23423423' x 50,
> > >);

<SNIP lots of string manipulations>

I've been watching this thread evolve for about a week, and wondering 
what problem you all are trying to solve.  Apparently you are trying to 
sort by numerical value strings of arbitrary length that seem to 
represent floating-point numbers, using the GRT.  While perhaps 
interesting, this bears little relation to reality.  One can sort those 
strings using double-precision floating-point representation.  That is 
certainly adequate for most data sets, including the test case shown 
above.

Here is all it takes, copied verbatim from the paper:


BEGIN {
  my $big_endian = pack('N', 1) eq pack('L', 1);
  sub double_sort ($) {
    ($big_endian ? pack 'd', $_[0] :
      reverse pack 'd', $_[0]) ^
      ($_[0] < 0 ? "\xFF" x 8 : "\x80" . "\x00" x 7)
  }
}

my @orderd = map substr($_, 8) => sort
	map { double_sort($_) . $_ } @data;
	
print "$_\n\n" for @orderd;

__END__

Here is another way of coding it, which is more verbose but slightly 
more efficient, because the endian test isn't repeated for each 
comparison:

my $double_sort = pack(N => 1) eq pack(L => 1) ?
      sub { (pack d => $_[0]) ^
          ($_[0] < 0 ? "\xFF" x 8 : "\x80" . "\x00" x 7) } :
      sub { (reverse pack d => $_[0]) ^
          ($_[0] < 0 ? "\xFF" x 8 : "\x80" . "\x00" x 7) } ;

my @orderd = map substr($_, 8) => sort
	map { $double_sort->($_) . $_ } @data;

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


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

Date: Wed, 06 Sep 2000 21:14:00 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Re-learn Perl
Message-Id: <utbdrsog5tnrl32jms44gh5v2j477les26@4ax.com>

P.Eftevik wrote:

>I used to program perl (4.0), but it's some years ago now.
>And now it's time to code perl again, so I need to re-learn what I've
>spent 6-7 years to forget.
>
>In addition, the language has probably evolved significantly over
>this period.

You bet. Perl has grwon into a whole different ballgame since Perl4.
Most notable additions: modules (compile-time require()) and references,
useful for building tree-like data structures.

As for relearning: Do not assume you know this language. Simply start
anew as if you're completely new to it.

>Question: where do I find a 'Quick reference Guide' and some brief
>code samples and other hints to freshen up my prior skill ?

Eh... A very complete reference is included with each perl distribution.
An online version is available at:

	<http://www.perl.com/pub/v/documentation>


In my mind, the learning curve is a bit steep. Try borrowing ( ;-) the
book "Learning Perl" by Randal Schwartz et al. A lot easier.

Oh, and the links section at <www.perl.com> has quite a few nice
pointers.

-- 
	Bart.


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

Date: Wed, 06 Sep 2000 16:18:54 -0500
From: Rob VanFleet <rob@needless.virtualave.net>
Subject: Re: Re-learn Perl
Message-Id: <p1ddrs0kp7hki8qior1vnoop0sug8rnaec@4ax.com>

>P.Eftevik wrote:
[snip]
>Question: where do I find a 'Quick reference Guide' and some brief
>code samples and other hints to freshen up my prior skill ?

Two Oreilly books come to mind: Perl in a Nutshell and The Perl
Cookbook, respectively.


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

Date: Wed, 06 Sep 2000 12:17:01 -0700
From: Matthew Stoker <matt.stoker@motorola.com>
Subject: Re:[OT]why does foreach iterate on an undef variable?
Message-Id: <39B6982D.556B0C64@motorola.com>

Louise Davis wrote:
> 
> Martien Verbruggen <mgjv@tradingpost.com.au> wrote in message
> news:slrn8rc90h.ucf.mgjv@martien.heliotrope.home...
> > [please, in the future, put your followup text AFTER the text you
> > respond to. Also, don't respond twice to your own message.
> 
> I'll remember that but I don't think I will be posting again - not after
> this !

Don't let them ruffle your feathers!  It doesn't take too much reading
of this newsgroup to realize that some of the posters have spent far too
many hours debugging their latest entry in the obfuscated perl contest.
:,)

We'd kick them out, but then we'd be flooded with requests such as:

"I need a perl script to wake me up in the morning, wash my clothes,
make me breakfast, and then go to work for me.  Please send completed
source and documentation to lazy_me@deja.com -- Thanks in advance" 

> 
> > Rather: think
> > the problem through a bit better before posting, so you don't have to
> > post as much. One followup to yourself is acceptable, two is a bit much]
> 
> Sorry - I don't understand this - I only posted once and this is my only
> follow up.
> 

Don't worry about it, I think he was just confused.

If you made it this far in my post, please excuse this brief
interruption of traffic on the information superhighway.

-- 
/------------------------------------------------------------------\
| Matt Stoker                |     email: matt.stoker@motorola.com |
| Unit Process Modeling      | Mail Drop: M360                     |
| DigitalDNA(TM) Laboratories|     Phone: (480)655-3301            |
| Motorola, SPS              |       Fax: (480)655-5013            |
| 2200 W Broadway Road       |     Pager: (888)699-8803            |
| Mesa, AZ 85202             |                                     |
\------------------------------------------------------------------/


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

Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 16 Sep 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.  

| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

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.

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


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