[9001] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2619 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat May 16 16:07:16 1998

Date: Sat, 16 May 98 13:00:25 -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           Sat, 16 May 1998     Volume: 8 Number: 2619

Today's topics:
        Clearing an associative array (Newbie question) (Brian Franklin)
    Re: Clearing an associative array (Newbie question) (Matthew Cravit)
    Re: date, datediff, yesterday perl functions ? (Steffen Beyer)
    Re: date... (Steffen Beyer)
    Re: date... <carton.lao@shaw.wave.ca>
    Re: dereferencing question (Mark-Jason Dominus)
    Re: Does Perl have a IDE?I don't like command line. <tchrist@mox.perl.com>
    Re: Does Perl have a IDE?I don't like command line. <ljz@asfast.com>
    Re: Does Perl have a IDE?I don't like command line. <ljz@asfast.com>
    Re: Does Perl have a IDE?I don't like command line. <webmaster@fccjmail.fccj.org>
    Re: Does Perl have a IDE?I don't like command line. (Mark-Jason Dominus)
    Re: Does Perl have a IDE?I don't like command line. <tim@toolman.org>
    Re: How to generate random passwords? (Preston L. Bannister)
    Re: IF problems.... <lr@hpl.hp.com>
    Re: IF problems.... (Jon Bell)
    Re: IF problems.... (Andre L.)
    Re: localtime() chris+usenet@netmonger.net
    Re: perl cgi script help (Mark-Jason Dominus)
        Perl Error Documentation <skc1234@hotmail.com>
        Piping a fiel to a perl script (Paul Farber)
    Re: Piping a fiel to a perl script (Mark-Jason Dominus)
    Re: Problem with spaces in directory path names in Perl (J. Bacon)
    Re: Removing ^M at the end of each line of a file. (Thijs Kinkhorst)
    Re: Removing ^M at the end of each line of a file. <jnebeard@earthlink.net>
        Which perl? (new user question) (CGSchmitt)
        Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Sat, 16 May 1998 17:42:40 GMT
From: bf14@prism.gatech.edu (Brian Franklin)
Subject: Clearing an associative array (Newbie question)
Message-Id: <355dcd9f.105828319@news.gatech.edu>

I'm new to Perl so this is a simple question.

Is there an EASY  way to clear an associative array?  My book only
talks about copying, appending and deleting terms.  I want to
use an associative  array repeatedly but I want to be sure it is
"empty" before I read into it new info.

Also is there script for an FTP server?  I have found numerous clients
but no servers. Is it because 

  a. Not possible
or
  b. Possible security risk for system administrators so none are made
      available.


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

Date: 16 May 1998 11:01:59 -0700
From: mcravit+usenet@mcravit.vip.best.com (Matthew Cravit)
Subject: Re: Clearing an associative array (Newbie question)
Message-Id: <6jkkan$k2t$1@shell3.ba.best.com>

In article <355dcd9f.105828319@news.gatech.edu>,
Brian Franklin <bf14@prism.gatech.edu> wrote:
>I'm new to Perl so this is a simple question.
>
>Is there an EASY  way to clear an associative array?  My book only
>talks about copying, appending and deleting terms.  I want to
>use an associative  array repeatedly but I want to be sure it is
>"empty" before I read into it new info.

     %hash = ();

or

     undef %hash;

should both work.

/MC

-- 
Matthew Cravit, N9VWG               | Experience is what allows you to
E-mail: mcravit@best.com (home)     | recognize a mistake the second
        mcravit@net.com (work)      | time you make it.


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

Date: 16 May 1998 12:53:16 GMT
From: sb@engelschall.com (Steffen Beyer)
Subject: Re: date, datediff, yesterday perl functions ?
Message-Id: <6jk27s$t10$2@en1.engelschall.com>

[mailed && posted]

anon5f6b@nyx.net wrote:

> Is there a date library in perl that would provide functionality
> for say yesterday's date, tomorrow's date, days between dates,
> date n days from now, etc.

See Date::Calc or Date::Manip on CPAN:

http://www.perl.com/CPAN/modules/by-module/Date/

or http://www.engelschall.com/u/sb/download/

Yours,
-- 
    Steffen Beyer <sb@engelschall.com>
    Free Perl and C Software for Download: www.engelschall.com/u/sb/download/
    "Perl is like sex: If you never had it, you wonder what the fuss is all
     about. Once you had it, you never want to be without it again." (unknown)


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

Date: 16 May 1998 12:50:55 GMT
From: sb@engelschall.com (Steffen Beyer)
Subject: Re: date...
Message-Id: <6jk23f$t10$1@en1.engelschall.com>

