[18658] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 826 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu May 3 06:07:19 2001

Date: Thu, 3 May 2001 03: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)
Message-Id: <988884307-v10-i826@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Thu, 3 May 2001     Volume: 10 Number: 826

Today's topics:
    Re: ActiveState config problem <mk@ticklets.com>
    Re: blank lines on asp using PerlScript (Eric Bohlman)
    Re: DBD::ODBC <mrp@hafatel.com>
        Does anyone have anything to do with perl.org? <ralawrence@mailandnews.co.uk>
        flushing to gdbdm files (Diana McCarthy)
    Re: Hacker challenge. Can you break this script for me? <jfreeman@tassie.net.au>
        hexadecimal convert to binary <Per-fredrik.Pollnow@epk.ericsson.se>
    Re: How to: Create Regex which extracts N number of wor <bart.lateur@skynet.be>
        newbie question <hpya78@postoffice.pacbell.net>
    Re: NT version of LWP::UserAgent <kstep@pepsdesign.com>
    Re: Perl for Dreamweaver Extension Posted <jfreeman@tassie.net.au>
        Please repost name of ssi offline processor <alun.moon@unn.ac.uk>
        re-evaluate as a scalar <"relaxedrob@optushome.com.au">
    Re: Recursing a directory tree <jfreeman@tassie.net.au>
    Re: Recursing a directory tree <jfreeman@tassie.net.au>
    Re: Recursing a directory tree (Dave Bailey)
    Re: Running perl script on the DOS prompt (Windows) <jfreeman@tassie.net.au>
        Test for integer? <"relaxedrob@optushome.com.au">
    Re: Test for integer? <jfreeman@tassie.net.au>
    Re: Test for integer? <"relaxedrob@optushome.com.au">
    Re: Test for integer? <"relaxedrob@optushome.com.au">
    Re: Test for integer? <bart.lateur@skynet.be>
    Re: Uploading to http sites nobull@mail.com
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Thu, 3 May 2001 10:43:17 +0200
From: "Paul Kersey" <mk@ticklets.com>
Subject: Re: ActiveState config problem
Message-Id: <9cr5s2$g0p$1@news1.xs4all.nl>

> An upgrade installation of Perl 5.6.0.623 a couple of weeks ago rendered
> previously-working scripts inaccessible.  The path on the NT 4 server is
> c:\perl\bin, where the exe resides.  A test script located in the
> \inetpub\wwwroot\myMain\cgi-bin directory executes properly on the web,
but
> anywhere else (including \inetpub\wwwroot\myMain) they yield a 403.1
Execute
> access forbidden error.  The permissions for both directories are
identical:
> Everyone has Read/Execute.
>
> What did or didn't I do?

My first guess is that it has something to do with your web-server
configuration.
When your using IIS, make sure you give all directories execute rights (you
can do this with the Internet Service Manager).
When you are using Apache webserver: check your httpd.conf file.

Good luck!





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

Date: 3 May 2001 07:32:27 GMT
From: ebohlman@omsdev.com (Eric Bohlman)
Subject: Re: blank lines on asp using PerlScript
Message-Id: <9cr1ib$732$1@bob.news.rcn.net>

Just in <justin.devanandan.allegakoen@intel.com> wrote:
> I do believe I'm stuck yet again.

> I'm using PerlScript for an asp, the file handling and
> processing of the file occur before the actual
> table is displayed.

> But before the table is printed on the asp there are a
> whole heap of blank lines printed for no apparent
> reason. (It seems they are proportional to the
> amount of rows in the table).

> Viewing the source HTML doesnt help - I can't see
> any dead give aways like extra <P>'s or <BR>'s

Look for markup inside <table> or <tr> but outside any <td>.  You might 
want to capture your output and run it through an HTML validator.  What 
you describe is a fairly common way for browsers to "recover" from nesting 
errors inside tables.


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

Date: Thu, 3 May 2001 15:09:34 +1000
From: "Michael R. McPherson" <mrp@hafatel.com>
Subject: Re: DBD::ODBC
Message-Id: <9cqpfb0168r@enews3.newsguy.com>


