[6938] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 563 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jun 3 11:27:18 1997

Date: Tue, 3 Jun 97 08:00:40 -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, 3 Jun 1997     Volume: 8 Number: 563

Today's topics:
     Re: (URGENT HELP!) Formating to SendMail <psrc@corp.airmedia.com>
     Re: *NOT SPAM* Apprentice Perl Hacker, Summer Work Offe (Wolf Paul)
     Re: 5.004 problem with Hashes (Andy Wardley)
     Re: Can I perl script download a HTML page??? (Eric Bohlman)
     Re: Help for "date" <rootbeer@teleport.com>
     Re: help!!! (Kyzer)
     ICMP in perl... (Alexei Yakimovich)
     Re: ICMP in perl... (Paul Marquess)
     Re: inconsistent opendir behaviour in Perl for win32 (Nathan V. Patwardhan)
     Re: inconsistent opendir behaviour in Perl for win32 (Simon Oosthoek)
     Re: leading zeroes ( Thomas Lachlan XMS x4206 )
     Re: leading zeroes (Tung-chiang Yang)
     Re: leading zeroes (Kyzer)
     Re: leading zeroes (Honza Pazdziora)
     Re: LOG base 10  operator (Tung-chiang Yang)
     Re: LOG base 10  operator <jbokma@caiw.nl>
     Re: most *robust* DBD::DBI/database combination ( <1M r ( Thomas Lachlan XMS x4206 )
     Re: Out of memory with big hashes <rootbeer@teleport.com>
     Re: Out of memory with big hashes (Phil Glatz)
     Re: performance question for sorting text from a large  <rootbeer@teleport.com>
     Re: PERL with Windows NT (Jim Esten)
     Re: pipes , tail, and buffering? <rootbeer@teleport.com>
     Re: print keys %something how do I sepearte each key? <jbokma@caiw.nl>
     Re: printing a hash in order? <seay@absyss.fr>
     Re: Protecting perl code *Important* (I R A Aggie)
     Re: Read a file to $wholefile <rootbeer@teleport.com>
     Re: reading and writing from/to the same file (Tad McClellan)
     script to parse one file, search another (Monty Scroggins)
     Re: Setting a variable for both split and join... (Tad McClellan)
     STDERR to variable <dickenrp@boat.bt.com>
     Re: STDERR to variable (Nathan V. Patwardhan)
     Re: Trying to get a DATE/TIME from MS-Excel. <vts4mars@rshx01.rz.fht-esslingen.de>
     Re: Who will win?  Borland or Microsoft or Programmers? <rmycroft@cyberatl.net>
     why won't 'print <<end_print...end_print' work? (Will Sexton)
     Re: Working with multiple files (simultaneously). (Tad McClellan)
     Re: Working with multiple files (simultaneously). <clark@s3i.com>
     WTD: perl script for HTML list of Ph servers on the fly (Andrew Starr)
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Tue, 03 Jun 1997 10:15:03 -0400
From: Paul S R Chisholm <psrc@corp.airmedia.com>
To: "A. Kello" <synchro@logos.cy.net>
Subject: Re: (URGENT HELP!) Formating to SendMail
Message-Id: <339426E7.1F4A@corp.airmedia.com>

A. Kello wrote:
> I used :     printf (MAIL,"%-40s %10s\n"$dummy1,$dummy2) ;

That'll set the minimum width of the fields. If you want to also control
the maximum width of the fields (i.e., make them exactly 40 and 10
characters wide), try:

printf MAIL "%40.40s %10.10s\n", $dummy1, $dummy2;

I'm really pretty sure you *don't* want the comma after MAIL and *do*
need the comma after the format string.

Dunno what the -40 for the width is supposed to do; right justification?
I suspect you'd be better off using write and FORMAT (and that you had a
problem with the file handle, i.e., as you did with the comma after MAIL
above).  --PSRC


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

Date: 3 Jun 1997 14:21:38 GMT
From: wnp@aut.alcatel.at (Wolf Paul)
Subject: Re: *NOT SPAM* Apprentice Perl Hacker, Summer Work Offered
Message-Id: <5n199i$hdt$1@atusks02.aut.alcatel.at>

I would not take such a narrow view. I can imagine that there are folks in
Europe and elsewhere outside the US who might be interested in that job
and could even get the necessary permits.

Now if he had posted to a dozen different newsgroups it would be different, but
to post a job offer for a perl job in the perl newsgroup seems quite appropriate.
This is a global village, after all.

However I agree that it would have made sense to mention the state ... the
Tappan Zee bridge is not THAT well known outside its immediate vicinity.

Regards,

Wolf

In article <3394b30d.12764996@news.ntr.net>,
	mark@ntr.net (Mark Mills) writes:
) On Thu, 29 May 1997 19:26:30 -0400, "Robert S. Kissel"
) <kissel@kissel.spicerack.ibm.com> wrote:
) 
)>I have suitable work for an apprentice Perl hacker (college student,
)>or even high-school, if you're real good).  The location is Westchester
)>County, just north of the Tappan Zee bridge.
)
) You just announced, to the _WHOLE WORLD_, that you have _ONE_ job
) available north of a locally famous tourist attraction...
) 
) *IS SPAM*
) 
) Don't take this too harshly but your note is right, you are a lunatic.

-- 
W. N. Paul/KSRU * Alcatel Austria AG * Scheydgasse 41 * A-1210 Vienna, Austria 
wnp@aut.alcatel.at * +43-1-277-22 x2523 (voice)/x118 (fax) * +43-1-774-1947 (h)





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

Date: 3 Jun 1997 08:31:27 +0100
From: abw@peritas.com (Andy Wardley)
Subject: Re: 5.004 problem with Hashes
Message-Id: <5n0h8f$q93@aoxomoxoa.peritas.com>