Philipp <Philipp999@gmx.net> wrote:

> Does anybody know how to easily get the date from a day that is a week
> ago?

You might also want to look at the modules on CPAN which do exactly that
(and more) very nicely:

Date::Calc
Date::Manip

See http://www.perl.com/CPAN/modules/by-module/Date/
or http://www.engelschall.com/u/sb/download/.

Hope this helps.

Yours,
-- 
    Steffen Beyer <sb@engelschall.com>
    Free Perl and C Software for Download: www.engelschall.com/u/sb/download/
    "Perl is like sex: If you never had it, you wonder what the fuss is all
     about. Once you had it, you never want to be without it again." (unknown)


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

Date: Sat, 16 May 1998 15:58:09 GMT
From: Carton Lao <carton.lao@shaw.wave.ca>
To: Philipp <Philipp999@gmx.net>
Subject: Re: date...
Message-Id: <355DB80B.50E4E4ED@shaw.wave.ca>



Philipp wrote:

> Hi all!
>
> Does anybody know how to easily get the date from a day that is a week
> ago?
>
> Thanks
>
> phil

  I'm sure there is a 'DATE' module that can probably do that, but I'm not
familiar with modules, I try to use only those that I really need.

Carton




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

Date: 16 May 1998 15:00:35 -0400
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: dereferencing question
Message-Id: <6jknoj$4sp$1@monet.op.net>
Keywords: culture Goldstein pint redact


In article <6jerdf$jtq@fidoii.cc.Lehigh.EDU>,
Phil R Lawrence <prl2@lehigh.edu> wrote:
>Why must I use the dereferencing brackets with $self->{key1}{key2}, but not with
>$ary_ref?

Because of precendence.  Does 2+3*5 mean (2+3)*5, or 2+(3*5)?
It means the second one.  

Does @$self->{key1}{key2} mean {@$self}->{key1}{key2} 
                            or @{$self->{key1}{key2}}?
It means the first one.



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

Date: 16 May 1998 16:23:38 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Does Perl have a IDE?I don't like command line.
Message-Id: <6jkeia$54s$1@csnews.cs.colorado.edu>

 [courtesy cc of this posting sent to cited author via email]

In comp.lang.perl.misc, smcdow@arlut.utexas.edu (Stuart McDow) writes:
:NT is good for productivity tools. I even use it to run Word when I
:want to type a document. 

Strange -- I always use vi.

:But for real computing, I give it 5 to 10
:years before it is mature enough to be trusted.

That would appear to assume that given of them, and enough time, even 
mediocre programmers can produce high-quality work.  I'm not convinced
of this.

--tom
-- 
It is, of course, written in Perl.  Translation to C is left as an
exercise for the reader.  :-)  --Larry Wall in <7448@jpl-devvax.JPL.NASA.GOV>


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

Date: 16 May 1998 12:36:38 -0400
From: Lloyd Zusman <ljz@asfast.com>
Subject: Re: Does Perl have a IDE?I don't like command line.
Message-Id: <ltzpgiyxyh.fsf@asfast.com>

smcdow@arlut.utexas.edu (Stuart McDow) writes:

> Lloyd Zusman <ljz@asfast.com> writes:
> > 
> > But I still agree with your main point: Sun-based systems are
> > generally more expensive than those built on an Intel platform.
> 
> If you factor in the cost of machine and network maintenance, I don't
> think this holds true.

Unfortunately, it still does hold true.  Based on my experience,
maintaining NT in a network environment is no worse than maintaining
Suns, cost-wise.  At one place I worked, they needed something
line one SA per 100-150 desktops, be they Unix or NT desktops.