"Chris" <cpryce@pryce.net> wrote in message
news:B7144E7F.3E81%cpryce@pryce.net...
> in article dwilga-MUNGE-62C8AB.10572230042001@nap.mtholyoke.edu, Dan Wilga
> at dwilga-MUNGE@mtholyoke.edu wrote on 04/30/2001 9:57 AM:
[SHORT]
> If you're running Apache, you can also use the SetEnv directive to set the
> environment variables for the Web server.
>
> See: http://httpd.apache.org/docs/env.html (or
> http://httpd.apache.org/docs-2.0/env.html for version 2.0 docs)
>
> For more information.
>
> -----
> cp
>

Thanks Chris ... That did the trick.  I had to set both the ODBCINI and
UDBCINI paths in apache.






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

Date: Thu, 3 May 2001 06:02:20 -0400
From: Richard Lawrence <ralawrence@mailandnews.co.uk>
Subject: Does anyone have anything to do with perl.org?
Message-Id: <3AF527FC@MailAndNews.com>

Hi,

Can anyone help? A long time ago I (foolishly) posted a message to the 
perl5porters list regarding a bug in Net::Ping from my work address. Less 
than 
several weeks later, I experienced large amounts of unsolicited commercial 
email (spam) to my always unpublished email address.

Several months later I came across a webpage at perl.org which contained my 
email address so I sent an letter to an email address I have long forgotten 
asking that my posting be either removed or that my email address be masked 
so 
that web crawlers would not pick up this address. I received a response, 
which 
I have long since deleted, which indicated this would happen.

About 18 months later, whilst searching on the web, I was a little surprise 
to 
find the offending page at http://tmtowtdi.perl.org/archive/25/3360 which is 
still showing my email address despite assurances that it would be removed, 
or 
at least munged.

So I fired off another letter asking if it would be possible to have either 
the posting removed or if they wish to preserve the content to munge my 
email 
address and remove the signature that contains my work and mobile number as 
well as my email address. As of yet I've had nothing back.

I've now found that my email address has now appears on 
http://archive.develooper.com/perl5-porters@perl.org/msg02708.html too! Does 
anyone know of anyone I can speak to in terms of getting my address munged?

Thanks!

Rich