Prince Mystery  <mystery@itis.com> wrote:
>I'm getting an error that I didn't used to get when the system was on
>the previous version of perl (5.003):
>
>Odd number of elements in hash list at...
>
>Over the line:
>
>%final = {};

You're assigning a *reference* to an anonymous hash array to the first
key of your hash array.  You're not providing as associated value to go
with it, hence the warning.

Either do this:

  $final = {};    # reference to anonymous hash 

or:

  %final = ();    # hash array initialiased empty

It's an easy mistake to make.  I know.


A


-- 
Andy Wardley <abw@peritas.com>  **NEW** http://www.peritas.com/~abw 
A responsible and professional individual who has no need for silly 
comments, inane banter or bizarre "in-jokes" in his signature file.  


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

Date: Tue, 3 Jun 1997 08:50:42 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: Can I perl script download a HTML page???
Message-Id: <ebohlmanEB6z8I.Fs8@netcom.com>

Tina Marie Holmboe (tina@htmlhelp.com) wrote:
:   'cuse me for butting in like this with a slightly (!) off-topic comment,
: but when refering to URLs that point to servers or directories as opposed
: to files, please remember to include the '/' at the end, ie.

:     http://www.perl.com/

:   and not

:     http://www.perl.com

Those two are *exactly* equivalent, since the URL consists of only a 
protocol and a domain name.  Once there's anything more than a domain 
name, though, the trailing slash becomes significant.

http://www.perl.com == http://www.perl.com/

http://www.perl.com/CPAN != http://www.perl.com/CPAN/



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

Date: Tue, 3 Jun 1997 07:57:56 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Jun Zhuang <jzhuang@ringer.cs.utsa.edu>
Subject: Re: Help for "date"
Message-Id: <Pine.GSO.3.96.970603075653.1116F-100000@kelly.teleport.com>

On 2 Jun 1997, Jun Zhuang wrote:

> Under UNIX prompt, enter "date" will get : Mon Jun 2 13:45:34 CDT 1997
> Is there a similar function in PERL? What if I only want digits of the
> date? i.e. I want 970602 instead of Jun 2 1997?

Check out localtime() in perlfunc(1), and the various Date modules on
CPAN. These are the best ways to use Perl to get a date. :-)

    http://www.perl.com/CPAN/

-- Tom Phoenix        http://www.teleport.com/~rootbeer/
rootbeer@teleport.com   PGP  Skribu al mi per Esperanto!
Randal Schwartz Case:     http://www.lightlink.com/fors/



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

Date: 3 Jun 1997 11:13:36 GMT
From: junkmail@sysc.abdn.ac.uk (Kyzer)
Subject: Re: help!!!
Message-Id: <5n0u90$1gl@info.abdn.ac.uk>

When A. Deckers met comp.lang.perl.misc....:
: In comp.lang.perl.misc,
: 	yzhou@mtu.edu wrote:
: >I am tired.
: >
: >   There's a perl program, 
: >
: >#!/usr/local/perl/bin/perl
: >
: >print "Content-type: text/html\n\n";
: >
: > print <<END1;

to be honest, IMHO you meant

 print <<" END1";

: > END1
:   ^
:   |--------- This must start on column 0. Remove the space in front of it.

no no, that's surely not it :)

--
Stuart 'Kyzer' Caie - Kyzer/CSG |undergraduate of Aberdeen University |100%
http://www.abdn.ac.uk/~u13sac   |My opinions aren't those of Aberdeen |Amiga -
kyzer@4u.net kyzer@hotmail.com  |University or AUCC, thankfully.***** |always!

-- 
Random sig of the day:
"Newspapers are plagued with anonymous messages, often written in multicoloured
ink, predicting an imminent shortage of sausage rolls." - Roly Lishman


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

Date: 3 Jun 1997 09:07:10 GMT
From: alex@bear.dol.donetsk.ua (Alexei Yakimovich)
Subject: ICMP in perl...
Message-Id: <5n0mru$kss$1@bear.dol.donetsk.ua>

Dear,

Module in Net::Ping use TCP and echo service !!?
Normal Unix ping this is ICMP ECHO_REQUEST & ECHO_RESPONSE
I need help in example scripts using ICMP in Perl:)

Sincerely,
---
Alexei Yakimovich		ISP "Donbass OnLine"
Donetsk, Ukraine		http://www.dol.donetsk.ua
mailto:alex@dol.donetsk.ua	tel.380-622-350-350


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

Date: 3 Jun 1997 12:02:54 GMT
From: pmarquess@bfsec.bt.co.uk (Paul Marquess)
Subject: Re: ICMP in perl...
Message-Id: <5n115e$ff5$1@pheidippides.axion.bt.co.uk>

Alexei Yakimovich (alex@bear.dol.donetsk.ua) wrote:
: Dear,

: Module in Net::Ping use TCP and echo service !!?
: Normal Unix ping this is ICMP ECHO_REQUEST & ECHO_RESPONSE
: I need help in example scripts using ICMP in Perl:)

The latest version of Net::Ping allows ICMP pings. It is included in
Pelr 5.004.

Paul


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

Date: 3 Jun 1997 14:15:28 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: inconsistent opendir behaviour in Perl for win32
Message-Id: <5n18u0$ljt@fridge-nf0.shore.net>

Simon Oosthoek (s.oosthoek@student.utwente.nl) wrote:

: But the problem persists, with the added error information of $!, the 
: error is: "No such file or directory". I definately do have a d:\ (or 
: d:/), but both give the same error...

What version of NT Perl are you using?

--
Nathan V. Patwardhan
nvp@shore.net



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