> > The "Gnu-Win32" stuff put out by Cygnus is free and seems to be
> > pretty good.  Its `gcc' works just fine for me, and it comes with
> > include files, libraries, etc.
> 
> I've played with the cygnus port. I don't like it because applications
> built with gcc won't run outside the gnu-win32 environment. I like my
> compiled applications to run stand-alone. perl is a different story
> altogether.

Well, all I've had to do in order to port my some cygnus stuff to a
random win32 box is to include a .DLL with the .EXE.  Two files.  With
Perl, you need at minimum the Perl exectuable and the script.  Two
files.

> > Cost-wise, you're still way ahead with NT, unfortunately.  That's
> > why so many corporations are swtiching from Unix on the desktop to
> > NT.
> 
> They are making a mistake. Maintenance and reliability issues will
> come back to bite them, and they'll end up losing more money than they
> saved.

The reliability issues are indeed biting them in some cases.  That's
why most corporations I've consulted at lately (Wall-street-type
firms) use Unix boxes (usually Suns) as servers and workstations for
certain critical or high-use applications, and NT boxes for the
average, run-of-the-mill desktop user (the majority of desktops).

> http://www.aberdeen.com/research/comp/onsite/case1/body.htm
> http://www.kirch.net/unix-nt.html
> 
> > Unix boxes from Sun et al are starting to come down in price, but NT
> > still has a lot of momentum right now in the corporate desktop
> > world,
> 
> This is being driven by know-nothing executives, and not by IT
> professionals. I predict, that unless MS gets their act together soon
> and introduces a *much* more reliable OS than the current NT, we will
> see a slow but wholesale move back to Unix-based IT installations.

IT departments are driving this effort towards NT as much as
"know-nothing executives".  It's cheaper and easier to deal with
for the majority of users in the company.

IT groups still seem to favor Unix for critical applications.  NT's
increasing reliability is slowly eroding this advantage, however.

> > and overall, an Intel/Microsoft solution is still cheaper overall.
> 
> This is short-term thinking. In the short term, you are correct. NT is
> still a immature and buggy OS. Especially compared to Unix, which has
> had 20 years of shaking out.

That's why NT is OK for the majority of desktops, while Unix is being
used for the smaller number of machines that do "important" stuff.

> > The big-name Unix-box vendors are going to have to cut prices even
> > more if they want to effectively compete over the next few years.
> 
> The issue here is reliability, not short term cost.

NT is reliable enough for most of the desktops it resides on.

> > Linux, FreeBSD, and other Unices that run on Intel boxes are looking a
> > bit better these days in the corporate world (cost-wise), but most
> > corporations I'm familiar with seem to be leery of going with a
> > platform for which they can't purchase a 24x7 support contract from a
> > vendor they think will still be around in a few years.
> 
> 24x7 support for Red Hat Linux can be purchased from Collective
> Technologies, Inc.

The firms I've consulted at want 24x7 support from a company they
think will still be around in a couple years.  RedHat is not yet
generally perceived as such a company.

> > And the integrated email/web/spreadsheet/database/word-processing
> > software that Microsoft sells is very attractive (cost-wise, as
> > well) in a corporate environment, and there's nothing that runs
> > under Unix that comes close in terms of price, interoperability, or
> > support.
> 
> Agreed. But we were talking about compilers and SDKs, not productivity
> tools.

I'm talking about both, because the applications that are produced by
the people using compilers and SDK's are often used by the
rank-and-file users on their corporate desktops ... which so far are
increasingly becoming NT boxes.

> > So far in my experience, the Microsoft boxes don't quite compete
> > with Unix platforms in terms of hard-core applications where speed
> > and OS reliability are issues.  But NT is closing the gap here as
> > time goes on.
> 
> I disagree. NT does not scale well for multiprocessor systems. NT's
> performance is very bad on a four or more processor machine compared
> to many Unixes.

I agree that NT's performance doesn't scale well.  But it is improving
over time.  Unices will still be used for many of the high-volume,
critical applications where single-box scalability is an issue.  But
distributed desktop applications generally do well enough for most IT
departments under NT, and these kinds of applications are popular
these days.

> > If we really want to kick Bill's ass, we will have to do more than
> > carp about GUI's and insult Windows users.  One way to do this would
> > be to offer an "integrated desktop solution" that runs under an
> > inexpensive, Intel-based, supportable Unix which is as cheap,
> > robust, easy to use, and interoperable as IE4.0/Office-97.  Like it
> > or not, this means some major GUI-based development.
> 
> NT is good for productivity tools. I even use it to run Word when I
> want to type a document. But for real computing, I give it 5 to 10
> years before it is mature enough to be trusted.

I agree with you.  But a significant piece of the money being spent by
the big corporations I'm familiar with is going towards Microsoft
solutions, and this money is pushing the industry in certain
directions.  Like it or not, the Unix world (and also the Perl world,
I contend) will need to focus more on GUI-based applications on cheap
boxes with an IE4.0-like integrated desktop environment in order to
keep up with this unfortunate trend.

And even more unfortunate is the fact that Unices will probably have
to start emulating the Windows look-and-feel as well as maybe even
providing emulation modes that allow the execution of populare Windows
software in order to appeal to the corporate desktop market.

Without the corporate desktop market, the market for Unix-based
applications will decline.

-- 
 Lloyd Zusman   ljz@asfast.com
 perl -e '$n=170;for($d=2;($d*$d)<=$n;$d+=(1+($d%2))){for($t=0;($n%$d)==0;
 $t++){$n=int($n/$d);}while($t-->0){push(@r,$d);}}if($n>1){push(@r,$n);}
 $x=0;map{$x+=(($_>0)?(1<<log($_-0.5)/log(2.0)+1):1)}@r;print"$x\n"'


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

Date: 16 May 1998 12:52:19 -0400
From: Lloyd Zusman <ljz@asfast.com>
Subject: Re: Does Perl have a IDE?I don't like command line.
Message-Id: <ltwwbmyx8c.fsf@asfast.com>

Bill 'Sneex' Jones <webmaster@fccjmail.fccj.org> writes:

> Stuart McDow wrote:
> > NT is good for productivity tools. I even use it to run Word when I
> > want to type a document. But for real computing, I give it 5 to 10
> > years before it is mature enough to be trusted.
> 
> RedHat 5.0 (Hurricane) ApplixWare is what I use.  Doesn't have the
> 'kitchen sink' like Word does, but very productive none the less :-)

I use RedHat 5.0 at home, but most of the desktops at the places that
hire me these days have NT boxes.  I therefore am forced to use
Windows-based Xterms and telnet windows to reach the appropriate Unix
boxes from my desk at many places that I work.

And the software I get hired to write these days often has to be
runnable from these desktops.  At least I'm lucky enough to be able to
use Java for this.  So far, I haven't seen the day when the majority
of potential clients are wanting their applications written in Visual
Basic and Visual C++ ...

Right now, the only places I'm able to use Perl at a paid job is for
an ISP I have a contract with.  I've been writing an automated,
web-based, Sysadmin and account-maintenance system for him, primarily
in Perl.  And even there, the owner is starting to think about moving
more towards Microsoft, since he can hire cheap, inexperienced
programmers who can use Microsoft Access and Visual-Basic/VB-Script
much more readily than he can hire Perl programmers to maintain and
enhance the code.  Some of this will have to remain in Perl no matter
what (the "guts" of the Sysadmin part of the system), but all the
account management and associated billing stuff will probably move
over to Microsoft, if the owner of this company has his way.

A couple years ago, I was getting paid to write a lot more Perl than
I'm getting paid to write these days.  Fortunately, I get to play with
Perl all I want at home on my Linux box.

-- 
 Lloyd Zusman   ljz@asfast.com
 perl -e '$n=170;for($d=2;($d*$d)<=$n;$d+=(1+($d%2))){for($t=0;($n%$d)==0;
 $t++){$n=int($n/$d);}while($t-->0){push(@r,$d);}}if($n>1){push(@r,$n);}
 $x=0;map{$x+=(($_>0)?(1<<log($_-0.5)/log(2.0)+1):1)}@r;print"$x\n"'


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

Date: Sat, 16 May 1998 17:11:02 GMT
From: Bill 'Sneex' Jones <webmaster@fccjmail.fccj.org>
Subject: Re: Does Perl have a IDE?I don't like command line.
Message-Id: <355DC6CC.7F256D4F@fccjmail.fccj.org>

Lloyd Zusman wrote:
> 
> Bill 'Sneex' Jones <webmaster@fccjmail.fccj.org> writes:
> 
> > Stuart McDow wrote:
> > > NT is good for productivity tools. I even use it to run Word when I
> > > want to type a document. But for real computing, I give it 5 to 10
> > > years before it is mature enough to be trusted.
> >
> > RedHat 5.0 (Hurricane) ApplixWare is what I use.  Doesn't have the
> > 'kitchen sink' like Word does, but very productive none the less :-)
> 
> I use RedHat 5.0 at home, but most of the desktops at the places that
> hire me these days have NT boxes.  I therefore am forced to use
> Windows-based Xterms and telnet windows to reach the appropriate Unix
> boxes from my desk at many places that I work.
> 

I understand what you are saying, I am saying that I wouldn't do it 
unless there were no other way and/or the client said they wouldn't
want it any other way, and then I would expect to get paid accordingly.
I have always charged less for Unix-centric solutions - I know long
term I will have to support those less.

Someone once asked me why I wasn't totally in the NT world; they say
it's heading that way.  I told them I can still think for myself and
I would rather use what works.  Just because everyone is doin' it
doesn't mean 'it' is good :-)  They said I would never be successful.
I said success is relative.  I would rather be sane :-)

PS - If you must use NT-based Telnet clients to access Unix, you may
wish to research WRQ's Reflection suite.  I personally use the
Reflection-X Suite when I 'must' use NT :-)  I find it the most
compatible of any.  I have used eXceed and others.  Reflection-X
isn't cheap through, about $500 is what I paid for it.  It has
carnal knowledge of termcaps and terminfo stuff for just about
any Unix out there, plus if you are fortunate enough to be on a
backbone when consulting then you have native X access when you
want it.

-Sneex-  :-)
____________________________________________________________________________
Bill Jones | FCCJ Webmaster | Voice 1-904-632-3089 | Fax 1-904-632-3007
Florida Community College at Jacksonville | 501 W. State St. | Jax, FL 32202
mailto:webmaster@fccjmail.fccj.org | http://webmaster.fccj.org/Webmaster


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

Date: 16 May 1998 14:19:02 -0400
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: Does Perl have a IDE?I don't like command line.
Message-Id: <6jklam$4ok$1@monet.op.net>
Keywords: jest Nouakchott remote retrogressive


In article <6j7hiu$q68$3@info.uah.edu>, Greg Bacon <gbacon@cs.uah.edu> wrote:
>: >    XTerm*background: darkslateblue
>: >    XTerm*foreground: lightblue
>: 
>: Pining for your Commodore 64?
>
>Actually, I picked up those resource specs from you on #perl a while
>back. :-)

That's odd, because the first thing I always did after turning on my
C64 was to change it to use medium gray text on white bacground.





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

Date: Sat, 16 May 1998 19:47:13 +0000
From: Tim Peoples <tim@toolman.org>
Subject: Re: Does Perl have a IDE?I don't like command line.
Message-Id: <355DED41.A36CADFE@toolman.org>

Samuel King wrote:
> 
> Yes there is one for perl 95/Nt it is available as a preview release>> Free
> Download
> at
> http://www.solutionsoft.com/perl.htm
> Samuel King
> 

Okay... but it appears to be "cripple-ware"[1].  Kinda goes against the
spirit of Perl... don't ya think?

Tim.

[1]  The preview release expires 19980615

-- 
 ____________________________________________   _                       _ 
                           Timothy E. Peoples  |_| C o l l e c t i v e |_|
                            Senior Consultant   |_    technologies     _| 
                             tep@colltech.com     []                 []   
                                                    a pencom company


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

Date: Sat, 16 May 1998 17:38:53 GMT
From: preston@home.com (Preston L. Bannister)
Subject: Re: How to generate random passwords?
Message-Id: <Nak71.65$Jd6.1026460@news.rdc2.occa.home.com>

In article <355C5397.F27805A1@kci.wayne.edu>, Jennifer Telisky 
<teliskyj@kci.wayne.edu> wrote:

>I have this script that will create user accounts, however I need to
>assign a password at the same time.  Any help on generating a random
>password and updating the passwd file will be appreciated.

I would suggest generating "random" passwords that users can remember.  
Something like the <word><number><word> style used by AOL & company.

One of the problems with assigning meaningless passwords is that users 
have a tendency to change their password to something they can remember, 
and they usually choose poorly.

I believe it is better to assign an initial password that is relatively 
easy to remember, but not particularly easy to guess.

Attached below is a Perl script to generate AOL style passwords.  I have 
put the script and an example word list at:

  http://members.home.net/preston/PasswordGenerator.html


FILE: PasswordGenerator.pm
--------------------------------
package PasswordGenerator;

use strict;

#
#   Create instance of password generator.
#

sub new {
    my $class = shift;
    my $self  = {};

    $self->{WORDS} = [];
    
    bless $self, $class;
}

#
#   Load word list used in generating passwords.
#

sub LoadWords($) {
    my $self = shift;
    my $filename = shift;

    my $words = [];
    
    local *WORDS;
    return 0 if not open WORDS,"<$filename";
    while (<WORDS>) {
        chomp;
        push @$words,$_;
    }
    close WORDS;
    
    $self->{WORDS} = $words;
   
    return $#$words;
}

#
#   Generate one password.
#

sub MakePassword {
    my $self = shift;
    my $words = $self->{WORDS};
    
    my $n  = $#$words;
    my $i1 = int(rand($n));
    my $i2 = int(rand(10));
    my $i3 = int(rand($n));
    
    my $word1 = $$words[$i1];
    my $word3 = ${$words}[$i3];
    
    return $word1 . $i2 . $word3;
}

#
#   Unit test.
#

if (1) {
    my $v = new PasswordGenerator;

    print "Loading word list...\n";

    $v->LoadWords("words4to6.txt")
                or die "Cannot load word list!\n";

    print "Generating passwords...\n";

    foreach (1..10) {
        my $password = $v->MakePassword;
        print "password $password\n";
    }   
}

#
#
#

1;

#
#   $Author: preston $
# $Revision: 1.2 $
#     $Date: 1998/05/16 10:13:13 $
#   $Source: f:/archive/plb/WebPages/PasswordGenerator.pm,v $
#

--
Preston L. Bannister
preston@home.com
http://members.home.net/preston


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

Date: Sat, 16 May 1998 08:14:31 -0700
From: "Larry Rosler" <lr@hpl.hp.com>
Subject: Re: IF problems....
Message-Id: <6jkahh$fip@hplntx.hpl.hp.com>

[posted and emailed]

Ali wrote in message <6jk7r5$emk@news1.rad.net.id>...
>I create a script to determine a specific number between a range this
cause an error message.
>I need help how perl could find a the number with IF Statement?
>
>any help would be appreciated.
>
>@URL=(1,2,3,4,5,6,7,8,9,10);
>
>$Counter=0;
>foreach $Match (@URL) {
>    if (2 <= $match <= 3) {
>    $URL1[Counter]=$Match;
> $Counter++;}
> }


This is a very old trap, inherited from C and many other languages.
What it means as written is this:  Compare the result of '2 <= $match'
(which in a numerical context is 0 or 1) to 3.  Or does it mean this:
Compare the result of 2 to '$match <= 3'?  As I didn't know how Perl
associates these operators (because I do know never to write it), I
tried it and guess what?  It produces a syntax error unless
parenthesized explicitly.  Chalk one up for Perl!  Are you sure you're
using Perl 5?

if (2 <= $match && $match <= 3) {

or

if (2 <= $match and $match <= 3) {

depending on your taste for math or English.

--
Larry Rosler
Hewlett-Packard Laboratories
lr@hpl.hp.com





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

Date: Sat, 16 May 1998 15:16:53 GMT
From: jtbell@presby.edu (Jon Bell)
Subject: Re: IF problems....
Message-Id: <Et22G5.3s6@presby.edu>

 Ali <ampun@bigfoot.com> wrote:
>I create a script to determine a specific number between a range

>    if (2 <= $match <= 3) {

I bet you're a COBOL programmer.  :-)  COBOL is the only language I know
of that allows one to write conditions like the one above (with different
syntax, of course).  In Perl, as in most languages, one has to combine two
individual comparisions using Boolean operators. 

    if ($match >= 2 && $match <= 3) {

-- 
Jon Bell <jtbell@presby.edu>


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

Date: Sat, 16 May 1998 13:34:31 -0500
From: alecler@cam.org (Andre L.)
Subject: Re: IF problems....
Message-Id: <alecler-1605981334310001@dialup-615.hip.cam.org>

In article <6jk7r5$emk@news1.rad.net.id>, "Ali" <ampun@bigfoot.com> wrote:

> I create a script to determine a specific number between a range this
cause an error message.
> I need help how perl could find a the number with IF Statement?
> 
> any help would be appreciated.
> 
> @URL=(1,2,3,4,5,6,7,8,9,10);
> 
> $Counter=0;
> foreach $Match (@URL) {
>     if (2 <= $match <= 3) {
>     $URL1[Counter]=$Match;
>  $Counter++;}
>  }

==========

@URL1 = grep { $_ >= 2 && $_ <= 3 } @URL;

HTH,
A.L.


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

Date: 16 May 1998 17:13:32 GMT
From: chris+usenet@netmonger.net
Subject: Re: localtime()
Message-Id: <6jkhfs$buq$1@schenectady.netmonger.net>

In article <semxqfqcuhkb.pminews@alien>,
Frank Winkler @home <frank@consol.de> wrote:
> Hi there !
> 
> Can anybody give me a hint how I can easily compute the day number
> (in the year) of an arbitrary date? For today I can use localtime[7]
> but to feed this with some other date I have to convert it into UTC
> - for which I found no PERL routine. Or has anyone written some own
> code for this job?

I'm a fan of the Date::Parse module, which you'll find on CPAN.  It's
not fast, but it accepts just about anything resembling a date.
-- 
	    Christopher Masto <chris+usenet@netmonger.net>
	Director of Operations, NetMonger Communications, Inc.

		     "Behold the Power of Cheese"


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

Date: 16 May 1998 14:42:47 -0400
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: perl cgi script help
Message-Id: <6jkmn7$4qr$1@monet.op.net>

In article <01bd80e2$07087180$8c3737a6@main>,
Brian Willis <bigkingwillie@bigfoot.com> wrote:
>There are approximately 50 questions
>on each test.  I have each answer to each question being assigned to a
>value called "answer#" (where # is the number of the question).  I want to
>able to compile a list of the right answers and wrong answers.  


Put the correct answers into a data structure like this:

	# Correct answer to question #3 is `e'; to question #4 is `d'.
	@correct_answer = qw(X a c e d d 
			       e b a c e
			       . . .			
			       d b c d e);

