[12363] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5963 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Jun 11 13:07:15 1999

Date: Fri, 11 Jun 99 10:00:21 -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           Fri, 11 Jun 1999     Volume: 8 Number: 5963

Today's topics:
    Re: "use IO::Socket" hangs (M.J.T. Guy)
    Re: "use IO::Socket" hangs <cassell@mail.cor.epa.gov>
    Re: Calculating weekday given year, month and day (Whiskey Mike)
    Re: CGI and SSI in perl <simon_banton@ipc.co.uk>
        comparing substrings of array values bernd1615@my-deja.com
    Re: Error using DBI package <gellyfish@gellyfish.com>
        File Uploading via html form <uucon@my-deja.com>
        good newbie advice (was Re: Silly old me) <uri@sysarch.com>
    Re: Help me please! <jdporter@min.net>
    Re: How do I sort files in a dir by last modified time? <tchrist@mox.perl.com>
        how to check if file exists? <rusenet@bigfoot.com>
        I'm really peaved off! <Tobin@breathemail.net>
    Re: I'm really peaved off! (brian d foy)
    Re: if (my $a=1) { } print $a; Why do i get undef an no <janning@vygen.de>
    Re: if (my $a=1) { } print $a; Why do i get undef an no <craig@mathworks.com>
        interesting problem involving query <marktoth@mindspring.com>
    Re: Linus Torvalds and Carmen Electra? <john.bjorgen@cplc.com>
    Re: mod_perl require problem <cw@dwc.ch>
        NT Perl - .plx work, .pl don't <rhjones@arn.net>
    Re: Odd/Even Numbers? <tchrist@mox.perl.com>
        Perl class and constructor <songtao@cisco.com>
    Re: Please Help!! <jknoll@ipt-inc.com>
    Re: Please Help!! <cassell@mail.cor.epa.gov>
    Re: run .exe on Win32 <cassell@mail.cor.epa.gov>
    Re: shortest self printing perl program <jdporter@min.net>
    Re: Silly old me <jknoll@ipt-inc.com>
    Re: Win95/DOS - can't install modules <gellyfish@gellyfish.com>
    Re: Win95/DOS - can't install modules <craig@mathworks.com>
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: 11 Jun 1999 16:25:19 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: "use IO::Socket" hangs
Message-Id: <7jrd9f$f5n$1@pegasus.csx.cam.ac.uk>

In article <FD4K1B.Lx4@vortex.com>, Lauren Weinstein <lauren@vortex.com> wrote:
>Greetings.  A newly compiled 5.005_03 perl, which passed installation
>tests, exhibits the behavior that any program that includes:
>
>  use IO::Socket
>
>immediately hangs at that point.  Any clues appreciated!

That's very odd, as the regression tests include ones which "use IO::Socket;".

What happens when you run that test?

   perl  /path/to/perl/src/t/lib/io_sock.t

You should see

1..5
ok 1
ok 2
ok 3
ok 4
ok 5


Does      perl -we 'use IO::Socket'         hang?

Does      perl -we 'use IO::Socket ()'      hang?

What about use-ing other modules?


Mike Guy


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

Date: Fri, 11 Jun 1999 09:26:15 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
To: Lauren Weinstein <lauren@vortex.com>
Subject: Re: "use IO::Socket" hangs
Message-Id: <376138A7.589CB35D@mail.cor.epa.gov>

[courtesy cc sent to poster]

Lauren Weinstein wrote:
> 
> Greetings.  A newly compiled 5.005_03 perl, which passed installation
> tests, exhibits the behavior that any program that includes:
> 
>   use IO::Socket
> 
> immediately hangs at that point.  Any clues appreciated!
> Thanks much.

You have me stumped.  I haven't seen this.. yet.  :-)  Could
you run 'perl -V' and submit the output to this ng?  That might 
help.  since you say it passed all the installation tests, I
trust that you ran 'make test' with no problems.

What happens when you run this:

#!/usr/bin/perl -w
use strict;
use diagnostics;

use IO::Socket;

print 'sock_stream is ', SOCK_STREAM, "\n";



And can you 'use Socket;' instead and get results?

HTH,
David
-- 
David Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician


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

Date: 11 Jun 1999 11:09:07 -0500
From: whiskey@earth.execpc.com (Whiskey Mike)
Subject: Re: Calculating weekday given year, month and day
Message-Id: <7jrcb4$r2@newsops.execpc.com>

