[12925] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 335 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Aug 2 13:07:17 1999

Date: Mon, 2 Aug 1999 10:05:14 -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, 2 Aug 1999     Volume: 9 Number: 335

Today's topics:
    Re: <<END_OF_TEXT function (Kai Henningsen)
    Re: [Summary] Korn Shell or Perl? <tchrist@mox.perl.com>
    Re: [Summary] Korn Shell or Perl? (Anno Siegel)
        BOOLEAN SEARCH inlandpac@my-deja.com
    Re: CGI.pm Example (Abigail)
        CHMOD function (NightFever)
    Re: How to access only last field of a split ? (Larry Rosler)
    Re: How to access only last field of a split ? <sariq@texas.net>
    Re: How to determine a date in the past <prlawrence@lehigh.edu>
    Re: How to determine a date in the past <emschwar@rmi.net>
        How to Pass Dynamic Array Values to subroutines... kkmmperl@my-deja.com
        How to Pass Dynamic Array Values to subroutines... kkmmperl@my-deja.com
    Re: how to remove cr/lf ??? (Larry Rosler)
    Re: http_referer problems (Malcolm Ray)
    Re: IP Address validation (Mike Bristow)
    Re: IP Address validation inlandpac@my-deja.com
    Re: passing command-line arguments to script ! (Abigail)
        Perl Begineer Question... <c6635500@comp.polyu.edu.hk>
        Perl Begineer Question. <c6635500@comp.polyu.edu.hk>
        Perl Penetration <tchrist@perl.com>
        PL_na issues (was ANNOUNCE: 5.005_58 perldelta page) (Reini Urban)
    Re: string comparision ( newbie ) (Abigail)
    Re: string comparision ( newbie ) <sariq@texas.net>
        Syncing Domains in NT <paulnap@umich.edu>
    Re: system function broken - ActivePerl - build 517 or  (Reini Urban)
    Re: why are you so harsh to this guy ? <jeff_kerrigan@hotmail.com>
    Re: working with = sign in a directory name - please he (Anno Siegel)
        Digest Administrivia (Last modified: 1 Jul 99) (Perl-Users-Digest Admin)

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

Date: 02 Aug 1999 11:37:00 +0200
From: kaih=7M6uonXmw-B@khms.westfalen.de (Kai Henningsen)
Subject: Re: <<END_OF_TEXT function
Message-Id: <7M6uonXmw-B@khms.westfalen.de>

flavell@mail.cern.ch (Alan J. Flavell)  wrote on 02.08.99 in <Pine.HPP.3.95a.990801231903.6130D-100000@hpplus03.cern.ch>:

> On 1 Aug 1999, Kai Henningsen wrote:
>
> > > OK, das stimmt, but it was already discussed about trying scripts from
> > > the shell first, and that kind of problem would surely show up at _that_
> > > stage.
> >
> > Richtig, except the guy claimed to have no shell access.
>
> Well, then I'd say the first priority is to get the appropriate access,
> for example on one's own machine.

And again, that won't help you with a ascii/binary ftp problem (because  
it's not happened yet, obviously).

> > >                      "Bei dreibegriffigen mechanischen Vorsignalen ohne
> > >                       Doppelstellerhebel steuern zwei Fluegelkupplungen"
> >
> > SBB?
>
> I'm sorry, I spotted it as part of an explanation in a de. group and
> it just kind'a appealed to me.  I don't understand the details.
> Is that honest enough for you?

Of course. I just assumed from your address (and the contents) that it  
might be related to the Swiss railways, but obviously that was a false  
lead.


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


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

Date: 2 Aug 1999 10:47:24 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: [Summary] Korn Shell or Perl?
Message-Id: <37a5cb9c@cs.colorado.edu>

     [courtesy cc of this posting mailed to cited author]

In comp.lang.perl.misc, 
    anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) writes:
:originator of this thread was quetching about.

I doubt whether in German you would pronounce them differently, but I
had thought that you'd really meant "kvetch" there, as least as we commonly
spell it these days.  But then I looked them both up and was surprised.

    kvetch kvetS. U.S. slang. Also kvetsch.

    Etymology: Yiddish kvetsh, ad. G. quetsche crusher, presser.

    A term of personal abuse: spec. a person who complains a great deal,
    a fault-finder. Also 'kvetcher.

    Hence as v. intr. ad. Yiddish kvetshn, to complain, to whine; so
    'kvetching vbl. sb.