This makes an array of correct answers.  (The X is there because Perl
arrays start at 0, and you have no question 0.)  

Then, to total the correct answers, look at each question in turn,
like this:

	for $qnumber (1 .. 50) {
	  $users_answer = $in{"answer$qnumber"};
	  $correct_answer = $correct_answer[$qnumber];
	  if ($users_answer eq $correct_answer) {
	    $TOTAL_CORRECT++;
	    push @questions_answered_correctly, $qnumber;
	  } else {
	    push @questions_answered_wrong, $qnumber;
	  }
	}

Now `@questions_answered_correctly' has a list of the numbers of the
questions that were answered correctly, and `@questions_answered_wrong
has a list of the numbers of the questions that were answered wrong.
$TOTAL_CORRECT has the total number of questions answered correctly.

This supposes that the user's reponses to the form are stored in the
variable `%in', which is typical.

You certainly don't want to repeat the same code over and over fifty
times.  The cardinal rule of programming is that if you were the same
thing more than once, you made a mistake, and you should fix the
program so that the parts that are similar are joined together.




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

Date: Fri, 15 May 1998 09:10:48 -0400
From: "Bill Ferraro" <skc1234@hotmail.com>
Subject: Perl Error Documentation
Message-Id: <6jhf17$b1d@sjx-ixn4.ix.netcom.com>

Is there anything on the Web which gives more informative explanations of
the most common Perl errors (i.e. something better than perldiag), and the
quick way to fix them?

Thanks,
Bill

--






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

Date: Sat, 16 May 1998 17:46:52 GMT
From: farber@f-tech.net (Paul Farber)
Subject: Piping a fiel to a perl script
Message-Id: <355dd04d.2122622@news.f-tech.net>

Hello all, 

I have a need fo a per script to be feed a text file, chew it up, and
spit out a formated one.  I would like it work like 
script < infile > outfile, but not sure on how to do the I/O.  What
will the fiel Open and Close look like?

Right now i'm thinking I have to get the file names from the cmd line
(ARGV[X]) and then just use the open with the |> or |< paramater???

Thanks in advance..

Paul


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

Date: 16 May 1998 15:10:13 -0400
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: Piping a fiel to a perl script
Message-Id: <6jkoal$4u8$1@monet.op.net>
Keywords: claw infinity Lena need


In article <355dd04d.2122622@news.f-tech.net>,
Paul Farber <farber@f-tech.net> wrote:
>I would like it work like 
>script < infile > outfile, but not sure on how to do the I/O.  What
>will the fiel Open and Close look like?

The whole point about < and > is that you don't have to do the open
and close, so your program does not need to care where the input is
coming from or where it is giong to.  Write the script like this:

	while (<>) {  # This reads from the `standard input'
	  # The next line is now in the $_ variable
	  # Do something with $_
  	  print;     # Print $_ to the `standard output'
	}