ps. To anyone considering mailing any of the mailing lists, MUNGE YOUR EMAIL 
ADDRESS. I'm a little disappointed they didn't mention that it would be 
posted 
up for everyone (including email harvesters) to see and, as such, I'm 
suffering the concequences :o(

------------------------------------------------------------
 Get your FREE web-based e-mail and newsgroup access at:
                http://MailAndNews.com

 Create a new mailbox, or access your existing IMAP4 or
 POP3 mailbox from anywhere with just a web browser.
------------------------------------------------------------



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

Date: 3 May 2001 09:44:45 GMT
From: dianam@cogs.susx.ac.uk (Diana McCarthy)
Subject: flushing to gdbdm files
Message-Id: <9cr9ad$e25$1@ames.central.susx.ac.uk>
Keywords: flush buffer gbdm

I wish to flush buffers at specific points in my program. I can see that
$oldfh = select("FILE");
$| = 1;

will flush FILE automatically, (presumably until I change back with $| = 0).
Can I flush to GBDM files

thanks for any advice
Diana


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

Date: Thu, 03 May 2001 15:13:43 +1000
From: Jfreeman <jfreeman@tassie.net.au>
Subject: Re: Hacker challenge. Can you break this script for me?
Message-Id: <3AF0E907.9D85048F@tassie.net.au>



"Randal L. Schwartz" wrote:

> >>>>> "Bart" == Bart Lateur <bart.lateur@skynet.be> writes:
>
> Bart> It's not *that* illogical. Randal has a few favourite examples, on how
> Bart> loading or not loading a module changes how perl compiles a script.
>
> You don't even need to load a module:
>
>         BEGIN {
>           eval (time % 2 ? 'sub zany ();' : 'sub zany (@);');
>         }
>         zany / 25 ; # / ; die "do I die or not?";
>
> It's the halting problem (I think).  You cannot determine whether or
> not to strip that comment without *executing* the Perl code in the
> BEGIN block.  And even then, on even-numbered seconds, it'll die, but
> not odd-numbered!

Yes this problem is totally insoluble and documented in the pod under the heading
Abigail's teaser. Exactly the same principle but the code will or will not be
broken if you strip the comment depending on whether or not it is called with a
command line arg.

    BEGIN {if ($ARGV [0]) {eval 'sub foo ()  {print}'}
           else           {eval 'sub foo ($) {print}'}
    }
    $_ = "# Just another Perl Hacker\n";
    foo /#/;
    1;

    # the variable $& stores the last match found
    ($&) ? print "Matched: $&\n" : print "\$& undefined\n";

Calling this script with warnings enabled without an argument:

    C:\>perl -w test.pl
    Just another Perl Hacker #
    Matched: #

    C:\>

and with an argument:

    C:\>perl -w test.pl 1
    Useless use of division (/) in void context at test.pl line 5.
    Just another Perl Hacker #
    $& undefined

    C:\>

James

>
>
> print "Just another Perl hacker,";
>
> --
> Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
> <merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
> Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
> See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!



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

Date: Thu, 3 May 2001 11:18:28 +0200
From: "Per- Fredrik Pollnow" <Per-fredrik.Pollnow@epk.ericsson.se>
Subject: hexadecimal convert to binary
Message-Id: <9cr6u5$b9u$1@newstoo.ericsson.se>

Hi,

I need some help with a perl script I have triad to script. I'm using sun
Solaris and snoop, what I want to do is to take out the data hexadecimal and
convert it to binary format.

I have a program that does binary to hexadecimal:

perl - myfile

 open(STDIN, $ARGV[0]) || die "Can't open $ARGV[0]: $!\n"
  if $ARGV[0];

 $empty = pack "N4", 0, 0, 0, 0; # for the last line, if < 16

 while ($len = read (STDIN, $data, 16)) { # take 16 Bytes at once
     @array = unpack('N4', ($len < 16) ? ($data | $empty) : $data);
     $data =~ tr/\0-\37\177-\377/./;
     printf "%8.8lx\t%8.8lx %8.8lx %8.8lx %8.8lx\t%s\n",
  $offset, @array, $data;
     $offset += 16;
 }
 __END__

But I want it to do the same thing but hexadecimal to binary.

The snoop dump looks like this:

    0: 00d0 d335 b41c 0800 20a9 8a94 0800 4500  ...5.... .....E.
   16: 0088 9764 4000 ff06 37b1 88e1 7067 88e1  ...d@...7...pg..
   32: 2a30 a065 1770 d983 8725 004d e786 5018  *0.e.p...%.M..P.
   48: 2238 6667 0000 4601 0005 0340 0032 0340  "8fg..F....@.2.@
   64: 0037 0013 0130 0007 000d 4c28 000e 0340  .7...0....L(...@
   80: 0032 0340 0034 0013 013b 5573 696e 6720  .2.@.4...;Using
   96: 6465 7669 6365 202f 6465 762f 686d 6520  device /dev/hme
  112: 2870 726f 6d69 7363 756f 7573 206d 6f64   (promiscuous mod
  128: 6529 4601 0005 0340 0032 0340 0036 012b  e)F....@.2.@.6.+
  144: 0130 0007 000d     .0....

Can someone please help me ?





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

Date: Thu, 03 May 2001 07:54:37 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: How to: Create Regex which extracts N number of words before target word
Message-Id: <uk22ftsgjja83u3dfqo8fmv1hqlf4rl2r7@4ax.com>

Richard J. Rauenzahn wrote:

>Now the tricky part which Bart was probably pointing out is that after
>you've captured the first cat, you're now past the second one.

Yes. If the intention was to capture the first "cat", and get the (at
most) n words before it, then you've gone too far. The regexes tries to
match n words, whatever they are, and then "cat".

> At this point, I'd personally use an
>RE to split up the words and use an array and a simple algorithm to find
>the matches:

I think I'd use split.

	my ($pre, $match, $post) = split /(cat)/, $_, 2;
	
These behave just like $`and $' but without overhead  for the other
regexes.

Now, continue matching with $pre:

	$pre =~ /((?:\S+\s+){0,2})$/;

This will match AT MOST 2 words at the end of the prefix.

If you want continue processing the string where you left of, continue
with $post.

-- 
	Bart.


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

Date: Thu, 03 May 2001 01:27:50 -0700
From: Paul Quigley <hpya78@postoffice.pacbell.net>
Subject: newbie question
Message-Id: <3AF11685.7C27B278@postoffice.pacbell.net>

Hi all,

How to add up two numbers together?

File:
apple 32
apple 21
orange 40
pear 98

output:
apple 53
orange 40
pear 98



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

Date: Thu, 3 May 2001 01:43:43 -0400
From: "Kurt Stephens" <kstep@pepsdesign.com>
Subject: Re: NT version of LWP::UserAgent
Message-Id: <9cqr68$592$1@slb0.atl.mindspring.net>

"smilepak" <smilepak@hotmail.com> wrote in message
news:xd1I6.3108$Cq3.285904@newsread1.prod.itd.earthlink.net...
> anyone know if there is a version of LWP::UserAgent for the NT version of
> Perl? If so, where and how can I obtain a copy of it?

If you're talking about ActiveState Perl, you should already have
LWP::UserAgent installed.  ActiveState Perl uses the Perl Package Manager
(PPM) module to install other modules from an online package repository.
The PPM module uses LWP::UserAgent for its HTTP functionality.

Regardless of your Perl build, you can find LWP::UserAgent and most other
commonly used modules on CPAN.

HTH,

Kurt Stephens





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

Date: Thu, 03 May 2001 15:40:52 +1000
From: Jfreeman <jfreeman@tassie.net.au>
Subject: Re: Perl for Dreamweaver Extension Posted
Message-Id: <3AF0EF64.21C18B59@tassie.net.au>



BarryK wrote:

> Macromedia has announced a Perl for Ultradev extension. I have no idea what
> it does, but if you have Ultradev I suspect it's powerful. You can get it
> at:
>
> http://www.macromedia.com/exchange/ultradev/
>
> If you can explain to me a) what it does and

This is not a perl question. But here is an answer anyway:

Most people can not code. Many would like the benefits of  code for thier
website. You can write software to allow users to point and click on
'behabiours'. The required code is then automatically generated by the visual
development tool. This machine generated code is generally quite reliable.
Basically a GUI approach to coding trying to make it idiot proof.

Sounds good and I guess it is if you have no coding background. Unfortunately
these visual development tools generally produce the most convoluted, complex,
bloated, unwieldy code you have ever seen. It is generally almost impossible for
humans to decode let alon modify.  Here are a few beautifully helpful var and
sub names taken from some machine generated javascript:

CSAction1
CSIm[im][3] = action;
CSAg
CSIm

If the required behaviour is not available then you are back to coding it
yourself.

> b) how to use it, I'd be in
> your debt.

I suggest you start at the website and work your way through the product
description, FAQs, and User support forums all documented there, no doubt they
will have an interest. Start here:

http://www.macromedia.com/software/ultradev/

James




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

Date: 03 May 2001 09:38:42 +0100
From: Alun Moon <alun.moon@unn.ac.uk>
Subject: Please repost name of ssi offline processor
Message-Id: <u66fi3jzh.fsf@unn.ac.uk>

Recently someone asked about the name of a Perl program that performed
the SSI translations and substitutions offline.
I've forgotten the name of the program, can some kind soul repost the
name so I can go search for it (or even a URI).

Many thanks

Alun Moon


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

Date: Thu, 03 May 2001 09:24:55 GMT
From: "Rob" <"relaxedrob@optushome.com.au">
Subject: re-evaluate as a scalar
Message-Id: <Ht9I6.1975$76.8217@news1.rdc1.nsw.optushome.com.au>

Hi all!

I want to have scalar that includes another scalar:

use strict;
my $one = "";
$two = "Isn't this a nice $one!";

I want to assign a particular value to $one whenever I need and then output
$two so it will contain a 'dynamic' value of $one.

My problem is that perl interpolates into $two whatever value of $one it has
when the scalars are declared and then forgets it was ever a variable..

So how do I declare $two in such a way that perl will remember the embedded
$one is a scalar and re-evaluate it when I output $two?

Thanks!
Rob




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

Date: Thu, 03 May 2001 16:14:49 +1000
From: Jfreeman <jfreeman@tassie.net.au>
Subject: Re: Recursing a directory tree
Message-Id: <3AF0F759.A325C0EF@tassie.net.au>

[Posted to perl.misc and CC Author]

Arun Horne wrote:

> Does anyone have some simple code to recurse a directory tree please?? Best
> regards Arun Horne.

Here you are:

#!usr/bin/perl -w

use strict;

my $root = 'e:/perl/lib/'; # point to wherever
my @dirs;

print "Checking directory $root (including all subdirectories)\n";
print "Searching....";

# now find all subdirectories. by pushing the found first level subdirectories
# onto the end of our @dirs list we will eventually search these subdirs for
# their first level subdirectories and so on ad infinitum until @dirs contains
# the entire tree above $root.

$dirs[0] = $root;
for (@dirs){
 print ".";
  my @subdir =&find_dirs($_);
 push (@dirs,@subdir) if @subdir;
}
print "\nHere are all the directories for root: $root:\n";
@dirs = sort @dirs;
for (@dirs) {print "$_\n";}

exit;

# find the first level subdirectories in a given path and return a list

sub find_dirs {

    my $path = shift;
 my @dirs;
 opendir (DIR, $path) || die "Unable to open directory $path: $!\n";
 my @files = readdir DIR;
 close DIR;
 for (@files) {
  next if m/^\.{1,2}/; # skip the dot files
  if (-d "$path$_"){
     push @dirs,"$path$_/" ;
  }
 }
  return @dirs;
}


Presume this is what you wanted.

James

>
>
> Replace NOSPAM with @ in address to reply



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

Date: Thu, 03 May 2001 16:15:25 +1000
From: Jfreeman <jfreeman@tassie.net.au>
Subject: Re: Recursing a directory tree
Message-Id: <3AF0F77D.32EBA780@tassie.net.au>

[Posted to perl.misc and CC Author]

Arun Horne wrote:

> Does anyone have some simple code to recurse a directory tree please?? Best
> regards Arun Horne.

Here you are:

#!usr/bin/perl -w

use strict;

my $root = 'e:/perl/lib/'; # point to wherever
my @dirs;

print "Checking directory $root (including all subdirectories)\n";
print "Searching....";

# now find all subdirectories. by pushing the found first level subdirectories
# onto the end of our @dirs list we will eventually search these subdirs for
# their first level subdirectories and so on ad infinitum until @dirs contains
# the entire tree above $root.

$dirs[0] = $root;
for (@dirs){
 print ".";
  my @subdir =&find_dirs($_);
 push (@dirs,@subdir) if @subdir;
}
print "\nHere are all the directories for root: $root:\n";
@dirs = sort @dirs;
for (@dirs) {print "$_\n";}

exit;

# find the first level subdirectories in a given path and return a list

sub find_dirs {

    my $path = shift;
 my @dirs;
 opendir (DIR, $path) || die "Unable to open directory $path: $!\n";
 my @files = readdir DIR;
 close DIR;
 for (@files) {
  next if m/^\.{1,2}/; # skip the dot files
  if (-d "$path$_"){
     push @dirs,"$path$_/" ;
  }
 }
  return @dirs;
}


Presume this is what you wanted.

James

>
>
> Replace NOSPAM with @ in address to reply



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

Date: 03 May 2001 06:27:18 GMT
From: dave@sydney.daveb.net (Dave Bailey)
Subject: Re: Recursing a directory tree
Message-Id: <slrn9f1k9v.4cf.dave@sydney.daveb.net>

On Thu, 03 May 2001 16:15:25 +1000, Jfreeman <jfreeman@tassie.net.au> wrote:
>[Posted to perl.misc and CC Author]
>
>Arun Horne wrote:
>
>> Does anyone have some simple code to recurse a directory tree please?? Best
>> regards Arun Horne.
>
>Here you are:
>
>#!usr/bin/perl -w
[...]
>sub find_dirs {
>
>    my $path = shift;
> my @dirs;
> opendir (DIR, $path) || die "Unable to open directory $path: $!\n";
> my @files = readdir DIR;
> close DIR;
> for (@files) {
>  next if m/^\.{1,2}/; # skip the dot files

You don't want to do that.  For example, my home directory has 253
subdirectories which begin with "." (recursively counting subdirs
of my dot-directories):

[dave@sydney dave]$ find . -type d | grep "\.\/\." | wc
    253     292    7549
[dave@sydney dave]$ 

The poster's question has been answered many, many times on this 
newsgroup.  There is no need to waste time answering it again,
especially incorrectly.

--
Dave Bailey
davidb54@yahoo.com



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

Date: Thu, 03 May 2001 15:52:07 +1000
From: Jfreeman <jfreeman@tassie.net.au>
Subject: Re: Running perl script on the DOS prompt (Windows)
Message-Id: <3AF0F207.B64C888A@tassie.net.au>



Bruno Pagis wrote:

> Does anybody has a replacement for the hugly MS-DOS windows that comes by
> default with Microsoft windows (I'm talking of this window with a black
> background, no scrollbar, and so on ...).
> Is there an alternative to access the DOS prompt (something similar to an
> xterm).

It is similar. If by chance you have a default full screen setting right click
on the MSDOS prompt and select proerties.

Select the screen tab, click the window radio. Choose 50 lines for the initial
size if you want a scroll bar.

James

>
>
> Thanks. BRUNO.



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

Date: Thu, 03 May 2001 05:59:26 GMT
From: "Rob" <"relaxedrob@optushome.com.au">
Subject: Test for integer?
Message-Id: <2t6I6.1899$76.7930@news1.rdc1.nsw.optushome.com.au>

Hi all!

Is there a way for me to test if a scalar holds an integer value (positive
or negative)?

Thanks!

Rob




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

Date: Thu, 03 May 2001 17:35:45 +1000
From: Jfreeman <jfreeman@tassie.net.au>
Subject: Re: Test for integer?
Message-Id: <3AF10A51.A7C67BDE@tassie.net.au>



Rob wrote:

> Hi all!
>
> Is there a way for me to test if a scalar holds an integer value (positive
> or negative)?

Yes, run this

James

#!usr/bin/perl -w

use strict;

my $do_this_sub;

print "Simple match\n\n";
$do_this_sub = \&is_integer1;
&tests;
print "\nMore flexible match\n\n";
$do_this_sub = \&is_integer2;
&tests;
print "\nVery Accomodating match\n\n";
$do_this_sub = \&is_integer3;
&tests;

sub tests {
    &$do_this_sub('2');
    &$do_this_sub('+2');
    &$do_this_sub('-2');
    &$do_this_sub('42');
    &$do_this_sub(' + 2 ');
    &$do_this_sub('  2000');
    &$do_this_sub('2,000');
    &$do_this_sub('+2.0');
    &$do_this_sub('2000.00');
    &$do_this_sub('2,000,000.00');
    &$do_this_sub(',2000.');
    &$do_this_sub('20  00');
    &$do_this_sub('foo');
    &$do_this_sub('foo+2');
    &$do_this_sub('255.255.255.0');
}


#this allows only a leading + - or '' with digits ie an integer
sub is_integer1 {
    my $int = shift;
    $int =~ /^[+-]?\d+$/ ? print "'$int' is an integer\n" : print "'$int' is not
an integer\n";
}

#this ismore flexible it allows spaces before and after the + or - and
# after the numberno inter number  spaces
    sub is_integer2 {
    my $int = shift;
$int =~ /^\s*[+-]?\s*?\d+\s*$/ ? print "'$int' is an integer\n" : print "'$int'
is not an integer\n";
}

# this is even more flexy it allows spaces commas (not at begining or end)
# and a decimal point no inter number spaces
sub is_integer3 {
    my $int = shift;
    $int =~ /^\s*[+-]?\s*(?:\d+,)*\d+(?:\.\d+)?\s*$/ ? print "'$int' is an
integer\n" : print "'$int' is not an integer\n";
    print "\n$int is actually a default subnet mask!\n\nCheers\n\nJames\n" if
$int =~ m/^(?:\d+\.){3}\d$/;
}

>
>
> Thanks!
>
> Rob



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

Date: Thu, 03 May 2001 07:28:55 GMT
From: "Rob" <"relaxedrob@optushome.com.au">
Subject: Re: Test for integer?
Message-Id: <XM7I6.1928$76.8176@news1.rdc1.nsw.optushome.com.au>

I have constructed this line to do it:
  print "Variable is an integer!\n" if ($variable =~ /^-\d+$/);

but I was wondering if there is a perl function to do this?
Rob

"Rob" <"relaxedrob@optushome.com.au"> wrote in message
news:2t6I6.1899$76.7930@news1.rdc1.nsw.optushome.com.au...
> Hi all!
>
> Is there a way for me to test if a scalar holds an integer value (positive
> or negative)?
>
> Thanks!
>
> Rob
>
>




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

Date: Thu, 03 May 2001 07:39:54 GMT
From: "Rob" <"relaxedrob@optushome.com.au">
Subject: Re: Test for integer?
Message-Id: <eX7I6.1933$76.8159@news1.rdc1.nsw.optushome.com.au>

Howdy!

I came up with the same idea you are using here, but I was wondering if
there was an inbuilt function to do it... anyway, I have a couple of
questions about your code if you don't mind..

> my $do_this_sub;

> $do_this_sub = \&is_integer1;
> &tests;

What exactly are you doing here?
I can see:
 - creating a scalar called $do_this_sub and assigning it with a reference
to a subroutine. (Assigning it the physical address of the subroutine?)
 - calling the tests subroutine

> sub tests {
>     &$do_this_sub('2');
>     &$do_this_sub('+2');
>     &$do_this_sub('-2');
>     &$do_this_sub('42');
>     &$do_this_sub(' + 2 ');
>     &$do_this_sub('  2000');
>     &$do_this_sub('2,000');
>     &$do_this_sub('+2.0');
>     &$do_this_sub('2000.00');
>     &$do_this_sub('2,000,000.00');
>     &$do_this_sub(',2000.');
>     &$do_this_sub('20  00');
>     &$do_this_sub('foo');
>     &$do_this_sub('foo+2');
>     &$do_this_sub('255.255.255.0');
> }

The tests subroutine calls whichever subroutine is stored in $do_this_sub,
sending it the listed parameter.

Is that right?

Thanks
Rob




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

Date: Thu, 03 May 2001 07:59:04 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Test for integer?
Message-Id: <7s32ftob41852avpbui7fd8v8mik0pvob5@4ax.com>

Rob wrote:

>Is there a way for me to test if a scalar holds an integer value (positive
>or negative)?

FAQ, perlfaq4:
	How do I determine whether a scalar is a
	 number/whole/integer/float?

This will do:

	/^[+-]?\d+$/

If it doesn't, try the remainder of this perlfaq entry.

-- 
	Bart.


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

Date: 03 May 2001 08:37:39 +0100
From: nobull@mail.com
Subject: Re: Uploading to http sites
Message-Id: <u9ae4uvmqo.fsf@wcl-l.bham.ac.uk>

"Eric" <mail@NOSPAMericmarques.net> writes:

> this has been puzzling me all day
> i am trying to recreate the browsers uploading function so i can upload to a
> website that uses this function

Are you using the standard libraries to do this or rolling your own
implementation?

If you are not using the standard library why not?

If you are rolling your own do you have an HTTP question or a Perl
question?

If you have an HTTP question why are you posting to a Perl newsgroup?

> Please tell me whats wrong with these headers that its not accepted

That's definitely an HTTP question.

> the headers are:
> 
> POST http://194.165.160.74/test/debug.cgi HTTP/1.0

Full URL in HTTP request method line?  IIRC that's not supported in
HTTP/1.0 for origin servers.  I may be wrong.  I can't be bothered to
check because this has nothing even remotely to do with Perl.

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

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


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