Date: 3 Jun 1997 14:47:39 GMT
From: simon@shadow.student.utwente.nl (Simon Oosthoek)
Subject: Re: inconsistent opendir behaviour in Perl for win32
Message-Id: <5n1aqb$di8@pandora.cs.utwente.nl>

Nathan V. Patwardhan (nvp@shore.net) wrote:
: Simon Oosthoek (s.oosthoek@student.utwente.nl) wrote:

: : But the problem persists, with the added error information of $!, the 
: : error is: "No such file or directory". I definately do have a d:\ (or 
: : d:/), but both give the same error...

: What version of NT Perl are you using?

build 304.

is it fixed in a never version?

thanks,

Simon.


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

Date: 3 Jun 1997 09:44:25 GMT
From: etltsln@etlxd30.ericsson.se ( Thomas Lachlan XMS x4206 )
Subject: Re: leading zeroes
Message-Id: <5n0p1p$elf@newstoo.ericsson.se>

Mariana Wuerz (mariana.wuerz@fernuni-hagen.de) wrote:
: $four=04

: How can I get $four=4?

My version of Perl seems to interpret $four=04 as 4.
However should you, for whatever reason have $four="04",
then $four_no_leading_zero=substr($four,1), should work.
I'm sure this as the name suggests is a function for use
on strings and not numbers. Anyway I hope this helps.

		Regards Tam


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

Date: Tue, 3 Jun 1997 10:17:02 GMT
From: tcyang@netcom.com (Tung-chiang Yang)
Subject: Re: leading zeroes
Message-Id: <tcyangEB738F.5Ku@netcom.com>

$four + 0 produces 4.  Or Herr Wuerz can directly use it in an expression
which expects a number, say, if ($four == 3), I believe.

=======================
Thomas Lachlan XMS x4206 (etltsln@etlxd30.ericsson.se) wrote:
: Mariana Wuerz (mariana.wuerz@fernuni-hagen.de) wrote:
: : $four=04

: : How can I get $four=4?

: My version of Perl seems to interpret $four=04 as 4.
: However should you, for whatever reason have $four="04",
: then $four_no_leading_zero=substr($four,1), should work.
: I'm sure this as the name suggests is a function for use
: on strings and not numbers. Anyway I hope this helps.

: 		Regards Tam

--
Tung-chiang Yang                       tcyang@netcom.com

soc.culture.taiwan, soc.culture.china (by SCC FAQ Team) FAQ's:
   http://www.iglou.com/tcyang/Taiwan_faq.shtml, China_faq.shtml


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

Date: 3 Jun 1997 11:18:12 GMT
From: junkmail@sysc.abdn.ac.uk (Kyzer)
Subject: Re: leading zeroes
Message-Id: <5n0uhk$1gl@info.abdn.ac.uk>

When Mariana Wuerz met comp.lang.perl.misc....:
: $four=04

: How can I get $four=4?

$four='04';
print $four . "\n"; # yields '04'

$four=int($four);
print $four . "\n"; # yields '4'

I think that's what you meant... ?

--
Stuart 'Kyzer' Caie - Kyzer/CSG |undergraduate of Aberdeen University |100%
http://www.abdn.ac.uk/~u13sac   |My opinions aren't those of Aberdeen |Amiga -
kyzer@4u.net kyzer@hotmail.com  |University or AUCC, thankfully.***** |always!

-- 
Random sig of the day:
DC.W f+++ s+++ df h++++ Csilv a+ $+++ m d--- WL++ Fr---- Bslobber


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

Date: Tue, 3 Jun 1997 12:19:29 GMT
From: adelton@fi.muni.cz (Honza Pazdziora)
Subject: Re: leading zeroes
Message-Id: <adelton.865340369@aisa.fi.muni.cz>

Mariana Wuerz <mariana.wuerz@fernuni-hagen.de> writes:

> $four=04
> 
> How can I get $four=4?

	$ perl
	$four=04;
	print $four, "\n";
	__END__
	4

What is the problem? ;-)
 
Maybe if you meant how to make 4 out from '04', the solution might me:

	$four =~ s/^0*//;
or
	$four + 0;

Hope this helps.

--
------------------------------------------------------------------------
 Honza Pazdziora | adelton@fi.muni.cz | http://www.fi.muni.cz/~adelton/
                   I can take or leave it if I please
     Have you done your DES today? --> http://www.des.sollentuna.se/


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

Date: Tue, 3 Jun 1997 03:54:01 GMT
From: tcyang@netcom.com (Tung-chiang Yang)
To: ctgmod@iglou.com
Subject: Re: LOG base 10  operator
Message-Id: <tcyangEB6LI1.7Cp@netcom.com>

I am a newbie .....  but I wonder why we need to use "$_[0]"......

=======================
Tom Phoenix (rootbeer@teleport.com) wrote:
: On 2 Jun 1997, Michael J. Rocchetti wrote:

: > Does anyone know how to take the log base 10 of a number using PERL?

: Sure...

:    sub log10 ($) { log($_[0])/log(10) }

: Hope this helps!

--
Tung-chiang Yang                       tcyang@netcom.com

soc.culture.taiwan, soc.culture.china (by SCC FAQ Team) FAQ's:
   http://www.iglou.com/tcyang/Taiwan_faq.shtml, China_faq.shtml


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

Date: 3 Jun 1997 10:49:20 GMT
From: "John Bokma" <jbokma@caiw.nl>
Subject: Re: LOG base 10  operator
Message-Id: <01bc700b$85aba0e0$c40ab2c2@tschai>



Michael J. Rocchetti <miker@maverick.facil.uconn.edu> wrote in
article
<01bc6f51$08fa8080$1e716389@miker.maverick.facil.uconn.edu>...
> Does anyone know how to take the log base 10 of a number using
PERL?
> 
> miker
> 

Yes! Some maths:

a log b = c log b / c log a (where a log b means log base a of b)

in perl: 

$logbase10 = log($number) / log(10) 

(log in Perl has base e)

Regards,

John


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

Need a Freelance Software Developer (MSc)? (CGI, Perl, Java, C, C++)

http://www.caiw.nl/~jbokma [Java demo's, Curriculum Vitae and
more...]

email: jbokma@caiw.nl  phone: +31 10 4291827



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

Date: 3 Jun 1997 11:44:59 GMT
From: etltsln@etlxd30.ericsson.se ( Thomas Lachlan XMS x4206 )
Subject: Re: most *robust* DBD::DBI/database combination ( <1M records ) ??
Message-Id: <5n103r$elf@newstoo.ericsson.se>

Linux_User (amore@teleport.com) wrote:

: After having scanned some www urls, I wonder which combination 
: of DBI and database is the most stable and robust? Which has 
: been the most time tested (esp. for www work) ?? 

: Some of these modules/combinations seem as unstable as many MS
: products. Alphas, betas, etc. Help a newbie perl chap out :-)

: Any suggestions, or reference articles?

: TIA -


: Brett

I use DBD/DBI with Oracle RDBMS 7.2.2.3, it seems to work
superbly. 
			Regards Tam


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

Date: Tue, 3 Jun 1997 07:42:13 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Phil Glatz <phil@glatz.com>
Subject: Re: Out of memory with big hashes
Message-Id: <Pine.GSO.3.96.970603073545.1116C-100000@kelly.teleport.com>

On Tue, 3 Jun 1997, Phil Glatz wrote:

> I have an analysis perl (5.003) program that puts stuff into a big
> hash array - I eventually get an out of memory fatal exception.  I'm
> running an HP 9000 with 192 megs, HPUX 10.20.

Well, you may have a truly monstrous hash there; hashes can expand to take
up all of your virtual memory. I'd guess that you have around a million
items in it, or perhaps fewer, larger items. If your hash is this large,
you may wish to consider keeping it on disk, which is slower but will
allow a larger size.

On the other hand, it seems likely that you've been the victim of a memory
leak in 5.003; does the problem still occur with 5.004?

> Looking for hints on memory efficiency, I tries using the
> Tie::SubstrHash module to create a tighter table.  But wow, things
> seem to slow to a crawl!  

Yep; you're giving up some time to save some memory. 

Depending upon your application, one of those three techniques should
help. Good luck!

-- Tom Phoenix        http://www.teleport.com/~rootbeer/
rootbeer@teleport.com   PGP  Skribu al mi per Esperanto!
Randal Schwartz Case:     http://www.lightlink.com/fors/



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

Date: Tue, 03 Jun 1997 14:55:40 GMT
From: phil@glatz.com (Phil Glatz)
Subject: Re: Out of memory with big hashes
Message-Id: <33942fe3.4469826@news.ricochet.net>

Tom Phoenix <rootbeer@teleport.com> wrote:
>> I have an analysis perl (5.003) program that puts stuff into a big
>> hash array - I eventually get an out of memory fatal exception.

> If your hash is this large,
>you may wish to consider keeping it on disk, which is slower but will
>allow a larger size.

By using dbmopen?  Still run out of memory - any way to force it to
disk rather than memory?
>
>On the other hand, it seems likely that you've been the victim of a memory
>leak in 5.003; does the problem still occur with 5.004?

Don't have 004 up yet, stable enough to use in production?
thanks!

------------------------------------------
Phil Glatz                (phil@glatz.com)
Software Engineer       Lake Tahoe, Nevada
WWW: http://www.glatz.com


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

Date: Tue, 3 Jun 1997 07:35:12 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Shane 'Fishman' Sherman <fishman@vvm.com>
Subject: Re: performance question for sorting text from a large file
Message-Id: <Pine.GSO.3.96.970603073250.1116B-100000@kelly.teleport.com>

On Tue, 3 Jun 1997, Shane 'Fishman' Sherman wrote:

> I was wondering if performance becomes a serious factor when reading
> and sorting a large file of words. like maybe 1000 words or less. Does
> speed become a huge factor? 

Do you define "performance" as "how fast your computer can complete a
given task"? In that case, speed is a huge factor, and probably the only
one. :-)

But, seriously, it shouldn't take Perl very long at all to sort 1000
items. 

> the script would read the words from a txt file and sort them and
> output them into an html file.  

But if you're going to be calling this script repeatedly (say, if it's a
CGI script) there's no point in loading down your system by sorting
repeatedly. Why not store the sorted list so that you won't have to sort
twice, if that's possible?

Hope this helps!

-- Tom Phoenix        http://www.teleport.com/~rootbeer/
rootbeer@teleport.com   PGP  Skribu al mi per Esperanto!
Randal Schwartz Case:     http://www.lightlink.com/fors/



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

Date: 3 Jun 1997 07:45:59 -0500
From: jesten@earth.execpc.com (Jim Esten)
Subject: Re: PERL with Windows NT
Message-Id: <5n13m7$gvn$1@earth.execpc.com>