Rather than quetch:

    quetch, quitch, v. Obs. exc. dial. Forms: <alpha>. 1 cweccan,
    (cu-), 3 quecchen, queche, 6 queech, queatche, 6-7 que(t)ch;
    <beta>. (? 3 cwich, quic), 5 qvycch-, qvyhch-, qvytchyn, quycche,
    6 quytch(e, quyche, quich, 6-7 quitch, 9 dial. quitchy; <gamma>. 6
    (9 dial.) quatch. Pa. t. 1 cwæhte, 1, 3 cwehte, 3 quehte, qu-,
    cuahte, 4 quei(3) te, qua3te; also 6 quitched, 6-7 quetched, 7
    quatched, quitcht.

    Etymology: OE. cwe(hook)ccan:-*cwacjan, causative from the root
    *cwac-: see quake, and cf. OS. quekilik glossing L. versatilem or
    vibrabilem (gladium).  See also aquetch.

    1 trans. To shake; to brandish; to drive, chase. Obs. (OE. and
    early ME.)

    2 intr. Of things: To shake, tremble. Obs.

    3 intr. To stir or move from one place to another; to go, run,
    hasten. Obs.

    4 intr. Of persons (or animals): a To move the body or any part of
    it; to stir; in later use esp. to shrink, wince, twitch (with pain),
    and usually in negative clauses. Obs. exc. dial. [ The phr. cwich
    ne cwed in Leg. St. Kath.  1261, quic ne qued in Ancr. R. 122 (two
    MSS.), app. belongs here, meaning `stirred nor spoke', though the
    form is difficult to account for. ]

    b intr. To utter a sound. (Usually in negative clauses). Also with
    against, at. Obs. exc. dial.

    c Freq. in phr. one dare (or durst) not quetch, implying fear or
    absolute submission. Also const. against, at. Obs.

    Hence 'quetching, 'quitching vbl. sb. Obs.

Interesting: it looks like they're from the same origin.  Maybe either
will work after all.  Learn something new every day; cool! :-) 

--tom
-- 
    "Big Brother is hallucinating."  
--Elizabeth D Zwicky (zwicky@cis.ohio-state.edu), title of a comp.risks article


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

Date: 2 Aug 1999 16:48:54 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: [Summary] Korn Shell or Perl?
Message-Id: <7o4i5m$8sr$1@lublin.zrz.tu-berlin.de>

Uri Guttman  <uri@sysarch.com> wrote in comp.lang.perl.misc:
>>>>>> "AS" == Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> writes:
>
>  AS> Ken Pizzini <ken@halcyon.com> wrote in comp.lang.perl.misc:
>  >> my $pid = open(P, "-|);
>                        ^^
>that is an implied fork. read open again.
>
>  AS> This can't be right.  (Open will either fail or return a true value.)
>  AS> Looks like a fork got lost somewhere along the way.

Ouch!  Looks like I stepped on the fork I thought was lost on the
way but wasn't.  Errmmm...  Let me try again.

Would it help to be nitpicky and say there's a quote missing?  I
thought not.

Well, in fact I did see (as opposed to read) the crucial passage

   If you open a pipe on the command C<'-'>, i.e., either C<'|-'>
   or C<'-|'>, then there is an implicit fork done...

before.  But I thought by myself, "Well, the manual is a bit
redundant here.  All piped open's do an implicit fork."  Thanks
for the enlightenment.  And yes, this provides most of the pipe
functionality the originator of this thread was kvetching about.

Anno


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

Date: Mon, 02 Aug 1999 16:29:42 GMT
From: inlandpac@my-deja.com
Subject: BOOLEAN SEARCH
Message-Id: <7o4h17$r46$1@nnrp1.deja.com>

I have a script that fetches URLs (using LWP::UserAgent) via search
engines and then searches those urls for specific words.

What I am trying to do is modify the search to include boolean
operators.

One example is this:

I need to take the initial search keyword (let's use 'pepsi') and then
search each URL that comes up with that keyword for the keyword and one
extra word (let's use 'like') but with these limitations:

'pepsi' and 'like' cannot be one word,
'pepsi' and 'like' cannot be one right after each other (such as, "I
like pepsi"),
and the words must be within one word of each other (such as, "Pepsi is
like....).

Does anyone know how to create this search pattern?

It seems that this would be quite complicated (at least for me since I
am not too experienced in this area).

Can anyone help, please?

Thanks,
Chad.
passme


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


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

Date: 2 Aug 1999 11:51:13 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: CGI.pm Example
Message-Id: <slrn7qbj2v.r33.abigail@alexandra.delanet.com>

GEOFFREY HALLIWELL (GEOFFREY.HALLIWELL@Sun.COM) wrote on MMCLXII
September MCMXCIII in <URL:news:37A5B78C.AC8C4CD5@Sun.COM>:
^^ Hi,
^^ 
^^ I'm trying to run one of Lincoln Stein's CGI.pm examples
^^ (see below) and it won't allow me to view or 
^^ write to the guestbook file.  It is unable to secure 
^^ the lock on the file system so it bails with "Sorry, an 
^^ error occurred: unable to open  guestbook file."
^^ 
^^ Any ideas?

So, what's $! set to?



Abigail
-- 
perl5.004 -wMMath::BigInt -e'$^V=Math::BigInt->new(qq]$^F$^W783$[$%9889$^F47]
 .qq]$|88768$^W596577669$%$^W5$^F3364$[$^W$^F$|838747$[8889739$%$|$^F673$%$^W]
 .qq]98$^F76777$=56]);$^U=substr($]=>$|=>5)*(q.25..($^W=@^V))=>do{print+chr$^V
%$^U;$^V/=$^U}while$^V!=$^W'


  -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
   http://www.newsfeeds.com       The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including  Dedicated  Binaries Servers ==-----


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

Date: Mon, 02 Aug 1999 16:46:16 GMT
From: abc@abc.net (NightFever)
Subject: CHMOD function
Message-Id: <37a5cb50.16860675@news.idt.net>

I'm tring to make this work:

$OrignialLogFile = 'sample.txt';
 ..
 ..
 ..
 ..
chmod (0770, $OrignialLogFile);

I'm tring to chmod a file to 770 (or any mode for that matter) and it
won't change it.  It will change it if I put the exact file, but not a
a variable like this example, can anyone help?


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

Date: Mon, 2 Aug 1999 08:49:11 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: How to access only last field of a split ?
Message-Id: <MPG.120f5dce211e6188989d97@nntp.hpl.hp.com>

In article <37A5656F.D109EB85@Mark.Com> on Mon, 02 Aug 1999 10:31:28 
+0100, Mark <Mark@Mark.Com> says...
> Try:
> $line = "word.10.word.20.30.40.50";
> $scalar = ( reverse split '.',$line)[0]; # last element of split line

Before suggesting to someone that they try something, you ought to try 
it yourself.  ALWAYS!

Hint: '.' is a regex metacharacter.

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


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

Date: Mon, 02 Aug 1999 11:50:50 -0500
From: Tom Briles <sariq@texas.net>
Subject: Re: How to access only last field of a split ?
Message-Id: <37A5CC6A.C71B89E6@texas.net>

Andreas Fehr wrote:
> 
> On Mon, 02 Aug 1999 10:31:28 +0100, Mark <Mark@Mark.Com> wrote:
> 
> >Try:
> >$line = "word.10.word.20.30.40.50";
> >$scalar = ( reverse split '.',$line)[0]; # last element of split line
> >
> >
> 
> Sorry, does not work for me, I got:
> Use of uninitialized value at C:\TEMP\bla11.plx line 17.
> 
> Did you try it?
> 
> Andreas

So Abigail was right all along!  The syntax error *is* on line 17! ;-)

She must have used the Psychic::Hotline module...

- Tom


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

Date: Thu, 29 Jul 1999 13:02:57 -0400
From: "Phil R Lawrence" <prlawrence@lehigh.edu>
Subject: Re: How to determine a date in the past
Message-Id: <7nq1ga$1gl2@fidoii.cc.Lehigh.EDU>


Steve Walker <Steve.Walker@ing-barings.com> wrote in message
news:37A07A71.28798CAC@ing-barings.com...
> Does anyone know of a way of determining a date in the past, by counting
> back a specified number of days?  Ideally the date would be returned as
> an integer, i.e. YYYYMMDD.
>
> Are there any Perl libraries which provide such a function?

sub today {
    use Date::Calc qw/Today Add_Delta_Days Month_to_Text/;
    my $self = shift;

    my $offset = (@_) ? shift() : 0;
    $self->dielog("Non-integer offset!") unless ($offset =~ /^-?\d+$/);
    # Steffen Beyer kindly provided the next 2 lines...
    my ($year, $month, $day) = Add_Delta_Days(Today(), $offset);
    my $date = uc sprintf("%02d-%.3s-%d", $day, Month_to_Text($month), $year);
    return $date;
}
This gives MM-DD-YYYY...

Phil R Lawrence




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

Date: 02 Aug 1999 10:37:15 -0600
From: Eric The Read <emschwar@rmi.net>
Subject: Re: How to determine a date in the past
Message-Id: <xkf1zdmgmv8.fsf@valdemar.col.hp.com>

e-lephant@b-igpond.com (elephant) writes:
> Eric The Read writes ..
> >Um... where did I say *anything* about subtracting a known number of
> >seconds?  The poster wanted to subtract a number of *days* (not seconds)
> >from a given date, which is exactly the sort of thing described in the
> >readme for Date::Manip.
> 
> you are right .. the poster did ask for the ability to count back a 
> certain number of days .. for most applications the amounts to the same 
> thing as being able to count back a certain number of seconds

Well, I jumped on you too quickly here, and I apologize.  But I was
thinking specifically of the case where the DST line is crossed, and
counting back a specific number of seconds *isn't* the same as counting
back a given number of days.

> you're right - I should have included the caveat that I've now provided 
> concerning the more robust solution .. my omission there doesn't make the 
> Date::Manip module any more appropriate for this task

As I mentioned to the author of Date::Manip when he wrote to me in
support of your post, I tend to find a module that works and stick with
it.  Since 90%+ of my Perl programs tend to be one-offs, my orientation
is "find a module that does what I want, correctly," and not "find a
module that does what I want, quickly."  Programmer time being more
expensive, in general, than CPU time.

-=Eric


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

Date: Mon, 02 Aug 1999 16:22:56 GMT
From: kkmmperl@my-deja.com
Subject: How to Pass Dynamic Array Values to subroutines...
Message-Id: <7o4gkj$qot$1@nnrp1.deja.com>

Hi,
         My Problem is like this. I have a generic subroutine, that
takes an Array and performs some Manipulation returns an Array.
I call this subroutine as

@outputarray=&subroutine(\@inputarray);

I am building the inputarray inside a while loop. The code is like this

__BEGIN_SUBROUTINE__

sub Main_Subroutine{

my (@inputarray)=();
my (@outputarray)=();
my (@listarray)=();


@inputarray=&buildarray("parameter");
@outputarray=&subroutine(\@inputarray);
&printarray(\@outputarray);

@listarray=&buildlistarray();
foreach $arrayelement( @listarray){
         @inputarray=&buildarray($arrayelement);
         @outputarray=&subroutine(\@inputarray);
         &printarray(\@outputarray);
}

sub buildarray{
--------
}

sub buildlistarray{
--------
}

sub printarray{
-------
}


}

__END__MAIN_SUBROUTINE __


When I tested the program with just the one array with the same array
name used in the subroutine called, this program works properly. When
the foreach loop was introduced and the subroutines use the $_ operator
to get the inputs, the array are all empty inside the called subroutine.
I do not know why. In the simple example which worked, the called
subroutines used the same array variable names as that of the passed
array variable names.

PERL gurus, please let me know what is the problem. I am thankful for
your help.

thanks
kkmmperl


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


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

Date: Mon, 02 Aug 1999 16:26:29 GMT
From: kkmmperl@my-deja.com
Subject: How to Pass Dynamic Array Values to subroutines...
Message-Id: <7o4gr7$qro$1@nnrp1.deja.com>

Hi,
         My Problem is like this. I have a generic subroutine, that
takes an Array and performs some Manipulation returns an Array.
I call this subroutine as

@outputarray=&subroutine(\@inputarray);

I am building the inputarray inside a while loop. The code is like this

__BEGIN_SUBROUTINE__

sub Main_Subroutine{

my (@inputarray)=();
my (@outputarray)=();
my (@listarray)=();


@inputarray=&buildarray("parameter");
@outputarray=&subroutine(\@inputarray);
&printarray(\@outputarray);

@listarray=&buildlistarray();
foreach $arrayelement( @listarray){
         @inputarray=&buildarray($arrayelement);
         @outputarray=&subroutine(\@inputarray);
         &printarray(\@outputarray);
}

sub buildarray{
--------
}

sub buildlistarray{
--------
}

sub printarray{
-------
}


}

__END__MAIN_SUBROUTINE __


When I tested the program with just the one array with the same array
name used in the subroutine called, this program works properly. When
the foreach loop was introduced and the subroutines use the $_ operator
to get the inputs, the array are all empty inside the called subroutine.
I do not know why. In the simple example which worked, the called
subroutines used the same array variable names as that of the passed
array variable names.

PERL gurus, please let me know what is the problem. I am thankful for
your help.

thanks
kkmmperl


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


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

Date: Mon, 2 Aug 1999 09:20:30 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: how to remove cr/lf ???
Message-Id: <MPG.120f6528b52c2079989d98@nntp.hpl.hp.com>

In article <37A59652.B7E0A52C@eed.ericsson.se> on Mon, 02 Aug 1999 
15:00:02 +0200, Alex Farber <eedalf@eed.ericsson.se> says...
> Ming Hubert wrote:
> > ........
> > so all the entries have cr/lf. i'd like them to have in the file separated
> > by ";" ex:
> > user-input-field1;user-input-field2;user-input-field3;user........
> > 
> > my print-command for the file looks like this:
> > 
> > print FILETO $outbuffer;
> > 
> > how can i eliminate the cr/lf and replace it by a separator ??
> 
> maybe
> 
>     $outbuffer =~ s /\r?\n/;/;

Maybe not.  This newsgroup is for facts, not speculation.

> Rgeards
> Alex
> 
> --
> Ich studiere  Elektrotechnik (Technische  Informatik) an der RWTH Aachen
> und bin ein guter Perl-Programmierer (arbeite seit 4 Jahren als Intranet-
> Entwickler).

In that case, maybe your forgetting to append the '/g' modifier is an 
oversight.  Just as you overlooked testing your suggestion before 
posting it.

What a waste of bandwidth!

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


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

Date: 2 Aug 1999 16:48:07 GMT
From: M.Ray@ulcc.ac.uk (Malcolm Ray)
Subject: Re: http_referer problems
Message-Id: <slrn7qbiu7.qq1.M.Ray@carlova.ulcc.ac.uk>

On Mon, 02 Aug 1999 15:10:14 GMT, velo1@earthlink.net <velo1@earthlink.net>
wrote:
>Try this. 
>
>Seems someone else here should have known this. I am 
>amazed that everyone else just gives lip about going elsewhere to get
>the info. I am relatively new with perl so maybe I have not yet
>developed the lousy attitude protrayed by some of the other posters
>here.
>
>Hope this helps, I've tried it on several machines and it seems to
>work fine.

The good thing about telling someone to 'go elsewhere' (either to a
FAQ, or to a more appropriate group) is that they're more likely to
get a complete and accurate answer there.  For example, no answer to
this question is complete without pointing out that you can't trust
the value of $ENV{HTTP_REFERER}.  It comes (ultimately) from a header
supplied by the browser (or whatever other agent made the access
in question), which is free to supply whatever value it feels like
(what value would you expect to be supplied when a URL is selected
from a bookmark list, for example?).

People are sometimes tempted to use it for security purposes, but
this is easily subverted.
-- 
Malcolm Ray                           University of London Computer Centre


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

Date: Mon, 02 Aug 1999 16:22:46 GMT
From: mike@fat.dotat.at (Mike Bristow)
Subject: Re: IP Address validation
Message-Id: <slrn7qbhel.7j5.mike@lindt.fat.dotat.at>

On Mon, 02 Aug 1999 15:37:12 GMT, dave4000@my-deja.com <dave4000@my-deja.com> wrote:
>I require a small routine that validates an IP address that has been
>entered.
>
>The following routine, accepts invalid addresses such as 123.45 or
>123.45...67
>
>sub ip_add_chk {
>
>	if (($ip=~/(\d+)\.*(\d+)\.*(\d+)\.*(\d+)/) &
>			(($1>=0 && $1<256) & ($2>=0 && $2<256) &
>				($3>=0 && $3<256) & ($4>=0 && $4<256)))

How does $ip get set?


You seem to have erronus code; I think I see what you're trying to do, 
so here's my version.

It'll match any line which contains 4 numbers seperated by periods
seperated from other data be either whitespace or the start/end of lines
when the numbers are one, two or three digits long smaller than 256, and
are either 0 or do not start with 0.

It's probably not tight enough; if there's an error either with the
translation of ``ip address'' into the more verbose description of
what is acceptable or an error in the implementation, yell, and 
/someone/ will correct it, I hope ;-)

mike@shivan:~$ cat ip_add_chk.pl
#!/usr/bin/perl -w
use strict;

sub ip_add_chk {
	my ($ip) = @_;
	my $octet = '1?[1-9]?\d|2[0-4]\d|25[0-5]';
	if ($ip =~ /(:?^|\s)($octet)\.($octet)\.($octet)\.($octet)(?:\s|$)/) {
		return "$1.$2.$3.$4";
	} else {
		return undef;
	}
}

while (<>) {
	my $ip = ip_add_chk($_);
	chomp;
	if (defined $ip) {
		print "$_: OK ($ip)\n"
	} else {
		print "$_: NOT OK\n"
	}
}
mike@shivan:~$ ./ip_add_chk.pl
1.2.234.123 
1.2.234.123 : OK (1.2.234.123)
IP address: 1.2.234.123
IP address: 1.2.234.123: OK (1.2.234.123)
There's no IP address here, bob.
There's no IP address here, bob.: NOT OK
There's no IP address here, bob: 1.2.3.256
There's no IP address here, bob: 1.2.3.256: NOT OK
1.2.3.255  
1.2.3.255: OK (1.2.3.255)
1.2..3
1.2..3: NOT OK
^D
mike@shivan:~$

-- 
Mike Bristow, Geek-At-Large.                GK/RT0038
one tequila - two tequila - three tequila - FLOOR !!!



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

Date: Mon, 02 Aug 1999 16:42:47 GMT
From: inlandpac@my-deja.com
Subject: Re: IP Address validation
Message-Id: <7o4hq4$rkr$1@nnrp1.deja.com>

In article <7o4dv7$ojq$1@nnrp1.deja.com>,
  dave4000@my-deja.com wrote:
> I require a small routine that validates an IP address that has been
> entered.
>
> The following routine, accepts invalid addresses such as 123.45 or
> 123.45...67
>
> sub ip_add_chk {
>
> 	if (($ip=~/(\d+)\.*(\d+)\.*(\d+)\.*(\d+)/) &
> 			(($1>=0 && $1<256) & ($2>=0 && $2<256) &
> 				($3>=0 && $3<256) & ($4>=0 && $4<256)))

------------------------
HOW ABOUT:

m/^([01]?\d\d|2[0-4]\d|25[0-5])\.([01]?\d\d|2[0-4]\d|25[0-5])\.([01]?
\d\d|2[0-4]\d|25[0-5])\.([01]?\d\d|2[0-4]\d|25[0-5])$/
------------------------

> {
>
> 		$_[0]="$1.$2.$3.$4";
> 		$retry=0;
> 		return $retry;
> 		}
> 	else {
> 		print ("\nError, Please enter again!\n");
> 		$retry=1;
> 		return $retry;
> 	}
>
> }
>
> Any help would be great.  Thanks
>
> Dave
>
> Sent via Deja.com http://www.deja.com/
> Share what you know. Learn what you don't.
>


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


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

Date: 2 Aug 1999 11:55:03 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: passing command-line arguments to script !
Message-Id: <slrn7qbja3.r33.abigail@alexandra.delanet.com>

PaulK (paul@vdkamer.nl) wrote on MMCLXII September MCMXCIII in
<URL:news:37a5b3f8.34041852@news.wxs.nl>:
~~
~~ >>>> When i try to do it the correct way :
~~ >>>> $uitkomst=system("perl","\\query\\query1.cgi","FileNaam=test.txt);
~~ 
~~ Excuses, i will resolve the variable $FileNaam in query1.cgi as
~~ follows:
~~ 
~~ use CGI;
~~ $FileNaam = param('FileNaam');
~~ if (!$FileNaam)
~~ {
~~ 	print "Not Filled";
~~ }


Well, did you read the manpage of CGI.pm to see where it gets its
parameters from?



Abigail
-- 
perl5.004 -wMMath::BigInt -e'$^V=Math::BigInt->new(qq]$^F$^W783$[$%9889$^F47]
 .qq]$|88768$^W596577669$%$^W5$^F3364$[$^W$^F$|838747$[8889739$%$|$^F673$%$^W]
 .qq]98$^F76777$=56]);$^U=substr($]=>$|=>5)*(q.25..($^W=@^V))=>do{print+chr$^V
%$^U;$^V/=$^U}while$^V!=$^W'


  -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
   http://www.newsfeeds.com       The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including  Dedicated  Binaries Servers ==-----


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

Date: Tue, 03 Aug 1999 01:05:18 -0700
From: Jimmy <c6635500@comp.polyu.edu.hk>
Subject: Perl Begineer Question...
Message-Id: <37A6A2BE.99DF2DB9@comp.polyu.edu.hk>

Hello all,
    I am new to Perl. I want to implement the following requirements in
using Perl.

    If the length of variable A (after trim) is equal to zero, then put
$no_of_space space characters into variable B.

    So :

    if length(trim($A)) == 0 then {
        put null string to variable B, the length of null string is
equal to $no_of_space value
   }

    How can I implement the above requirements in Perl?

Thanks,
Jimmy





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

Date: Tue, 03 Aug 1999 01:00:36 -0700
From: Jimmy <c6635500@comp.polyu.edu.hk>
Subject: Perl Begineer Question.
Message-Id: <37A6A1A4.E0D0096C@comp.polyu.edu.hk>

Hello all,
    I am new to Perl. I want to implement the following requirements in
using Perl.

    If the length of variable A (after trim) is equal to zero, then put
$no_of_space space characters into variable B.

    So :

    if length(trim($A)) == 0 then {
        put null string to variable B, the length of null string is
equal to $no_of_space value
   }

    How can I implement the above requirements in Perl?

Thanks,
Jimmy



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

Date: 2 Aug 1999 10:21:42 -0700
From: Tom Christiansen <tchrist@perl.com>
Subject: Perl Penetration
Message-Id: <37a5c596@cs.colorado.edu>

Long ago and far away, I used to keep a list of the operating systems
that included Perl in their distributions.  I'd like to do this again.
But I don't myself run all operating systems.  I just have a few Linuxes,
one BSD, and a trusty old SunOS, with random other things like MkLinux
and MacOS X lying about.  I'd like to ask for help in reporting to me
what operating system comes with what version of Perl, and as of when.
Not runs on, but comes with.

I found this about Sun:

    http://www.xray.mpe.mpg.de/mailing-lists/perl5-porters/1999-07/msg01880.html

Please send me entries more or less like this sample.  No need to be
too strict; I'll reformat as needed.

    Vendor Name: 	TLA Nanosystems
    OS Name/Version:	TLAnix release 6.0.2.23
    Since when:		Summer 1995
    Perl version:	perl3.044
    Status:		standard part of installed system utility set
    Notes:		Installs v5.005_05 as "perl5", but leaves
			v3.044 as "perl".  

Status fields might also be something like "standard, but in /unsupported
dir", or "part of optionally-installed user contrib tape", or "part of
service pack 381", etc.

And yes, I am going to count each branch of Linux and of BSD separately,
so OpenBSD != NetBSD, SuSE Linux != Redhat Linux, etc.  Whether we
have separate things for SuSE Linux 5.0 versus 6.0, I don't know yet.
I'm especially interested in the other (non-free) workstation and
desktop vendors.

--tom
-- 
	    It's a dark abyss or tunnel:
	    Strewn with stones, stowed, solace, gunwale,


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

Date: Mon, 02 Aug 1999 16:55:11 GMT
From: rurban@xarch.tu-graz.ac.at (Reini Urban)
Subject: PL_na issues (was ANNOUNCE: 5.005_58 perldelta page)
Message-Id: <37a5ca82.20964565@judy.x-ray.local>

what is the recommended c preprozessor conditional to switch between na
and PL_na resp. the old POLLUTEd and the new 5.006 names?

i want to keep the XSUBs for older perl version, but want to fix them
for 5.006.
for now i used this in all older xs module code

#ifdef PATCHLEVEL
  // old xs code with na, ...
#else
  // fixed to PL_na, localized it, added dTHR, ...
#endif

but patchlevel.h could be manually included (which would fail then) and
it is not so obvious. i couldn't find a meaningful POLLUTE definition
for a conditional.
#if ((PERL_SUBVERSION > 5) || 
     ((PERL_SUBVERSION == 5) && (PERL_REVISION >= 58)))

could also be used. but this is a bit too hard to recommend for every
XSUB writer.

i don't want to use perl Makefile.PL POLLUTE=1, because i want to fix
the xs code directly to adopt the new names.

--                                         
Reini


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

Date: 2 Aug 1999 11:58:18 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: string comparision ( newbie )
Message-Id: <slrn7qbjg7.r33.abigail@alexandra.delanet.com>

Heather Wiley (heather.wiley@bentley.com) wrote on MMCLXII September
MCMXCIII in <URL:news:37A5BDAC.A41D1AB3@bentley.com>:
"" I am running active Perl on Windows NT
"" want to compare two vars
"" I know:
""    if ( $var1 eq $var2)
"" whats the converse
"" 
""  if (! ( $var1 eq $var2 ))
"" works but is this the correct method?

As usual with Perl, there's more than one way to do it.

"" I thought it was neq but I get a syntax error

You could use 'ne'. Or 'unless'. Or '!'. Or 'not'. None is more correct
than the others.

"" ( my camel book is at home and the online docs for active perl aren't
"" much help )


Really? I've never heard that Active Perl doesn't have the standard
documentation set.



Abigail
-- 
perl -we 'print q{print q{print q{print q{print q{print q{print q{print q{print 
               qq{Just Another Perl Hacker\n}}}}}}}}}'    |\
perl -w | perl -w | perl -w | perl -w | perl -w | perl -w | perl -w | perl -w


  -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
   http://www.newsfeeds.com       The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including  Dedicated  Binaries Servers ==-----


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

Date: Mon, 02 Aug 1999 11:47:53 -0500
From: Tom Briles <sariq@texas.net>
Subject: Re: string comparision ( newbie )
Message-Id: <37A5CBB9.D9998A8@texas.net>

Heather Wiley wrote:
> 
> I am running active Perl on Windows NT
> want to compare two vars
> I know:
>    if ( $var1 eq $var2)
> whats the converse
> 
>  if (! ( $var1 eq $var2 ))
> works but is this the correct method?
> 
> I thought it was neq but I get a syntax error
> 
> thanks
> heather
> 
> ( my camel book is at home and the online docs for active perl aren't
> much help )

Perhaps you have an unusual definition of "aren't much help", or perhaps
you didn't try looking at the 'perlop' docs.

- Tom


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

Date: Mon, 2 Aug 1999 12:30:58 -0400
From: "Paul Napolitano" <paulnap@umich.edu>
Subject: Syncing Domains in NT
Message-Id: <BIjp3.3585$nB.514623@news.itd.umich.edu>

Does anyone know of a way to synchronize an NT domain with a Perl Script?
I've looked thru every Win 32 Module and couldn't find a thing. What I'm
trying to do is write an account creation script that also automatically
adds permissions to the newly created home directory. I'm having a problem
giving permissions to the newly created user to  his home directory when the
script runs. It seems to be a timing issue with the account taking a few
minutes after it's created before I can give this account any directory
permissions. Any suggestions?

-Paul

--
Paul Napolitano, MCSE
System Administrator III
University of Michigan
College of Literature, Science, & Arts
1007 East Huron Ann Arbor, MI. 48104-1690
paulnap@umich.edu




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

Date: Mon, 02 Aug 1999 16:28:37 GMT
From: rurban@xarch.tu-graz.ac.at (Reini Urban)
Subject: Re: system function broken - ActivePerl - build 517 or 518
Message-Id: <37a5c68b.19949896@judy.x-ray.local>

anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) wrote:
>Reini Urban <rurban@sbox.tu-graz.ac.at> wrote in comp.lang.perl.misc:
>>mike@zelea.com (Michael Allan) wrote:
>>>> Try using this syntax and see if it helps:
>>>> print system '"CALC.EXE"';
>>
>>even this will work
>>perl -e "system '\"calc\"'"
>>
>>but all standard perl's I use (5.00502 and 5.00558, AP's 518 is 5.00503)
>>do accept
>>perl -e "system 'calc'"
>
>That is not so much a question of what Perl accepts but what the
>shell does to the quotes.

i meant that he doesn't need any path (as he tried) nor any extension
(as he does). the os searches automatically any executable.
by using the shell (which needs those strange quoting rules: 
" outside, ' or \" inside the -e string) it is easier to test it out.
--                                         
Reini


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

Date: Mon, 02 Aug 1999 09:20:17 -0700
From: Jeff Kerrigan <jeff_kerrigan@hotmail.com>
Subject: Re: why are you so harsh to this guy ?
Message-Id: <37A5C540.CD619A7A@hotmail.com>

Get a life.  If you were half as great as you thought you were, Tad, you wouldn't have time
to give 25,000 word responses to every "newbie" who writes to this NG.

Tad McClellan wrote:

> Thomas Schmickl (schmickl@magnet.at) wrote:
> : Tad McClellan schrieb:
>
> : > : what kind of sort is sort() function ? (selection sort, quick sort !?)
> : >
> : >       perl -ne 'print "$ARGV: $_" if /quick/i and /sort/i' *.pod
> : >
> : > perldelta.pod: =head2 Quicksort is internally implemented
> : > perlmodlib.pod: (though having 23 called Sort::Quick is only marginally better :-).
> : > perltoc.pod: =item Quicksort is internally implemented
> : >
> : >    You could have answered that one yourself too.
> : >
> : >    Stop it!
> : >
> : >    Your time is NOT more valuable than everyone else's.
> : >
> : >    Spend _some_ of yours before asking others to spend their's.
>
> : Do you really have to be so unpolite to this guy ???
>
>    Yes.
>
>    When you are rude to someone, it is not unexpected that they
>    will be rude in return.
>
>    How come you are not asking Ryan why he is so unpolite to
>    *thousands* of people?
>
>    Do you defend someone who takes cuts in line?
>
>    How about when they come back the next day and take cuts again?
>
>    How about when they come back a few days later, and take cuts
>    yet again?
>
> : To me it seems that he simply had a question, he couldnt answer by himself.
>
>    That is your opinion.
>
>    My opinion is that he didn't even *try* to answer it himself
>    (because the answer is so easy to find).
>
> : Maybe he is just a beginner in perl, who couldnt just type
> : "  perl -ne 'print "$ARGV: $_" if /quick/i and /sort/i' *.pod " ?
>
>    That is Perl talk for "do a word search".
>
>    He can do a word search however you do that on his system.
>    I don't know what "his system" is, so I wrote it in Perl.
>    I figure he has access to perl, or he wouldn't be posting
>    here.
>
>    If he cannot do a word search across multiple files, then
>    he needs to stop programming and find out how to do a
>    word search across multiple files.
>
>    Else he will be waiting for hours, days or forever for
>    someone to answer his question on Usenet, when he could
>    have had the answer in less than *30 seconds!*
>
> : What the question was about, you could have easily detect by his self-explanatory
> : subject in the mail header.
>
>    And he could have easily answered his question without posting.
>
>    I'm waiting for your followup to him asking him why he is
>    so inconsiderate of everybody else on clpmisc...
>
> : So if your time is that expansive, why have you read his
> : posting ?
>
>    Because he is working stupid.
>
>    I would like to see him working smart instead.
>
> : Have you got a few frustrations you wanted to loose.
>
>    Yes.
>
>    Please sift through the hundreds of posts per day here for
>    a *few years*, then count _your_ frustrations.
>
> : ciao, and my your problems disapear like smoke in the sky
> : thomas.
>
>    That ain't gonna happen. The world is full of pre-K "programmers".
>
>    After putting one through kindergarten, three more show up
>    to take his place.
>
> -------------------------------------
> In article <1995Nov9.193745.13694@netlabs.com>, lwall@netlabs.com (Larry
> Wall) wrote: ...
>
> <Larry>  [snip]  I view a programming language as a place to be
> <Larry>  explored, like Disneyland. You don't need to have a lot of preparation
> <Larry>  to explore a theme park.  You do have to go along with the crowd
> <Larry>  control measures, though.  In a sense, each ride has its own
> <Larry>  prerequisites--if you cut in line, you risk getting tossed out of the
> <Larry>  park.
> <Larry>
> <Larry>  What we have here in this newsgroup is a failure in crowd control.
> <Larry>  Reading the FAQ is like staying in line--it's something you should
> <Larry>  learn in kindergarten.  Usenet needs a better kindergarten.
> -------------------------------------
>
> There is some "history" behind my followup.
>
> Here are some of Ryan's past postings.
>
> I am a regular here, so I remembered them.
>
> You can look them up at www.deja.com if you want to see them
> yourself.
>
> -------------
> Date: 1999/06/01
>
> Q:   how to sort by values
>
> A:    Perl FAQ, part 4:
>
>       "How do I sort a hash (optionally by value instead of key)?"
>
> -------------
> Date: 1999/06/19
>
> Q: is there any command to translate perl script to c source file
>
> A: Perl FAQ, part 3:
>
>    "How can I compile my Perl program into byte code or C?"
>
> -------------
> Date: 1999/06/20
>
> Q: i'm setting Linux Apache
>    ......it's not work!...... it can only show html, but not cgi
>
> A: This question is Perl-content free, yet it was posted to the
>    Perl newsgroup.
>
>    Perl questions should be asked in the Perl newsgroup.
>
>    Server setup questions should be asked in a server newsgroup.
>
> -------------
> Date: 1999/07/16
>
> Q: Subject: Get Time , Less Than a second
>
> A: Perl FAQ, part 8:
>
>    "How can I measure time under a second?"
>
> -------------
> Date: 1999/07/29
>
> Q: %HASH = ( "k" => [1,2,3] );
>    $x = $HASH{ "k" }-> [1]++;
>    print $x;
>
>    ...... the result is "2" but i expect "3";...... why this not work !?
>
> A: because that is the defined behavior for postfix increment.
>
>    from perlop.pod:
>
>       "++" and "--" work as in C.  That is, if placed before a variable,
>       they increment or decrement the variable before returning the value,
>       and if placed after, increment or decrement the variable after
>       returning the value.
>
> -------------
> Date: 1999/07/29
>
> Q: why can't i do this:
>
>    test();
>
>    sub test{
>       my $a;
>       my $b;
>       my %HASH=("a"=>5,"c"=>7,"b"=>6,"d"=>8,"z"=>10,"x"=>9);
>
>       my @SBV = sort { $HASH{$a} <=> $HASH{$b} } keys %HASH;
>
> A: the description for sort() in perlfunc.pod says:
>
>    "package global variables $a and $b (see example below).
>     They are passed by reference, so don't modify $a and $b.
>     And don't try to declare them as lexicals either."
>
>    He has declared them as lexicals!
>
> -------------
> Date: 1999/07/30
>
> Q: by sorting the [1] of array if the [1] of array is equal then
>    perform second sort on [0]
>
> A: The answer for Perl FAQ, part 4:
>
>    "How do I sort an array by (anything)?"
>
>    Has this:
>
>    "If you need to sort on several fields, the following paradigm is useful."
>
> --------------
>
>    Each of those questions was probably read by thousands of people!
>
>    Some of them probably also took the time to followup.
>
>    There is a Whole Bunch of wasted time directly attributable to
>    Ryan being too lazy to even try and find the answer himself.
>
>    He doesn't need to try like everybody else does. He can just
>    post to clpmisc and some fool will read the docs *for him*.
>
>    I don't think so...
>
> --
>     Tad McClellan                          SGML Consulting
>     tadmc@metronet.com                     Perl programming
>     Fort Worth, Texas



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

Date: 2 Aug 1999 16:11:39 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: working with = sign in a directory name - please help!
Message-Id: <7o4fvr$8pc$1@lublin.zrz.tu-berlin.de>

Timothy J Flynn <tflynn@iastate.edu> wrote in comp.lang.perl.misc:
>HI,
>
>    I am in the process of converting several shell scripts to perl.  I have
>come accross some system calls that work with directories starting with an =
>sign for listing purposes I guess.  I have found that the only perl function
>that works is a mkdir.  I have tried just about every way of escaping for
>this with little success.  Is there any way around this?  Thanks!

What have you tried and how did it fail?  "Just about every way"
isn't very descriptive, you know.  "With little success" isn't
any better.  In Perl it isn't harder to use '=' in a directory
name than any other character.

Anno


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

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


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