[11785] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5385 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Apr 14 19:07:22 1999

Date: Wed, 14 Apr 99 16:00:20 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Wed, 14 Apr 1999     Volume: 8 Number: 5385

Today's topics:
        Database Objects In Perl (NA)
    Re: Database Objects In Perl (Paul Boyes)
    Re: Dummy Question about Perl Licence (Tad McClellan)
    Re: Dummy Question about Perl Licence <cassell@mail.cor.epa.gov>
        efficient file I/O for file updates (Christian M. Aranda)
    Re: efficient file I/O for file updates <greg.wimpey@waii*removetomail*.com.invalid>
    Re: FAQ 1.1: What is Perl? (John Stanley)
    Re: FAQ 1.1: What is Perl? (John Stanley)
    Re: flocking question - worried (Graham Ashton)
    Re: flocking question - worried NOSPAMcrstlblu@planet.eon.net
        Help on Sendmail! <cuksa@cuksa.monisys.ca>
        Help on Sendmail! <cuksa@cuksa.monisys.ca>
    Re: how do I match all the "1"s in strings like 231451, (Randal L. Schwartz)
    Re: how to find unused IP addresses on a subnet <bwebb@fred.net>
    Re: I need a script written. (Tad McClellan)
        I need help!!!!! help me <sergue@ica.net>
    Re: I need help!!!!! help me <cassell@mail.cor.epa.gov>
    Re: Location target (Abigail)
        Looking for y2k code scanner for Perl code <twk@unity.ncsu.edu>
        Need to print \n - Not do a carrage return <sspringett@cwe2.com>
    Re: Novice needs learning suggestions <cassell@mail.cor.epa.gov>
    Re: pattern matching <aqumsieh@matrox.com>
    Re: Q: Convert two newlines to \n<p> <staffan@ngb.se>
    Re: reference to an *existing* sub <aqumsieh@matrox.com>
    Re: regex - meta char's (Tad McClellan)
        Sending data to HTML from perl script <robert@chackmore.demon.co.uk>
        URI.pm not installing with libwww-perl <dsmorey@unconundrum.com>
        Would anyone care to teach me perl? <WizeGuy@nettaxi.com>
    Re: Would anyone care to teach me perl? <jeffp@crusoe.net>
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: 14 Apr 1999 22:05:27 GMT
From: NA@NA.COM (NA)
Subject: Database Objects In Perl
Message-Id: <7f33f7$ske$1@eskinews.eskimo.com>

Hello,

I have been looking for some examples of creating Database Objects in Perl, but 
have been unsuccessful in finding any.  I am trying to get away from using 
in-line sql by creating objects to represent my database.  In other words, if I 
had a simple person/address database, I would have a person object with all of 
the person attributes(properties) and methods and an address object with all of 
the address attributes and methods. 

I have seen this done in other languages, but have not done it myself.  It 
seems like a good way to write managable code.  Perl is fairly new to me so any 
help would be appreciated.

Thanks,

Paul



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

Date: 14 Apr 1999 22:16:08 GMT
From: boyes@eskimo.com (Paul Boyes)
Subject: Re: Database Objects In Perl
Message-Id: <7f3438$ske$2@eskinews.eskimo.com>

My e-mail address is boyes@eskimo.com.  Sorry about that.

In article <7f33f7$ske$1@eskinews.eskimo.com>, NA@NA.COM says...
>
>Hello,
>
>I have been looking for some examples of creating Database Objects in Perl, 
but 
>have been unsuccessful in finding any.  I am trying to get away from using 
>in-line sql by creating objects to represent my database.  In other words, if 
I 
>had a simple person/address database, I would have a person object with all of 
>the person attributes(properties) and methods and an address object with all 
of 
>the address attributes and methods. 
>
>I have seen this done in other languages, but have not done it myself.  It 
>seems like a good way to write managable code.  Perl is fairly new to me so 
any 
>help would be appreciated.
>
>Thanks,
>
>Paul
>



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

Date: Wed, 14 Apr 1999 12:19:44 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Dummy Question about Perl Licence
Message-Id: <07f2f7.p17.ln@magna.metronet.com>

haytounet@my-dejanews.com wrote:

: p.s: i tried to read the Faq but my browser crashes each time I try.


   The FAQs are included with the perl distribution.

   They are on your hard disk. Find out where they were put.

   You don't need to view them on the WWW.


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


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

