[11500] in Perl-Users-Digest
Perl-Users Digest, Issue: 5100 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Mar 10 08:07:41 1999
Date: Wed, 10 Mar 99 05:00:56 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Wed, 10 Mar 1999 Volume: 8 Number: 5100
Today's topics:
(un) pack and bit mask ? <waldekg@uhc.lublin.pl>
[Perl] How to find the Perl FAQ <rootbeer&pfaq*finding*@redcat.com>
Re: append 3 huge log files (Larry Rosler)
Re: Array of Array???? lufan@hotmail.com
Re: Can I turn a Perl program into an NT .exe? <hal9000@fetchmail.com>
Re: cobol line seq. file - one very long line - (Larry Rosler)
Debugging perl code (embedded interpreter) hemantp@writeme.com
Re: Encrypt/decrypting form input data held in a flatfi <partha@mihy.mot.com>
Re: Encrypt/decrypting form input data held in a flatfi <zenin@bawdycaste.org>
FAQ 3.20: How can I make my CGI script more efficient? <perlfaq-suggestions@perl.com>
FAQ 3.21: How can I hide the source for my Perl program <perlfaq-suggestions@perl.com>
Re: File Question (Newbie) (Larry Rosler)
Re: flock / sysopen / open confusion (Bart Lateur)
Re: flock / sysopen / open confusion <zenin@bawdycaste.org>
Re: Getting rid of ^M lufan@hotmail.com
Re: Getting rid of ^M <staffan@ngb.se>
Hashes ?? pvdkamer@inter.NL.net
Re: how do i format a forwarded letter (Larry Rosler)
Re: how do i format a forwarded letter (Larry Rosler)
Mail Problems dccobb@yahoo.com
Re: Perl & PostgreSQL <fabascal@gredos.cnb.uam.es>
Perl and NT backoffice <horizon@internetexpress.com.au>
Perl and Syslog <verstege@hik.fzk.de>
Re: Printing in Perl (Larry Rosler)
Re: questions about grep in a void context (Larry Rosler)
Re: Sub calls: how can I do this? (Larry Rosler)
Re: Using Multiple Servers <ebohlman@netcom.com>
Win32: which files as minimum distribution? <edwin@mindless.com.killspam>
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 10 Mar 1999 12:07:10 +0100
From: "Waldek Grudzien" <waldekg@uhc.lublin.pl>
Subject: (un) pack and bit mask ?
Message-Id: <7c5jg2$q5k$1@helios.man.lublin.pl>
Hello everyone,
I have to do the following :
1. I have got int number (4 bytes) and would like to convert it into 100
bytes long string
(I mean I would like to copy number bitmask to string bitmask)
I guess it can be done using pack function, but how ???
2. I have got 100 bytes long string bitmask. How can I set chosen bits (e.g.
bit no 43, 100 and
150) (if it possible in the simplest and the most efficient way)
I played with pack / unpack / vec functions, but the results wasn't the ones
I expected for ;o)
I heard about Bit::Vector module, but couldn't I do it using standard PERL
functions ?
Could anyone help me please ??? ;o)
Regards,
--
Waldek Grudzien
_____________________________
http://www.uhc.lublin.pl/~waldekg/
University Health Care
Lublin/Lubartow, Poland
tel. +48 81 44 111 88
fax +48 81 44 112 09
ICQ # 20441796
------------------------------
Date: Wed, 10 Mar 1999 11:25:15 GMT
From: Tom Phoenix <rootbeer&pfaq*finding*@redcat.com>
Subject: [Perl] How to find the Perl FAQ
Message-Id: <pfaqmessage921065042.25052@news.teleport.com>
Archive-name: perl-faq/finding-perl-faq
Posting-Frequency: weekly
Last-modified: 10 Sep 1998
[ That "Last-modified:" date above refers to this document, not to the
Perl FAQ itself! The last major update of the Perl FAQ was in Summer of
1998; of course, ongoing updates are made as needed. ]
For most people, this URL should be all you need in order to find Perl's
Frequently Asked Questions (and answers).
http://cpan.perl.org/doc/FAQs/
Please look over (but never overlook!) the FAQ and related docs before
posting anything to the comp.lang.perl.* family of newsgroups.
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
Beginning with Perl version 5.004, the Perl distribution itself includes
the Perl FAQ. If everything is pro-Perl-y installed on your system, the
FAQ will be stored alongside the rest of Perl's documentation, and one
of these commands (or your local equivalents) should let you read the FAQ.
perldoc perlfaq
man perlfaq
If a recent version of Perl is not properly installed on your system,
you should ask your system administrator or local expert to help. If you
find that a recent Perl distribution is lacking the FAQ or other important
documentation, be sure to complain to that distribution's author.
If you have a web connection, the first and foremost source for all things
Perl, including the FAQ, is the Comprehensive Perl Archive Network (CPAN).
CPAN also includes the Perl source code, pre-compiled binaries for many
platforms, and a large collection of freely usable modules, among its
560_986_526 bytes (give or take a little) of super-cool (give or take
a little) Perl resources.
http://cpan.perl.org/
http://www.perl.com/CPAN/
http://cpan.perl.org/doc/FAQs/FAQ/html/
http://www.perl.com/CPAN/doc/FAQs/FAQ/html/
You may wish or need to access CPAN via anonymous FTP. (Within CPAN,
you will find the FAQ in the /doc/FAQs/FAQ directory. If none of these
selected FTP sites is especially good for you, a full list of CPAN sites
is in the SITES file within CPAN.)
California ftp://ftp.cdrom.com/pub/perl/CPAN/
Texas ftp://ftp.metronet.com/pub/perl/
South Africa ftp://ftp.is.co.za/programming/perl/CPAN/
Japan ftp://ftp.dti.ad.jp/pub/lang/CPAN/
Australia ftp://cpan.topend.com.au/pub/CPAN/
Netherlands ftp://ftp.cs.ruu.nl/pub/PERL/CPAN/
Switzerland ftp://sunsite.cnlab-switch.ch/mirror/CPAN/
Chile ftp://ftp.ing.puc.cl/pub/unix/perl/CPAN/
If you have no connection to the Internet at all (so sad!) you may wish
to purchase one of the commercial Perl distributions on CD-Rom or other
media. Your local bookstore should be able to help you to find one.
Another possibility is to use one of the FTP-via-email services; for
more information on doing that, send mail to <mail-server@rtfm.mit.edu>
(not to me!) with these lines in the body of the message, flush left:
setdir usenet-by-group/news.announce.newusers
send Anonymous_FTP:_Frequently_Asked_Questions_(FAQ)_List
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
Comments and suggestions on the contents of this document
are always welcome. Please send them to the author at
<pfaq&finding*comments*@redcat.com>. Of course, comments on
the docs and FAQs mentioned here should go to their respective
maintainers.
Have fun with Perl!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Sun, 7 Mar 1999 07:57:07 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: append 3 huge log files
Message-Id: <MPG.114c41a93ae1f051989707@nntp.hpl.hp.com>
[Posted and a courtesy copy sent.]
In article <7bt6tq$a5b$1@nnrp1.dejanews.com> on Sun, 07 Mar 1999
06:38:50 GMT, vnguyen2891@my-dejanews.com <vnguyen2891@my-dejanews.com
>says...
> I got 3 huge log files which I want to append them all into one file ( put 3
> files into 1 file). Do you have any suggestion to do it? Please give me
> detailed suggestion.
Within a Perl program:
system "cat $file1 $file2 $file3 >$out" &&
die "Couldn't cat files. $?\n";
or from the command line:
cat file1 file2 file3 >out
or, if you insist on using Perl (why???):
perl -pe 1 file1 file2 file3 >out
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personl/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Tue, 09 Mar 1999 09:38:32 -0800
From: lufan@hotmail.com
Subject: Re: Array of Array????
Message-Id: <36E55C98.477A@hotmail.com>
Yu Fang wrote:
>
> I think you are talking about 2-d array.
>
> Here is one way:
> @array = (['a','b'],['c','d']);
> # $array[1][1] will be 'd'.
>
> Here is another way:
> @a = ('a','b');
> @b = ('c','d');
> @array = (\@a, \@b);
> # $array[1][1] will be 'd'.
>
> lufan@hotmail.com wrote:
> >
> > hi,
> >
> > How to make a PERL array contains several pointers to
> > others arrays ? All 2 arrays are scalable.
> >
> > Here is what I think of it,
> >
> > array1 -> {a,b,c,d,e,f ...}
> >
> > array1{a} -> {1,2,3,4 ..}
> > array1{b} -> {4,1,2,3,4 ..}
> >
> > thanks ;)
>
> --
> Frank Yu Fang
>
> GTE Internetworking
> 40 Sylvan Road
> Waltham, MA 02451-1128
>
> Phone: 781-466-3351
> Fax: 781-466-2650
> Pager: 1-800-759-8888 PIN# 1619895 or 1619895@skytel.com
I may confuse you. What I want to do is about hash.
2 scalable arrays, one is @ and another is hash %.
@a1={1,2,3,4,5 ...}
@a2={a,s,23245,1,44,...}
@a3=
.
.
@an=
$hash{a1} = \@a1
$hash{a2} = \@a2
.
.
.
Can you show me some sample code ?
thanks
lufan
------------------------------
Date: Wed, 10 Mar 1999 10:08:55 +0100
From: hal 9000 <hal9000@fetchmail.com>
Subject: Re: Can I turn a Perl program into an NT .exe?
Message-Id: <36E636A7.5DF342AB@fetchmail.com>
Perl2Exe at <http://www.demobuilder.com/perl2exe.htm> looks
as what you are after. I have not yet tried it myself
though...
leonandrews@my-dejanews.com wrote:
>
> Hi,
>
> Can anyone point me towards some documentation on compiling perl programs on
> NT into standalone executables? I'm using ActivePerl 509 on NT4.
>
> many thanks,
>
> Leon.
>
> -----------== Posted via Deja News, The Discussion Network ==----------
> http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
--
~hal9000
------------------------------
Date: Sat, 6 Mar 1999 07:56:21 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: cobol line seq. file - one very long line -
Message-Id: <MPG.114aefff1aa878c5989703@nntp.hpl.hp.com>
[Posted and a courtesy copy sent.]
In article <7br96v$r6$1@gellyfish.btinternet.com> on 6 Mar 1999 13:05:35
-0000, Jonathan Stowe <gellyfish@btinternet.com >says...
> On Fri, 05 Mar 1999 20:11:58 GMT Dale Phillips wrote:
> > I have a cobol line sequential file that I need
> > to parse up into record length of 57 each....
> >
> > This has got to be brain dead easy but I
> > can not seem to find anything that
> > counts x chars from slurped file and add \r start counter over ....
>
> Assuming you have slurped your entire file into $string :
>
> while($string =~ /(.{57}/g )
> {
> print $1,"\n";
> }
>
Unmatched () in regex at ...!
Unless you want to lose the last hunk, ITYM /(.{1,57})/gs
where I've added the /s just in case (who knows *what* is in that 'cobol
line sequential file'?). (And perhaps when he said \r he meant \r, not
\n :-)
For the braces-deprived:
print $1, "\r" while $string =~ /(.{1,57})/gs;
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personl/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Wed, 10 Mar 1999 11:59:02 GMT
From: hemantp@writeme.com
Subject: Debugging perl code (embedded interpreter)
Message-Id: <7c5mq3$f2j$1@nnrp1.dejanews.com>
I am embedding a perl interpreter in my C++ program.
And invoking the perl subroutines using "perl_call_pv".
I am not able to debug the perl code using -d switch of perl.
Anybody know about this ? please let me know.
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Wed, 10 Mar 1999 12:47:27 +0530
From: Ramanujam Parthasarathi <partha@mihy.mot.com>
To: Steve <me@me.com>
Subject: Re: Encrypt/decrypting form input data held in a flatfile database.
Message-Id: <36E61C87.DC211728@mihy.mot.com>
Hi
Try "perldoc -f crypt" - it might help. It also refers to a module present on
the CPAN.
HTH
-Partha
Steve wrote:
> Hi,
>
> I'm creating a website which users can create their own accounts on. All the
> accounts will be held in a flatfile database, and I want some of the fields
> to be encrypted for security (passwords and other fields). This'll be on a
> secure server so transmissions are secure.
>
> What I want to do is implement a subroutine in my perl script which will
> encrypt one or more form input fields and return it as a value (eg.
> "$encryptedpass") for writing to a database. I have all the database stuff
> done but I can't find any help on encryption, even on looking at other
> people's scripts as none of them do what I want. I also need a subroutine
> for decrypting the data in the same way, for returning the data to a web
> page.
>
> The strength of encryption doesn't need to be industrial-strength, but if
> someone where to get hold of the database file I don't want them to be able
> to figure out what the information is.
>
> Any help would be appreciated.
>
> Thanks.
>
> Steve.
------------------------------
Date: 10 Mar 1999 09:46:57 GMT
From: Zenin <zenin@bawdycaste.org>
Subject: Re: Encrypt/decrypting form input data held in a flatfile database.
Message-Id: <921059445.878099@thrush.omix.com>
[posted & mailed]
Steve <me@me.com> wrote:
>snip<
: The strength of encryption doesn't need to be industrial-strength, but if
: someone where to get hold of the database file I don't want them to be able
: to figure out what the information is.
The (huge) thread on XOR encryption not to long ago might interest
you. Search for XOR and encryption at DejaNews. There are also
a few modules on CPAN for a few different encryption systems.
--
-Zenin (zenin@archive.rhps.org) From The Blue Camel we learn:
BSD: A psychoactive drug, popular in the 80s, probably developed at UC
Berkeley or thereabouts. Similar in many ways to the prescription-only
medication called "System V", but infinitely more useful. (Or, at least,
more fun.) The full chemical name is "Berkeley Standard Distribution".
------------------------------
Date: 10 Mar 1999 01:45:38 -0700
From: Tom Christiansen <perlfaq-suggestions@perl.com>
Subject: FAQ 3.20: How can I make my CGI script more efficient?
Message-Id: <36e63132@csnews>
(This excerpt from perlfaq3 - Programming Tools
($Revision: 1.33 $, $Date: 1998/12/29 20:12:12 $)
part of the standard set of documentation included with every
valid Perl distribution, like the one on your system.
See also http://language.perl.com/newdocs/pod/perlfaq3.html
if your negligent system adminstrator has been remiss in his duties.)
How can I make my CGI script more efficient?
Beyond the normal measures described to make general Perl
programs faster or smaller, a CGI program has additional issues.
It may be run several times per second. Given that each time it
runs it will need to be re-compiled and will often allocate a
megabyte or more of system memory, this can be a killer.
Compiling into C isn't going to help you because the process
start-up overhead is where the bottleneck is.
There are two popular ways to avoid this overhead. One solution
involves running the Apache HTTP server (available from
http://www.apache.org/) with either of the mod_perl or
mod_fastcgi plugin modules.
With mod_perl and the Apache::Registry module (distributed with
mod_perl), httpd will run with an embedded Perl interpreter which
pre-compiles your script and then executes it within the same
address space without forking. The Apache extension also gives
Perl access to the internal server API, so modules written in
Perl can do just about anything a module written in C can. For
more on mod_perl, see http://perl.apache.org/
With the FCGI module (from CPAN) and the mod_fastcgi module
(available from http://www.fastcgi.com/) each of your perl
scripts becomes a permanent CGI daemon process.
Both of these solutions can have far-reaching effects on your
system and on the way you write your CGI scripts, so investigate
them with care.
See http://www.perl.com/CPAN/modules/by-
category/15_World_Wide_Web_HTML_HTTP_CGI/ .
A non-free, commercial product, ``The Velocity Engine for Perl'',
(http://www.binevolve.com/ or http://www.binevolve.com/bine/vep)
might also be worth looking at. It will allow you to increase the
performance of your perl scripts, upto 25 times faster than
normal CGI perl by running in persistent perl mode, or 4 to 5
times faster without any modification to your existing CGI
scripts. Fully functional evaluation copies are available from
the web site.
--
There is, however, a strange, musty smell in the air that reminds me of
something...hmm...yes...I've got it...there's a VMS nearby, or I'm a Blit.
--Larry Wall in Configure from the perl distribution
------------------------------
Date: 10 Mar 1999 04:15:49 -0700
From: Tom Christiansen <perlfaq-suggestions@perl.com>
Subject: FAQ 3.21: How can I hide the source for my Perl program?
Message-Id: <36e65465@csnews>
(This excerpt from perlfaq3 - Programming Tools
($Revision: 1.33 $, $Date: 1998/12/29 20:12:12 $)
part of the standard set of documentation included with every
valid Perl distribution, like the one on your system.
See also http://language.perl.com/newdocs/pod/perlfaq3.html
if your negligent system adminstrator has been remiss in his duties.)
How can I hide the source for my Perl program?
Delete it. :-) Seriously, there are a number of (mostly
unsatisfactory) solutions with varying levels of ``security''.
First of all, however, you *can't* take away read permission,
because the source code has to be readable in order to be
compiled and interpreted. (That doesn't mean that a CGI script's
source is readable by people on the web, though, only by people
with access to the filesystem) So you have to leave the
permissions at the socially friendly 0755 level.
Some people regard this as a security problem. If your program
does insecure things, and relies on people not knowing how to
exploit those insecurities, it is not secure. It is often
possible for someone to determine the insecure things and exploit
them without viewing the source. Security through obscurity, the
name for hiding your bugs instead of fixing them, is little
security indeed.
You can try using encryption via source filters (Filter::* from
CPAN), but any decent programmer will be able to decrypt it. You
can try using the byte code compiler and interpreter described
below, but the curious might still be able to de-compile it. You
can try using the native-code compiler described below, but
crackers might be able to disassemble it. These pose varying
degrees of difficulty to people wanting to get at your code, but
none can definitively conceal it (this is true of every language,
not just Perl).
If you're concerned about people profiting from your code, then
the bottom line is that nothing but a restrictive licence will
give you legal security. License your software and pepper it with
threatening statements like ``This is unpublished proprietary
software of XYZ Corp. Your access to it does not give you
permission to use it blah blah blah.'' We are not lawyers, of
course, so you should see a lawyer if you want to be sure your
licence's wording will stand up in court.
--
You have made an excellent hit on the UNIX.--More--
------------------------------
Date: Sat, 6 Mar 1999 07:13:31 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: File Question (Newbie)
Message-Id: <MPG.114ae5f1ce8f5eb989701@nntp.hpl.hp.com>
In article <1do80nz.t516x6rkaqa1N@bay1-437.quincy.ziplink.net> on Sat, 6
Mar 1999 04:31:20 -0500, Ronald J Kimball <rjk@linguist.dartmouth.edu
>says...
> Larry Rosler <lr@hpl.hp.com> wrote:
> > It has to do with single-quotes vs. double-quotes. You seem to be
> > using them backwards.
>
> I can conceive of using parentheses and braces backwards )like this }or
> like this{(. But how the heck does one use quotes backwards?
>
> ;-)
Not only are those parentheses and braces backwards, they are also
upside-down. The single-quotes and double-quotes are not: backwards
single-quote = '; backwards double-quote = ".
I think I meant 'using them sideways'. :-)
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personl/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Wed, 10 Mar 1999 08:37:30 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: flock / sysopen / open confusion
Message-Id: <36e82e0c.3194383@news.skynet.be>
Ronald J Kimball wrote:
>It's too late to lock the file if you've already changed the file
>contents. Instead, you need to open the file with a mode of "+>", which
>does not clobber the file contents.
Oh yes it does!
This one will open the file for writing and reading, but clearing the
file also. Before locking. Actually, I'd prefer it if this output mode
were declared obsolete and give a warning, because I don't think there's
ANY use at all for it.
This is the proper way (though I could be wrong ;-):
open(FH, "+<$filename")
or die "Cannot open $filename for write: $!";
flock(FH, 2);
truncate FH,0;
Bart.
------------------------------
Date: 10 Mar 1999 10:05:05 GMT
From: Zenin <zenin@bawdycaste.org>
Subject: Re: flock / sysopen / open confusion
Message-Id: <921060533.634753@thrush.omix.com>
[posted & mailed]
Bart Lateur <bart.lateur@skynet.be> wrote:
: Ronald J Kimball wrote:
:>Instead, you need to open the file with a mode of "+>", which does not
:>clobber the file contents.
:
: Oh yes it does!
: This one will open the file for writing and reading, but clearing the
: file also. Before locking. Actually, I'd prefer it if this output mode
: were declared obsolete and give a warning, because I don't think there's
: ANY use at all for it.
And how would you suggest opening a file for reading and writing if
it doesn't already exist? -Hint: <+ will fail if the file does not
exist already.
This is however, one of the (many) reasons I like sysopen() over
open(). Sysopen() lets me do:
use Fcntl;
sysopen HANDLE, "somefile", O_RDWR|O_CREAT, 0666
or die $!;
This is the same as +> except that it won't truncate the file, or
the same as <+ except that it will create the file if it doesn't
exist.
In general I hate open(). It's an error-prone nightmare. The mode
flags are non-intuitive and buggy. Valid filenames with any of
open()'s special characters, space, etc passed in a variable will
cause open() to go nuts without a warning. For these reasons I
don't recommend using open() at all except for the simplest of quick
hack scripts. If it's anything you need to rely on, don't touch
open().
>snip<
: flock(FH, 2);
BTW, test your flock() returns just like you'd test your open()
returns, or you'll get into trouble.
: truncate FH,0;
Same here.
--
-Zenin (zenin@archive.rhps.org) From The Blue Camel we learn:
BSD: A psychoactive drug, popular in the 80s, probably developed at UC
Berkeley or thereabouts. Similar in many ways to the prescription-only
medication called "System V", but infinitely more useful. (Or, at least,
more fun.) The full chemical name is "Berkeley Standard Distribution".
------------------------------
Date: Mon, 08 Mar 1999 16:43:04 -0800
From: lufan@hotmail.com
Subject: Re: Getting rid of ^M
Message-Id: <36E46E98.3A66@hotmail.com>
Robert Saunders wrote:
>
> I am sure this is very simple.. but I have a data files that gets
> created and I open it up and want to take out the ^M at the end of
> several lines..
>
> I have tried the simple
>
> $data_line =~ s/\^M//ig;
>
> With no luck.. it doesnt seem to want to remove it.. I have been
> looking the perl books I have but so far have not ran across the
> symbol..
>
> Robert Saunders
> robert@iminet.com
remember ftp with text mode.
------------------------------
Date: Wed, 10 Mar 1999 13:29:11 +0100
From: Staffan Liljas <staffan@ngb.se>
Subject: Re: Getting rid of ^M
Message-Id: <36E66597.C92383C2@ngb.se>
lufan@hotmail.com wrote:
>
> Robert Saunders wrote:
> >
> > I am sure this is very simple.. but I have a data files that gets
> > created and I open it up and want to take out the ^M at the end of
> > several lines..
> >
> > I have tried the simple
> >
> > $data_line =~ s/\^M//ig;
> >
> > With no luck.. it doesnt seem to want to remove it.. I have been
> > looking the perl books I have but so far have not ran across the
> > symbol..
> >
> > Robert Saunders
> > robert@iminet.com
>
> remember ftp with text mode.
or use $data_line =~ s/\cM//g; that isn't a real '^', it is actually a
control character.
Staffan
------------------------------
Date: Wed, 10 Mar 1999 10:17:46 GMT
From: pvdkamer@inter.NL.net
Subject: Hashes ??
Message-Id: <36e64636.7609123@news.wxs.nl>
Hello,
Ok i've got two flat file database. In the first one there is a unique
code wich i've to lookup in the second file. In the second file there
can be more of the same key's.
I've been told i have to do it with hashes but i do not know how. Can
someone please help ?
Thank's,
Paul van de Kamer
------------------------------
Date: Sat, 6 Mar 1999 08:37:03 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: how do i format a forwarded letter
Message-Id: <MPG.114af98661110450989704@nntp.hpl.hp.com>
[Posted and a courtesy copy sent.]
In article <Pine.BSF.4.05.9903060817010.9317-100000@schultz-2.io.com> on
Sat, 6 Mar 1999 08:59:23 -0500, Poohba <poohba@io.com >says...
> you know how when a letter is forwarded it has '>' at the begining of each
> line. I want to take it out. How can i do that? I currently tried:
> #!/usr/local/perl -w
'-w' is a good start. Now start using 'use strict;' also.
> $file = 'fix-letter';
>
> open (FILE, "+<$file") || die "Can't open $file: \n";
I think you meant to say why the open failed. $!
> while(<FILE>) {
This reads every line of the file into $_.
> $letter =~ s/>//g;
But this modifies $letter. Also, do you want to remove *every* '>' or
just at the beginning of a line?
> print FILE "$letter\n";
Do you want to add a second new-line after every line?
> }
> close(FILE);
>
> this does not work thoug. any suggestions?
The biggest problem is that you cannot in general modify a file in place
by reading and writing simultaneously. See perlfaq5: "How do I change
one line in a file/delete a line in a file/insert a line in the middle
of a file/append to the beginning of a file?"
All these problems could be fixed by something like this (UNTESTED):
#!/usr/local/perl -w
use strict;
my $file = 'fix-letter';
open FILE, "+<$file" or die "Can't open $file: $!\n";
{ local $/; $_ = <FILE> }
s/^>//gm;
seek FILE, 0, 0 or die "Can't rewind $file: $!\n";
print FILE;
close FILE;
But you could do it all in one line (TESTED):
perl -i.bak -pwe 's/^>//' fix-letter
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personl/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Sat, 6 Mar 1999 09:09:19 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: how do i format a forwarded letter
Message-Id: <MPG.114b0117c6949b5b989705@nntp.hpl.hp.com>
[Posted and a courtesy copy sent.]
In article <7brga9$194$1@gellyfish.btinternet.com> on 6 Mar 1999
15:06:49 -0000, Jonathan Stowe <gellyfish@btinternet.com >says...
...
> perl -pi.bak -e 's/^>//g;'
^
Exactly how many matches per line were you expecting, /J\? :->
Good about the rugby. We have Cal this afternoon, playing for an NCAA
berth. GO BEARS!!!
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personl/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Wed, 10 Mar 1999 12:30:10 GMT
From: dccobb@yahoo.com
Subject: Mail Problems
Message-Id: <7c5okj$ggg$1@nnrp1.dejanews.com>
Can you help me please?
I need to inject data from a perl script into the mail program on our sun
server the mail program is 'mail'
I know how to do this using sendmail & qmail-inject, however i am
unsure as to how to do it with mail. Can you help, please?
Thanks
"Everything should be as simple as possible, but no simpler",
Albert Einstein.
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Wed, 10 Mar 1999 11:24:17 +0100
From: Federico Abascal <fabascal@gredos.cnb.uam.es>
Subject: Re: Perl & PostgreSQL
Message-Id: <36E64850.282FF21B@gredos.cnb.uam.es>
And, what about DBI + DBD:ODBC. Isn't it the more portable option.?
Thanks for your help
Fede
------------------------------
Date: Wed, 10 Mar 1999 23:14:05 +1100
From: Mick <horizon@internetexpress.com.au>
Subject: Perl and NT backoffice
Message-Id: <36E6620C.AC9211F2@internetexpress.com.au>
Hi.....Can Perl communicate with Backoffice?
--
----------------------------------------------------------------
HORIZON Software Solutions
Visit Site - http:www.deakin.edu.au/~bellears/horizon/index.html
e-mail - mailto:horizon@internetexpress.com.au
----------------------------------------------------------------
------------------------------
Date: Wed, 10 Mar 1999 09:52:18 +0100
From: News System <verstege@hik.fzk.de>
Subject: Perl and Syslog
Message-Id: <36E632C2.8F3D5FAB@hik.fzk.de>
Hi,
I am using SuSE Linux 6.0 with Kernel 2.2.1 and Perl 5.00502.
Setting up INN 2.2 I found a problem when trying to write to
Syslog from Perl.
The following Perl programm
#!/usr/bin/perl
use Sys::Syslog;
openlog($program, 'cons,pid', 'user');
syslog('info', 'Hello world');
closelog();
produces the error message
Can't locate stdarg.ph in @INC (did you run h2ph?) (@INC contains:
/usr/lib/perl
5/5.00502/i586-linux /usr/lib/perl5/5.00502
/usr/lib/perl5/site_perl/5.005/i586-
linux /usr/lib/perl5/site_perl/5.005 .) at
/usr/lib/perl5/site_perl/5.005/i586-l
inux/sys/syslog.ph line 160.
BEGIN failed--compilation aborted at ./tt line 2.
The INN INSTALL file told me to do a h2ph * in /usr/include and
/usr/include/sys, but there is no stdarg.h at all.
I found stdarg.h in
./usr/lib/gcc-lib/i486-linux/egcs-2.91.60/include/stdarg.h
./usr/lib/gcc-lib/i486-linux/2.7.2.3/include/stdarg.h
After running h2ph -a -h in one of these directories I get
no more error messages, but I get no syslog entry at all.
Any hints ?
Thanks
Bernhard
------------------------------
Date: Sat, 6 Mar 1999 07:32:22 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Printing in Perl
Message-Id: <MPG.114aea639f2472c989702@nntp.hpl.hp.com>
In article <36e1f420.4119869@news.skynet.be> on Sat, 06 Mar 1999
09:55:24 GMT, Bart Lateur <bart.lateur@skynet.be >says...
> Larry Rosler wrote:
> >Are there any benefits to Perl formats other than what I have noted
> >above?
>
> I've never used them, and I never will.
>
> They are closely linked to the concept of fixed width fonts, a seriously
> outdated concept that nevertheless refuses to stay down.
I dunno. That's how I set my newsreader, so I can decipher any posted
code. Don't you?
Any columnar output benefits from fixed-width fonts. Why 'a seriously
outdated concept'?
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personl/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Sat, 6 Mar 1999 07:06:13 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: questions about grep in a void context
Message-Id: <MPG.114ae430cc9949fc989700@nntp.hpl.hp.com>
In article <1do87rs.1f75wfz1nak2hnN@bay1-437.quincy.ziplink.net> on Sat,
6 Mar 1999 04:31:25 -0500, Ronald J Kimball <rjk@linguist.dartmouth.edu
>says...
...
> Neither of those [scalar expressions] builds
> up an unneeded list of return values, which is the main complaint
> against using grep or map in a void context.
If this is indeed the main complaint, then it sounds like an opportunity
for a compiler optimization. Perl expressions know the context in which
they are being evaluated, don't they? Why not simply *not* build up an
unneeded list of return values, if a list expression is being evaluated
in a void context?
I agree with the stylistic preference not to use grep or map in a void
context, but your argument is based on a compiler problem that could be
fixed (no, not by me :-).
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personl/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Sat, 6 Mar 1999 18:11:00 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Sub calls: how can I do this?
Message-Id: <MPG.114b800bc56cbbb8989706@nntp.hpl.hp.com>
[Posted and a courtesy copy sent.]
In article <7bsbti$fug$1@news.campus.mci.net> on Sat, 6 Mar 1999
18:03:28 -0000, Rafala <rafala@loyolanet.campus.mci.net >says...
...
> Suppose my script uses a module with a slew of subs in it. But the script
> doesn't know which of those subs to call until the sub name is passed via an
> argument or read in through a data file.
>
> I was hoping that I could put the sub name into a scaler and use that in the
> call, e.g.:
>
> $yyy = $ARGV[0]; #the sub name was passed as an argument
> @xxx = $yyy ("hello");
You were off by only one character. You have to tell perl that it is a
subroutine.
@xxx = &$yyy('hello');
or directly -- note the required grouping brackets:
@xxx = &{$ARGV[0]}('hello');
This would do what you want to do, but you don't really want to do it!
For one thing, what if the string didn't correspond to the name of an
existing function? The program would fail, out of your control.
At the least, you would want something like this:
eval q{@xxx = &{$ARGV[0]}('hello')};
$@ and print "No subroutine '$ARGV[0]'.\n";
> Of course, it looks kind of silly now that I've tried it.
>
> I hope I don't have to do something like
>
> if ($ARGV[0] = "sub_1") {
You don't want to assign "sub_1" to $ARGV[0], do you? Use 'eq' to
compare strings.
> @xxx = sub_1 ("hello");
> } elsif ($ARGV[0] = "sub_2") {
> @xxx = sub_2 ("hello");
> } elsif ...
>
> }
You don't have to do it that crudely. Use a hash lookup:
my %subs = (
sub_1 => \&sub_1,
sub_2 => \&sub_2,
...
);
defined $subs{$ARGV[0]} ?
@xxx = &{$subs{$ARGV[0]}}('hello') :
print "No subroutine '$ARGV[0]'.\n";
> Can someone steer me in the right direction?
I just did. :-)
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personl/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Wed, 10 Mar 1999 09:05:31 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: Using Multiple Servers
Message-Id: <ebohlmanF8DFx7.Etq@netcom.com>
On Line Auctions UK <support@onlineauctions.co.uk> wrote:
: I have got two servers one with the main script on it and another that i
: want to pass data to. I need to post two variables like
: http://host.com/cgi-bin/script.cgi?var1=thing&var2=thing2 to the script
: on the other server. But how do actually code this in Perl.
use LWP::Simple.
------------------------------
Date: 10 Mar 1999 10:34:09 GMT
From: Edwin van Geelen <edwin@mindless.com.killspam>
Subject: Win32: which files as minimum distribution?
Message-Id: <8D857F6F4edwinmindlesscomkill@news.ing.nl>
Hi,
I use Vim 5.3 with the Perl interface. Now I want to make as small a
distribution of the both as possible. I've already trimmed Vim to the minimum,
but now what about Perl? Which files (I use the Sarathy distribution) do I
need as an absolute minimum. Perl.exe of course, and what else?
Thanks,
Edwin
------------------------------
Date: 12 Dec 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Special: Digest Administrivia (Last modified: 12 Dec 98)
Message-Id: <null>
Administrivia:
Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing.
]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body. Majordomo will then send you instructions on how to confirm your
]subscription. This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.
The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V8 Issue 5100
**************************************