Depends a bit on your web server software... (BTW - your post would be better suited to the cgi groups...

For O'Reilly's Website, put your perl cgi scripts in the cgi-shl 
directory and associate whatever extension you use (like .pl) with
the perl.exe program...

Jim


Sameer Samat (ssamat@ucsd.edu) wrote:
: This may be a naive question... I haven't worked with PERL much at all..

: I have perl5 installed on my system (I run a web server under win nt),
: and I was curious what steps I needed to take to get perl scripts to be
: able to run from web pages hosted on my machine.  do I just put the perl
: dir in my path and then call programing in the cgi-bin dir as if I was
: running on a unix machine?..anything special I need to do?

: Thanks for the help

: Sameer Samat
: ssamat@ucsd.edu

-- 
Jim Esten
(temporarily between .sigs)


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

Date: Tue, 3 Jun 1997 07:55:02 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: M Melick <mmelick@gpu2.srv.ualberta.ca>
Subject: Re: pipes , tail, and buffering?
Message-Id: <Pine.GSO.3.96.970603074746.1116E-100000@kelly.teleport.com>

On 2 Jun 1997, M Melick wrote:

>        open(PIPE, "tail -f -n 0 A |");

You can emulate 'tail -f' directly in Perl; see seek() in perlfunc(1) for
some example code to follow growing files.

>        select(PIPE); $| = 1;
>        select(STDOUT);

I don't think that's doing what you think it's doing. $| controls
filehandles open for output; PIPE is open only for input.

> Changing the open line to include another file named B
> is where problems occur. ( Altering the open line to be ) 
>        open(PIPE, "tail -f -n 0 A B |");
> 
> Executing "tail -f -n 0 A B", from the shell, will print data to STDOUT
> as soon as data is appended into file A or B. 

Really? You may be right, but it's not documented to do that on my system. 
Hmmm... Could you have more than one tail utility installed? Maybe you're
calling a different one from the shell than from Perl.

Hope this helps!

-- Tom Phoenix        http://www.teleport.com/~rootbeer/
rootbeer@teleport.com   PGP  Skribu al mi per Esperanto!
Randal Schwartz Case:     http://www.lightlink.com/fors/



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

Date: 3 Jun 1997 09:35:29 GMT
From: "John Bokma" <jbokma@caiw.nl>
Subject: Re: print keys %something how do I sepearte each key?
Message-Id: <01bc7001$357883e0$de0ab2c2@tschai>



Dimitiris Vayenas <User_id@webads.gr> wrote in article
<01bc6f96$b1915300$fceb1ec2@ft>...
> I wonder if anyone has found a way of getting - out of the print
keys
> %something (or print values %something) each key separated by a
user
> defined delimiter?
> 
> Thanking you in Advance,
> 
> Dimitris
> 

How about:

print join("user separator", keys %something), "\n";

print join("user separator", values %something), "\n";

e.g.

print join("\n", sort keys %something), "\n";

prints all the keys, each on a new line, and sorted!

Regards,

John


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

Need a Freelance Software Developer (MSc)? (CGI, Perl, Java, C, C++)

http://www.caiw.nl/~jbokma [Java demo's, Curriculum Vitae and
more...]

email: jbokma@caiw.nl  phone: +31 10 4291827



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

Date: Tue, 03 Jun 1997 15:14:19 +0200
From: Douglas Seay <seay@absyss.fr>
To: atstarr@negia.net
Subject: Re: printing a hash in order?
Message-Id: <339418AB.7E4ABA26@absyss.fr>

[posted amd mailed]

Andrew Starr wrote:
> 
> Am I correct that it is basically impossible, just using a hash, to print
> it in order?

Yes, you understand this Frequently Answered Question.  Hashes do not
preserve order.  Use a list if you want FIFO/LIFO style order.


> *when does one need to and not need to use \n's when printing? Is it
> mandatory for every print? What happens without it?

\n is just the end-of-line character.  Without it the next text appears
on the same line.  Use it when formatting requires it.


> Please post here and also send a copy to me if your newsreader makes it
> easy to do so. (But I will be looking for responses in group as well).

OK.


> Don't send responses after August 1, 1997. (I really appreciate responses,
> but then I find either slow news servers or Dejanews, etc. make it so that
> responses can trickle in for months. I'll just post again if I still have
> questions...)

Kinda planning for the future there, aren't you?


- doug


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

Date: Sun, 01 Jun 1997 16:30:59 -0500
From: fl_aggie@hotmail.com (I R A Aggie)
Subject: Re: Protecting perl code *Important*
Message-Id: <fl_aggie-ya02408000R0106971630590001@news.fsu.edu>

In article <3391CA7A.6E64@acm.vt.edu>, noasat@acm.vt.edu wrote:

+ I have a very serious issue; I am selling some code that I wrote and
+ would like to protect it against copying, etc.

Talk to a lawyer about writing up a license agreement.

+ I have heard that there are ways to convert perl into its binary form.
+ Is that true?

Yes. The interpreter does this every time you invoke a perl program.

+ That would certainly solve my problem.

I doubt it...security by obscurity isn't secure.

James

-- 
Consulting Minister for Consultants, DNRC
Support the anti-Spam amendment <url:http://www.cauce.org/>
To cure your perl CGI problems, please look at:
<url:http://www.perl.com/perl/faq/idiots-guide.html>


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

Date: Tue, 3 Jun 1997 07:45:52 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Zenin <zenin@best.com>
Subject: Re: Read a file to $wholefile
Message-Id: <Pine.GSO.3.96.970603074247.1116D-100000@kelly.teleport.com>

On 2 Jun 1997, Zenin wrote:

> 	open SESAME, $message_dat or die $!;
> 	$wholefile = join '', <SESAME>;
> 	close SESAME;
> 
> 	Don't ever undef $/ unless it can't be avoided.

Why do you say that? Your solution is less efficient than this.

    {
	local($/) = undef;
	$wholefile = <SESAME>;		# Slurp whole file
    }

In your code, Perl has to read the input, separate it according to $/,
then recombine the list of chunks. In mine, it simply reads the input.

> 	Setting it to something
> 	else can be helpful, but don't undef it.

I don't think that the perl docs agree with this advice.

-- Tom Phoenix        http://www.teleport.com/~rootbeer/
rootbeer@teleport.com   PGP  Skribu al mi per Esperanto!
Randal Schwartz Case:     http://www.lightlink.com/fors/



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