Now you can run this script like this:

	# standard input is `infile'; standard output is `outfile'
	script < infile   > outfile

or like this:

	# standard input is three files; standard output is `outfile'
	script infile1 infile2 infile3  > outfile

or like this:

	# standard input is a program; standard output is a different program
	program1 | script | program2

and it will all work magically.


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

Date: 16 May 1998 10:50:37 +0500
From: jwbacon@ix.netcom.com (J. Bacon)
Subject: Re: Problem with spaces in directory path names in Perl on WIN32
Message-Id: <355db5cd.0@news2.uswest.net>

The TRULY UGLY (but 'foolproof') thing to do seems to be to get the DOS 
pathname and open the file using that method.

This 'foolproof' method still fails, though, if you're accessing long 
filenames on a Netware volume from a Win95 or NT machine.

Where/when possible I use the File::Copy and File::Path modules -- I still get 
occasional problems, but they are easier to find & fix.

This is one of those issues where I sincerely hope everybody takes offense at 
my solutions and posts the better way to do it, so we can all save those 
approaches for future reference.


In article <355D0BF4.2595@McCann.cz>, Jan@McCann.cz says...
>
>tipirneni@yahoo.com wrote:
>> 
>> Folks,
>> 
>>     Whenever I try to execute a script from the perl that has sapce in its
>> path, it is failing. Like the following script,
>> 
>>     `C:\Program files\DevStudio\programs\preprocess\release\preprocess.exe
>> data.txt`;
>> 
>>     gives "The system cannot find the path specified." message and exits.
>> is there are a way to solve this problem.
>> 
>>      tipirneni
>
>If you'd try that from the command line you'd found out it doesn't work
>even from there. 
>
>c:\> C:\Program
>files\DevStudio\programs\preprocess\release\preprocess.exe data.txt
>
>You HAVE to enclose the whole .exe name into doublequotes:
>
>c:\> "C:\Program
>files\DevStudio\programs\preprocess\release\preprocess.exe" data.txt
>
>or
>
>`"C:\Program files\DevStudio\programs\preprocess\release\preprocess.exe"
>data.txt`
>
>
>HTH, Jenda
>
>BTW, unless strictly necessary never install anything into a directory
>with 
>a space in it's name. It's pretty annoying to have to enclose everything 
>into quotes.



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

