[23325] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5545 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Sep 22 21:05:58 2003

Date: Mon, 22 Sep 2003 18:05:07 -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           Mon, 22 Sep 2003     Volume: 10 Number: 5545

Today's topics:
        [Simple] Function arguments and return value (Gao Chao)
    Re: [Simple] Function arguments and return value <zoooz@gmx.de>
        Can't locate POE.pm in @INC (Michael Evanchik)
    Re: Can't locate POE.pm in @INC <bdonlan@users.sf.net>
    Re: CGI.pm <notavailable@nospamplease.com>
    Re: length of the longest $_ in @_ <cs@edu.edu>
    Re: length of the longest $_ in @_ (Jay Tilton)
        Perl: how to stop users from executing commands from br (Nick)
    Re: Perl: how to stop users from executing commands fro <tony_curtis32@yahoo.com>
    Re: Perl: how to stop users from executing commands fro (laura fairhead)
    Re: PPM problems <notavailable@nospamplease.com>
    Re: Sending html mail with inline images <noreply@gunnar.cc>
    Re: Stupid perl regexp question <uri@stemsystems.com>
    Re: Stupid perl regexp question <ddunham@redwood.taos.com>
    Re: Stupid perl regexp question <notavailable@nospamplease.com>
    Re: Stupid perl regexp question <pinyaj@rpi.edu>
    Re: Using variables in RegEx statements? <NoSpamPlease@bellsouth.net>
    Re: Using variables in RegEx statements? <abigail@abigail.nl>
    Re: Using variables in RegEx statements? <NoSpamPlease@bellsouth.net>
    Re: Using variables in RegEx statements? <NoSpamPlease@bellsouth.net>
    Re: Using variables in RegEx statements? <mgjv@tradingpost.com.au>
    Re:  <bwalton@rochester.rr.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 22 Sep 2003 16:54:56 -0700
From: gaochao@voila.fr (Gao Chao)
Subject: [Simple] Function arguments and return value
Message-Id: <c5a22ad.0309221554.6f1b32e8@posting.google.com>

I don't know how to write a function with arguments and return values
that are not scalars. I have learn to write something like

sub foo {
  my $arg1 = shift;
  my $arg2 = shift;

  return $bar;
}

but I cannot pass lists or file handles like that. Can somebody
explain me how to pass lists and file handles as arguments and return
values of a function?

Thanks!

GC


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

Date: Tue, 23 Sep 2003 02:31:25 +0200
From: Amir Kadic <zoooz@gmx.de>
Subject: Re: [Simple] Function arguments and return value
Message-Id: <bko4ge$402s1$1@ID-142982.news.uni-berlin.de>

Gao Chao wrote:

> but I cannot pass lists or file handles like that. Can somebody
> explain me how to pass lists and file handles as arguments and return
> values of a function?

You can pass (and return) lists by reference:

sub foo {
   my $arrayref= shift;

   print $$arrayref[0];
   return $arrayref;
}


If you don't want to write $$arrayref all the time, you
can create local aliases, like this:

sub foo {
   local (*array1,*array2,...) = @_; # can't use 'my' here

   print @array1[0];
}

but you still have to pass array _references_ to the sub.

Filehandles can be 'passed' by passing typeglobs:

sub write {
  local *GLOB= shift;
  my @otherparameters= @_;

  print GLOB @otherparameters;
}

write *STDIN,1,2,3;

You can also use references to typeglobs, the IO:File module, etc...


HTH
Amir

        


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

Date: 22 Sep 2003 15:58:37 -0700
From: mike@high-pow-er.com (Michael Evanchik)
Subject: Can't locate POE.pm in @INC
Message-Id: <36194296.0309221458.7fe3ce23@posting.google.com>

Hi i installed perl-POE and when in test a pearl script this is my
error.