Date: Tue, 3 Jun 1997 06:26:22 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: reading and writing from/to the same file
Message-Id: <u0v0n5.4i.ln@localhost>

thordur arnason (thordur@eunet.no) wrote:
: When I open a file with

: open(filehandle,"+>foo.dat")

from the perlfunc man page:

-----------------------------
=item open FILEHANDLE,EXPR

=item open FILEHANDLE

Opens the file whose filename is given by EXPR, and associates it with
FILEHANDLE.  If FILEHANDLE is an expression, its value is used as the name
of the real filehandle wanted.  If EXPR is omitted, the scalar variable of
the same name as the FILEHANDLE contains the filename.  If the filename
begins with "<" or nothing, the file is opened for input.  If the filename
begins with ">", the file is opened for output.  If the filename begins
with ">>", the file is opened for appending.  You can put a '+' in front
of the '>' or '<' to indicate that you want both read and write access to
the file; thus '+<' is usually preferred for read/write updates--the '+>'
mode would clobber the file first.  These correspond to the fopen(3) modes
of 'r', 'r+', 'w', 'w+', 'a', and 'a+'.
-----------------------------


See that "clobber" part?


--
    Tad McClellan                          SGML Consulting
    Tag And Document Consulting            Perl programming
    tadmc@flash.net


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

Date: Tue, 03 Jun 1997 13:22:27 GMT
From: Monty@dhc.net (Monty Scroggins)
Subject: script to parse one file, search another
Message-Id: <339266f6.93695430@news.dhc.net>

I have two files like this:

file 1:
39993 45848888833
20909 27739299911
44944 28288388484
etc..

file 2:
49958399934005983009289
32993209093812883918888
39928449442884928784992

I need to figure out how to open two files at once, use the
string from the first file to search the second, and write
out both strings to a third...

Do I need to load both files into arrays???

Any help would be greatly appreciated.

Monty

Monty@dhc.net


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

Date: Mon, 2 Jun 1997 15:29:53 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Setting a variable for both split and join...
Message-Id: <1gavm5.8kg.ln@localhost>

CHAN TANG Eric-Aubert (chantane@JSP.UMontreal.CA) wrote:

: Here's an example (non working) for what I'm looking for:

: $SEPARATOR = '|';

: $string = join($SEPARTOR, @text);
                  ^^^^^^^^

typo...


: @text = split(/$SEPARATOR/, $text);

: This won't work because, 'split' should be call this way:
: @text = split(/\|/, $text);


: Any clue?


@text = split(/\Q$SEPARATOR/, $text);
               ^^
               ^^ quotes metacharacters


--
    Tad McClellan                          SGML Consulting
    Tag And Document Consulting            Perl programming
    tadmc@flash.net


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

Date: Tue, 03 Jun 1997 12:49:33 +0000
From: Rob Dickens <dickenrp@boat.bt.com>
Subject: STDERR to variable
Message-Id: <339404CD.42C2@boat.bt.com>

I am wanting to put the output of STDERR to a variable.

I do not want to put the output to a file and then read it back in
because the program could be called by many people.

Does anyone know a way of doing it directly.

Many thanks
Rob.


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

Date: 3 Jun 1997 14:18:12 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: STDERR to variable
Message-Id: <5n1934$ljt@fridge-nf0.shore.net>

Rob Dickens (dickenrp@boat.bt.com) wrote:
: I am wanting to put the output of STDERR to a variable.

You need the FAQ.

: I do not want to put the output to a file and then read it back in
: because the program could be called by many people.

Backticks: $val = `program 2>&1`;

Filehandle:

	open(FH, "program |") || die("error: $!");
	while($err = <FH>) {
	   print $err,"\n";
	}
	close(FH);

--
Nathan V. Patwardhan
nvp@shore.net



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

Date: 3 Jun 1997 13:03:03 GMT
From: "Martin Schmid" <vts4mars@rshx01.rz.fht-esslingen.de>
Subject: Re: Trying to get a DATE/TIME from MS-Excel.
Message-Id: <01bc701a$08c32a80$0100007f@134.108.51.1.rz.fht-esslingen.de>

joeyGibson@mindspring.com schrieb im Beitrag
<865275190.2503@dejanews.com>...
>    I am using the latest version of Perl for Win32 with MS-Excel
> for Windows95. I am using the OLE interface to access a spreadsheet.
> I can get all of the cells with no problem, but how do I convert the
> date/time fields? I get a XXXXX.YYYYYY type number, but I don't
> know how to decode it. According to the Excel docs, the digits on the
> left of the dot are the date and those to the right are the time. But
> I couldn't figure out what the encoding scheme was. If anyone can
> help, PLEASE do!
> 
> Thanks for any help,
> Joey Gibson
> 
> -------------------==== Posted via Deja News ====-----------------------
>       http://www.dejanews.com/     Search, Read, Post to Usenet
> 
XXXXX.YYYYYY 
 ... decoding the date is not very difficult.
The reference is:  1.January 1900

	X=1		=> 1.January 1900
	X=2		=> 2.January 1900
	X=365		=> 1.January 1901

Today:
	X=35584	=> 3.June 1997

Y=1	means 1 second - value in Excel: 0.0000115740767796524
Y=10	means 10 seconds - value in Exce: 10*0.0000115740767796524
 ....

	Hope this helps - Martin !!!
vts4mars@rshx01.rz.fht-esslingen.de
http://www-stall.rz.fht-esslingen.de/~vts4mars


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

Date: Tue, 03 Jun 1997 08:20:14 -0400
From: rmycroft <rmycroft@cyberatl.net>
To: "Vineet S. Joshi" <vineet@usa.net>
Subject: Re: Who will win?  Borland or Microsoft or Programmers?
Message-Id: <33940BFE.5415@cyberatl.net>