Date: Wed, 14 Apr 1999 15:08:14 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Dummy Question about Perl Licence
Message-Id: <371511CE.FADCE350@mail.cor.epa.gov>

Tad McClellan wrote:
> 
> haytounet@my-dejanews.com wrote:
> 
> : p.s: i tried to read the Faq but my browser crashes each time I try.
> 
>    The FAQs are included with the perl distribution.
> 
>    They are on your hard disk. Find out where they were put.
> 
>    You don't need to view them on the WWW.

Based on the original posting, it's entirely possible haytounet hasn't
installed Perl yet, and wants some info before doing so.  Having seen
some of the licensing agreements for vertical apps in win32-land, I
can see the logic of that.  Of course, I might have made some effort
to learn a little about the language before snarfing a copy of it...

David
-- 
David Cassell, OAO                               
cassell@mail.cor.epa.gov
Senior Computing Specialist                          phone: (541)
754-4468
mathematical statistician                              fax: (541)
754-4716


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

Date: Wed, 14 Apr 1999 21:08:36 GMT
From: christianarandaOUT@OUTyahoo.com (Christian M. Aranda)
Subject: efficient file I/O for file updates
Message-Id: <371603d1.3703585@news.bmc.com>

Hi folks -

The following is a script which automatically updates the /etc/system
file.  Basicall, it takes the value and increments it by what is in
the hashref for that kernal_tag.  The problem is, it is doing WAY too
much work.

Right now, I have it opening the file 6 times so that I can check each
line for the 6 values I have to set, then write the new file and start
over.  I think you'll understand the problem once you see the code
below.

Because of this, it's inefficient as, well, you know.

Any and all suggestions appreciated!  Tear it apart -- it's the only
way I'll learn :)

[begin code]

sub update_kernal {

@kernal_tags = ("set semsys:seminfo_semmns=",
                "set semsys:seminfo_semmni=",
                "set shmsys:shminfo_shmseg=",
                "set shmsys:shminfo_shmmni=",
                "set semsys:seminfo_semmap=",
                "set semsys:seminfo_semmnu=");

%kernal_vals = (
   "@kernal_tags[0]", "140",
   "@kernal_tags[1]", "90",
   "@kernal_tags[2]", "44",
   "@kernal_tags[3]", "100",
   "@kernal_tags[4]", "50",
   "@kernal_tags[5]", "170"
);

   $old = "./system.old";
   $orig = "./system";
   $new = "./system.new"; ## intermediate never seen
   $old_vals = $sys_changes = '';  ## no warning messages (-w)

   system("cp $orig $old"); ## create backup 

   for ($x = 0; $x < @kernal_tags; $x++) {
      $new_val = $1 = 0; ## no warnings!
      open ( FH, "$orig" ) || die "can't: $!";
      open ( NEW, ">>$new" ) || die "can't: $!";

      while ( <FH> ) {

         if ( index($_, $kernal_tags[$x]) > -1 ) { 
            $old_vals .= "* $_";
            /([\d]+)/;
            $new_val = $1 + $kernal_vals{$kernal_tags[$x]};
            s/$1/$new_val/;
            $sys_changes .= "* $kernal_tags[$x]$new_val\n";
         }
         print NEW $_; 
      }

      close (FH);
      close (NEW);
      system ("rm $orig");
      system ("mv $new $orig");
   }
}

[end code]


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

Date: 14 Apr 1999 16:11:32 -0600
From: Greg Wimpey <greg.wimpey@waii*removetomail*.com.invalid>
To: christianaranda@yahoo.com (Christian M. Aranda)
Subject: Re: efficient file I/O for file updates
Message-Id: <snzp4adf8r.fsf@ddcspn37.denver.waii.com>

christianarandaOUT@OUTyahoo.com (Christian M. Aranda) writes:

> Hi folks -
> 
> The following is a script which automatically updates the /etc/system
> file.  Basicall, it takes the value and increments it by what is in
> the hashref for that kernal_tag.  The problem is, it is doing WAY too
> much work.
> 
> Right now, I have it opening the file 6 times so that I can check each
> line for the 6 values I have to set, then write the new file and start
> over.  I think you'll understand the problem once you see the code
> below.
> 

If you need to reduce the amount of file open()ing/close()ing, you
need to switch your loops.  Speaking in pseudocode, rather than:

for (each kernel_tag) {
   open file
   while (read line from file) {
      update (line)
   }
   close file
}

you want:

open file
while (read line from file) {
   for (each kernel_tag) {
      update (line)
   }
}
close file

Implementing this in perl is left as an exercise to the reader :) In
particular, the meaning of $_ will change if you swap the inner and
outer loops.  If you make the for loop the inner loop, $_ may no
longer refer to the line you read from the file.

I think this is what you're looking for.  Hope this helps.

-- 
Greg Wimpey
greg.wimpey@waii*removetomail*.com.invalid


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

Date: 14 Apr 1999 21:21:46 GMT
From: stanley@skyking.OCE.ORST.EDU (John Stanley)
Subject: Re: FAQ 1.1: What is Perl?
Message-Id: <7f30ta$1t2$1@news.NERO.NET>

In article <7f2mnh$ao2$6@news.rz.uni-karlsruhe.de>,
Marc Haber <Marc.Haber-usenet@gmx.de> wrote:
>stanley@skyking.OCE.ORST.EDU (John Stanley) wrote:
>>Instead of splitting the FAQs up into little pieces and stuffing them
>>onto the net in dribs and drabs, can you please just post the updated
>>FAQs whole?
>
>The idea is to make Newbies searching DejaNews or their local spool
>find something in the subject.

Newbies using DejaNews to access the FAQ will find the words in the full
FAQ just like they find them in the chopped up versions. And the rest of
us won't see the traffic volume go up.

Posting to keep DejaNews happy is not productive.



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

Date: 14 Apr 1999 21:23:25 GMT
From: stanley@skyking.OCE.ORST.EDU (John Stanley)
Subject: Re: FAQ 1.1: What is Perl?
Message-Id: <7f310d$1te$1@news.NERO.NET>

In article <MPG.117e8d571e7ef7b79898af@nntp.hpl.hp.com>,
Larry Rosler <lr@hpl.hp.com> wrote:
>I, for one, appreciate gettimg the FAQs in quickly re-readable short 
>pieces.

And as someone who has a concern for the mail side of the house, do not.

>If we can assume that as FAQs are updated, they are uploaded to 
>http://www.perl.com/ or http://www.perl.org/ , then there is easy access 
>to them as packed units.

And you can chop them up as you see fit.



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

Date: 14 Apr 1999 22:11:52 GMT
From: billynospam@mirror.bt.co.uk (Graham Ashton)
Subject: Re: flocking question - worried
Message-Id: <slrn7ha4l9.j6n.billynospam@wing.mirror.bt.co.uk>

In article <hr0R2.1417$MQ1.11163@typhoon-sf.pbi.net>, Benjamin Franz wrote:
>
>No. This won't work, either. 'flock' works on
>_file handles_ - not _file names_.

just to go off on a quick tangent...

if you want to unlock a file after you've finished writing to it, and
you unlock it with flock() just before you close() it, do you have a
potential race condition?

i.e. could the buffers be flushed in between calling flock() and
close(), allowing another process to obtain a lock on the file before
the first process has finished writing?

I know that some versions of the open syscall unlock files whilst
closing them, but I think I read somewhere that this isn't always the
case.

are there any fully portable solution to this problem? I'm currently not
bothering unlock files, but am letting close() do it for me.

-- 
Graham


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

Date: Wed, 14 Apr 1999 22:41:37 GMT
From: NOSPAMcrstlblu@planet.eon.net
Subject: Re: flocking question - worried
Message-Id: <37122a7f.3885937@news.planet.eon.net>

On Wed, 14 Apr 1999 16:34:44 -0500, danbeck@scott.net (Daniel Beckham) wrote:
>I'm not sure what type of database you are using, but could you use it to 
>store the counter information?  Since most database engines already 
>account for similtaneous read/writes, why not let it do the work for you?  
>Create a new table with an int field in it and increment the number 
>everytime you need to... locking issues solved...
>Daniel

	so,... are "DBM_File", and "NDBM_File" qualified to be referred to as
	DATABASE ENGINES???

	thankx,
wj


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

Date: Wed, 14 Apr 1999 18:13:03 -0400
From: CUKSA <cuksa@cuksa.monisys.ca>
Subject: Help on Sendmail!
Message-Id: <371512EE.C360C3FD@cuksa.monisys.ca>

Please, help!