[root@localhost POE-Component-IRC-2.9]# make test
PERL_DL_NONLAZY=1 /usr/bin/perl "-Iblib/lib" "-Iblib/arch" test.pl
1..1
Can't locate POE.pm in @INC (@INC contains: blib/lib blib/arch
/usr/lib/perl5/5.8.0/i386-linux-thread-multi /usr/lib/perl5/5.8.0
/usr/lib/perl5/site_perl/5.8.0/i386-linux-thread-multi
/usr/lib/perl5/site_perl/5.8.0 /usr/lib/perl5/site_perl
/usr/lib/perl5/vendor_perl/5.8.0/i386-linux-thread-multi
/usr/lib/perl5/vendor_perl/5.8.0 /usr/lib/perl5/vendor_perl
/usr/lib/perl5/5.8.0/i386-linux-thread-multi /usr/lib/perl5/5.8.0 .)
at blib/lib/POE/Component/IRC.pm line 14.
BEGIN failed--compilation aborted at blib/lib/POE/Component/IRC.pm
line 14.
Compilation failed in require at test.pl line 12.
BEGIN failed--compilation aborted at test.pl line 12.
make: *** [test_dynamic] Error 2

Anyone know what i should look for or do.
Thanks for your help in advance.


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

Date: Mon, 22 Sep 2003 19:35:26 -0400
From: bd <bdonlan@users.sf.net>
Subject: Re: Can't locate POE.pm in @INC
Message-Id: <0jd441-351.ln1@bd-home-comp.no-ip.org>

Michael Evanchik wrote:

> Hi i installed perl-POE and when in test a pearl script this is my
> error.
> 
> [root@localhost POE-Component-IRC-2.9]# make test
> PERL_DL_NONLAZY=1 /usr/bin/perl "-Iblib/lib" "-Iblib/arch" test.pl
> 1..1
> Can't locate POE.pm in @INC (@INC contains: blib/lib blib/arch
> /usr/lib/perl5/5.8.0/i386-linux-thread-multi /usr/lib/perl5/5.8.0
> /usr/lib/perl5/site_perl/5.8.0/i386-linux-thread-multi
> /usr/lib/perl5/site_perl/5.8.0 /usr/lib/perl5/site_perl
> /usr/lib/perl5/vendor_perl/5.8.0/i386-linux-thread-multi
> /usr/lib/perl5/vendor_perl/5.8.0 /usr/lib/perl5/vendor_perl
> /usr/lib/perl5/5.8.0/i386-linux-thread-multi /usr/lib/perl5/5.8.0 .)
> at blib/lib/POE/Component/IRC.pm line 14.
> BEGIN failed--compilation aborted at blib/lib/POE/Component/IRC.pm
> line 14.
> Compilation failed in require at test.pl line 12.
> BEGIN failed--compilation aborted at test.pl line 12.
> make: *** [test_dynamic] Error 2
> 
> Anyone know what i should look for or do.
> Thanks for your help in advance.

You're apparently trying to install the POE::Component::IRC module. However,
first you need to install the POE module. Get it from cpan.org, or use
'cpan POE' to install it. Then restart the POE::Component::IRC module
installation.
-- 
More are taken in by hope than by cunning.
                -- Vauvenargues



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

Date: Mon, 22 Sep 2003 22:41:13 +0100
From: "D Borland" <notavailable@nospamplease.com>
Subject: Re: CGI.pm
Message-Id: <11Kbb.860$pz4.2687520@newsfep1-win.server.ntli.net>

OK, dudes i understand - I'm a lazy git, and i really gotta get my head out
my arse and in gear!

Maybe not in those exact words, but i understand.

Thanks

"Tore Aursand" <tore@aursand.no> wrote in message
news:pan.2003.09.22.20.30.05.716336@aursand.no...
> On Mon, 22 Sep 2003 16:53:15 +0100, D Borland wrote:
> > How do i go about get a parameter list from a form, without having to
use
> > CGI.pm?
>
> You don't want to _not_ use CGI.pm.  Reading - and parsing - web requests
> is quite hard, but CGI.pm makes it extremely easy.
>
> Read the CGI.pm documentation.  It takes you 15 minutes to browse through
> it and learn what you're looking for.  Later on, you will have a clue
> where to start reading when you encounter a CGI-related problem.
>
>
> -- 
> Tore Aursand <tore@aursand.no>
>
> "You know the world is going crazy when the best rapper is white, the best
>  golfer is black, France is accusing US of arrogance and Germany doesn't
>  want to go to war."




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

Date: Mon, 22 Sep 2003 15:44:15 -0700
From: Chief Squawtendrawpet <cs@edu.edu>
Subject: Re: length of the longest $_ in @_
Message-Id: <3F6F7B3F.1F0A37CF@edu.edu>