Vineet S. Joshi wrote:
> 
> rmycroft wrote:
> 
> > Tim Smith wrote:
> > >
> > > rmycroft  <rmycroft@cyberatl.net> wrote:
> > > >>  VC5.0 and else do not force you to use MFC in any shape or form.
> >
> > > ...
> > > >Ah, but what happens when you use CrapWizard - I may be wrong but
> > it
> > > >seems to generate
> > > >a ton of MFC based code.  Yes you can use COM (selectable now I
> > think
> > >
> > > The *purpose* of AppWizard is to generate MFC code for you, so of
> > course
> > > you get MFC code when you use it!  No one forces you to use
> > AppWizard--there
> > > is nothing in any Microsoft compiler that looks at your code and
> > refuses to
> > > compile it if it doesn't contain enough MFC calls or appears to have
> > been
> > > generated by hand rather than by AppWizard.
> > >
> > > --Tim Smith
> >
> > Oh Timmy, you amaze me with such news.  I never new CrapWizard was
> > there
> > to gen. MFC code.  I thought it was just there to stun and amaze us
> > all
> > with the genius of it's pretty interface.  And do you mean to tell me
> > you can actually
> > build an app using MFC without using CrapWizard.  Oh, will the wonders
> >
> > never cease.
> > Next you'll tell me that computers aren't really evil and that Bill
> > was
> > never
> > actually gonna buy the Catholic church.  Or stun me even more and tell
> >
> > me that VC
> > can actually compile code without using MFC.  Can this be?
> >
> > Just to let you know, I have built apps in VC without the blessing of
> > MFC and
> > that is partly my point.  Earlier in the thread I pointed out that to
> > many
> > programmers it is easier to build apps using straight SDK rather than
> > bothering
> > with MFC at all.  I have no complaints with the compiler in general
> > which seems
> > to be quite good.  My complaint is with MFC and it's convoluted,
> > obtuse
> > way of
> > doing things.  From the DB perspective CRecordSet is an abomination to
> >
> > the
> > extent that myself and others have written our own class libraries for
> >
> > db access.
> > Maybe DAO solves most of this, but I can't say as I haven't been
> > anywhere yet
> > where it has been used.
> >
> > My point on CrapWizard was that it now supports building lots of
> > things
> > besides
> > just basic Windows apps and therefore may well not use MFC for those
> > things.  I
> > well understand the tie between MFC and the Wizard and that is my
> > complaint with
> > the wizard.
> >
> > By the way, if you don't think MFC is a pain in the fanny just try
> > building a serious
> > app using MFC without resorting to any of the wizards.  I'll take VB,
> > Rogue Wave,
> > zApp, Delphi or Borland-Builder and be done months ahead of you.
> >
> > Anyway, not to be nasty - just don't presume I'm dense about VC.  I
> > use
> > it every
> > day until I can go home and work with something I like, such as Java.
> > (Using VC 5.0 at the moment at work. Still trying to get used to the
> > new
> > IDE.)
> >
> > Sorry if I got testy.  Living amongst MFC fans all day just tends to
> > make me
> > snappy.
> >
> > Rich Mycroft
> 
>  Hi Rich,
> 
> You have a friend and well wisher in me. I cannot wait to get home to
> use C++Builder or Delphi after using VC++ all day at work. However, I
> think my job may be a little bit easier than yours as I also get to use
> UNIX at work.
> 
> Regards,
> 
> Vineet S. Joshi

Vineet:

Since you're actively involved with both Borland products I have a
question for you.  Of the two which one do you prefer, why, and how's
their ODBC support now.  (Used Delphi 1.0 and ODBC support was poor. 
Heard it got a lot better with 2.0 but by then tool choices were already
made.  {Besides, one VC programmer threatened immediate evacuation if we
went with a Pascal based product.})  Thanks for any news.

Rich Mycroft
Give me Java or give me lots of money!


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

Date: 3 Jun 1997 14:10:36 GMT
From: sextw@ils.unc.edu (Will Sexton)
Subject: why won't 'print <<end_print...end_print' work?
Message-Id: <5n18ks$7n$1@fddinewz.oit.unc.edu>

If I do the following:

	print <<"end_print";
	some text
	some text on the next line
	end_print

my (multiple) sources tell me the program should print the text, without 
having to set the print command for each new line (said sources lacking 
further explanation).  But when I try it, I get an error message ("Can't 
find string terminator "end_print" anywhere before EOF at <progname> 
line <line number>.")  And can't find feature documented among usual 
suspects (camel, llama, etc.).

Why won't it work?
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Will Sexton			wise2@mindspring.com
UNC-CH/Info Sci			sextw@ils.unc.edu



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

Date: Mon, 2 Jun 1997 17:20:15 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Working with multiple files (simultaneously).
Message-Id: <vugvm5.lug.ln@localhost>

CHAN TANG Eric-Aubert (chantane@JSP.UMontreal.CA) wrote:
: [ On 2 Jun 1997 20:09:55 GMT, chantane@JSP.UMontreal.CA said :
: | Is it possible to work with multiples file handles simultaneously?
: | 
: | For example (in pseudo-code):
: | 
: | sub FileCopy
: | {
: |  my ($original, @copies) = @_;
: | 
: |  # open $original
: |  # open each @copies in a table of file handles
: | 
: |  # for each line read from $original
: |   # write the line in each @copies
: | 
: |  # close $original
: |  # close all @copies
: | }

: Of course, it's not for copies.

: I should have ask: Is it possible to create arrays of
                                       ^^^^^^^^^^^^^^^^
: file handles?
  ^^^^^^^^^^^^



faq.5:=head2 How can I make a filehandle local to a subroutine?  How do I 
pass filehandles between subroutines?  How do I make an array of filehandles?
                                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^


:  Those <FILE>, and not the contents like
:  my %table;
:  @file = <FILE>;
:  $table{$index} = @file;

: You get the idea.


I get the idea that you did not check the Perl FAQ before posting
to the Perl newsgroup...



--
    Tad McClellan                          SGML Consulting
    Tag And Document Consulting            Perl programming
    tadmc@flash.net


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

Date: 03 Jun 1997 13:37:59 +0000
From: Clark Dorman <clark@s3i.com>
Subject: Re: Working with multiple files (simultaneously).
Message-Id: <dlo4rdcxz.fsf@s3i.com>


chantane@JSP.UMontreal.CA (CHAN TANG Eric-Aubert) writes:
> Is it possible to work with multiples file handles simultaneously?

Of course.
 
> For example (in pseudo-code):
> 
> sub FileCopy
> {
>  my ($original, @copies) = @_;
> 
>  # open $original
>  # open each @copies in a table of file handles
> 
>  # for each line read from $original
>   # write the line in each @copies
> 
>  # close $original
>  # close all @copies
> }

Amazingly enough, the actual perl code looks very close, but be sure
to see my comment at the bottom.  Yes, this code is not very terse,
but I program like I think.  
----------------------------------------------------------------------
#!/home/dorman/bin/perl -w

use FileHandle;

mycopy( ".cshrc", "copy1", "copy2", "copy3" );

exit;

sub mycopy {
   my( $original, @copies ) = @_;

   open( ORIG, "$original") or die "bad original ($!)";
   
   $copycounter = 0;
   foreach $copyname (@copies) {
      $fh[$copycounter] = new FileHandle ">$copyname" or 
	die "cannot open file $copyname for output ($!)";
      $copycounter++;
   }

   while (<ORIG>) {
      $inputline = $_;
      for ($copycounter=0; $copycounter<scalar(@fh); $copycounter++) {
	 select $fh[$copycounter];		# SEE BELOW
	 print "$inputline" ;			# SEE BELOW
      }
   }

   select STDOUT;

   for ($copycounter=0; $copycounter<scalar(@fh); $copycounter++) {
      $fh[ $copycounter ]->close;
   }

   close( ORIG );
}
----------------------------------------------------------------------

The "secret" is to use the FileHandle module which lets you do the above
quickly and easily with the file handles.  WARNING:  the following does not
work in place of the lines with the SEE BELOW on them:

	print $fh[$copycounter] "$inputline";

This gives: 

grant:~ (9:22am) 193% mycopytest.pl
String found where operator expected at mycopytest.pl line 27, near "] "$inputline""
	(Missing operator before  "$inputline"?)
syntax error at mycopytest.pl line 27, near "] "$inputline""
Execution of mycopytest.pl aborted due to compilation errors.
grant:~ (9:22am) 194% 

Why?  I don't know; maybe perl is not recognizing it as a filehandle,
so it expects a , in there.  Help!!

However, the following _does_ work in place of the for loop:

      foreach $thisfilehandle (@fh) {
	 print $thisfilehandle "$inputline";
      }

So perl recognizes this.


Final Comment:  

	Don't reinvent the wheel.  Don't do the above just to copy
	stuff.  Use the	File::Copy module.

-- 
Clark Dorman				"Evolution is cleverer than you are."
http://cns-web.bu.edu/pub/dorman/D.html                -Francis Crick


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

Date: Tue, 03 Jun 1997 04:52:38 -0600
From: atstarr@negia.net (Andrew Starr)
Subject: WTD: perl script for HTML list of Ph servers on the fly
Message-Id: <atstarr-0306970452390001@max01-03.qni.com>

See http://www.amherst.edu/~atstarr/computers/ph.html

Currently, the table is created initially (or after losing track of what
updates I've done manually) by obtaining the complete list of known Ph
servers from ns.nwu.edu:

    ph://ns.nwu.edu/query%20ns-servers

or

   in English: send command of "query ns-servers" to the Qi/Ph server:  
   ns.nwu.edu

I then used Word Perfect to do some search/replaces, imported the columns
into a table, and used WordPerfect's save as HTML feature.  Then, as I
receive reports of updates or new servers, I pass them along to the person
at Northwestern, and manually enter them into my HTML. When I fall behind
and can't be sure I've found the various e-mails with the last few updates
(yet knowing I forward them to NWU instantly upon reading the messages), I
just redo the process described above for starting from scratch.)

Actually, I am hoping to avoid redoing the step above.  Looking for a
volunteer (since I don't maintain the Ph page for money, nor do I make any
money off of it) to do a Perl script which would generate the HTML on the
fly. I would move the list of servers to a different page (which I've been
meaning to do anyway), and on the main Ph page just have a link to
list.cgi which would be the Perl script that would generate the page on
the fly.

Although I'm learning Perl, I don't know how to access Ph servers via Perl
(might be a CGI question, I realize, but I'll leave that up to whomever
volunteers to find out...), nor am I any good with massaging data (which I
gather is one of the many places where Perl really shines).

Volunteers: contact me at this address, or see my website and ignore
everything which says not o e-mail me.  If in doubt, check the Ph page
(URL above). I'll post there that I am looking for a volunteer. If you
don't see anything, I still am looking for a volunteer, just haven't made
the change yet. Once I have something working, you will know I'm all set.

Thanks!

-Andrew
(posting to perl newsgroup for obvious reasons; posting to eudora
newsgroups because Eudora is a major Ph client)

-- 
Andrew Starr  atstarr@negia.net
http://www.amherst.edu/~atstarr/eudora has my unoff. Eudora Site
http://www.amherst.edu/~atstarr/eudora/faq.html by Hank Zimmerman
I have no connection to Qualcomm other than being a happy customer!


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

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

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