Date: Sat, 16 May 1998 18:23:16 GMT
From: thijs@kinkhorst.com (Thijs Kinkhorst)
Subject: Re: Removing ^M at the end of each line of a file.
Message-Id: <6jklil$ku3$1@news2.xs4all.nl>

In article <6j9jhi$plt$1@inn.imcn.com>, "N6006024"
<pernande@dev.amadeus.net> writes:

>After having saved a perl script with Homesite 3.0, when I open the script
>using vi I can see that each line is ended by a  ^M. Consequently, I made a
>perl script to remove ^M.

You won't need this script. Your problem lies in the difference in file
endings between DOS/Windows and UNIX. Uploading your script in ASCII mode
should take care of the ^Ms, otherwise some option on your editor as
"Save as UNIX text" or something alink will do.


-- 
Thijs Kinkhorst      *    Jaze Web Design    *        ICQ 432406
thijs@kinkhorst.com  *  http://www.jaze.net  *  KeyID 0x371EFCB1
print "Perl is cool"; print "Perl is cool"; print "Perl is cool";



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

Date: Sat, 16 May 1998 11:58:19 -0800
From: Jeff & Eilene Beard <jnebeard@earthlink.net>
Subject: Re: Removing ^M at the end of each line of a file.
Message-Id: <355DEFDB.7553@earthlink.net>