Barry Kimelman wrote:
> > $maxlen = (sort { $b <=> $a } map { length $_ } @names)[0];

Sam wrote:
> that is very clean, thanks alot

Sorting the entire list of lengths just to find the max seems like
overkill, at least if speed is an issue. The straightforward solution seems
best, and you can even type it all on one line if you want.

for (map length, @list){ $max = $_ if $_ > $max }

Chief S.


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

Date: Tue, 23 Sep 2003 00:29:53 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: length of the longest $_ in @_
Message-Id: <3f6f9248.24508480@news.erols.com>

Sam <samj2@austarmetro.com.au> wrote:

: after I search my book and the online hlep. trying to find it there is a 
:   built-in function to get the length of the longest item in a givin 
: array. length will not do it and scalar @array will not do it. I can 
: loop through the array but just wanted to ask if there is a built in 
: function for it.

No, there is not.  It is a useful thing to be able to do, but not so
useful to be worth consuming another keyword.

You can get there very easily with two built-in functions and one
bundled-in module.

    use List::Util 'max';
    $max = max( map length, @array );

: and how would you know if there is a built-in-function 
: for a task you want to do?

Habitual reading of perlfunc.

: or is it by time-experiance combo?

Bingo.



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

Date: 22 Sep 2003 16:08:14 -0700
From: qasim@ti.com (Nick)
Subject: Perl: how to stop users from executing commands from browser
Message-Id: <9d603421.0309221508.5ba5c9fb@posting.google.com>

I'm working on an HTML file that calls cope of Perl scripts with
parameters.
If you take your cursor over to the link, you can see the command that
will be send to the perl script and at this point user can modify that
and execute it from web browser. How can i prevent this from
happening?????
Anyway to block users from executing any commands from web browser????

Thanks in advance.
Nick


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

Date: Mon, 22 Sep 2003 18:15:33 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: Perl: how to stop users from executing commands from browser
Message-Id: <87k780s9d6.fsf@limey.hpcc.uh.edu>

>> On 22 Sep 2003 16:08:14 -0700,
>> qasim@ti.com (Nick) said:


> I'm working on an HTML file that calls cope of Perl
> scripts with parameters.

I don't know what "cope of" is supposed to mean.

> If you take your cursor over to the link, you can see
> the command that will be send to the perl script and at
> this point user can modify that and execute it from web
> browser.

 ... can pass the specified arguments to a server-side
process ...

> Anyway to block users from executing any commands from
> web browser????

Never pass code from client to server.  Always pass a
token that the server-side code looks up in a table and
then executes code based on the token.  An unknown token
generates an error.

perldoc CGI
perldoc -q server

hth
t


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

Date: Tue, 23 Sep 2003 00:49:33 GMT
From: run_signature_script_for_my_email@INVALID.com (laura fairhead)
Subject: Re: Perl: how to stop users from executing commands from browser
Message-Id: <3f6f973a.8827342@NEWS.CIS.DFN.DE>

On 22 Sep 2003 16:08:14 -0700, qasim@ti.com (Nick) wrote:

>I'm working on an HTML file that calls cope of Perl scripts with
>parameters.
>If you take your cursor over to the link, you can see the command that
>will be send to the perl script and at this point user can modify that
>and execute it from web browser. How can i prevent this from
>happening?????
>Anyway to block users from executing any commands from web browser????


No, you can't do this from the client side, at least by itself, anyone
can construct an arbitary URL/POST and send it to the server very
easily!

The correct way to do it is to put the commands at the server side
and then the HTML would just send a data index telling the server
side script which one to execute, so you might make an array;

@array=("command 1","command 2","command 3",.....,"command n");

The HTML would send the index, a form value 'idx=3' for instance
and the server script would first validate 'idx' (because a user
can still send any data they like for it) then execute the command
in it's table ("command 3"). 

                            The command table can't even be
relative to a HTML URL (like if you wanted to allow a certain
set of commands for each page) because the user could spoof that
too - if you want to do something like that you'll need to keep
a session id., this can be generated when they log in at the
start page and thereafter used to track where they are (the session
state) and therefore allow you to limit the choices at a given
stage. I've seen web-mail programs that use this technique maybe
it's what you want but you need to say more about what you're doing
to give more detail. I don't think this is a perl question
so I've set the follow-ups to comp.infosystems.www.authoring.cgi