I would like to know how to specify the name of the sender and reply
address.

This is my code.

open (MAIL, "|/usr/lib/sendmail -t");
print MAIL "To: $_\n";
print MAIL "From: Me\n";
print MAIL "subject: $sub\n";
print MAIL "Dear $name:\n\n$con\n";
close (MAIL);

Thanks in advance!






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

Date: Wed, 14 Apr 1999 18:16:03 -0400
From: CUKSA <cuksa@cuksa.monisys.ca>
Subject: Help on Sendmail!
Message-Id: <371513A3.7C8CF3D6@cuksa.monisys.ca>

Please, help!

I would like to know how to specify the name of the sender and reply
address.

This is my code.

open (MAIL, "|/usr/lib/sendmail -t");
print MAIL "To: $_\n";
print MAIL "From: Me\n";
print MAIL "subject: $sub\n";
print MAIL "Dear $name:\n\n$con\n";
close (MAIL);

Thanks in advance!





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

Date: 14 Apr 1999 15:49:32 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: how do I match all the "1"s in strings like 231451,3132414131,etc?
Message-Id: <m1n20a24xv.fsf@halfdome.holdit.com>

>>>>> "SAM" == SAM  <same@minspring.com> writes:

SAM> Hello,
SAM>              Here is a newbie question on perl re.
SAM> How do I match a minimum of 2  and a maximum of 4 "1"s in strings like
SAM> 2312312134
SAM> 56132141313416512

SAM> I used the following re

SAM> $String =~ /[1]{2,4}/g;

SAM> but this seem to match only successive occurances of "1"s.

When you hear "character counts", think "tr".

    my $count = $String =~ tr/1//;
    if ($count >= 2 and $count <= 4) { ... }

print "Just another Perl hacker,"

-- 
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@teleport.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me


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

Date: Wed, 14 Apr 1999 17:49:01 -0400
From: "Robert E Webb" <bwebb@fred.net>
Subject: Re: how to find unused IP addresses on a subnet
Message-Id: <138R2.38$q42.78846@news.abs.net>

On some tcp stacks you can ping the broadcast address, and it will ping all
addresses in that subnet. Not sure which stacks support this. That may be
quicker than pinging each individual address.

HTH

Bob/
<mjbower@my-dejanews.com> wrote in message
news:7f29jp$a29$1@nnrp1.dejanews.com...
>
>
> I'd like to find the unused IP addresses on a subnet,  at the moment I use
a
> script which loops and tests the result from a ping command,  which takes
1
> second per IP address.
>
> Does anyone know a quick way of doing this ?
>
> -----------== Posted via Deja News, The Discussion Network ==----------
> http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own




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

Date: Wed, 14 Apr 1999 12:23:30 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: I need a script written.
Message-Id: <2ef2f7.p17.ln@magna.metronet.com>

Foggy (foggy@foggys-funnies.com) wrote:

: the script verifies the
: address to be good


   If you NEED that, then you have a big problem, 
   because it is impossible.

   You will need to back off to something more like:

      "the script verifies that the address looks kind of
       like an address"


: the same people to be able to come back later, and use the same box to
: UNsubscribe. 


   What's to keep Joe Pissedoff from unsubscribing other folks?


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


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

Date: Wed, 14 Apr 1999 17:30:01 -0700
From: serguei <sergue@ica.net>
Subject: I need help!!!!! help me
Message-Id: <37153309.BBB11219@ica.net>

Hi everybody,

I have a problem that I cant to solve.
I would very much appreciate it if someone can help me.
The problem is:
 I wrote database program in Perl (flat database)
The program can write dates to database, search database.
The line is ($num, | $one, | $two, | $three, | $four, | $five, | $six, |
$seven, |$eight, | $nine)
Besides I counted every line it's parameter $num
In short every database line has its own number.
Searching database I get short dates from database only three parameters
$num, $one, and $two.
Parameter $one has link to another script that draws out more
information from the database line (all parameter)
The question is:
How can I make a link from parameter $one to draw out exactly the line
from database that content parameter $one
using the number ($num) of each database line?

sincerely,

Serguei



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

Date: Wed, 14 Apr 1999 15:01:13 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: I need help!!!!! help me
Message-Id: <37151029.42E39C14@mail.cor.epa.gov>

serguei wrote:
> 
> Hi everybody,
> 
> I have a problem that I can?t to solve.