for years we always said ftp ascii files in text mode and everything 
else in binary -- it just works.

Along comes Windows/NT 4.0 (in particular fix pack 1) and we start to
see ^M in ascii files!  emperical tests have shown

	UNIX			NT 4.0 fp1		results

login  ftp
		open nt
		get and put						

diff  origin to derived				    aok

					login ftp
					open unix
					get and put	
		
diff  origin to derived				    ^M will appear				


interestingly, NT fixpack 3 seems to resolve the problem.

your milage may vary :-)  JB
	
Thijs Kinkhorst wrote:
> 
> In article <6j9jhi$plt$1@inn.imcn.com>, "N6006024"
> <pernande@dev.amadeus.net> writes:
> 
> >After having saved a perl script with Homesite 3.0, when I open the script
> >using vi I can see that each line is ended by a  ^M. Consequently, I made a
> >perl script to remove ^M.
> 
> You won't need this script. Your problem lies in the difference in file
> endings between DOS/Windows and UNIX. Uploading your script in ASCII mode
> should take care of the ^Ms, otherwise some option on your editor as
> "Save as UNIX text" or something alink will do.
> 
> --
> Thijs Kinkhorst      *    Jaze Web Design    *        ICQ 432406
> thijs@kinkhorst.com  *  http://www.jaze.net  *  KeyID 0x371EFCB1
> print "Perl is cool"; print "Perl is cool"; print "Perl is cool";


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

Date: 16 May 1998 19:33:06 GMT
From: cgschmitt@aol.com (CGSchmitt)
Subject: Which perl? (new user question)
Message-Id: <1998051619330600.PAA05884@ladder03.news.aol.com>

Hi,

I'm just learning perl (I bought O'Reilly's Learning Perl yesterday) and am
interested in experienced perl hackers' opinions of how I should proceed. I'll
be using perl primarily for cgi-scripts on unix servers. However, I'll probably
be using my Powermac to learn perl and write the scripts. I understand that
perl ports very well, but there are still some differences between MacPerl and
Unix perl.

What would be the best way for me to learn? Learn the basics on MacPerl and
then alter my scripts for Unix, or learn on Unix in the first place. I do have
an old 486 with Windows that I'm not really using too much. Would it be worth
it (or possible) to make this a Unix machine?

I'm somewhat new to programming - I have a little experience with Pascal and C,
so I need someone out there to set me straight. Thanks in advance.

Curtis (future perl hacker)
cgschmitt@aol.com
David Said, an independent band
mix of industrial, folk, new age, and metal
http://members.aol.com/davidsaid


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

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


Administrivia:

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

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

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

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

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

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

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

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


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

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