seeyafornow
l


>
>Thanks in advance.
>Nick

-- 
echo alru_aafriehdab@ittnreen.tocm |sed 's/\(.\)\(.\)/\2\1/g'


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

Date: Mon, 22 Sep 2003 22:42:16 +0100
From: "D Borland" <notavailable@nospamplease.com>
Subject: Re: PPM problems
Message-Id: <q2Kbb.861$pz4.2687454@newsfep1-win.server.ntli.net>

Does your firewall require a username and password, if so i believe you need
to set HTTP_proxy_user and HTTP_proxy_pass

If that isn't it you can try here, were you'll see many people seem to
suffer from ppm http://aspn.activestate.com/ASPN/Mail/Browse/Threaded/ppm

Hope tat helps you

Dagmar

"David McDivitt" <x12code-del@del-yahoo.com> wrote in message
news:u4fumvkmgbspmvlltudrugtt2vvgmp9heq@4ax.com...
> I read what I could find about package importing prior to posting. When I
> typed:
>
>    ppm install DBI
>
> I received an error and what I read indicated it was because of our
> firewall. I displayed connection properties in internet explorer and found
> the following:
>
>    a03.zzzz.zzzz.zz.us:8080
>
> The following environment variable was added to Win2000:
>
>    set HTTP_PROXY=a03.zzzz.zzzz.zz.us:8080
>
> Now I the following error with PPM:
>
>    Error: No valid repositories: Error: 501 Protocol scheme
>    'a03.zzzz.zzzz.zz.us' is not supported Error: 501 Protocol
>    scheme 'a03.zzzz.zzzz.zz.us' is not supported
>
> DBI.zip was downloaded from ActivePerl and unzipped into a folder honoring
> folder names in the zip file. When I type the following:
>
>    ppm install DBI.ppd
>
> I still get the internet error above. I would like to know two things.
> First, how do I get rid of the internet error so I don't have to download
> stuff. Second, why is it trying to use the internet if I invoked PPM from
> within the directory I unzipped the files. Thanks
>




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

Date: Tue, 23 Sep 2003 02:43:42 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Sending html mail with inline images
Message-Id: <bko4uv$403vd$1@ID-184292.news.uni-berlin.de>

Sebastian Scholz wrote:
> I wrote a small script to send a html mail with inline images using
> mail:sender. Sending html mails without the images works fine, but
> when I try to have the images sent with the mail I only get the
> html and the image attached to the mail. I used the example for the
> mail:sender module but that did not work. Here is my code snippet :
> 
<snip>

>                 ->Part({ ctype => 'text/html',
>                   disposition => 'attachment',
>                   msg => $htmlfile
>                 })

That does not look right. Try this instead:

                 ->Attach({ ctype => 'text/html',
                   disposition => 'NONE',
                   file => $htmlfile
                 })

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl



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

Date: Mon, 22 Sep 2003 22:11:44 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Stupid perl regexp question
Message-Id: <x7eky8iicf.fsf@mail.sysarch.com>

>>>>> "GK" == G Klinedinst <g_klinedinst@hotmail.com> writes:

  GK> help. BTW, please do not reply with suggestions to use grep, or
  GK> sed/awk, or python, or C, or Lisp, or Smalltalk or any other
  GK> languages or techniques. I want to use Perl for what I am doing.

i doubt anyone here would suggest anything but perl for what you are
trying to do.

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org
Damian Conway Class in Boston - Sept 2003 -- http://www.stemsystems.com/class


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

Date: Mon, 22 Sep 2003 23:00:53 GMT
From: Darren Dunham <ddunham@redwood.taos.com>
Subject: Re: Stupid perl regexp question
Message-Id: <FaLbb.64$Gw1.15180961@newssvr21.news.prodigy.com>

G Klinedinst <g_klinedinst@hotmail.com> wrote:
> This is a really stupid regexp question but can someone please explain
> to me why this doesn't work:

> if( m/\/{1}/ ) { print $_; }

It works, it's just not what you want to happen... :-)

Since you haven't anchored anything, that will match any string which
has one slash in it.  Not "one and only one", just "one".