I don't think we can solve it either.  Not with just a generic
description.  Please submit a small but complete example showing what 
went wrong, the error codes you got, any output, and what output
you were expecting. 

> I would very much appreciate it if someone can help me.
> The problem is:
>  I wrote database program in Perl (flat database)
> The program can write dates to database, search database.
> The line is ($num, | $one, | $two, | $three, | $four, | $five, | $six, |
> $seven, |$eight, | $nine)
> Besides I counted every line it's parameter $num
> In short every database line has its own number.
> Searching database I get short dates from database only three parameters
> $num, $one, and $two.
> Parameter $one has link to another script that draws out more
> information from the database line (all parameter)

Sorry, but I can't figure out what you're getting at from this
description.

> The question is:
> How can I make a link from parameter $one to draw out exactly the line
> from database that content parameter $one
> using the number ($num) of each database line?

I have an icky feeling you're trying to make a symbolic reference
somewhere in here.  Please don't do that.

David
-- 
David Cassell, OAO                               
cassell@mail.cor.epa.gov
Senior Computing Specialist                          phone: (541)
754-4468
mathematical statistician                              fax: (541)
754-4716


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

Date: 14 Apr 1999 21:39:46 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Location target
Message-Id: <7f31v2$ccu$1@client2.news.psi.net>

Dreas van Donselaar (dreas@email.com) wrote on MMLII September MCMXCIII
in <URL:news:7f2r41$1q7$1@news.quicknet.nl>:
@@ Is it possibvle to specify a target when I use location?
@@ 


$ perldoc location
No documentation found for "location".
$ perldoc target
No documentation found for "target".
$ perldoc -f location
No documentation for perl function `location' found
$ perldoc -f target
No documentation for perl function `target' found
$ perldoc -q location
No documentation for perl FAQ keyword `location' found
$ perldoc -q target
No documentation for perl FAQ keyword `target' found
$


Probably not, I'd say.




Abigail
-- 
perl -MNet::Dict -we '(Net::Dict -> new (server => "dict.org")
                       -> define ("foldoc", "perl")) [0] -> print'


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

Date: Wed, 14 Apr 1999 17:51:23 -0400
From: Tom Karches <twk@unity.ncsu.edu>
Subject: Looking for y2k code scanner for Perl code
Message-Id: <37150DDB.9C463E87@unity.ncsu.edu>


We would like to scan our internally developed Perl code for potential
y2k coding problems. If someone has develped such a tool, I'd like to
hear from you.

Thanks,
Tom
-- 
Tom Karches
Systems Programmer, Information Technology
North Carolina State University
phone...919.515.5508...email...twk@ncsu.edu


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

Date: Wed, 14 Apr 1999 22:47:18 GMT
From: "Steve Springett" <sspringett@cwe2.com>
Subject: Need to print \n - Not do a carrage return
Message-Id: <WV8R2.1021$DZ3.89653374@dca1-nnrp1.news.digex.net>

I am trying to actually print a \n to the browser but do not know how.  For
example:

print "<PARAM NAME = \"contents\" VALUE = \"First Line\nSecondLine\">\n";

The above code is part of a larger piece that prints out HTML to the browser
and has a Java Applet.  I need to format the text for the applet using a \n
but perl interprets it as the escape character it is.

What I need the browser to see is:
<PARAM NAME="contents" VALUE="First Line\nSecondLine>

How can I make this happen?







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

Date: Wed, 14 Apr 1999 14:37:53 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Novice needs learning suggestions
Message-Id: <37150AB1.6558FEAA@mail.cor.epa.gov>

Larry Rosler wrote:
> 
> [Posted and a courtesy copy mailed.]
> 
> In article <x3y676zavr5.fsf@tigre.matrox.com> on Wed, 14 Apr 1999
> 14:43:10 -0400, Ala Qumsieh <aqumsieh@matrox.com> says...
> > "Michael Villeneuve" <mickv@home.com> writes:
> > > Here's how it's done:
> > > 1)  Buy a good book on Perl (O'reilly has a couple)                                          ^^^^^^
> >
> > If by "couple" you mean "two", then you are wrong. O'Reilly has at
> > least 5 good books on Perl.
> > If by "couple" you mean "several", then you are wrong again, as my
> > webster dictionary defines "couple" as:
> >
> >       2. Two of the same kind connected or considered together; a
> >          pair; a brace.
> 
> No, you are wrong.  I know because I had my nose rubbed in it by this
> newsgroup a few weeks ago.

That's us.  Cruel.  Cruel, but fair.
 
>       4. An indefinite small number : FEW
> 
> > yeah yeah .. I am a pain in the butt sometimes :-)
> 
> Regardless...

