[8890] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2507 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue May 5 18:07:46 1998

Date: Tue, 5 May 98 15:00:46 -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           Tue, 5 May 1998     Volume: 8 Number: 2507

Today's topics:
    Re: 256 char limitation? <rootbeer@teleport.com>
    Re: [Q] subsitute (Jonathan Stowe)
        A question about crypt. <jcheung@fedex.com>
    Re: Bad interaction between eval and require: perl bug? <rootbeer@teleport.com>
        Buiding Perl 5.004_04 on Solaris 2.5.1 <cmihaly@fa.disney.com>
    Re: Compare integes is faster than compare strings also <rootbeer@teleport.com>
    Re: Computing length of hash (Tom Rokicki)
    Re: Computing length of hash <jkry3025@comenius.ms.mff.cuni.cz>
        COUNTING DAYS UNTIL 2000 <thijs@esense.nl>
    Re: COUNTING DAYS UNTIL 2000 (Aaron B. Dossett)
    Re: COUNTING DAYS UNTIL 2000 <rootbeer@teleport.com>
    Re: database file where specific users can edit ONLY on <rootbeer@teleport.com>
        deleting lines from file help <rburditt@london.gos.fedex.com>
    Re: deleting lines from file help <brianm@kodak.com>
    Re: deleting lines from file help <rootbeer@teleport.com>
    Re: deleting lines from file help <lr@hpl.hp.com>
    Re: Embedded systems programming (Jonathan Stowe)
    Re: Ever Wonder Why Not Everyone Uses Modules? <neeri@iis.ee.ethz.ch>
    Re: Ever Wonder Why Not Everyone Uses Modules? <brianm@kodak.com>
    Re: fpt.pl needs sys/socket.ph / what is socket.ph? (Jonathan Stowe)
    Re: help a novice in perl! <andrewf@cp.pathfinder.com>
    Re: help a novice in perl! (Bart Lateur)
    Re: help a novice in perl! (Jonathan Stowe)
        Help Needed for sorting a delimited text file <aaa@dms2.com>
    Re: Help Needed for sorting a delimited text file <brianm@kodak.com>
    Re: Help Needed for sorting a delimited text file <rootbeer@teleport.com>
        HELP: line continuation character appears to fail <brannon@lnc.usc.edu>
    Re: HELP: line continuation character appears to fail <brianm@kodak.com>
    Re: HELP: line continuation character appears to fail <rootbeer@teleport.com>
        Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Tue, 05 May 1998 21:05:49 GMT
From: Tom Phoenix <rootbeer@teleport.com>
To: N/A <pittdno@spamexecpc.com>
Subject: Re: 256 char limitation?
Message-Id: <Pine.GSO.3.96.980505140337.13101S-100000@user2.teleport.com>

On Tue, 5 May 1998, N/A wrote:

> if I try to send more than 256 chars from the client to the server, the
> first 256 get lost and only the chars after that show up at the other
> clients!

That's a sign that one of the programs you're using has a bug. Try using
(say) telnet as the client and also as the server, then (if everything
works) replace one end or the other with a program until you isolate the
problem. Hope this helps! 

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Tue, 05 May 1998 16:57:05 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: [Q] subsitute
Message-Id: <354f1ad7.5806121@news.btinternet.com>

On Mon, 4 May 1998 21:52:39 -0700, <darknerd@shell4.ba.best.com> wrote
:

>
>How would I take a date in the format of 5/4/98 at the beginning of a line
>and change it to 980504.
>
You could use something like this:

#!/develop/bin/perl

use Date::Parse;
use Date::Format;

$mdate = "7/04/96";

print time2str("%y%m%d",str2time($mdate));

__END__

the Date::* modules are part of the TimeDate package available from
CPAN.

This is not however the fastes solution but it should protect you to
some extent from a change in input date format.

A possibly more glamorous solution (and not using extra modules):

$mdate =~
s|(\d+)/(\d+)/(\d+)|$newdate=sprintf("%02d%02d%02d",$3,$1,$2)|e;

but its all a matter of taste really;

/J\
Jonathan Stowe
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>



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