> I want to match only those lines which contain 1 and only 1 "/"
> character. My understanding is that a forward slash needs escaped or
> else it would signal the end of the regexp, the {1} indicates to match
> one and only one time. I have seen examples such as:

> $string =~ m/^\S{1,8}\.\S{0,3}/;

In general the regex /x{1,5}/ is equivalent to /x/, because if there are
5, there's at least 1, and /x/ will match.

They are different only when 
1) you are caputuring data or
2) you are specifying data on both sides of the expression

In your example, the \S{1,8} *must* be bounded on the front by the
beginning of the string, and on the rear by a dot (\.).  If the front of
string specification weren't there, the {1,8} expression would be no
more useful than a single \S, because 1, 8, or a thousand characters in
the string would still allow a match.

Another way to say "one and only one slash", is "starts with any number
of non-slash characters, has a slash, and ends with any number of
non-slash characters.

> I want to match only those lines which contain 1 and only 1 "/"
> character. My understanding is that a forward slash needs escaped or
> else it would signal the end of the regexp, the {1} indicates to match
> one and only one time. I have seen examples such as:

You can use different characters to delmit the regex.  When you want to
match forward slashes, that can come in handy.

> which clearly show the syntax of both escaping and repetition and I
> can't see for the life of me how mine is different, except that I
> don't care about the pattern matching at the beginning of the string.

Lets try constructing a regex for my restatement of your target string,
using an alternate delimiter, and a character class.  [^/] will
represent all characters other than a forward slash.

m!^[^/]*/[^/]*$!

You could probably do the same thing with negative lookahead and
lookbehind, but I'm less familiar with those techniques.

-- 
Darren Dunham                                           ddunham@taos.com
Unix System Administrator                    Taos - The SysAdmin Company
Got some Dr Pepper?                           San Francisco, CA bay area
         < This line left intentionally blank to confuse you. >


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

Date: Mon, 22 Sep 2003 23:29:52 +0100
From: "D Borland" <notavailable@nospamplease.com>
Subject: Re: Stupid perl regexp question
Message-Id: <zJKbb.867$pz4.2699586@newsfep1-win.server.ntli.net>

you could try... (note, not tested)

if (/\/(.*)/) {
    print $_  unless ($1 =~ /\//);
}

i'm sure someone here could show you something neater though :)

Dagmar


"G Klinedinst" <g_klinedinst@hotmail.com> wrote in message
news:168f035a.0309221404.769f4994@posting.google.com...
> This is a really stupid regexp question but can someone please explain
> to me why this doesn't work:
>
> if( m/\/{1}/ ) { print $_; }
>
> I want to match only those lines which contain 1 and only 1 "/"
> character. My understanding is that a forward slash needs escaped or
> else it would signal the end of the regexp, the {1} indicates to match
> one and only one time. I have seen examples such as:
>
> $string =~ m/^\S{1,8}\.\S{0,3}/;
>
> which clearly show the syntax of both escaping and repetition and I
> can't see for the life of me how mine is different, except that I
> don't care about the pattern matching at the beginning of the string.
>
> Output is returning lines that have 1 or more "/" chars. TIA for any
> help. BTW, please do not reply with suggestions to use grep, or
> sed/awk, or python, or C, or Lisp, or Smalltalk or any other languages
> or techniques. I want to use Perl for what I am doing.
>
> G. Klinedinst




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

Date: Mon, 22 Sep 2003 19:58:25 -0400
From: Jeff 'japhy' Pinyan <pinyaj@rpi.edu>
To: G Klinedinst <g_klinedinst@hotmail.com>
Subject: Re: Stupid perl regexp question
Message-Id: <Pine.SGI.3.96.1030922195533.781034A-100000@vcmr-64.server.rpi.edu>

[posted & mailed]

On 22 Sep 2003, G Klinedinst wrote:

>This is a really stupid regexp question but can someone please explain
>to me why this doesn't work:
>
>if( m/\/{1}/ ) { print $_; }
>
>I want to match only those lines which contain 1 and only 1 "/"

That regex doesn't say "does $_ have ONLY one / in it?", it says "does $_
have a / in it?".  To get what you want, you'll need to use either

  print if tr!/!! == 1;

which uses the tr/// operator (which returns the count of the characters
it matches in your string, so "alphabet" =~ tr/ab// would return 3, for
the a, a, and b it finds), or else

  print if m{^[^/]*/[^/]*$};