"Isn't it true he nailed your wife's head to a coffee table?"
"Oh no no.. yes."

-- 
David Cassell, OAO                               
cassell@mail.cor.epa.gov
Senior Computing Specialist                          phone: (541)
754-4468
mathematical statistician                              fax: (541)
754-4716


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

Date: Wed, 14 Apr 1999 15:32:40 -0400
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: pattern matching
Message-Id: <x3y4smjatgn.fsf@tigre.matrox.com>


Jim Bostwick <jbostwic@valinor.cargill.com> writes:

> "There's more than one way to do it. (also more than shown here)..."
> 
> $var = (your input);
> 
> if ($var =~ /^\d+$/) {
>     # it's all digits
>     # begin-string, one-or-more digits, end-string
>     # change '+' to '*' for zero-or-more digits

Are negative numbers allowed? Your regexp won't deal with that.

> }
> 
> if ($var =~  /![0..9]+/ {
>     # it's got something else in it
>     # string contains something NOT in [0..9] set

Where did you get that from? Your regexp matches an exclamation mark,
followed by any combination of zero, dot or nine characters. This is
definitely NOT what you wanted to say. Not to mention that missing
right bracket. Perhaps, you should try out your code before posting.

	if ($var =~ /[^0-9]+/) {

which could be more easily written as:

	if ($var =~ /\D/) {

> }
> 
> if ($var eq int($var)) {
>     # string == number - wierd! (even for me)
>     # how many conversions does this do anyway? ;-)

This will complain under '-w' if $var is not a number.

> }
> 
> if ($var == ($var+0)) {
>     # DON'T do this!!
>     # it'll return a false positive long as $var begins with a digit!

Then why do you suggest it?

> }
> 
> Seriously, the first above is one good method. Later methods are sort of
> because it's been a long day.

It all depends on what the original poster wants. If all he wants is
digits, then I agree. But if he wants to match numbers in general
(like, 3.1415 or 1e6) then a trip to the FAQs would help.

> Try reading 'perldoc perlre', for lots more ways to do it...
> 
> enjoy
>     -j
> 
> 
> bing-du@tamu.edu wrote:
> 
> > Hello there,
> >
> > How to judge if a variable is composed of digits only?
> >
> > Thanks in advance for your hints.
> >
> > Bing
> >
> > -----------== Posted via Deja News, The Discussion Network ==----------
> > http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own



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

Date: Wed, 14 Apr 1999 23:45:04 +0200
From: Staffan Liljas <staffan@ngb.se>
Subject: Re: Q: Convert two newlines to \n<p>
Message-Id: <37150C60.C19760A5@ngb.se>

Jonathan Stowe wrote:
> Mike Collins <mike@w3z.com> wrote:
> > On Tue, 13 Apr 1999 21:12:25 -0500, therzog@knotech.com (Tim Herzog)
> > wrote:
> >>$everything =~ s/\n\n/\n<p>/sg;

Have you tried 

	$everything =~ s/\n\s*\n/\n<p>/sg;

this would fix any "empty" characters in the line. This should also do
what you probably want, i.e. convert more than two newlines to \n<p> as
well.

Staffan


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

Date: Wed, 14 Apr 1999 16:20:24 -0400
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: reference to an *existing* sub
Message-Id: <x3y3e23ar93.fsf@tigre.matrox.com>


Ronny <ronald_f@my-dejanews.com> writes:

> Hi,
> 
> does anyone know if there is a way to create a reference to an existing
> subroutine?

Is this a trick question?

> Example:
>   sub A {};
>   sub B {};
>   $ref = $some_condition ? \A : \B; # syntactically incorrect!!

$refA = sub { 
	# A's declaration goes here
}

$refB = sub { 
	# B's declaration goes here
}

$ref = $some_condition? $refA : $refB;

Does this do what you want?



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

Date: Wed, 14 Apr 1999 13:42:26 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: regex - meta char's
Message-Id: <22k2f7.b77.ln@magna.metronet.com>

Tim Herzog (therzog@knotech.com) wrote:
: In article <7f29e1$a0p$1@nnrp1.dejanews.com>, kscurry@my-dejanews.com wrote:

: >I am trying to use regex to match query data with wildcards
: >( *,? ) 


   Wildcards are regexen are not the same thing.

   * actually matches characters when a wildcard.

   It does not match anything in a regex.


   You meant to say "quantifiers", not "wildcards" there.

   wildcards are weak pattern matchers, regexen are powerful
   pattern matchers.

   You do yourself a disservice by confusing the two...


: >but I want other special characters ((,),{,},.,^) to
: >be interpreted literally.
: >
: >Any help would be appreciated.

: Just precede characters that you want to be interpreted literally with a
: "\"  For example:

: /\*.*/

: will match "*hobo" and "*mail" but not "hobo"


   Or, if the regex is not known when you write the script,
   backslash _all_ punctuation chars, then unescape the
   few that you want to retain their meta-ness:


     my $re = quotemeta 'a(b*';         # escape a bunch of chars

     $re =~ s/\\([*?])/$1/;             # unescape desired metachars


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


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

Date: Wed, 14 Apr 1999 23:17:34 +0100
From: "Robert Carter" <robert@chackmore.demon.co.uk>
Subject: Sending data to HTML from perl script
Message-Id: <924128628.15247.0.nnrp-02.c2deb910@news.demon.co.uk>

Can any body helpme. I am printing text from my perl script to HTML.

print "Content-type: text/html\n\n";
print"hello world";

The browser opens a new page automatically and displays the message.

1.    I want to define the background that the browser uses when it displays
the output from the script. Is there a command for this?

2.    Can I print to the current page?



Thanks

Robert





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

Date: Wed, 14 Apr 1999 17:22:01 -0400
From: "Dan Smorey Jr." <dsmorey@unconundrum.com>
Subject: URI.pm not installing with libwww-perl
Message-Id: <7157B516B5F8D11198320080296571A26879F7@EXCHANGE>

This code comes from the May edition of Web Techniques.  *** It is not
my own...***

 unless ($ua) {
       require LWP::UserAgent;
       require URI;

       $ua = LWP::UserAgent->new;
       $uri = URI->new('http://www.dejanews.com/[ST_rn=ps]/dnquery.xp');
     }
     $uri->query_form(
                      ST => "PS",        # hidden
                      QRY => $query,
                      "groups" => "misc.jobs.offered",
                      "fromdate" => $fromdate,
                      "todate" => $todate,
                     );

When I get to the URI line, of course it's not going to find the URI.pm
file because for some reason the libwww-perl on ActiveState's site
didn't install uri.pm.  Can somebody tell me why libwww-perl doesn't
have the uri.pm file and where I can get it for a Win32 machine?  I
needed GIFgraph and Date::Calc which I found and they installed fine,
however, libwww-perl seemed to not have everything it was supposed to or
is there something that needs to be changed here?

Thanks in advance.

Dan R. Smorey Jr.
Programmer/Analyst
UnConundrum, Inc.
http://www.unconundrum.com
dsmorey@unconundrum.com




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

Date: Wed, 14 Apr 1999 18:16:41 -0400
From: Raymond Yu <WizeGuy@nettaxi.com>
Subject: Would anyone care to teach me perl?
Message-Id: <371513C8.3CD3086C@nettaxi.com>

Would anyone care to teach me perl?  Just with email though.



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

Date: Wed, 14 Apr 1999 18:51:14 -0400
From: evil Japh <jeffp@crusoe.net>
Subject: Re: Would anyone care to teach me perl?
Message-Id: <Pine.GSO.3.96.990414184948.9341H-100000@crusoe.crusoe.net>

> Would anyone care to teach me perl?  Just with email though.

Sure.  First lesson:

1) open a terminal window
2) type: man perl
3) if that doesn't work, try: perldoc perl
4) if that doesn't work, try: which perl
5) if that doesn't work, you don't have perl
6) download perl
7) go to step 1

-- 
Jeff Pinyan (jeffp@crusoe.net)
www.crusoe.net/~jeffp

Crusoe Communications, Inc.
732-728-9800
www.crusoe.net



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

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


Administrivia:

Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing. 

]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body.  Majordomo will then send you instructions on how to confirm your
]subscription.  This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.

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

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.

The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.

The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.

For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V8 Issue 5385
**************************************

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