Date: Tue, 05 May 1998 15:59:32 -0400
From: Jason Cheung <jcheung@fedex.com>
Subject: A question about crypt.
Message-Id: <354F6FA4.983959C9@fedex.com>

Hi there,

Hope you can help on this.

I'm now using Perl v5.004_04 for sun4-solaris.  And I try to use the
Perl's built-in function "crypt" to encrypt the passwords and store the
results in a database.

According to the documentation (perlfunc), the built-in "crypt" should
behave exactly the same as the C library crypt(3).  However, crypt(3) is
not installed on my system, but crypt(3C).  So I've been experiencing
something that puzzles me, i.e., the value returned from Perl's crypt is
different from the value returned from crypt(3C).  

Here is my question:

Is there any difference between crypt(3) and crypt(3C)?  If so, what is
it?

Any thought and insight to the described "feature" is welcomed.

Thanks for your kind attention.

Cheers,
Jason


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

Date: Tue, 05 May 1998 20:09:13 GMT
From: Tom Phoenix <rootbeer@teleport.com>
To: Martin Gregory <mgregory@asc.sps.mot.com>
Subject: Re: Bad interaction between eval and require: perl bug?
Message-Id: <Pine.GSO.3.96.980505130501.13101L-100000@user2.teleport.com>

On 5 May 1998, Martin Gregory wrote:

> This is VERY BAD.  Where did my variable values go?  Why didn't the
> fact that the require fails get reported?

I think you're right that this is a bug. In your bug report, you should
probably change the code to use eval BLOCK instead of eval STRING, which
also shows the bug, but is generally preferable. Thanks!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Tue, 05 May 1998 14:42:12 -0700
From: Chris Mihaly <cmihaly@fa.disney.com>
Subject: Buiding Perl 5.004_04 on Solaris 2.5.1
Message-Id: <354F87B4.9AA50E1D@fa.disney.com>

I am trying to build perl on a Sun box.  THe following is uname -a 
SunOS devil 5.5.1 Generic_103640-12 sun4u sparc SUNW,Ultra-Enterprise

	I run configure, and default all the prompts except for install
directories which we are putting in a different place.  I did not select
a dynamic version of libperl,did select perl's malloc (which are the
defaults anyways).  Configure appeared to work fine, and then I did a
make install.  At the very end of the install I get:
Warning: perl appears in your path in the following locations beyond
where
we just installed it:
    /usr/bin/perl
    /usr/5bin/perl

  Installation complete