which matches a string containing zero or more non-slashes, followed by a
slash, followed by zero or more non-slashes, and anchored at the beginning
and end of the string.

-- 
Jeff Pinyan            RPI Acacia Brother #734            2003 Rush Chairman
"And I vos head of Gestapo for ten     | Michael Palin (as Heinrich Bimmler)
 years.  Ah!  Five years!  Nein!  No!  | in: The North Minehead Bye-Election
 Oh.  Was NOT head of Gestapo AT ALL!" | (Monty Python's Flying Circus)



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

Date: Mon, 22 Sep 2003 18:09:21 -0400
From: "Rodney" <NoSpamPlease@bellsouth.net>
Subject: Re: Using variables in RegEx statements?
Message-Id: <YmKbb.12719$iO.1221@bignews5.bellsouth.net>

Here's an example of my code so far... it simply doesn't work ????

  ##-- NOTE: I enter my own IP test in here for the test.
  ##    I want to be able to match the first 2 parts of the IP address.

  @IP_Rejects = ("123.123.123.123", "222.222.222.222");
   $Remote_IP_Address = $ENV{REMOTE_ADDR};
   my $KickOut    = 0;
   my $SubIP_1    = "";
   my $SubIP      = "";
   my $ListTicker = 0;
   my $ArraySize  = @IP_Rejects;

   while($ListTicker <= $ArraySize)  {
      $SubIP_1 = $IP_Rejects[$ListTicker];
      @SubIP = split(/./, $Remote_IP_Address);

      if ($SubIP_1 =~ /$SubIP[0]\.$SubIP[1]\.\d+\.\d+/)  {
         $KickOut = 1;
         $ListTicker ++;
         last;
      }
      $ListTicker ++;
   }

  if ($KickOut == 1) {
     ##-- send them a nice note.
  }






-- 
 ...
    `·.¸¸.·´¯`·.¸¸.·´¯`·->  rodney




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

Date: 22 Sep 2003 22:19:21 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: Using variables in RegEx statements?
Message-Id: <slrnbmutb8.sig.abigail@alexandra.abigail.nl>

Rodney (NoSpamPlease@bellsouth.net) wrote on MMMDCLXXIV September
MCMXCIII in <URL:news:YmKbb.12719$iO.1221@bignews5.bellsouth.net>:
:}  Here's an example of my code so far... it simply doesn't work ????
:}  
:}    ##-- NOTE: I enter my own IP test in here for the test.
:}    ##    I want to be able to match the first 2 parts of the IP address.
:}  
:}    @IP_Rejects = ("123.123.123.123", "222.222.222.222");
:}     $Remote_IP_Address = $ENV{REMOTE_ADDR};

What if this variable isn't set?

:}     my $KickOut    = 0;
:}     my $SubIP_1    = "";
:}     my $SubIP      = "";
:}     my $ListTicker = 0;
:}     my $ArraySize  = @IP_Rejects;
:}  
:}     while($ListTicker <= $ArraySize)  {
:}        $SubIP_1 = $IP_Rejects[$ListTicker];
:}        @SubIP = split(/./, $Remote_IP_Address);

/./ matches *any* character, except newlines. So, @SupIP will turn
into an array loaded with empty strings.

:}        if ($SubIP_1 =~ /$SubIP[0]\.$SubIP[1]\.\d+\.\d+/)  {

That regex will expand to: /\.\.\d+\.\d+/, and unlikely to match anything.

:}           $KickOut = 1;
:}           $ListTicker ++;
:}           last;
:}        }
:}        $ListTicker ++;
:}     }


Abigail
-- 
INIT  {print "Perl "   }
BEGIN {print "Just "   }
CHECK {print "another "}
END   {print "Hacker\n"}


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

Date: Mon, 22 Sep 2003 18:21:45 -0400
From: "Rodney" <NoSpamPlease@bellsouth.net>
Subject: Re: Using variables in RegEx statements?
Message-Id: <AyKbb.12762$iO.5763@bignews5.bellsouth.net>

I found the problem....

I failed to use the \ in front of the period in split routine.

:)


Thanks everyone...

-- 
 ...
    `·.¸¸.·´¯`·.¸¸.·´¯`·->  rodney




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

