[6939] in Perl-Users-Digest
Perl-Users Digest, Issue: 564 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jun 3 14:08:17 1997
Date: Tue, 3 Jun 97 11:00:37 -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: 564
Today's topics:
[Q] Passing Variable to an Interactive Program (William [Billy] Harrison)
Calling iTCL from Perl (Brand and Karina Hilton)
Re: Collect all Function Names in a C file (Matthew H. Gerlach)
Cookies using the Perl CGI.pm module(s) robrecht@neonsoft.com
Re: Cookies using the Perl CGI.pm module(s) <rootbeer@teleport.com>
database script needed... <cat33@iname.com>
Decoding of the 'Zafir' language :) (Tina Marie Holmboe)
Re: inconsistent opendir behaviour in Perl for win32 (Nathan V. Patwardhan)
Introductory Comparison of Perl and Python (Terry Reedy)
Re: leading zeroes <rootbeer@teleport.com>
Re: LOG base 10 operator <rootbeer@teleport.com>
Re: moving form BSD to SunOS 5.5 (formmail.pl) (Tina Marie Holmboe)
Re: New draft of scripting white paper <fellowsd.cs@man.ac.uk>
Re: New FAQ question? Decimal -> Binary conversion (Kyzer)
Re: Out of memory with big hashes <rootbeer@teleport.com>
Re: pack template that packs like 'a' but unpacks like <rootbeer@teleport.com>
Re: pack template that packs like 'a' but unpacks like <uwe@ptc.spbu.ru>
Re: Perl and Excel spreadsheets - WIN32 <auxilec@auxilec.com>
Perl Package containing constants <Pierre.Bergdolt@ansf.alcatel.fr>
Re: Perl Package containing constants <rootbeer@teleport.com>
perl source split to floppysize? (Steven Elliot Pav)
Re: perl source split to floppysize? <rootbeer@teleport.com>
Re: perl source split to floppysize? (Nathan V. Patwardhan)
Re: print keys %something how do I sepearte each key? <merlyn@stonehenge.com>
Q: Perl on NT where is stdout? <arnoudm@ijssel.xs4all.nl>
Re: Reading Comma delimited, Quoted String records (Abigail)
Re: script to parse one file, search another <rootbeer@teleport.com>
Solaris 2.5 perl compile problem <molenda@ibm.net>
Re: STDERR to variable <rootbeer@teleport.com>
Re: STDERR to variable <seay@absyss.fr>
Where do I find Perl 5? <webmaster@danlogic.dk>
Re: working with Perl and Multiplicity <dougm@osf.org>
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 3 Jun 1997 15:37:22 GMT
From: harrison@ug.cs.dal.ca (William [Billy] Harrison)
Subject: [Q] Passing Variable to an Interactive Program
Message-Id: <5n1dni$75n$1@News.Dal.Ca>
I'm very sorry if this question is answered elsewhere, but I'm stuck.
Both myself and a friend are using Perl for CGI scripts, and we've had some
realy problems trying to pass a variable into anther program. I myself
am trying to call the UNIX passwd program, while he is trying to call
a search engine. We are both using the open() function with a leading
vertical bar, like so:
open(PASS, "|passwd");
We've both checked, and the strings are correct upon output. Yet when they
are passed to the programs, they misfire. Is there some kind of phantom
character getting inserted in there?
I greatly appreciate any and all assistance.
--
_________________________________________________________________
| William Harrison harrison@ug.cs.dal.ca |
| |
| Student at Dalhousie University, Halifax, NS, Canada, |
| e-wrestling participant, video game lover and Internet junkie |
|_________________________________________________________________|
------------------------------
Date: Tue, 3 Jun 1997 16:42:37 GMT
From: bkhilton@netcom.com (Brand and Karina Hilton)
Subject: Calling iTCL from Perl
Message-Id: <bkhiltonEB7L32.2r4@netcom.com>
A colleague has written about 5000 lines of iTCL, and I'd
like to use his classes and methods from Perl. I've tried
Malcolm Beattie's TCL module, but about a third of the tests
fail and 5.003 and 5.004 generate several warnings in the
"use" statement. Besides, it's just TCL, not iTCL.
So, has anyone successfully married iTCL and Perl? Or written
an iTCL to Perl translator?
Thanks in advance for any help.
Brand
------------------------------
Date: Tue, 3 Jun 1997 14:54:52 GMT
From: gerlach@netcom.com (Matthew H. Gerlach)
Subject: Re: Collect all Function Names in a C file
Message-Id: <gerlachEB7G3H.B51@netcom.com>
In article <Pine.SV4.3.95.970602211452.17977B-100000@vu-vlsi.ee.vill.edu> Senthilvel Rangaswamy <senthil@ece.vill.edu> writes:
>
>Hi All:
>
>I am looking for a perl script which will read in a standard C file and
>output all the function names used in that C file. Does anybody have
>any ideas or pointers...
>
>Thanks,
Have you thought about using ctags to create such a file?
Matthew
------------------------------
Date: Tue, 03 Jun 1997 11:54:25 -0600
From: robrecht@neonsoft.com
Subject: Cookies using the Perl CGI.pm module(s)
Message-Id: <865356166.26006@dejanews.com>
I have a requirement to pass 1 or more cookies between CGI scripts. How
in the world do I do this using the CGI.pm modules?
HELP!!!
Cheers,
Rich
PS - Please respond to robrecht@neonsoft.com
-------------------==== Posted via Deja News ====-----------------------
http://www.dejanews.com/ Search, Read, Post to Usenet
------------------------------
Date: Tue, 3 Jun 1997 10:36:30 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: robrecht@neonsoft.com
Subject: Re: Cookies using the Perl CGI.pm module(s)
Message-Id: <Pine.GSO.3.96.970603103442.10995H-100000@kelly.teleport.com>
On Tue, 3 Jun 1997 robrecht@neonsoft.com wrote:
> I have a requirement to pass 1 or more cookies between CGI scripts. How
> in the world do I do this using the CGI.pm modules?
If you have a recent version of CGI.pm, its own documentation should tell
you everything you need. Try 'perldoc CGI' and see whether your computer
says anything interesting. :-)
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: Tue, 03 Jun 1997 23:17:17 +0800
From: ccm <cat33@iname.com>
Subject: database script needed...
Message-Id: <3394357D.68E96B6C@iname.com>
Anyone send me a sample database script with "search" , "edit", "input"
capabilities.
--
[BLACK DRaGON] from Hong Kong
mailto:cat33@iname.com
Fax: 852-2944-8842
BBS: 852-2614-0170 (16:700/1221@HKNet)
Pager: 78932748 a/c 486
Address: P.O.Box No.434, Texaco Road Post Office,
Tsuen Wan, HONG KONG.
------------------------------
Date: 3 Jun 1997 17:01:48 +0200
From: tina@htmlhelp.com (Tina Marie Holmboe)
Subject: Decoding of the 'Zafir' language :)
Message-Id: <5n1bks$p1j@hrotti.ifi.uio.no>
Warning: posting without anything but academic interest, and possibly
not even that... do not read if low on sense of humor.
Background: the phrase 'Evel Eroz!'; used as a greeting :) Sadly I
cannot tell you what the original is, or was, but for those out there who
have been reading the comics of Franquin might reckognise the name 'Zafir'.
Said person was a genius, but also quite mad at times. He developed
his own language, used by all his troops. The correct phrase to greet him
would be:
"Rifaz Evil Gnol!" = "Long Live Zafir!"
As you can see, the language is a very simple one. This is his suggestion
for an algorithm, using the test-string
"Rolling On the Floor Laughing And Scaring The Cat"
$s="Gnillor No eht Roolf Gnihgual Dna Gniracs Eht Tac";
foreach ( split(/ /, $s)) {
$c = lcfirst($_);
substr($c, length()-1, 1) = uc(substr($c, length()-1, 1))
if $_ ne $c;
$c = reverse($c);
print "$c ";
}
print $/;'
here, for comparison, is mine:
$s = "Gnillor No eht Roolf Gnihgual Dna Gniracs Eht Tac" ;
$s =~ y/A-Z/a-z/ ; $s = ~s/(\S)(\s|$)/\u$1$2/ig ;
foreach $w (split(/ /,$s) ) {
foreach $c( reverse( split(//,$w) ) ) {
print $c ;
}
print" " ;
}
print "\n" ;
Comments ? As there is More Than One Way, I'd love to see some suggestions
for other implementations... >:) Any RegExperts willing to attempt a
oneliner ?
--
Tina Marie Holmboe
[ tina@htmlhelp.com ] WDG [ http://www.htmlhelp.com/%7Etina/ ]
[ tina@ifi.uio.no ] University [ http://www.ifi.uio.no/%7Etina/ ]
[ tina@elfi.adbkons.se ] Private [ http://www.elfi.adbkons.se/%7Etina/ ]
------------------------------
Date: 3 Jun 1997 16:51:01 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: inconsistent opendir behaviour in Perl for win32
Message-Id: <5n1i1l$1me@fridge-nf0.shore.net>
Simon Oosthoek (simon@shadow.student.utwente.nl) wrote:
: : What version of NT Perl are you using?
: build 304.
: is it fixed in a never version?
I dunno. For my "weekly M'soft hour featuring NT Perl" I've been
using build 303 without a hitch, including opening directories like:
$dir = 'd:/';
which you *might* have to represent like:
$dir = 'D:/';
but I might be blowing smoke. :-)
--
Nathan V. Patwardhan
nvp@shore.net
------------------------------
Date: 3 Jun 1997 17:36:14 GMT
From: tjreedy@udel.edu (Terry Reedy)
Subject: Introductory Comparison of Perl and Python
Message-Id: <5n1kme$prv$1@news.udel.edu>
Perl and Python are interpreter-based scripting languages distributed freely
by their authors and enthsiaticly supported by users via comp.lang.perl.*,
comp.lang.python and other channels. They are sometimes used for similar
purposes (quick scripts, web cgi scripts) and sometimes by the same
programmers, who know both.
This article compares basic features of Perl (4.x) and Python (1.4) by means
of side-by-side code examples followed by minimal commentary. It is aimed at
programmers of either language who want to learn something about the other,
whether to read it, translate it, or learn it as an additional tool.
Programmers (experienced in other languages) who are trying to decide which
to learn might also find it useful.
The Perl material is based on Randal Schwartz's book, Learning Perl (the
llama book, 94 April edition). The order of topics is based on his
Introduction, Chapter 1, and the Perl code is mostly lifted directly
therefrom (without permission, under the fair use doctrine). Further
explanation can be sought therein. The Python code is written and tested
by myself.
(As this implies, I am a Python programmer just learning Perl, so I am mostly
ignorant of anything I missed in Learning Perl or not included there, such
as the Perl 5 additions. My apologies to Perlists for any erroneous code,
statements, or implications. I have tried to be careful.)
I have thus far referred to Perl and Python alphabetically. In the columns
below, I reverse the order and put Python on the left for a simple practical
reason - so I could cut the Python code and paste it into the interpreter to
test it before adding Schwartz's Perl code, which I assume to be correct.
PYTHON PERL
PRINT/WRITE PRINT
#! /use/bin/python #! /use/bin/perl
print "Hello, world" # or print "Hello, world\n"; # or
FILE.write("Hello, world\n) print FILE "Hello, world\n";
# For both, comments extend from unquoted '#' to end of line
; separates simple statements on 1 line ; terminates statements
\n usually terminates statements
print adds \n (unless terminal ,) print/print() does not
write takes one string argument print takes multiple arguments
READLINE <> (DIAMOND OPERATOR)
from sys import stdin, stdout
stdout.write("What is your name? ") print "What is your name? ";
name = stdin.readline()[:-1] $name = <STDIN>; chop($name);
# or, combining prompt and input # $a=chop(<STDIN>); assigns \n to $a
name=raw_input("What is your name? ")
# To avoid name collisions, both provide multiple name spaces
- multiple modules and classes - flags for types of variables
$name is a scaler (number/string)
- Perl 5 packages?
# Both automatically provide files stdin/out/err = STDIN/OUT/ERR
- in builtin importable module sys - as part of core language
STRINGS STRINGS
print 'Hello,', name print ('Hello, ', $name, '\n');
print 'Hello, '+name+'\n', print 'Hello, '.$name.'\n;
stdout.write('Hello, %s\n' % (name,)) print "Hello, $name\n";
'' and "" are same "" enables $var interpolation
(except for inclusion of ' or ") and expanded \ escapes
print add spaces between args print does not
COMPARISON, IF/THEN COMPARISON, IF/THEN
if name == 'Randal': if ($name eq 'Randal) {
print "Hello, Randal: How's this?" print "Hello, Randal: How's this?\n";
else: } else {
print 'Hello,', name+'!' print "Hello, $name!\n";
}
==, <, etc compare any 2 Python values == compares $numbers, eq $strings
(conversion is automatic)
blocks delimeted by required indent blocks delimeted by {}
LOOPS LOOPS
secretword = 'llama' $secretword = 'llama';
guess = raw_input('Secret word? ') print 'Secret word? ';
$guess = <STDIN>; chop($guess);
while guess != secretword: while ($guess ne $secretword) {
guess=raw_input('Wrong, try again ') print 'Wrong, try again ';
$guess = <STDIN>; chop($guess);}
TUPLES/LISTS, NUMBERS ARRAYS, NUMBERS
words = ('camel','llama','oyster') @words= ('camel','llama','oyster');
i=0; correct='?' # 0-based index $i = 0; $correct = '?'; # ditto
while correct == '?': while ($correct eq '?') {
if guess == words[i]: if ($guess eq $words[i])
correct = 'y' {$correct = 'y';}
elif i < 2: i = i+1 elsif ($i < 2) {$i = $i+1;}
else: break else {last;}
}
[] instead of () would make words @ flags array variable
modifiable list instead of fixed tuple but $ flags element of array
Numbers are int (C long), long Numbers are internally C doubles
('infinite'), float (C double) or Also increment $i with $i += 1;
complex (pair of floats) ++$i; or $i++; as in C syntax.
DICTIONARIES ASSOCIATIVE ARRAYS
Pthn: words = {'fred':'camel', 'barney':'llama', 'wilma':'oyster'}
Perl: %words= ('fred','camel', 'barney','llama', 'wilma','oyster');
secretword = words[name] $secretword = $words{$name};
{} flags dictionary literal % flags associative array variable
[] indexes dict (as with sequences) {} flags a.a. lookup
Key can be any hashable object Key is scalar (number or string)
STRING MATCHING, MANIPULATION STRING MATCHING, MANIPULATION
from string import *
import regex; m=regex.match
find(name,'Randal',0)==0 $name =~ /^Randal/; # at beginning
find(lower(name), 'randal', 0)==0 $name =~ /^Randal/i; # ignore case
m('randal\>',lower(name)) == 6 $name =~ /^Randal\b/i; # \b=word-end
import regsub # extract first word of name var
name = regsub.sub('\W.*','',name) $name =~ s/\W.*//;
# not mentioned by Schwartz: above assumes no initial non-word stuff
name = lower(name) # or, more general $name =~ tr/A-Z/a-z/; # lowercase it
name = translate(name,maketrans(uppercase,lowercase))
functions in importable modules functions build into language
# New Python regular expression module 're' will be more like Perl
FUNCTIONS FUNCTION/SUBROUTINES
def lowerfirst(word): sub lowerfirst {
# assume lower(), sub() imported local($word) = @_;
return lower(sub('\W.*', '', word)) $word =~ s/\W.*//;
$name =~ tr/A-Z/a-z/;
}
params received by name,list,dict. parameters received in @_ array
return None or explicit expression return last expression evaluated
The above gives a taste of each language. Not discussed are file and
directory manipulation, process management, or internet access. Perl has
built-in facilities for producing formatted, paged reports with top-of-page
headers from picture format templates. Python has a nice class/instance
object system (I do not know what Perl 5 has along this line). It could be
used (and maybe has been) to write a report-pager class generating
report-pager instances that imitate the Perl report system.
Terry J. Reedy, consultant, tjreedy@udel.edu
------------------------------
Date: Tue, 3 Jun 1997 08:03:05 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Mariana Wuerz <mariana.wuerz@fernuni-hagen.de>
Subject: Re: leading zeroes
Message-Id: <Pine.GSO.3.96.970603080102.1116H-100000@kelly.teleport.com>
On Tue, 3 Jun 1997, Mariana Wuerz wrote:
> $four=04
Unless you intend to make an octal number, don't put leading zeroes on
integer numerals in Perl code.
> How can I get $four=4?
If you're reading input which has leading zeroes, simply use it as a
number, and everything will be fine. If you're trying to do something
else, please say so, so we can try again to help you! :-)
-- 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 08:06:53 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Tung-chiang Yang <tcyang@netcom.com>
Subject: Re: LOG base 10 operator
Message-Id: <Pine.GSO.3.96.970603080541.1116I-100000@kelly.teleport.com>
On Tue, 3 Jun 1997, Tung-chiang Yang wrote:
> I am a newbie ..... but I wonder why we need to use "$_[0]"......
That's Perl's way of saying "the first argument to the current
subroutine", more or less. See perlsub(1) for details on passing
parameters. 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 17:01:33 +0200
From: tina@htmlhelp.com (Tina Marie Holmboe)
Subject: Re: moving form BSD to SunOS 5.5 (formmail.pl)
Message-Id: <5n1bkd$p14@hrotti.ifi.uio.no>
= Tom Phoenix =
> When you're having trouble with a CGI program in Perl, you should first
> look at the please-don't-be-offended-by-the-name Idiot's Guide to
> solving such problems. It's available on the perl.com web pages. Hope
> this helps!
This is, of course, correct. However, I think it is worth mentioning that
in the case that Henry Hazan mentiones:
= Henry Hazan =
> Is there anyone to answer me why I am having problems to run this script
> on sunOs 5.5. I get the message: [Mon Jun 2 10:54:21 1997] httpd:
> malformed header from script
...the problem usually springs from one of two sources:
a) The script doesn't output a proper "Content-Type: mime-type\n\n"
string. This makes it a CGI-question. This script, however, does.
b) The script has either compile-time or run-time errors, which means it
will output something on STDERR - which the webserver will see as a
'malformed header'. That may make it a Perl-question...
In the case of b), there may be a reason for posting it here. I'd suggest
that you 1) run it with -w :), and 2) check to see whether any run-time
errors occur. There is a likelyhood that this is the problem.
If you find that there are any errors in it, then comp.lang.perl.misc
may yet be the Place For You ...
--
Tina Marie Holmboe
[ tina@htmlhelp.com ] WDG [ http://www.htmlhelp.com/%7Etina/ ]
[ tina@ifi.uio.no ] University [ http://www.ifi.uio.no/%7Etina/ ]
[ tina@elfi.adbkons.se ] Private [ http://www.elfi.adbkons.se/%7Etina/ ]
------------------------------
Date: 3 Jun 1997 14:43:57 GMT
From: Donal K. Fellows <fellowsd.cs@man.ac.uk>
Subject: Re: New draft of scripting white paper
Message-Id: <5n1ajd$54t$1@m1.cs.man.ac.uk>
In article <3383ADEA.58FA@dis.org>, Cimarron Taylor <cimarron@dis.org> wrote:
> My main objection here is to the use of the term "paradigm".
> The point is that Tcl, sh, csh, ksh, command.com, ... are all
> variations of shell languages. They all provide the bare essentials
> (expressions and control structures) you need to write simple
> programs and also provide mechanisms to interact with other code.
> This is what they are designed to do and this is what they do well.
>
> However, creating new procedures and alternate ways of expressing
> flow control are all well and good but to say these techniques
> allow you to extend the "programming paradigm" is too much of a
> stretch for me.
Tcl is more powerful than the shells since I know I can extend Tcl
(without additional C) to have object-oriented semantics (admittedly,
the syntax is not as good as you might wish) and I can also do things
that are remarkably close to lazy programming. I don't know what you
think, but they look like different paradigms to me.
Note that I don't claim that Tcl does these as well as some other
languages, but merely that it is possible to use techniques from those
styles of programming without great amounts of pain, unlike other
languages I can think of. Particularly helpful is the ability to
create new pieces of syntax to dress up new semantics - a great way of
making a piece of code easier to maintain since you can cut out the
bits which do not pertain to the overall conceptual semantics.
I know I can say this better if I try. Hmm...
By not attaching complex semantics to everything in sight itself and
not placing a complex syntax over the top of it all, Tcl makes it much
easier to add application-specific syntax and semantics to scripts.
My experience is that it is the app-specific stuff that tends to cause
Tcl scripting to win out (Tk is an example of app-specific syntax and
semantics being added to Tcl, and the difficulty that many other
authors have had with combining Tk with other languages has served to
indicate just how good Tcl is at embedding external syntax and
semantics). The fact that the core commands in the Tcl library are
fairly well rounded for general use is a bonus, but these are not what
makes Tcl.
Donal.
--
Donal K. Fellows http://r8h.cs.man.ac.uk:8000/ (SAY NO TO COMMERCIAL SPAMS!)
fellowsd.cs@man.ac.uk Dept. Comp. Sci, Univ. Manchester, U.K. +44-161-275-6137
The at symbol in my email address has been shifted one word right
to deter spam-bots. Sorry for any inconvenience this causes you.
------------------------------
Date: 3 Jun 1997 17:15:55 GMT
From: junkmail@sysa.abdn.ac.uk (Kyzer)
Subject: Re: New FAQ question? Decimal -> Binary conversion
Message-Id: <5n1jgb$cvb@info.abdn.ac.uk>
Tom Phoenix of rootbeer@teleport.com wrote in comp.lang.perl.misc:
: > number conversion from decimal or hex string etc. to output in binary
: > form.
: > I'd suggest having this as a new FAQ question, as I couldn't find it in
: > the FAQ when I was looking.
: Sounds good. Write it up and send it to the FAQ maintenance address.
: Thanks!
Could you make it 'decimal to binary, octal, hex (or any other base for that
matter)' as that would save space in the FAQ for asking different questions
that all get pretty much the same answer.
--
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:
StudentCode(v1.0) BSc A Y-- C++ E L W- G+ X? P-- T++ F M H++
------------------------------
Date: Tue, 3 Jun 1997 08:32:29 -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.970603083042.1116N-100000@kelly.teleport.com>
On Tue, 3 Jun 1997, Phil Glatz wrote:
> By using dbmopen? Still run out of memory - any way to force it to
> disk rather than memory?
If you're running out of memory when using dbmopen, chances are very good
that your Perl was miscompiled, or that you've found a memory leak in
Perl.
> >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?
It sounds better than what you're using. :-) Seriously, 5.004 is much
more stable and secure than previous versions of Perl. Install it today!
:-)
-- 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 07:59:50 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: "Valeriy E. Ushakov" <uwe@ptc.spbu.ru>
Subject: Re: pack template that packs like 'a' but unpacks like 'A'
Message-Id: <Pine.GSO.3.96.970603075832.1116G-100000@kelly.teleport.com>
On 3 Jun 1997, Valeriy E. Ushakov wrote:
> May be it would be useful to introduce a new pack template that packs
> like 'a' (null padded) but unpacks like 'A' (stripping trailing nulls
> and spaces).
It seems simpler to simply s/a/A/g between packing and unpacking. :-)
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: Tue, 3 Jun 1997 20:16:12 +0400
From: "Valeriy E. Ushakov" <uwe@ptc.spbu.ru>
To: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: pack template that packs like 'a' but unpacks like 'A'
Message-Id: <%ghDlzgrPn@snark.ptc.spbu.ru>
Hi, Tom.
Thanks for your prompt answer. To prevent the discussion from lagging
I'm replying to the CC'ed mail message and hope that my mail reader
will inject it into news as well (never tried this, I use tin to read
news otherwise).
On Tue, 3 Jun 1997, Tom Phoenix wrote:
> It seems simpler to simply s/a/A/g between packing and unpacking. :-)
Well, I used s/A/a/g. :-)
I'd dare to question the word `simpler', though. The point was to
avoid this conversion, so that I can have *single* tempalte for going
both ways. Many C structs exibit this behavior, utmp, lastlog, whod
to name few; every time you store a name of something (user, host,
line); actually -- every time printable string is stored in a fixed
size field of a C struct.
So, at least IMHO, doing s/A/a/g (i.e. using two templates) violates
at least two Perl Principles:
o laziness is a virtue
I don't want two templates for *the same thing*, I want one.
o least surprise
I do have pack/unpack experience (including few tricky cases), still
I was surprised when I stumbled across this problem. I was so
accustomed to the fact that perl automagically did what I meant,
that I was surprised that this common case is not handled the way
one (well, I) would expect.
If the very idea of this new format letter is deemed inapropriate and
in contradiction with perl spirit, I'd like to be enlightened why.
At first glance, implementing it requires 3 (!) lines of C code in
pp.c: two case labels for this new letter in pp_pack and pp_unpack and
modifying one condition in pp_unpack to handle this new letter the way
'A' is.
Thanks for your time.
SY, Uwe
--
uwe@ptc.spbu.ru | Zu Grunde kommen
http://www.ptc.spbu.ru/~uwe/ | Ist zu Grunde gehen
------------------------------
Date: Tue, 03 Jun 1997 10:44:19 -0700
From: jb <auxilec@auxilec.com>
Subject: Re: Perl and Excel spreadsheets - WIN32
Message-Id: <339457F3.3977@auxilec.com>
jbcofino@shadow.net wrote:
>
> Looking for help in obtaining information to read Excel spreadsheets
> from within a perl script. The environment is WIN95 using Perl-WIN32.
look at eg/excel1.pl and eg/excel2.pl in the perl-win32 distribution.
jb.
------------------------------
Date: Tue, 03 Jun 1997 17:25:01 +0200
From: Pierre BERGDOLT <Pierre.Bergdolt@ansf.alcatel.fr>
Subject: Perl Package containing constants
Message-Id: <3394374D.41C6@ansf.alcatel.fr>
Hello perl gurus!!
I'd like to have a perl package containing constants used by several
others perl scripts. Can I do this with perl? How do I have to declare
constant in the package, and how can I use this constants in my perl
scripts.
Thanks to answer me by e-mail.
--
-----------------------------------------------------------
Pierre Bergdolt Pierre.Bergdolt@ansf.alcatel.fr
Alcatel TELECOM
1 a 7, rue Ampere tel: + 33 (0)1.69.81.12.79
91300 Massy - FRANCE fax: + 33 (0)1.69.81.17.23
-----------------------------------------------------------
------------------------------
Date: Tue, 3 Jun 1997 08:50:32 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Pierre BERGDOLT <Pierre.Bergdolt@ansf.alcatel.fr>
Subject: Re: Perl Package containing constants
Message-Id: <Pine.GSO.3.96.970603084618.1116P-100000@kelly.teleport.com>
On Tue, 3 Jun 1997, Pierre BERGDOLT wrote:
> I'd like to have a perl package containing constants used by several
> others perl scripts. Can I do this with perl?
I think you want a module. See perlmod(1) for details. Note that you can
define constants in Perl 5.004 with 'use constant'. Try 'perldoc constant'
for information on that. 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 16:28:34 GMT
From: pav@LAS.alfred.edu (Steven Elliot Pav)
Subject: perl source split to floppysize?
Message-Id: <slrn5p83q6.lbd.pav@LAS.alfred.edu>
i am trying to put perl onto a linux machine that does _not_ have net
access. my only option, it seems, is via floppy.
the other machine i am working on, a sun station, does have access,
but i do not know how to split a tar file into floppy sized pieces
(maybe this should be posted to comp.unix.util.???).
does anyone out there have a solution other than fix hardware (which
i am not free to do)?
i tried writing a script to split a directory into manageable chunks,
but the sunstation only has perl 4.0, impeding my progress on the
matter.
help?
thanks.
--
s. y. elliot pav
pav@las.alfred.edu
http://las.alfred.edu/~pav/
3000 trinity drive apt 64, los alamos, nm 87544
------------------------------
Date: Tue, 3 Jun 1997 09:55:02 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Steven Elliot Pav <pav@LAS.alfred.edu>
Subject: Re: perl source split to floppysize?
Message-Id: <Pine.GSO.3.96.970603095318.10995A-100000@kelly.teleport.com>
On 3 Jun 1997, Steven Elliot Pav wrote:
> i am trying to put perl onto a linux machine that does _not_ have net
> access. my only option, it seems, is via floppy.
You can't plug in a modem or a cable? Okay... :-)
> the other machine i am working on, a sun station, does have access,
> but i do not know how to split a tar file into floppy sized pieces
> (maybe this should be posted to comp.unix.util.???).
Yes, and they'd tell you to use split(1). :-) 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 16:54:38 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: perl source split to floppysize?
Message-Id: <5n1i8e$1me@fridge-nf0.shore.net>
Steven Elliot Pav (pav@LAS.alfred.edu) wrote:
: the other machine i am working on, a sun station, does have access,
: but i do not know how to split a tar file into floppy sized pieces
: (maybe this should be posted to comp.unix.util.???).
Use the (Unix) split program.
--
Nathan V. Patwardhan
nvp@shore.net
------------------------------
Date: 03 Jun 1997 08:23:39 -0700
From: Randal Schwartz <merlyn@stonehenge.com>
To: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: print keys %something how do I sepearte each key?
Message-Id: <8coh9nn210.fsf@gadget.cscaper.com>
>>>>> "Tom" == Tom Phoenix <rootbeer@teleport.com> writes:
Tom> { local($")=':'; print "@{[ keys %hash ]}"; } # :-)
Well, if you're gonna be obtuse:
{ local ($,,$\) = (", ", "\n"); print keys %hash; }
:-)
print "Just another Perl hacker," # but not what the media calls "hacker!" :-)
## legal fund: $20,495.69 collected, $182,159.85 spent; just 455 more days
## before I go to *prison* for 90 days; email fund@stonehenge.com for details
--
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@ora.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me
------------------------------
Date: Tue, 03 Jun 1997 12:52:49 -0600
From: Arnoud Martens <arnoudm@ijssel.xs4all.nl>
To: arnoudm@ijssel.xs4all.nl
Subject: Q: Perl on NT where is stdout?
Message-Id: <865320234.4899@dejanews.com>
Hello,
I have a problem with perl under NT 4.0. Perl is version 5.003 downloaded
from CPAN. I have associated the .pl extension with perl.exe as stated in
the FAQs.
My problem has to do with stdout, when I just type:
try.pl
all output is displayed on the console (MS DOS prompt). But when I type:
try.pl > out.dat
I end up with a zero byte out.dat file. Strange things is when I do
perl.exe try.pl > out.dat
all output is correctly available in the file out.dat. So it looks like
the association is messing things up.
The association is made through:
assoc: .pl=plscript
ftype: plscript=d:\progra~1\perl5\bin\perl.exe %1 %*
Any help or pointers appreciated.
--
Arnoud Martens
arnoudm@ijssel.xs4all.nl
arnoud.martens@medtronic.com
-------------------==== Posted via Deja News ====-----------------------
http://www.dejanews.com/ Search, Read, Post to Usenet
------------------------------
Date: Tue, 3 Jun 1997 15:09:42 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Reading Comma delimited, Quoted String records
Message-Id: <EB7Gs7.9tu@nonexistent.com>
On 3 Jun 1997 02:02:23 GMT, Sean M. McKee (mckee@misslink.net) wrote in
comp.lang.awk,comp.lang.perl,comp.lang.perl.misc,comp.unix.sco.programmer
<URL: news:01bc6fc2$4805a7c0$fc412b9f@seanhome>:
++
++ I know how to read a comma delimited file (awk -F:) but if a string field
++ contains a comma (eg. ...,"McKee, Sean",...) then the field is surrounded
++ in double quotes. Is there a way to deal with this?
++
It's called RTFAQ.
Abigail -- http://www.phil.uni-sb.de/fun/jargon/RTFAQ.html
--
perl5.004 -wMMath::BigInt -e'$=new Math::BigInt+qq;$$783$[$%9889$47$|88768$596577669$%$5$3364$[$$$|838747$[8889739$%$|$673$%$98$76777$=56;;$=$]*(q.25..($=@))=>do{print+chr$%$;$/=$}while$!=$'
------------------------------
Date: Tue, 3 Jun 1997 08:29:24 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Monty Scroggins <Monty@dhc.net>
Subject: Re: script to parse one file, search another
Message-Id: <Pine.GSO.3.96.970603082745.1116M-100000@kelly.teleport.com>
On Tue, 3 Jun 1997, Monty Scroggins wrote:
> 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???
I would think you'd only need to save the strings from the first one.
(Strictly speaking, you wouldn't need to save them, but it seems the most
efficient way, based on what you've given us.) 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: Tue, 03 Jun 1997 13:17:13 -0700
From: Paul Molenda <molenda@ibm.net>
Subject: Solaris 2.5 perl compile problem
Message-Id: <33947BC9.387F@ibm.net>
I wonder if anyone could help me with this:
I have problem building perl 5.001 on Solaris 2.5.1 with GCC 2.6.3 all
default responses to
Configure.
I am getting Fcntl "Can't open PIC for reading" problem that I have
seen mentioned in this
newsgroup several times:
Making Fcntl (dynamic)
Writing Makefile for Fcntl
umask 0 && cp Fcntl.pm ../../lib/Fcntl.pm
AutoSplitting Fcntl (../../lib/auto/Fcntl)
../../miniperl -I../../lib -I../../lib ../../lib/ExtUtils/xsubpp
-noprototypes -typemap
../../lib/ExtUtils/typemap Fcntl.xs >Fcntl.tc && mv Fcntl.tc Fcntl.c
gcc -c -O -DVERSION=\"1.00\" -DXS_VERSION=\"1.00\" -fpic -I../..
Fcntl.c
*unknown*: Assembler messages:
*unknown*:0: Can't open PIC for reading: No such file or directory
Running Mkbootstrap for Fcntl ()
chmod 644 Fcntl.bs
LD_RUN_PATH="" gcc -o ../../lib/auto/Fcntl/Fcntl.so -G -L/usr/local/lib
Fcntl.o
/pub/GNU/sparc-sun-solaris2.5.1/sparc-sun-solaris2.5.1/bin/ld: invalid
number `-Y'
*** Error code 1
make: Fatal error: Command failed for target
`../../lib/auto/Fcntl/Fcntl.so'
Current working directory /opt/perl5/perl5.002/ext/Fcntl
*** Error code 1
make: Fatal error: Command failed for target `lib/auto/Fcntl/Fcntl.so'
I tried to follow up on all advise I found on Usenet:
- removed ld and as from GNU directories just in case
- removed cc and ld from /usr/ucb just in case...
- search order in path /usr/ccs/bin : /usr/bin/ : /opt/GNU/bin
-configured with gcc -shared instead of default -G flag
- LD_LIBRARY_PATH not set
- GCC_EXEC_PREFIX set to /usr/ccs/bin
Miniperl builds and tests fine.
What other options should I try?
Paul Molenda
molenda@ibm.net
------------------------------
Date: Tue, 3 Jun 1997 08:10:52 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Rob Dickens <dickenrp@boat.bt.com>
Subject: Re: STDERR to variable
Message-Id: <Pine.GSO.3.96.970603080800.1116J-100000@kelly.teleport.com>
On Tue, 3 Jun 1997, Rob Dickens wrote:
> I am wanting to put the output of STDERR to a variable.
If you're calling external programs, this may be difficult to do directly.
(Unless, of course, you've thought of something I haven't. :-)
> 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.
Why not simply use a unique file name for each process?
$my_stderr_file = "/usr/tmp/mystderr.$$.$^T.temp";
open STDERR, "> $my_stderr_file" or
die "Can't write to '$my_stderr_file': $!";
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: Tue, 03 Jun 1997 18:35:15 +0200
From: Douglas Seay <seay@absyss.fr>
To: dickenrp@boat.bt.com
Subject: Re: STDERR to variable
Message-Id: <339447C3.2F4F98EC@absyss.fr>
[posted and mailed]
Rob Dickens wrote:
>
> 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.
Why does "many people" change anything? Just append the pid to the file
name.
If all your STDERR comes from your program, just encapsulate your error
messages with a subroutine call and modify it to do what you want. But
this wouldn't work for any child processes launched by your script.
I have never done this, but if want to try, maybe you could play with
closing STDERR and reopening is a unnamed pipe at fd2. It should be
inherited by any children. But I've never done this, so I can't give
you any real advice.
- doug
------------------------------
Date: 3 Jun 1997 17:43:48 GMT
From: "Claus H. Rasmussen" <webmaster@danlogic.dk>
Subject: Where do I find Perl 5?
Message-Id: <01bc7045$055d82c0$6bc3e3c1@danlogic>
I need to get the Perl 5. Where do I get it?
Thanks!
Website: http://www.danlogic.dk & http://www.faaborgguide.dk
------------------------------
Date: Tue, 03 Jun 1997 10:49:31 -0400
From: Doug MacEachern <dougm@osf.org>
To: Doug Young <dyoung@chromium.geoworks.com>
Subject: Re: working with Perl and Multiplicity
Message-Id: <33942EFB.4981@osf.org>
Doug Young wrote:
>
> does anyone have any experience running perl with multiplicicy
> support...how do I specify which interpreter to use when making calls
> such an perl_call_argv or perl_eval_sv?
>
> Do I have to set a global variable? Then what's the point of
> MULTIPLICITY?
MULTIPLICITY is not perfect, in fact, it didn't work until 5.003_19 or so.
At the moment, you need to switch interpreters by setting the `curinterp'
global variable. Something like so:
#define switch_perl(interp) curinterp = interp
...
PerlInterpreter *one_perl, *two_perl;
...
switch_perl(one_perl);
perl_call_sv(...); #call function defined in one_perl's symbol table
...
switch_perl(two_perl);
sv = perl_get_sv(...); #fetch sv defined in two_perl's symbol table
...
This may seem cumbersome, but it's not too bad, really, and it works quite
well.
If you happen to be using multiple embedded interpreters in a multithreaded
program, you'll need a mutex lock/unlock around any perl_* calls.
Expect to see improvements in these areas in future versions of Perl.
-Doug
>
> Please help!
>
> --
> Doug Young -- dyoung@geoworks.com
> "All ice cubes will be boiled before using"
> -- U.S. Army Official, ordering sanitary measures.
> Phone: 510-814-5893 Fax: 510-814-4250
------------------------------
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 564
*************************************