panic: corrupt saved stack index.
panic: corrupt saved stack index.
panic: corrupt saved stack index.
panic: corrupt saved stack index.
panic: corrupt saved stack index.
panic: corrupt saved stack index.
panic: corrupt saved stack index.
panic: corrupt saved stack index.
panic: corrupt saved stack index.
panic: corrupt saved stack index.
panic: corrupt saved stack index.
panic: corrupt saved stack index.
panic: corrupt saved stack index.
panic: corrupt saved stack index.
panic: corrupt saved stack index.
panic: corrupt saved stack index.
panic: corrupt saved stack index.
panic: corrupt saved stack index.
panic: corrupt saved stack index.
panic: corrupt saved stack index.
panic: corrupt saved stack index.
panic: corrupt saved stack index.
panic: corrupt saved stack index.
panic: corrupt saved stack index.
panic: corrupt saved stack index.
panic: corrupt saved stack index.
panic: corrupt saved stack index.
panic: corrupt saved stack index.
panic: corrupt saved stack index.
panic: corrupt saved stack index.
panic: corrupt saved stack index.
panic: corrupt saved stack index.
panic: corrupt saved stack index.
panic: corrupt saved stack index.
panic: corrupt saved stack index.
panic: corrupt saved stack index.
panic: corrupt saved stack index.
panic: corrupt saved stack index.
panic: corrupt saved stack index.
panic: corrupt saved stack index.
panic: corrupt saved stack index.
panic: corrupt saved stack index.
panic: corrupt saved stack index.
panic: corrupt saved stack index.
panic: corrupt saved stack index.
panic: corrupt saved stack index.
panic: corrupt saved stack index.
panic: corrupt saved stack index.
panic: corrupt saved stack index.
panic: corrupt saved stack index.
panic: corrupt saved stack index.
panic: corrupt saved stack index.
panic: corrupt saved stack index.
panic: corrupt saved stack index.
panic: corrupt saved stack index.
panic: corrupt saved stack index.
panic: corrupt saved stack index.
panic: corrupt saved stack index.
panic: corrupt saved stack index.
panic: corrupt saved stack index.
panic: corrupt saved stack index.
panic: corrupt saved stack index.
panic: corrupt saved stack index.
panic: corrupt saved stack index.
panic: corrupt saved stack index.
*** Signal 11 - core dumped
make: Fatal error: Command failed for target `install.perl'

	The perl binary it creates appears to run but always core dumps when it
exits with the above message.  Anyone know what might be causing this?

	Thanks
 	 Chris


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

Date: Tue, 05 May 1998 21:00:32 GMT
From: Tom Phoenix <rootbeer@teleport.com>
To: Peng Li <teilipe@tss.tei.ericsson.se>
Subject: Re: Compare integes is faster than compare strings also in perl?
Message-Id: <Pine.GSO.3.96.980505135752.13101R-100000@user2.teleport.com>

On Tue, 5 May 1998, Peng Li wrote:

> someone told me in PERL all integers are converted to strings,

They lied.

>   if there are two strings scalar variables($a, $b) and two integer 
> variables ($c, $d), which comparation is faster?
>   1)    if ( $a eq $b ) { ...}
>   2)    if ( $c == $d ) { ... }

I could guess, but that's pointless. If you want to know which is faster,
use the Benchmark module to find out. Of course, for nearly any normal
application, only one of those is _correct_, and that's the one you should
use. Hope this helps! 

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: 5 May 1998 13:41:08 -0700
From: rokicki@cello.hpl.hp.com (Tom Rokicki)
Subject: Re: Computing length of hash
Message-Id: <6inth4$qtf@cello.hpl.hp.com>


> Ordinary %hash in scalar context returns "the number of items/the number
> of buckets".  That is something like "10/31".

Nope.  It returns the number of soiled buckets slash the number of buckets.

For instance:

[1741] % perl -de 1

Loading DB routines from perl5db.pl version 1.01
Emacs support available.

Enter h or `h h' for help.

main::(-e:1):   1
  DB<1> @a{'ab','ba'} = (1, 2) ;

  DB<2> $a = keys %a ;

  DB<3> $a2 = %a ;

  DB<4> p $a
2
  DB<5> p $a2
1/8

The keys 'ab' and 'ba' collide, so they share the same single bucket of the
eight initially allocated.

-tom


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

Date: Tue, 05 May 1998 23:12:15 -0700
From: Jan Krynicky <jkry3025@comenius.ms.mff.cuni.cz>
Subject: Re: Computing length of hash
Message-Id: <354FFF3F.3495@comenius.ms.mff.cuni.cz>

Tom Rokicki wrote:
> 
> > Ordinary %hash in scalar context returns "the number of items/the number
> > of buckets".  That is something like "10/31".
> 
> Nope.  It returns the number of soiled buckets slash the number of buckets.

Sorry, I was too quick (as usual). Please forget everything I said.