Date: Mon, 22 Sep 2003 18:29:02 -0400
From: "Rodney" <NoSpamPlease@bellsouth.net>
Subject: Re: Using variables in RegEx statements?
Message-Id: <pFKbb.12768$iO.6415@bignews5.bellsouth.net>

"Abigail"  wrote:

> :}
> :}    @IP_Rejects = ("123.123.123.123", "222.222.222.222");
> :}     $Remote_IP_Address = $ENV{REMOTE_ADDR};
>
> What if this variable isn't set?
===============

If you mean the $Remote_IP_Address variable, how could that be?




> :}        @SubIP = split(/./, $Remote_IP_Address);
>
> /./ matches *any* character, except newlines. So, @SupIP will turn
> into an array loaded with empty strings.
>
==================

Actually, there is a period in there.... I found out that I also needed to
put a  \  in front of that period, then it works.





> :}        if ($SubIP_1 =~ /$SubIP[0]\.$SubIP[1]\.\d+\.\d+/)  {
>
> That regex will expand to: /\.\.\d+\.\d+/, and unlikely to match anything.
>
======================

It seems to be working.... since I've included the  \  in fron of the period
in the split routine.








-- 
Q. Why are there rolling green pastures
    on the XP Desktop?

A. To keep the sheep happy.

swim away...
                       `·.¸¸.·´¯`·.¸¸.·´¯`·->  rodney




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

Date: 22 Sep 2003 22:53:35 GMT
From: Martien Verbruggen <mgjv@tradingpost.com.au>
Subject: Re: Using variables in RegEx statements?
Message-Id: <slrnbmuvbg.7ha.mgjv@verbruggen.comdyn.com.au>

On Mon, 22 Sep 2003 18:29:02 -0400,
	Rodney <NoSpamPlease@bellsouth.net> wrote:
> "Abigail"  wrote:
> 
>> :}
>> :}    @IP_Rejects = ("123.123.123.123", "222.222.222.222");
>> :}     $Remote_IP_Address = $ENV{REMOTE_ADDR};
>>
>> What if this variable isn't set?
>===============
> 
> If you mean the $Remote_IP_Address variable, how could that be?

That could be when $ENV{REMOTE_ADDRESS} isn't set. I just checked my
environment on four different machines here, and on none of them
REMOTE_ADDR is set.

>> :}        @SubIP = split(/./, $Remote_IP_Address);
>>
>> /./ matches *any* character, except newlines. So, @SupIP will turn
>> into an array loaded with empty strings.
>>
>==================
> 
> Actually, there is a period in there.... I found out that I also needed to
> put a  \  in front of that period, then it works.

Ok, so now you learned a trick.

Do you also understand _why_ you need to put a backslash in front of
that dot? Abigail already mentioned that a dot matches *any* character
(except newlines). What you need to do is try to understand what was
said there. First you need to read the entry for split() in perlfunc
to realise that that is called a regular expression. And then you need
to read about regular expressions in perlre (and probably perlretut).
Use the perldoc command to read documentation.

>> :}        if ($SubIP_1 =~ /$SubIP[0]\.$SubIP[1]\.\d+\.\d+/)  {
>>
>> That regex will expand to: /\.\.\d+\.\d+/, and unlikely to match anything.
>>
>======================
> 
> It seems to be working.... since I've included the  \  in fron of the period
> in the split routine.

No. The regex that Abigail quoted was not working, since you complained
about it, with the original data. If you suddenly change the data then
the regex you posted would expand to something else than Abigail
quoted. 

Be careful to read what people say, and respond appropriately.

Martien
-- 
                        | 
Martien Verbruggen      | Useful Statistic: 75% of the people make up
Trading Post Australia  | 3/4 of the population.
                        | 


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

Date: Sat, 19 Jul 2003 01:59:56 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: 
Message-Id: <3F18A600.3040306@rochester.rr.com>

Ron wrote:

> Tried this code get a server 500 error.
> 
> Anyone know what's wrong with it?
> 
> if $DayName eq "Select a Day" or $RouteName eq "Select A Route") {

(---^


>     dienice("Please use the back button on your browser to fill out the Day
> & Route fields.");
> }
 ...
> Ron

 ...
-- 
Bob Walton



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

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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.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 V10 Issue 5545
***************************************


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