perl_beginner@my-deja.com wrote:
:     what is the most efficient way to calculate the weekday (sunday=0,
: monday=1 ...) given the year, month, and day without using the module
: provided by perl (i.e using arithmatics and algorithm)? Any suggestion?

:     Thanks.....

My solution probably isn't the most efficient, and the algorithm is ugly,
but at least it's accurate...


my @DAY=qw(Sun Mon Tue Wed Thu Fri Sat);
my @tempdate=split(/\//,$temp[0]); #stored as MM/DD/YYYY
             #copied from one of my programs ($temp[0] that is))
$m=$tempdate[0];   #month
$d=$tempdate[1];   #day
$y=$tempdate[2];   #year
if ($m<3) {$m+=12; $y--;}
$weekday=($d+$m*2+int(($m+1)*0.6)+1+$y+int($y/4)-int($y/100)+
 int($y/400))%7;

-wm
-- 
      _ _
  @--(_8_[]= 


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

Date: Fri, 11 Jun 1999 17:48:31 +0100
From: Simon Banton <simon_banton@ipc.co.uk>
Subject: Re: CGI and SSI in perl
Message-Id: <37613DCB.DBB1CE02@ipc.co.uk>

The output from your script doesn't go back through your server for any
SSI parsing - it goes straight back to the user's browser, that's why
it's not doing what you want it to.

You could try grabbing the resource you are referencing in the SSI tag
from your own server using LWP::Simple.

eg:

Assuming you're currently emitting to STDOUT something like:

print $top_of_html;
print qq(<!--#include virtual="/path/to/desired/resource"-->);
print $rest_of_html;

try:

use LWP::Simple;
print $top_of_html;
print get("http://www.yoursite.dom/path/to/desired/resource");
print $rest_of_html;

Hope this helps.

Simon
IPC Webmaster


Sharma Madiraju wrote:

> Hi netters,
> I am  using a  perl cgi script to generate  html  file which uses
> server side includes.  But the server is not processing SSIs  in my
> html code written to stdout with mimetype text/html.  I am not
> even getting the error usually we get for error in processing message.
>
> Is it possible to use SSI in  html documents  generated using
> CGI scripts?
>
> thanks in advance.
> sharma



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

Date: Fri, 11 Jun 1999 15:10:54 GMT
From: bernd1615@my-deja.com
Subject: comparing substrings of array values
Message-Id: <7jr8tl$i5i$1@nnrp1.deja.com>

Dear participants,

I have an array of string values and
I want to compare a substring of these strings.

# an @bernd array with string values exists

$y = 1;

for ($i = 0; $i <= $x ; $i++) {

    if ( $bernd[$i] eq $bernd[$i+1] ) {
    # at this stage the substring instead of the whole string
    # should be compared
    # the substring starts with any single digit or letter and ends
    # with the first space char, in other words :
    # $_ =~ /^[a-zA-Z0-9]*\s/

    # if true, $bernd[$i] and $bernd[$i+1] should get the same $y number
    # (starting from 1) at the beginning
    }

    else {
    #increase the $y
    $y++;
    # $bernd[$i+1] gets the new $y
    # compare substrings of $bernd[$i+1] and $bernd[$i+2] ...
         }

            }

I'm not sure about the syntax. Is someone of you ?

Thank you very much for your consideration !

Markus Banach




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


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

Date: 11 Jun 1999 16:46:50 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Error using DBI package
Message-Id: <37612f6a@newsread3.dircon.co.uk>

Ralph Wiechmann <R.Wiechmann@alcatel.de> wrote:
> Hi Perl lovers 
> i get following error: 
> 
> install_driver(Oracle) failed: Can't load
> '/tools/perl5/lib/site_perl/5.005/sun4-solaris/auto/DBD/Oracle/Oracle.so'
> for module DBD::Oracle: ld.so.1: /usr/local/bin/perl: fatal:
> libclntsh.so.1.0: open failed: No such file or directory at
> /tools/perl5/lib/5.00502/sun4-solaris/DynaLoader.pm line 168.
> 
> using the syntax
>> use DBI;
>> $dbh = DBI->connect("DBI:Oracle:DES2000",$sqluid,$sqlpw, {PrintError => 1, > RaiseError => 1}) 
> im my script. 
> 
> Anybody an idea ? 
> 

Yeah - either DBD::Oracle is not properly installed or someone has deleted
some of the require files - I would reinstall it if I were you.

/J\
-- 
"Teletext - the information super B-road" - Exclusive, Channel 5


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

Date: Fri, 11 Jun 1999 15:22:11 GMT
From: Ryan Corder <uucon@my-deja.com>
Subject: File Uploading via html form
Message-Id: <7jr9in$ieu$1@nnrp1.deja.com>

I am currently designing a site that will allow users to upload image files
that can be viewed on their page as soon as they upload them.  I have
been working with cgi-lib.pl with no success.  I understand the process
of uploading the files, but is there a way to limit only files with certain
extensions to be uploaded (ie. .gif & .jpg) ?  I understand that this will
probably have to be coded into the cgi file because cgi-lib.pl cannont
filter file types on its own.

Any suggestions are greatly appreciated.  Thanks in advance!!

Ryan


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


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

Date: 11 Jun 1999 12:31:17 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: good newbie advice (was Re: Silly old me)
Message-Id: <x71zfik8bu.fsf_-_@home.sysarch.com>

>>>>> "j" == jrknoll  <jknoll@ipt-inc.com> writes:

  j> This is in like a gazillion FAQ's, goto www.perl.org www.perl.com for
  j> starters.  Just a little advice from one newbie to another;
  j> 1.  Try not to post off topic (ever) -the people on here dont have time
  j> for answers that can be easily found elsewhere.

see the page on selecting good subject names. (someone fill in the url
for me)

the recent linus and electra subject was a real luser. he got plonked
twice and got no help.

  j> 2.  Be VERY clear on what you post.  -they people here will take NO time
  j>  trying to figure out what you mean.
  j> 3.  ALWAYS include code.  -most wont even reply if you dont

and don't include 1300 line programs. try to create a minimal example of
what your are doing that shows the problem.

  j> 4.  Lurk for awhile- just monitor what is being said.
  j> 5.  Dont ask for them to do your work.  -people here try to help you
  j> learn, not to do things for you.
  j> 6.  Look for the answers on a archive FAQ or other pages before you
  j> post. -it gets annoying telling people things they could have found out
  j> themselves.

good advice that i wish all newbies would be forced to tattoo on their
eyelids. the new poster message they get doesn't seem to work well
enough. maybe a newbie faq should be posted more often, like once a
day. the regular one rootbeer posts doesn't seem to have an effect. a
better subject might help, like

	***HAVE LOTS OF SEX AND MAKE MONEY WITH PERL*** 

now that i've got your attention, here are some pointers on how to
participate effectively in this group......

half seriously,

uri

BTW, maybe i should do this? what do you think about it?

-- 
Uri Guttman  -----------------  SYStems ARCHitecture and Software Engineering
uri@sysarch.com  ---------------------------  Perl, Internet, UNIX Consulting
Have Perl, Will Travel  -----------------------------  http://www.sysarch.com
The Best Search Engine on the Net -------------  http://www.northernlight.com


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

Date: Fri, 11 Jun 1999 15:19:46 GMT
From: John Porter <jdporter@min.net>
Subject: Re: Help me please!
Message-Id: <7jr9e7$ic1$1@nnrp1.deja.com>

In article <7jr53d$gh5$1@nnrp1.deja.com>,
  alex@fire.elcom.ru wrote:
> How I can get using CGI the list of files stored at remote FTP
> directory?

You don't want CGI for this, you want Net::FTP.
Here's an example:

  use Net::FTP;
  my $ftp = Net::FTP->new("ftp.perl.org")
    or die "Couldn't connect: $@";
  $ftp->login( "anonymous", "alex\@fire.elcom.ru" );
  $ftp->cwd( "/pub/perl/CPAN/modules" );
  for ( $ftp->ls ) {
    print "$_\n";
  }
  $ftp->quit;

--
John Porter
Put it on a plate, son.  You'll enjoy it more.


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


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

Date: 11 Jun 1999 10:11:30 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: How do I sort files in a dir by last modified time?
Message-Id: <37613532@cs.colorado.edu>

     [courtesy cc of this posting mailed to cited author]

In comp.lang.perl.misc, 
    "AEF" <aef@pangea.ca> writes:
:How do I sort files in a directory, on the last modified time, and print
:that time out in a formated month, day , year?

% ls -lt
total 7
drwxrwxrwt   2 root     root         2048 Jun 11 10:10 vi.recover
drwxr-xr-x   2 tchrist  wheel        1024 Jun 11 10:05 card-listings
drwx------   2 tchrist  wheel        1024 May 24 04:02 OOPerl_PS
drwxr-xr-x  43 tchrist  wheel        1024 May 22 04:02 papers
drwxr-xr-x   5 root     root         1024 Apr 17 13:05 recover
drwxrwxrwx   2 tchrist  wheel        1024 Mar 26 04:02 upload

--tom
-- 
Let us be charitable, and call it a misleading feature  :-)
        --Larry Wall in <2609@jato.Jpl.Nasa.Gov>


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

Date: Fri, 11 Jun 1999 18:35:20 +0200
From: "R!k" <rusenet@bigfoot.com>
Subject: how to check if file exists?
Message-Id: <7jrdrj$tqs$2@enterprise.cistron.nl>

1. Can a .pl crash (Error 500 ) on opening a non-existing file?
2. How do i check if a file exists?

Rik




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

Date: Thu, 10 Jun 1999 17:32:04 +0100
From: "Tobin" <Tobin@breathemail.net>
Subject: I'm really peaved off!
Message-Id: <3761395d@news2.vip.uk.com>

Hi

I've been working on a program for a while and it has been running on the
Hypermart web server perfectly for ages.

I recenlty made some modifications and now I get the following error on
executing the script.
---------------------
Errors:
[Fri Jun 11 09:23:57 1999] access to /data1/hypermart.net/tobin/data1.pl
failed for 194.176.215.106, reason: file permissions deny server execution
exec of /data1/hypermart.net/tobin/data1.pl failed, reason: Exec format
error (errno = 8)
[Fri Jun 11 09:24:24 1999] access to /data1/hypermart.net/tobin/data1.pl
failed for 194.176.215.106, reason: Premature end of script headers
--------------------

I would be really greatful if anyone could let me know why this error
occurres.
I have made sure that the file is transferred in ASCI mode to the server,
and that it's access rights are ok. Also, it works fine on my local version
of Perl.

Thanks

Tobin




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

Date: Fri, 11 Jun 1999 13:04:47 -0400
From: brian@pm.org (brian d foy)
Subject: Re: I'm really peaved off!
Message-Id: <brian-ya02408000R1106991304470001@news.panix.com>

In article <3761395d@news2.vip.uk.com>, "Tobin" <Tobin@breathemail.net> posted:

> ---------------------
> Errors:
> [Fri Jun 11 09:23:57 1999] access to /data1/hypermart.net/tobin/data1.pl
> failed for 194.176.215.106, reason: file permissions deny server execution
> exec of /data1/hypermart.net/tobin/data1.pl failed, reason: Exec format
> error (errno = 8)
> [Fri Jun 11 09:24:24 1999] access to /data1/hypermart.net/tobin/data1.pl
> failed for 194.176.215.106, reason: Premature end of script headers
> --------------------
> 
> I would be really greatful if anyone could let me know why this error
> occurres.
> I have made sure that the file is transferred in ASCI mode to the server,

it looks like the file permissions are wrong. *shrug*  perhaps you 
should talk to your ISP since they'll know a lot more about their
system than we will.

-- 
brian d foy                    
CGI Meta FAQ <URL:http://www.smithrenaud.com/public/CGI_MetaFAQ.html>
Perl Monger Hats! <URL:http://www.pm.org/clothing.shtml>


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

Date: Fri, 11 Jun 1999 18:24:17 +0200
From: Janning Vygen <janning@vygen.de>
To: mikecard@my-deja.com
Subject: Re: if (my $a=1) { } print $a; Why do i get undef an not "1" ??
Message-Id: <37613831.805F1A7@vygen.de>

i want to assign $a the value of 1. 
its just an example. In a real world script 1 would be the return value
of a function like
if (my $a=getValue()) { } print $a;
i just want to know why i cant see my $a after the if statement

greetings, janning

mikecard@my-deja.com wrote:
> 
> Janning Vygen <janning@vygen.de> wrote:
> > if (my $a=1) {
> 
> if you want to check to see if $a is equal to 1 you need to write if
> $a==1  when you say if $a = 1 i believe you are assigning $a the value
> of 1.
> 
> mike cardeiro
> 
> Sent via Deja.com http://www.deja.com/
> Share what you know. Learn what you don't.


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

Date: Fri, 11 Jun 1999 12:49:14 -0400
From: Craig Ciquera <craig@mathworks.com>
Subject: Re: if (my $a=1) { } print $a; Why do i get undef an not "1" ??
Message-Id: <37613E0A.A660281C@mathworks.com>

In this case $a's scope is only applicable to the if block.  Try this:

my $a;

if ($a==1) {  } print $a;

or

my $a;
if ($a = getValue()) {} print $a;

Craig

Janning Vygen wrote:

> i want to assign $a the value of 1.
> its just an example. In a real world script 1 would be the return value
> of a function like
> if (my $a=getValue()) { } print $a;
> i just want to know why i cant see my $a after the if statement
>
> greetings, janning
>
> mikecard@my-deja.com wrote:
> >
> > Janning Vygen <janning@vygen.de> wrote:
> > > if (my $a=1) {
> >
> > if you want to check to see if $a is equal to 1 you need to write if
> > $a==1  when you say if $a = 1 i believe you are assigning $a the value
> > of 1.
> >
> > mike cardeiro
> >
> > Sent via Deja.com http://www.deja.com/
> > Share what you know. Learn what you don't.



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

Date: Fri, 11 Jun 1999 12:56:39 -0400
From: "marktoth" <marktoth@mindspring.com>
Subject: interesting problem involving query
Message-Id: <7jrf0b$3pv$1@nntp4.atl.mindspring.net>

Hello newsgroup,

I'm not a perl programmer (I have written some scripts about a year ago)

Here's what I have:

my $querytype = $formdata{'querytype'};

I get information passed from the form into the $querytype "variable"

is there anyway to parse that string???

In other words I want to check to see if the last character is an invalid
character (the / character)
if it is there I want to cut it off of the end

lets say $querytype = "WHERE+SP<>'"+"'/  (from the form)

and I want to remove the / from the end of $querytype

is this possible?????

The whole problem comes from MFC code.
When I send the query through ie4.01 I get this:

207.69.20.80 - - [11/Jun/1999:09:22:10 -0400] "GET
/cgi-bin/mmlogin.pl?username=mtoth&password=maxus99&database=mmdb&tablename=
fnmmdata&hostname=208.234.3.147&portnum=3318&querytype=WHERE+SP<>'"+"'
HTTP/1.1" 200 201944 "-" "Mozilla/4.0 (compatible; MSIE 4.01; Windows 95)"

In my access log

when I send it programatically using WinINet functions from Visual C++ I get

207.69.21.14 - - [11/Jun/1999:11:48:43 -0400] "GET
/cgi-bin/mmlogin.pl?username=mtoth&password=maxus99&database=mmdb&tablename=
fnmmdata&hostname=208.234.3.147&portnum=3318&querytype=WHERE+SP<>'"+"'/
HTTP/1.1" 200 5 "-" "Mozilla/4.0 (compatible; MSIE 4.01; Windows 95)"


Notice the difference between these two lines is a / at the end of the
string
querytype=WHERE+SP<>'"+"'   --> from ie
querytype=WHERE+SP<>'"+"'/   --> from my program (although the string that I
send from my program there is no / character at the end of the string.)

I can't figure out where the extra / is coming from so I thought well if its
there when it gets to the perl script then lets just take it off.  I know
programatically how I would do this in C++ code but not in perl and it would
save alot of time (the guy I contract for wrote the perl script  -> and hes
a stock broker not a programmer ->


All your help is extremely appreciated.  If you need the entire perl script
I would be happy to send it to you for review.

Thanks in advance!
Mark Toth





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

Date: Fri, 11 Jun 1999 12:23:27 -0400
From: "John Bjorgen" <john.bjorgen@cplc.com>
Subject: Re: Linus Torvalds and Carmen Electra?
Message-Id: <7jrd6c$6vc$1@gaddy.interpath.net>

I apologize...I'm a newbie and didn't realize I was committing such a grave
error.
Forgive my impropriety.  Just trying to get some attention to get my
questions
answered.  Will never do it again

John Bjorgen

By the way, what is killfiled?




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

Date: Fri, 11 Jun 1999 16:05:06 +0200
From: Christoph Wernli <cw@dwc.ch>
To: Jason Eggleston <jason@eggnet.com>
Subject: Re: mod_perl require problem
Message-Id: <37611792.43938682@dwc.ch>

[posted and mailed]

Jason Eggleston wrote:
> 
> I have written a mod_perl cgi script that "require()"s another script.
> Unfortunately, the functions in the script are not always available.
> The script works about 1 out of every 2 tries.
> 
> The script:
> 
> #!/usr/bin/perl -w -T
> 
> BEGIN { require '/home/httpd/html/stdinc.pl'; }

It looks like you've run into the "compile once, run multiple times" pitfall (indicated by
"works about 1 out of every two tries).

Try this:

- run your httpd with the -X switch (daemon won't fork)
- replace the BEGIN{}-block with 
	use lib '/home/httpd/html/';
	require 'stdinc.pl'

Cheers,

-werns


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

Date: Fri, 11 Jun 1999 11:08:22 -0500
From: "Ron Jones" <rhjones@arn.net>
Subject: NT Perl - .plx work, .pl don't
Message-Id: <37613429@news.usenetnews.org>

Help!
  Okay, I've got NT IIS 4.0 with SP 4.0.  I've just installed Perl build 517
over my previous build 515 to catch up and solve this problem....it didn't
solve the problem.
  Perl scripts named .plx work just fine when served from the web server,
but scripts named .pl are tyring to be downloaded instead of executed.  I
was hoping the fresh install of 517 would fix whatever was wrong...it
didn't.  Is the use of .pl files mutually exclusive of using .plx
(perlIS.dll)?  This should all be automatic, and yes, I did check off the
boxes for .plx mapping, and .pl file associations.  What could be wrong?  I
know when I looked at this before it suggested a mime mapping problem, but
shouldn't the re-install taken care of that?  Help!
--ron
reply newsgroup & email please: rhjones@arn.net





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

Date: 11 Jun 1999 10:35:31 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Odd/Even Numbers?
Message-Id: <37613ad3@cs.colorado.edu>

     [courtesy cc of this posting mailed to cited author]

In comp.lang.perl.misc, 
    Brent Singers <brent.s@ihug.co.nz> writes:
:Is there any way of Perl telling if a number is odd or even?  I have a
:script where I need do do one thing if a numerical result is even, and
:something if it is odd...

Either the successful completion of basic arithmetic courses in grammar
school is no longer a requirement for awarding our children access to
computers, or else you are a curious and innovative soul inquiring after
creative approaches of a more idiomatically perlian bent to this most
trivial of all possible problems.  As it would be severely depressing
if the former explanation were the root cause of your query, the latter
must then be taken as the actual case.  I shall consequently assume then
that you are not a hopeless idiot and instead present you with some more
interesting solutions to digest.

     ( (1 x $integer) =~ /^(11)+$/ ? $even : $odd ) = 1;

or

     ( (1 x $integer) =~ /^(1+)\1$/ ? $even : $odd ) = 1;

or

     ( ($integer / (1 << 1)) =~ /\.5$/ ? $odd : $even) = 1;

or:

    ($integer =~ /[13579]$/ ? $odd : $even) = 1;

or 

    (($integer & (1 << 0)) ? $odd : $even ) = 1;

or perhaps most obvious of all:

    sub odd { 
	my($n) = $_; 
	$n<=0 ? 0 : !even($n-1); 
    } 
    sub even { 
	my($n) = $_;
	$n<=0 ? 1 : !odd($n-1); 
    }

--tom
-- 
"Woe unto them who are wise in their own eyes,
 And prudent in their own sight!"
				- Isaiah, 5:21


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

Date: Fri, 11 Jun 1999 12:21:15 -0400
From: Songtao Chen <songtao@cisco.com>
Subject: Perl class and constructor
Message-Id: <3761377B.D8774B6E@cisco.com>

Hi everyone,

The code below (Person.pm) is from the perltoot manpage in Perl 5.004
package.

According to the manpage, we can do,

         use Person;

         $him = Person->new();
         $him->name("Jason");
         $him->age(23);
         $him->peers( "Norbert", "Rhys", "Phineas" );

I believe this is the right way to use the class. However,
since $him is the reference to the hash as returned from the
constructor, we could also do this,

         ...
         $him->{'NAME'} = "John";
         $him->{'AGE'}     = 32;
         ...

Any comments for this ?

Question: how could I return something other than the
               reference to the anonymous hash and keep
               the object alive ?

Thanks,

Songtao

================ The Code ===================
package Person;
use strict;

##################################################
## the object constructor (simplistic version)  ##
##################################################
sub new {
    my $self  = {};
    $self->{NAME}   = undef;
    $self->{AGE}    = undef;
    $self->{PEERS}  = [];
    bless($self);           # but see below
    return $self;
}

##############################################
## methods to access per-object data        ##
##                                          ##
## With args, they set the value.  Without  ##
## any, they only retrieve it/them.         ##
##############################################

sub name {
    my $self = shift;
    if (@_) { $self->{NAME} = shift }
    return $self->{NAME};
}

sub age {
    my $self = shift;
    if (@_) { $self->{AGE} = shift }
    return $self->{AGE};
}

sub peers {
    my $self = shift;
    if (@_) { @{ $self->{PEERS} } = @_ }
    return @{ $self->{PEERS} };
}

1;  # so the require or use succeeds




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

Date: Fri, 11 Jun 1999 15:25:30 GMT
From: jrknoll <jknoll@ipt-inc.com>
Subject: Re: Please Help!!
Message-Id: <7jr9ou$iia$1@nnrp1.deja.com>

Im thinking this post will apply here as well....

Just a little advice from one newbie to another;
1.  Try not to post off topic (ever) -the people on here dont have time
for answers that can be easily found elsewhere.
2.  Be VERY clear on what you post.  -they people here will take NO time
trying to figure out what you mean.
3.  ALWAYS include code.  -most wont even reply if you dont
4.  Lurk for awhile- just monitor what is being said.
5.  Dont ask for them to do your work.  -people here try to help you
learn, not to do things for you.
6.  Look for the answers on a archive FAQ or other pages before you
post. -it gets annoying telling people things they could have found out
themselves.

Just for reference I have violated #2,#4,#6
and was not treated very kindly for it- but it was my own damn fault.

hope this helps
Jesse Knoll


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


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

Date: Fri, 11 Jun 1999 09:50:09 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Please Help!!
Message-Id: <37613E41.CE3546A8@mail.cor.epa.gov>

Dave Cross wrote:
> 
> [snip]
> There are many free scripts out there on the web that do this kind of thing.
> You might try looking at <http://www.cgi-recourses.com>. Don't grab anything
                                           ^^^^^^^^^
s/recourses/resources/

Unless you have no recourse.  :-)

> by Matt Wright as they are Bad Scripts.

But if you *like* Y2K problems and failures at proxies and...
Well then go right ahead.  :-)

> ['nother snip]
>
> p.s. Look, I didn't even mention my own form mail script available from
> <http://www.mag-sol.com/Download.html>!
> 
> p.p.s. Damn!

P.P.P.S.  Go look at the whole site, in fact.  And read the 'Articles'
to learn some useful Perl-things.

David
-- 
David Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician


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

Date: Fri, 11 Jun 1999 09:14:31 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: run .exe on Win32
Message-Id: <376135E7.2B647E53@mail.cor.epa.gov>

jbell@263.net wrote:
> 
> I'm trying to run a .exe program(a C program) from perl
> with the "system" function.
> This programs reads input from a data file in the same
> directory.  Now I have two questions,

First, I have a question.  If all your C program does is
read input from a datafile, then have you considered
just writing that piece in Perl also?  You could use
sysread() and get nearly the performance you see in C.
And parsing the file contents could be more efficient.
That might fix some of the problems below...

> 1. The perl program can be run only when it's in the same
>    direcotry with the .exe program and the data file.
>    How can I run the perl program from a different dir.

Unless you're doing this as part of a CGI script, there
should be *no* problems with running the C program from
a different directory.  Just include the path in front
of the executable, just as if you were calling it from
the command line.

If you're doing this as part of a CGI script, then you
have to be aware of what directory and privileges your 
webserver assigns to running processes, and make sure you
can call your C program that way.  But that's a server
issue.  If your server does something strange, you'll
need to read the server docs or test it yourself.

> 2. This program prints output to the screen.  In the perl
>    program how can I store the output in a string or array?
> 3. Is there a more effective way to call this c program
>    other than using "system"?

The answer to both of these is the qx// operator which
acts like backticks.  It will let you save the lines of
output *either* as a single string or as an array, depending
on the context you give it.  Convenient, no?
 
> Thanks a lot!

You're welcome.

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

Share what you don't know is wrong.
Learn what you can't tell is true or not.

HTH,
David
-- 
David Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician


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

Date: Fri, 11 Jun 1999 15:35:10 GMT
From: John Porter <jdporter@min.net>
Subject: Re: shortest self printing perl program
Message-Id: <7jrabd$iqd$1@nnrp1.deja.com>

In article <87iu8vd1no.fsf@gate7.olympiakos.com>,
  Kiriakos Georgiou <kgnews@olympiakos.com> wrote:
>
> printf($x,39,$x='printf($x,39,$x=%c%s%c,39);',39);

Whoa, you *are* a guru.  I genuflect in your general direction.

  seek DATA,0,0;print<DATA>;
  __DATA__

Isn't this a FAQ by now?

--
John Porter
Put it on a plate, son.  You'll enjoy it more.


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


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

Date: Fri, 11 Jun 1999 15:18:41 GMT
From: jrknoll <jknoll@ipt-inc.com>
Subject: Re: Silly old me
Message-Id: <7jr9c6$iba$1@nnrp1.deja.com>

This is in like a gazillion FAQ's, goto www.perl.org www.perl.com for
starters.  Just a little advice from one newbie to another;
1.  Try not to post off topic (ever) -the people on here dont have time
for answers that can be easily found elsewhere.
2.  Be VERY clear on what you post.  -they people here will take NO time
 trying to figure out what you mean.
3.  ALWAYS include code.  -most wont even reply if you dont
4.  Lurk for awhile- just monitor what is being said.
5.  Dont ask for them to do your work.  -people here try to help you
learn, not to do things for you.
6.  Look for the answers on a archive FAQ or other pages before you
post. -it gets annoying telling people things they could have found out
themselves.

Just for reference I have violated #2,#4,#6
and was not treated very kindly for it- but it was my own damn fault.

hope this helps
Jesse Knoll




--
JESSE KNOLL
--Senior - Ball State University - INDIANA --
jrknoll@cwix.com


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


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

Date: 11 Jun 1999 16:51:39 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Win95/DOS - can't install modules
Message-Id: <3761308b@newsread3.dircon.co.uk>

Ben Hambidge <ben@expo-systems.co.uk> wrote:
> I'm trying to install DBD::Xbase and MIME::Base64 modules, but I'm
> guessing (as with everything else round here :-)) that its all intended
> for UNIX.
> 

If you have the a recent activestate perl then you should be able to do

ppm install DBD-XBase
ppm install MIME-Base64

at the command prompt

/J\
-- 
"Report accuses Royal Opera House of 'arrogance and elitism'. Report
further alleges that Pope is Catholic. Report further claims that bears
may well indeed defecate in the woods" - Private Eye


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

Date: Fri, 11 Jun 1999 12:00:22 -0400
From: Craig Ciquera <craig@mathworks.com>
Subject: Re: Win95/DOS - can't install modules
Message-Id: <37613296.BA1F15CA@mathworks.com>

If you are using the ActiveState distribution, then you can use ppm to
install these modules::

ppm install DBD-Xbase

ppm install MIME-Base64

or you could build from CPAN, but you need a C compiler and you need to know
the make utiltiy for that compiler ( i.e., nmake for Microsoft Visual C++ ).

Craig

Ben Hambidge wrote:

> I'm trying to install DBD::Xbase and MIME::Base64 modules, but I'm
> guessing (as with everything else round here :-)) that its all intended
> for UNIX.
>
> I've downloaded a few incantations of Perl. The instructions for install
> a CPAN module always involve 'perl Makefile.pl'.
>
> This then creates a 'Makefile' file. Typing 'make' then does nothing.
>
> Am I right in assuming this is a C makefile? I next tried downloading
> DJGPP and running make, but then I got the following error:
>
> make.exe: *** [blib\lib\MIME\.exists] Error -1
>
> Where am I going wrong? What am I supposed to be doing? I've tried the
> FAQs, the Camel book and Dejanews, so I think I'm not asking a over-
> repeated question.
>
> Many thanks for all help,
>
> --
> Ben Hambidge



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

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

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