Jenda :-(


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

Date: 5 May 1998 20:01:51 GMT
From: "Mathijs Oosterom" <thijs@esense.nl>
Subject: COUNTING DAYS UNTIL 2000
Message-Id: <01bd7860$50183840$a44a6dc2@earl.esense.nl>

Hi there,

Does anyone has a Perl-script that counts the days until the year 2000? 

Or does anybody know how to do that? Is there a function that gives a value
in days for each given date?

Thanx in advance,

Thijs.


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

Date: 5 May 1998 20:27:59 GMT
From: aarond@alpha.ewl.uky.edu (Aaron B. Dossett)
Subject: Re: COUNTING DAYS UNTIL 2000
Message-Id: <6insof$c0i$1@service3.uky.edu>

Mathijs Oosterom (thijs@esense.nl) wrote:
> Hi there,
> 
> Does anyone has a Perl-script that counts the days until the year 2000? 
> 
> Or does anybody know how to do that? Is there a function that gives a value
> in days for each given date?
> 

Date::DateCalc will compute the days between two dates.


-- 
Aaron B. Dossett   |   Finger aarond@london.cslab.uky.edu for PGP key
dossett@bigfoot.com|      
Comp. Sci. Senior  |         http://www.ewl.uky.edu/~aarond
    University of Kentucky    1996 & 1998 NCAA Basketball Champions


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

Date: Tue, 05 May 1998 21:34:38 GMT
From: Tom Phoenix <rootbeer@teleport.com>
To: Mathijs Oosterom <thijs@esense.nl>
Subject: Re: COUNTING DAYS UNTIL 2000
Message-Id: <Pine.GSO.3.96.980505143343.13101Y-100000@user2.teleport.com>

On 5 May 1998, Mathijs Oosterom wrote:

> Is there a function that gives a value in days for each given date? 

Yes, although you may need to write it yourself using the built-in
functions listed in perlfunc. Hope this helps!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Tue, 05 May 1998 21:11:26 GMT
From: Tom Phoenix <rootbeer@teleport.com>
To: Joe Raymundo <tasburfoot@yahoo.com>
Subject: Re: database file where specific users can edit ONLY one record each
Message-Id: <Pine.GSO.3.96.980505141010.13101T-100000@user2.teleport.com>

On Tue, 5 May 1998, Joe Raymundo wrote:

> I need to create a ascii database where certain users of the system can
> edit only one record. Basically their own.  Any thoughts as to the best
> way to set this up? 

Authenticate the users. Of course, there's nothing Perl-specific about
doing that, but Perl's crypt function may be useful. Hope this helps!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Tue, 05 May 1998 15:09:20 -0500
From: robert burditt <rburditt@london.gos.fedex.com>
Subject: deleting lines from file help
Message-Id: <354F71EE.1F6A9417@london.gos.fedex.com>

this should be a fairly simple task, but i cannot figure out
how to do it... i'd really appreciate any help out there.

i have a log file that grows pretty large and about once a week,
i'd like to go in and delete the first 20,000 lines or so.

could anyone give insight on how to do this?

thanks a lot,
robert
rburditt@fedex.com


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

Date: Tue, 05 May 1998 16:53:54 -0400
From: Brian Mathis <brianm@kodak.com>
To: rburditt@fedex.com
Subject: Re: deleting lines from file help
Message-Id: <354F7C62.E169BC98@kodak.com>

[emailed and posted]

robert burditt wrote:
> 
> this should be a fairly simple task, but i cannot figure out
> how to do it... i'd really appreciate any help out there.
> 
> i have a log file that grows pretty large and about once a week,
> i'd like to go in and delete the first 20,000 lines or so.
> 
> could anyone give insight on how to do this?
> 
> thanks a lot,
> robert
> rburditt@fedex.com

You could read the whole file into an array, then
$limit = $#array - 20000;
for($i=0; $i<$limit; $i++) {
    print FILE $array[$i];
}

or something similar (I that code will actually delete the most recent
entries).

Or, a smarter idea might be to simply rename the log file at a certain
time, then create a new one.  It's much simpler.

Brian Mathis
orev


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

Date: Tue, 05 May 1998 21:35:31 GMT
From: Tom Phoenix <rootbeer@teleport.com>
To: rburditt@fedex.com
Subject: Re: deleting lines from file help
Message-Id: <Pine.GSO.3.96.980505143516.13101Z-100000@user2.teleport.com>

On Tue, 5 May 1998, robert burditt wrote:

> i'd like to go in and delete the first 20,000 lines or so.

The FAQ talks about this. Hope this helps!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Tue, 5 May 1998 14:30:16 -0700
From: "Larry Rosler" <lr@hpl.hp.com>
Subject: Re: deleting lines from file help
Message-Id: <6io0da$rj2@hplntx.hpl.hp.com>

[posted and mailed]

robert burditt wrote in message
<354F71EE.1F6A9417@london.gos.fedex.com>...
>this should be a fairly simple task, but i cannot figure out
>how to do it... i'd really appreciate any help out there.
>
>i have a log file that grows pretty large and about once a week,
>i'd like to go in and delete the first 20,000 lines or so.
>
>could anyone give insight on how to do this?
>
>thanks a lot,
>robert
>rburditt@fedex.com

1 while <IN> and $. < 20000;
print while <IN>;

This should behave gracefully even on a shorter file.

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





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

Date: Tue, 05 May 1998 16:56:59 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: Embedded systems programming
Message-Id: <354f0d18.3131164@news.btinternet.com>

On Mon, 04 May 1998 19:49:11 -0500, Mohammad Razzak wrote :

>Hi!
>Can anybody enlighten me on the concept of Embedded systems programming?
>Some explanations with examples would be appreciated.
>
If anyone is doing Embedded systems in Perl that would be exciting.

/J\
Jonathan Stowe
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>



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

Date: 05 May 1998 23:19:58 +0200
From: Matthias Neeracher <neeri@iis.ee.ethz.ch>
Subject: Re: Ever Wonder Why Not Everyone Uses Modules?
Message-Id: <86d8ds76v5.fsf@gwaihir.ethz.ch>

Zenin <zenin@archive.rhps.org> writes:
> Harald Joerg <Harald.Joerg@mch.sni.de> wrote:
> 	>snip<
> : Using a module could make my program work on non-UNIX without change.
> : Or on UNIXes which don't have sendmail in /usr/lib, or not installed
> : at all. If you do a lot of cross-platform perl, modules can be safer.
> 
> 	Sendmail is in /usr/lib or /usr/sbin on %99.9 of all Unix systems,
> 	even if it's not the system mailer.

So "simply" opening a pipe to /usr/lib/sendmail is already a problem, because
sendmail might be in /usr/sbin. Of course, it's not hard to test where it
is, but the presence of a sendmail binary does not prove that the system is
set up correctly to deliver mail.

> 	On the other hand, I'd guess that easily 1/5 of the Unix systems
> 	I've worked worked with had nothing listing on port 25.

You're operating under the mistaken assumption that Net::SMTP simply connects
to port 25 on localhost.

>       Even if you have access to another SNTP server

That's "SMTP".

> (smell a vary non-portable code change here to point to it? I do!)

That's most likely because your knowledge of Net::Config is similar to your
knowledge of network protocols (or spelling, for that matter).

> it might not be up when you try to send your mail (intermittent connections
> never happen, right?).  Are you ready to setup your own local message que and
> daemon to handle it? If you simply pipe to sendmail you'll get delivered in
> the best possible way, automatically qued if needed, and a host of other
> features and fall backs you're just not going to get with SNTP, ever.

You are right that there are tradeoffs involved: With Net::SMTP you get to
pick your mail server of choice, get more immediate feedback about errors that
occur, but may have to face complex fallback strategies if the network between
you and your server fails. With sendmail, you are at the mercy of the sendmail
setup on the local host (sendmail never gets misconfigured, right?), but if
that setup is correct, you get best efforts delivery.

Neither method is very reliable for longer term network failures, unless your
script greps your mailbox for bounce messages.

> 	So, by using SNTP directly you build code that's *extremely*
> 	NON-portable between many, many common Unix servers

Nonsense.

> 	Of the 30+ NT machines in my company, I don't
> 	think there is a single one that is running an SNTP server.

Irrelevant. Net::SMTP doesn't send to localhost.

> 	Sendmail is FAR more cross-platform compatible then directly talking
> 	SNTP will *ever* be.

The percentage of hosts capable of talking SMTP far exceeds the percentage of
hosts running a correctly configured sendmail.

> 	If you want a fairly clean, robust, and portable interface to
> 	sendmail, checkout (soon to be at CPAN, but it's still alpha):
> 
> 	ftp://thrush.omix.com/pub/perl/modules/Mail-Sendmail-1.10.tar.gz

Hmm. Somebody complains about not being able to easily install a module which
is release quality and available on CPAN. You respond by recommending a
module in alpha testing not available on CPAN.

What's wrong with this picture?

Matthias

-- 
Matthias Neeracher   <neeri@iis.ee.ethz.ch>   http://www.iis.ee.ethz.ch/~neeri
   "I really don't want the SNMP agent controlling my toilet to tell
    someone when/where I'm using it." -- Sean Graham


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

Date: Tue, 05 May 1998 17:41:09 -0400
From: Brian Mathis <brianm@kodak.com>
Subject: Re: Ever Wonder Why Not Everyone Uses Modules?
Message-Id: <354F8775.4FC72D63@kodak.com>

Well, I've learned a lot from this thread..  But the phrase "beating a
dead camel" comes to mind.

I think we can surmise, that, depending on your needs, you might want to
use a module, or you might want to use sendmail.  Of course, we are all
intelligent people, so I think it's possible that we can each decide,
based on the situation, what is the "best" solution to a given problem.

Frankly, I never even thought about network downtimes and sendmail
queueing.  Before reading
this thread, I would've said "Net::SMTP all the way!"  Now I know that I
have been ignorant to some other issues.

I don't think it's worth fighting until we're red in the face about
which one to use, because, obviously, you should use the right tool for
the right job, and one answer isn't always more right than the other
(unless you disagree with my answer, then it's wrong :).

Brian Mathis
orev


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

Date: Tue, 05 May 1998 16:57:07 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: fpt.pl needs sys/socket.ph / what is socket.ph?
Message-Id: <354f3889.12675426@news.btinternet.com>

On Mon, 04 May 1998 19:40:12 GMT, Kenneth Baltrinic wrote :

>To anyone who can help:
>
>I have writen a perl script that needs aquire a datafile via ftp for
>processing.
>
>To do this I am "require"-ing ftp.pl which is found in /perl/lib in the
>Perl 5 distribution.
>
>This library contains the line:
>
>eval "require 'socket.ph'" || eval "require 'sys/socket.ph'" || die
>"socket.ph missing: $!\n";
>
>Which causes a runtime error like its is supposed to if sys/socket.pl is
>missing.  What is sys/socket.ph, what does it do, do I need it and where
>do I find it?
>
A *.ph file is the perl equivalent (almost) of a C *.h file.  It
contains such things as constant value definitions.  There is a script
called h2ph with the distribution which will create the former from
the latter.  It has documentation in pod format.  You probably can
just do:

cd /usr/include/sys
h2ph socket.h

>Or is there another way I can FTP via Perl?  I just need to log on and
>retrieve one file from a password secured FTP server.
>

The ftp.pl library is perhaps a little outdated by newer stuff like
Net::FTP which is part of the libnet bundle.  However if your code
works after you got socket.ph I cant see any reason for you to change
it.

/J\
Jonathan Stowe
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>



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

Date: Tue, 5 May 1998 17:41:32 -0400
From: "Andrew F. Lee" <andrewf@cp.pathfinder.com>
Subject: Re: help a novice in perl!
Message-Id: <Pine.GSO.3.95.980505173633.18176B-100000@cp.pathfinder.com>

On Tue, 5 May 1998, sg wrote:

> hello everybody!!
> 
> I would wanted to do a perl script which can
> put in a table, *.html files founded in a directory.
> but (even if i've made some researches on
> FAQ, and try to found an information on perl
> book) i didn't found a function which can return
> (or repertoriate) the *.html files in a directory.
> 
> thanks you very much to help me!
> sg
> info@atig.fr

you mean

@files = <*.html>;
foreach $file(@files) { print $file, "\n"; }

The BEST book for learning Perl is ... "Learning Perl" by Randal L. 
Schwartz & Tom Christiansen ... Published by O'Reilly.  The second edition
is out and is a must for every aspiring Perler (in my opinion).

-------------------------------------------------------------
Andrew F. Lee                 |                              |
Software Engineer             |  parenttime.com              |
email: andrewf@pathfinder.com |  1271 Avenue of the Americas |
Phone: (212) 522-2769         |  New York, N.Y. 10020        |
-------------------------------------------------------------
        When I say, "Ignore the man behind the curtain."   
        That is because there is no man behind the curtain.




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

Date: Tue, 05 May 1998 22:36:59 GMT
From: bart.mediamind@tornado.be (Bart Lateur)
Subject: Re: help a novice in perl!
Message-Id: <355190ff.5060459@news.tornado.be>

sg wrote:

>i didn't found a function which can return
>(or repertoriate) the *.html files in a directory.

Maybe because it's not one function. Try something like:

	opendir(DIR,$dirname);
	@html = grep { /\.html?$/i } readdir(DIR);
	closedir(DIR);

It will get you a list of all .html and .htm files. Good enough?

	Bart.


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

Date: Tue, 05 May 1998 16:57:01 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: help a novice in perl!
Message-Id: <354f116f.4045336@news.btinternet.com>

On Tue, 5 May 1998 17:04:07 +0200, sg wrote :

>hello everybody!!
>
>I would wanted to do a perl script which can
>put in a table, *.html files founded in a directory.
>but (even if i've made some researches on
>FAQ, and try to found an information on perl
>book) i didn't found a function which can return
>(or repertoriate) the *.html files in a directory.
>

perldoc -f opendir will provide some illumination.

There are a number of scripts around which will do this sort of thing.

I have an example ( a mere hack of convenience ) at:

<URL:http://www.btinternet.com/~gellyfish/resources/dir2html.htm>

THis might give you some ideas.

/J\
Jonathan Stowe
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>



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

Date: Tue, 05 May 1998 17:17:10 -0400
From: Alee Ali <aaa@dms2.com>
Subject: Help Needed for sorting a delimited text file
Message-Id: <354F81D6.7F50@dms2.com>

Hi,
I am very new to Perl and was wondering if somedoy can help me out.  I
am trying to sort an Ascii Delimited file.  Each line has 5 values in it
and I need it sorted by each value.  If anyone can suggest any ideas it
will be greatly appreciated.  Thank you for your time.

Alee


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

Date: Tue, 05 May 1998 17:33:08 -0400
From: Brian Mathis <brianm@kodak.com>
To: aaa@dms2.com
Subject: Re: Help Needed for sorting a delimited text file
Message-Id: <354F8594.F941E709@kodak.com>

[emailed and posted]

Alee Ali wrote:
> Hi,
> I am very new to Perl and was wondering if somedoy can help me out.  I
> am trying to sort an Ascii Delimited file.  Each line has 5 values in it
> and I need it sorted by each value.  If anyone can suggest any ideas it
> will be greatly appreciated.  Thank you for your time.
> Alee

What do you mean sorted by each value?  You need separate output for
each field?  You want to sort first field 1, then field 2, etc..?

For starters, take a look at the split function, which you'll probably
need to use.

Brian Mathis
orev


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

Date: Tue, 05 May 1998 21:50:01 GMT
From: Tom Phoenix <rootbeer@teleport.com>
To: Alee Ali <aaa@dms2.com>
Subject: Re: Help Needed for sorting a delimited text file
Message-Id: <Pine.GSO.3.96.980505144810.13101c-100000@user2.teleport.com>

On Tue, 5 May 1998, Alee Ali wrote:

> I am trying to sort an Ascii Delimited file.  

ASCII delimited? So, the data in the file are delimited by the ASCII
characters in the file? :-) 

> Each line has 5 values in it and I need it sorted by each value.  If
> anyone can suggest any ideas it will be greatly appreciated.

There's information in the perlfunc manpage under 'sort'. Hope this helps! 

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: 05 May 1998 13:55:04 -0700
From: Terrence Brannon <brannon@lnc.usc.edu>
Subject: HELP: line continuation character appears to fail
Message-Id: <lbbttc8ml3.fsf@seal.usc.edu>

#!/usr/local/bin/perl 

use Getopt::Long;
use Statistics::Descriptive;

while ($file=readdir(DOT)) {
    if ($file =~ $file_style) {
	$outfile = $cobble_dir . $1;
	
	open F, "<$file";
	while (<F>) {

	    foreach $header_word (@header_words) {
		if (/$header_word:$float_re/) { 
		    assign($header_word,$1);
		}
	    }
	    
	    if (/100\s(\d+)/) {
		assign(spike_count,$1);
	    }

	}

	if ($ampa_gmax < 1e-6) {
	    print  $/, "SKIPPING:", $/;

	    next;
	}



	if (not ref $P{$periodicity}{$synchronicity}{$ampa_gmax}) {
	    system "cat $file";
###########>>>> LINE BELOW FAILS AS IS	
	    $P{$periodicity}{$synchronicity}{$ampa_gmax} = \
		Statistics::Descriptive::Full->new();
###########>>>> THIS LINE WOULD WORK
	    $P{$periodicity}{$synchronicity}{$ampa_gmax} = Statistics::Descriptive::Full->new();

	    print ref $P{$periodicity}{$synchronicity}{$ampa_gmax}, $/;
	} else {
	    $P{$periodicity}{$synchronicity}{$ampa_gmax}->add_data($spike_count);

	}

	if (not ref $S{$Seriodicity}{$synchronicity}{$ampa_gmax}) {
	    $S{$Seriodicity}{$synchronicity}{$ampa_gmax} = Statistics::Descriptive::Full->new();
	} else {
	    $S{$Seriodicity}{$synchronicity}{$ampa_gmax}->add_data($spike_count);
	}
    }
}


-- 
Terrence Brannon * brannon@lnc.usc.edu * http://lnc.usc.edu/~brannon
USC, HNB, 3614 Watt Way, Los Angeles, CA 90089-2520 * (213) 740-3397
Great Milk Debate...  http://www.milk.com vs. http://www.notmilk.com


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

Date: Tue, 05 May 1998 17:29:49 -0400
From: Brian Mathis <brianm@kodak.com>
Subject: Re: HELP: line continuation character appears to fail
Message-Id: <354F84CD.7DCDDF97@kodak.com>

> ###########>>>> LINE BELOW FAILS AS IS
>             $P{$periodicity}{$synchronicity}{$ampa_gmax} = \
>                 Statistics::Descriptive::Full->new();
> ###########>>>> THIS LINE WOULD WORK

Please provide more description of your problem.  Please complete each
of the following statements:

I want this code to do this:

It appears to be doing this:

I know that it is not doing what I want it to because I have observed
this behaviour:

I am using perl version (type perl -v): 
on platform (UNIX, WinNT, ...):

If you provide this information, people here might be able to help you
out.

Brian Mathis
orev


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

Date: Tue, 05 May 1998 21:43:25 GMT
From: Tom Phoenix <rootbeer@teleport.com>
To: Terrence Brannon <brannon@lnc.usc.edu>
Subject: Re: HELP: line continuation character appears to fail
Message-Id: <Pine.GSO.3.96.980505143648.13101a-100000@user2.teleport.com>

On 5 May 1998, Terrence Brannon wrote:

> Subject: HELP: line continuation character appears to fail

What line continuation character? Since you never ask a question, I don't
have an answer. :-)

> while ($file=readdir(DOT)) {

Did you ever open that dirhandle?

> 	open F, "<$file";

Even when your script is "just an example" (and perhaps especially in that
case!) you should _always_ check the return value after opening a file.


> 	if (not ref $P{$periodicity}{$synchronicity}{$ampa_gmax}) {
> 	    system "cat $file";

Of course, you know that that line is potentially dangerous.

> ###########>>>> LINE BELOW FAILS AS IS	
> 	    $P{$periodicity}{$synchronicity}{$ampa_gmax} = \
> 		Statistics::Descriptive::Full->new();

What's that backslash doing there? If that's the line continuation
character you're talking about, it's not failing: it's a mistake.

> ###########>>>> THIS LINE WOULD WORK
> 	    $P{$periodicity}{$synchronicity}{$ampa_gmax} = Statistics::Descriptive::Full->new();

Yes, this one is missing the spurious backslash.

Hope this helps!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

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

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