[7077] in Perl-Users-Digest
Perl-Users Digest, Issue: 700 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jul 7 21:17:29 1997
Date: Mon, 7 Jul 97 18:03:41 -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 Mon, 7 Jul 1997 Volume: 8 Number: 700
Today's topics:
Re: Can perl call a dll? How? <dada@divinf.it>
Can't Print After &ReadParse <jeff@webdesigns1.com>
Re: Can't Print After &ReadParse (Bart Lateur)
Re: Can't Print After &ReadParse <dbenhur@egames.com>
Re: Cannot run NT EXE's from CGI (Scott McMahan)
Changing password from Perl script (Tatjana Todorovic)
checking for existence of file <rkaya@makiki.net>
Re: checking for existence of file (Tung-chiang Yang)
Re: checking for existence of file (Abigail)
Re: Code Formatter <rootbeer@teleport.com>
Re: Code Formatter <dedwards@homeaccount.com>
Re: Compression in Perl (Randy J. Ray)
Re: Compression in Perl (Abigail)
Re: Compression in Perl <rootbeer@teleport.com>
Re: concantenated HTML file printing (Geoffrey Hebert)
Re: concurrent dbm access? <zenin@best.com>
Re: Content type messages in frame? <rootbeer@teleport.com>
control characters in <TEXTAREA> boxes (shane whinfrey)
Convert newline to <br> <e.christensen@netjob.dk>
Re: Convert newline to <br> (Honza Pazdziora)
Re: Convert newline to <br> (Sandqvist Sami)
Re: Convert newline to <br> (Bart Lateur)
Converting newline to <br> <e.christensen@netjob.dk>
Re: Converting newline to <br> <jpnolan@voicenet.com>
Re: Converting newline to <br> (Tad McClellan)
Re: Converting newline to <br> (brian d foy)
Re: Day of the week. (Steffen Beyer)
Re: Day of the week. (Clay Irving)
Re: Day of the week. (Steffen Beyer)
Re: delete line in file directly(fixed length record) (Tad McClellan)
Re: deleting a record... <zenin@best.com>
Error compiling (missing vertigo@like.it
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 04 Jul 1997 23:16:30 +0200
From: Aldo Calpini <dada@divinf.it>
To: dclaar@cup.hp.com
Subject: Re: Can perl call a dll? How?
Message-Id: <33BD682E.9C5F939D@divinf.it>
Doug Claar wrote:
>
> Ok, I'm a unix-type, not a MS-type. But I have this PC, and it uses
> these things called DLLs, and I have one in particular that I'd like
> to use, but I just don't know enough of the MS lingo to know if this
> is possible, and if so how. For example, here is the header to one
> of the dll functions:
>
> HANDLE FAR PASCAL TWAIN_AcquireNative(HWND hwndApp, unsigned
> wPixTypes);
> // The minimal use of EZTWAIN.DLL is to just call this routine, with
> 0 for
> // both params. EZTWAIN creates a window if hwndApp is 0.
Hi Doug,
I've written a Win32::API module for this task. Your Perl code should
look like:
--------8<--------8<--------8<--------8<--------8<--------8<--------
use Win32::API;
$AcquireNative = new Win32::API('eztwain',
'TWAIN_AcquireNative',
[N, N], N);
# NOTE:
# 'eztwain' is the name of the dll. no path needed if it resides
# in the windows directory
# 'TWAIN_AcquireNative' is the name of the function
# [N, N] are the input parameters (2 numbers)
# N is the return value (a number too)
$result = $AcquireNative->Call(0, $pixTypes);
--------8<--------8<--------8<--------8<--------8<--------8<--------
You can find a pre-release of Win32::API at:
http://www.divinf.it/dada/perl/api/win32api-0.00.zip
It is built only for the ActiveWare version of Perl, at the moment.
Soon I'll release version 0.01, with support for both ActiveWare and
core (Perl 5.004_01) version, on CPAN too.
Bye,
Aldo Calpini
---/\-----------------------------------------------------------
--/ \--------------------------------- mailto:dada@divinf.it --
-<dada>-- POPULUS VULT DECIPI, -------- mailto:sis@divinf.it ---
--\ /------- ERGO DECIPIATUR --------- http://sis.divinf.it ---
---\/-----------------------------------------------------------
------------------------------
Date: 4 Jul 1997 02:38:25 GMT
From: "Jeff Oien" <jeff@webdesigns1.com>
Subject: Can't Print After &ReadParse
Message-Id: <01bc8823$a2acd580$4342cfa9@Pjeffo.execpc.com>
Hi,
I'm a newbie. I'm having an awful time with running a script I'm using
to learn how to parse form data. When I run this it will always say
there is an error at the next print statement after the print
"Content-type..."
#!/usr/bin/perl
print "Content-type: text/html\n\n";
require "cgi-lib.pl";
&ReadParse
print "<html><head>"; etc.
So here it would say-syntax error at formtest.pl line 5, near "print"
Any direction would be appreciated. Thanks,
------
Jeff Oien, WebDesigns
http://www.webdesigns1.com/
jeff@webdesigns1.com
------------------------------
Date: Fri, 04 Jul 1997 10:29:34 GMT
From: bart.mediamind@tornado.be (Bart Lateur)
Subject: Re: Can't Print After &ReadParse
Message-Id: <33cace5a.7064069@news.tornado.be>
"Jeff Oien" <jeff@webdesigns1.com> wrote:
...,
>&ReadParse
>print "<html><head>"; etc.
>
>So here it would say-syntax error at formtest.pl line 5, near "print"
That's one of the nasty things in the compiler error messages in Perl.
You should ALWAYS check out the previous line of code as well. It's the
semicolon after" &ReadParse" that is missing here.
Bart.
------------------------------
Date: Fri, 04 Jul 1997 17:07:21 -0700
From: Devin Ben-Hur <dbenhur@egames.com>
To: Jeff Oien <jeff@webdesigns1.com>
Subject: Re: Can't Print After &ReadParse
Message-Id: <33BD9039.8FD@egames.com>
Jeff Oien wrote:
> to learn how to parse form data. When I run this it will always say
> there is an error at the next print statement after the print
> "Content-type..."
> #!/usr/bin/perl
> print "Content-type: text/html\n\n";
> require "cgi-lib.pl";
> &ReadParse
> print "<html><head>"; etc.
>
> So here it would say-syntax error at formtest.pl line 5, near "print"
You have two problems:
1) you need a semi-colon after &ReadParse
-- this is basic Perl syntax.
2) You're using a very out-of-date CGI interface module.
cgi-lib.pl was written when Perl4 was still in common use
and has numerous problems (some of which you can find out
about in one of Tom Christianson's rants at
<URL:http://www.perl.com/perl/>. I don't think cgi-lib.pl
has been updated in a couple years now.
Most modern perl CGI scripts use the CGI.pm module authored
and maintained by Lincoln Stein. I suggest you do too.
--
Devin Ben-Hur <dbenhur@egames.com>
eGames.com, Inc. http://www.egames.com/
eMarketing, Inc. http://www.emarket.com/
Warning: Dates in Calendar are closer than they appear.
------------------------------
Date: 4 Jul 1997 19:59:10 GMT
From: scott@lighthouse.softbase.com (Scott McMahan)
Subject: Re: Cannot run NT EXE's from CGI
Message-Id: <5pjkme$ejl$1@mainsrv.main.nc.us>
Roger Vernon (roger@mantamedia.com) wrote:
: I'm just about ready to shoot either myself or the server.
You just described CGI on NT completely.
I finally gave up getting any CGI programs to run on NT. I installed an
Apache server over on a UNIX box and redirected any forms to it. Perl
doesn't work right, command line progams don't work right, CGI is
almost totally undocumented, and there is no documentation on it. I got
the thing so hosed up *no* CGI programs would work, even ones that were
working earlier.
I originally set up an NT server because of the zero-administration,
plug-it-in-and-forget-it, instant-Internet advertising. The truth is,
as long as you do things the designers of the system anticipated,
you're great; but as soon as you get off the beaten path, you're
utterly on your own.
Scott
------------------------------
Date: Mon, 07 Jul 1997 20:23:05 GMT
From: ttanja@EUnet.yu. (Tatjana Todorovic)
Subject: Changing password from Perl script
Message-Id: <33c14e1b.849872@news.EUnet.yu>
I'm writing a simple script for changing password for access to part
of Web (no problem) and changing password for same user on
system.
I know couple solutions:
1. Directly work with shadow file,
2. Using expect.
But I prefer pure Perl solution without working with shadow file.
Any hints? Thanks.
Best regards, Tanja
------------------------------
Date: Sat, 05 Jul 1997 23:23:11 -1000
From: "Raymond T. Kaya" <rkaya@makiki.net>
Subject: checking for existence of file
Message-Id: <33BF63FE.E72C7800@makiki.net>
Is there a standard function, or other means, to check for the existence
of a file in Perl? I'm writing a script to create a user-named file, but
I want to check to make sure the file doesn't already exist before
overwriting its contents with:
open (SOMEFILE,">$filename") || die "Can't Open $filename: $!\n";
--
Raymond T. Kaya
Honolulu, Hawaii
http://www.makiki.net
http://www.reikilinks.com
------------------------------
Date: Sun, 6 Jul 1997 10:30:26 GMT
From: tcyang@netcom.com (Tung-chiang Yang)
Subject: Re: checking for existence of file
Message-Id: <tcyangECw7uq.CDy@netcom.com>
Check file test operators. Hope this helps!!!
==================================
Raymond T. Kaya wrote after zapping the scum of the universe:
: Is there a standard function, or other means, to check for the existence
: of a file in Perl? I'm writing a script to create a user-named file, but
: I want to check to make sure the file doesn't already exist before
: overwriting its contents with:
: open (SOMEFILE,">$filename") || die "Can't Open $filename: $!\n";
--
========= Try the low-crossposting robomoderated 'alt.culture.taiwan' ===
soc.culture.taiwan, soc.culture.china (by SCC FAQ Team) FAQ's:
http://www.iglou.com/tcyang/Taiwan_faq.shtml, China_faq.shtml
------------------------------
Date: Sun, 6 Jul 1997 11:11:21 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: checking for existence of file
Message-Id: <ECw9qx.42C@nonexistent.com>
Raymond T. Kaya (rkaya@makiki.net) wrote on 1405 September 1993 in
<URL: news:33BF63FE.E72C7800@makiki.net>:
++ Is there a standard function, or other means, to check for the existence
++ of a file in Perl? I'm writing a script to create a user-named file, but
Look up the -X operators.
++ I want to check to make sure the file doesn't already exist before
++ overwriting its contents with:
++
++ open (SOMEFILE,">$filename") || die "Can't Open $filename: $!\n";
Then you should only open it if it doesn't exist. Testing if it
exists, and then opening it doesn't work; it might get created
in between. Check out File::Handle, and use the appropriate
parameter.
Abigail
--
perl5.004 -wMMath::BigInt -e'$^V=new Math::BigInt+qq;$^F$^W783$[$%9889$^F47$|88768$^W596577669$%$^W5$^F3364$[$^W$^F$|838747$[8889739$%$|$^F673$%$^W98$^F76777$=56;;$^U=$]*(q.25..($^W=@^V))=>do{print+chr$^V%$^U;$^V/=$^U}while$^V!=$^W'
------------------------------
Date: Thu, 3 Jul 1997 18:10:29 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: "Dana W. Edwards" <dedwards@homeaccount.com>
Subject: Re: Code Formatter
Message-Id: <Pine.GSO.3.96.970703180751.6445T-100000@kelly.teleport.com>
On Thu, 3 Jul 1997, Dana W. Edwards wrote:
> Do any of you have a script that will format C/Java code in a particular
> style?
Why should we? We're _Perl_ programmers. Do you ask a fancy French
restaurant to sell you an order of McFries? :-)
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Mon, 07 Jul 1997 15:00:09 -0400
From: "Dana W. Edwards" <dedwards@homeaccount.com>
Subject: Re: Code Formatter
Message-Id: <33C13CB9.14D2@homeaccount.com>
I was asking for the first but I have been askd to take my question
elsewhere so please do not respond.
Thanks,
Dana W. Edwards
Doug Seay wrote:
>
> Dana W. Edwards wrote:
> >
> > Hello everyone,
> > I am in a situation where there are several coders working on one
> > project. I am sure that many of you have been in this situation. Well,
> > each coder has his/her own coding style. This brings up a teeny
> > annoying problem for some to read code. Well, my question is this : Do
> > any of you have a script that will format C/Java code in a particular
> > style?
>
> Why not simply enforce coding standards?
>
> Are you asking "Is there a Perl program that formats C and/or Java?" or
> simply "Is there a program that formats C and/or Java?". The first one
> is only slightly related to Perl and the second is completely off topic.
>
> I know squat about Java, but there have been tools for formatting C for
> decades, why not use one of them? And don't you think you'd get better
> responses in C and Java newsgroups?
>
> - doug
------------------------------
Date: 03 Jul 1997 11:27:52 -0600
From: rjray@tremere.ecte.uswc.uswest.com (Randy J. Ray)
Subject: Re: Compression in Perl
Message-Id: <uow90zo6o6f.fsf@tremere.ecte.uswc.uswest.com>
Igor Vulfson <igorv@styx.or.fedex.com> writes:
> Does anyone have a code that would compress a string of upper case
> characters into a shorter string? - will need to decompress later!
There is a module to interface to the libz compression code, called
Compress::Zlib, and available at your nearest CPAN site.
If you are compressing smaller strings, with a more tightly-defined alphabet
(such as only A-Z), you can devise a much more effiecient scheme using Huffman
codes or something similar.
Randy
--
===============================================================================
Randy J. Ray -- U S WEST Technologies IAD/CSS/DPDS Phone: (303)595-2869
Denver, CO rjray@uswest.com
"It's not denial. I'm just very selective about the reality I accept." --Calvin
------------------------------
Date: Fri, 4 Jul 1997 02:54:27 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Compression in Perl
Message-Id: <ECrxEr.Azn@nonexistent.com>
Piers Cawley (pdcawley@aladdin.net) wrote on 1402 September 1993 in
<URL: news:54radgmob5.fsf@gunnar.aladdin.net>:
++ Eryq <eryq@enteract.com> writes:
++
++ > Igor Vulfson wrote:
++ > >
++ > > I have no option of using Compress:Zlib because it requires zlib,
++ > > which in turn, needs to be compiled on the machine, which is out of
++ > > the question because I don't have C compiler on Irix 5.3 (out web
++ > > server), which sucks.
++ >
++ > What about gcc? Or is your problem more about policy (i.e., you're not
++ > allowed to use a C compiler or have one installed)?
++ >
++
++ Sadly SGI consider that you only need their headers if you're buying
++ their compiler...
Crosscompile?
Abigail
--
perl5.004 -wMMath::BigInt -e'$^V=new Math::BigInt+qq;$^F$^W783$[$%9889$^F47$|88768$^W596577669$%$^W5$^F3364$[$^W$^F$|838747$[8889739$%$|$^F673$%$^W98$^F76777$=56;;$^U=$]*(q.25..($^W=@^V))=>do{print+chr$^V%$^U;$^V/=$^U}while$^V!=$^W'
------------------------------
Date: Fri, 4 Jul 1997 06:56:36 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Abigail <abigail@fnx.com>
Subject: Re: Compression in Perl
Message-Id: <Pine.GSO.3.96.970704065135.10208D-100000@kelly.teleport.com>
On Fri, 4 Jul 1997, Abigail wrote:
> ++ Sadly SGI consider that you only need their headers if you're buying
> ++ their compiler...
>
> Crosscompile?
Sadly, it's hard to crosscompile without the headers.
But somebody who has the SGI compiler (and sufficient time and other
resources) could compile and distribute any number of modules. So far, no
such person has materialized. If one doesn't show up soon, somebody will
port Linux to the SGI hardware.
:-)
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Mon, 07 Jul 1997 21:58:59 GMT
From: soccer@microserve.net (Geoffrey Hebert)
Subject: Re: concantenated HTML file printing
Message-Id: <5prngg$78e$1@news3.microserve.net>
I do not think this is a perl question.
Three html files each have start and stop
html. something like
<html>
<head>
</head>
<body> Beginning of each html
beginning of file 2 and 3
would have to be deleted.
</body> end of html
</html> end would have to be
deleted from 1 and 2
This is the simplest form of begin and end. Because there
are many posibilities, I doubt anyone has such a script.
Jesse Markham <foug@msg.ti.com> wrote:
>Hello,
> Was curious if anyone knew of Perl script that can grab several HTML
>files and throw them into one long file, then print them as one
>document. I have been picking up the pieces after I have inherited a
>mess of a perl script by a former colleague.
> Thanx!
-------------- Signature ------------------
Visit http://www.all-soccer.com
All soccer(what else is there?)
Put your soccer league on the internet today, FREE!
------------------------------
Date: 7 Jul 1997 16:46:21 GMT
From: Zenin <zenin@best.com>
Subject: Re: concurrent dbm access?
Message-Id: <5pr6gt$i87$3@nntp2.ba.best.com>
Martin Walsh <walsh-s@univ-rennes1.fr> wrote:
> (perl novice)
> Is there anyway of allowing concurrent access to a dbm or ndbm file?
Read only, or read/write? Check out the perldoc DB_File page
for information about locking the DBM filehandle (at least with
Berkeley DBM). If every process that uses that database locks
and unlocks it before and after each access, you can run
concurrently.
Kinda... I'd actually like to see this (locking and unlocking) be
automatic in the *DBM_File classes. Hmm, sounds like a generic
"wrapper" class might work just as well. I'll just put it on my
small list of personal projects I want to finish at some point. :)
--
-Zenin
zenin@best.com
------------------------------
Date: Thu, 3 Jul 1997 17:34:29 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Jonas Thvrnvall <labah@algonet.se>
Subject: Re: Content type messages in frame?
Message-Id: <Pine.GSO.3.96.970703173233.6445L-100000@kelly.teleport.com>
On Fri, 4 Jul 1997, Jonas Th=F6rnvall wrote:
> I'm using perl to create html text in a frame,=20
> My problem is that i get 3 content types messages in the loader frame
> that cover the graphics in it,=20
Well, it sure doesn't sound like a Perl error. Maybe you need to find out
more about frames and browsers, which would be a different newsgroup, or
their FAQ. Good luck!=20
--=20
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Mon, 07 Jul 1997 18:51:02 GMT
From: oa32@dial.pipex.com (shane whinfrey)
Subject: control characters in <TEXTAREA> boxes
Message-Id: <33c1376f.3863466@news.dial.pipex.com>
i'm entering data into a perl database and everything works fine apart
from when i use a multi-line text box . if i press return to move to
the next line, the control characters are held in the text string.
when the text string is written to a file, the control characters
screw the record.
could someone please tell me how to replace the control characters (i
think they are CR and LF) in the string with something like *!* for CR
and *!!* for LF. i can then write the record without corrupting it.
i then need the reverse to put the control characters back before
displaying the data.
please help. i've looked everywhere but can't find an answer.
thanks
shane
oa32@dial.pipex.com
------------------------------
Date: Fri, 04 Jul 1997 09:26:47 +0200
From: Ernst <e.christensen@netjob.dk>
Subject: Convert newline to <br>
Message-Id: <33BCA5B7.4492@netjob.dk>
I have a problem converting newline's in a string to the HTML tag <br>
I have tried something like this:
$ref=~ s/'\\n/<br>/;'
Any help?
------------------------------
Date: Fri, 4 Jul 1997 12:21:18 GMT
From: adelton@fi.muni.cz (Honza Pazdziora)
Subject: Re: Convert newline to <br>
Message-Id: <adelton.868018878@aisa.fi.muni.cz>
Ernst <e.christensen@netjob.dk> writes:
> I have a problem converting newline's in a string to the HTML tag <br>
>
> I have tried something like this:
>
> $ref=~ s/'\\n/<br>/;'
>
> Any help?
Yes. Check the expression for typos and do:
$ref=~ s/\n/<br>/g;
Hope this helps.
--
------------------------------------------------------------------------
Honza Pazdziora | adelton@fi.muni.cz | http://www.fi.muni.cz/~adelton/
I can take or leave it if I please
------------------------------------------------------------------------
------------------------------
Date: 4 Jul 1997 12:14:52 GMT
From: samiss@cc.tut.fi (Sandqvist Sami)
Subject: Re: Convert newline to <br>
Message-Id: <5pipfs$4fm$1@cc.tut.fi>
Ernst (e.christensen@netjob.dk) wrote:
>I have a problem converting newline's in a string to the HTML tag <br>
>I have tried something like this:
>$ref=~ s/'\\n/<br>/;'
>Any help?
Try
$ref =~ s/\\n/<BR>/g;
The "g" (global) modifier makes it replace all occurances of \n instead of
just the first one. You can also look at "man perlop". HTH.
Sami Sandqvist
------------------------------
Date: Fri, 04 Jul 1997 10:29:39 GMT
From: bart.mediamind@tornado.be (Bart Lateur)
Subject: Re: Convert newline to <br>
Message-Id: <33cbcf1d.7258888@news.tornado.be>
Ernst <e.christensen@netjob.dk> wrote:
>I have a problem converting newline's in a string to the HTML tag <br>
>
>I have tried something like this:
>
>$ref=~ s/'\\n/<br>/;'
You can use "\n" as a normal character, no need for special quoting
here. Also, if there could be more than one newline in $ref (though
improbable), use the g modifier to replace more than one occurence.
$ref =~ s/\n/<br>/g;
Bart.
------------------------------
Date: Fri, 04 Jul 1997 09:02:55 +0200
From: Ernst <e.christensen@netjob.dk>
Subject: Converting newline to <br>
Message-Id: <33BCA01F.4F47@netjob.dk>
Converting newline to <br>
I have a problem converting a (long) string containg new-line characters
to HTML <br>
I have tried something like this
$ref=~ tr/'\\n/<br>/;
but i dosn't work. Can anyone help.
Ernst
<a href="mailto:e.christensen@netjob.dk>mail</a>
------------------------------
Date: Sun, 06 Jul 1997 08:22:13 -0400
From: John Nolan <jpnolan@voicenet.com>
Subject: Re: Converting newline to <br>
Message-Id: <33BF8DF5.335B7617@dunx1.ocs.drexel.edu>
Tad McClellan wrote:
>
> Emiliano (qqehe@st5-oa6.oce.nl) wrote:
> : On Fri, 04 Jul 1997 09:02:55 +0200, Ernst wrote:
> : :I have a problem converting a (long) string containg new-line characters
> : :to HTML <br>
> : :
> : :I have tried something like this
> : :$ref=~ tr/'\\n/<br>/;
>
> : See man perlop, and try
> : $ref=~ s/\\n/<br>/sg;
> ^
> ^ this does not do anything
>
> $ref=~ s/\\n/<br>/g;
^^
Oops-- you escaped the escape character.
This regex doesn't match newlines, it matches the text string "\n";
I think you meant this:
$ref=~ s/\n/<br>/g;
For neatness, you may want to use something like these:
$ref=~ s/\n/ <br>\n/g;
$ref=~ s/\n/\n<br> /g;
------------------------------
Date: Fri, 4 Jul 1997 13:15:05 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Converting newline to <br>
Message-Id: <9jejp5.1s9.ln@localhost>
Emiliano (qqehe@st5-oa6.oce.nl) wrote:
: On Fri, 04 Jul 1997 09:02:55 +0200, Ernst wrote:
: :I have a problem converting a (long) string containg new-line characters
: :to HTML <br>
: :
: :I have tried something like this
: :$ref=~ tr/'\\n/<br>/;
: See man perlop, and try
: $ref=~ s/\\n/<br>/sg;
^
^ this does not do anything with this particular regex...
$ref=~ s/\\n/<br>/g;
--
Tad McClellan SGML Consulting
Tag And Document Consulting Perl programming
tadmc@flash.net
------------------------------
Date: Fri, 04 Jul 1997 03:52:28 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: Converting newline to <br>
Message-Id: <comdog-ya02408000R0407970352280001@nntp.netcruiser>
In article <33BCA01F.4F47@netjob.dk>, e.christensen@netjob.dk wrote:
> I have a problem converting a (long) string containg new-line characters
> to HTML <br>
>
>
> I have tried something like this
> $ref=~ tr/'\\n/<br>/;
that's not what tr/// does! see the man pages for the details
try the substitution operator, s///
$string =~ s/\n/<br>/g;
--
brian d foy <URL:http://computerdog.com>
------------------------------
Date: 7 Jul 1997 09:40:59 GMT
From: sb@en.muc.de (Steffen Beyer)
Subject: Re: Day of the week.
Message-Id: <5pqdjb$deh$1@en1.engelschall.com>
Clay Irving <clay@panix.com> wrote:
> Eh, does Time::Local know about "July"? Also, localtime() is going to
> return 0 .. 6 for $wday -- You'll need to build a hash to get "Wednesday"
> You could use the Date:DateCalc module:
> #!/usr/local/bin/perl -w
> use Date::DateCalc qw(day_name_tab day_of_week decode_month);
> $special_day = "July 2 1997";
> ($month,$day,$year) = split / /,$special_day;
> $mm = decode_month($month);
> $weekday = day_of_week($year,$mm,$day);
> $day_name = day_name_tab($weekday);
> print "$special_day is $day_name\n";
> This prints:
> July 2 1997 is Wednesday
Instead of decoding the date yourself, you could use the following:
#!/usr/local/bin/perl -w
use Date::DateCalc qw(day_name_tab day_of_week);
use Date::DateCalcLib qw(decode_date_us);
$special_day = "July 2 1997";
unless (($year,$month,$day) = decode_date_us($special_day))
{
die "Given date ('$special_day') is not a valid date!\n";
}
$weekday = day_of_week($year,$month,$day);
$day_name = day_name_tab($weekday);
print "$special_day is $day_name\n";
This allows more flexibility in the way the date may be entered; in fact
you may use almost any format (see the man page for more info!) as long as
the order of the three items is month - day - year.
Yours,
--
Steffen Beyer <sb@sdm.de> http://www.engelschall.com/u/sb/
"There is enough for the need of everyone in this world,
but not for the greed of everyone." - Mahatma Gandhi
>> Unsolicited commercial email goes directly to /dev/null <<
------------------------------
Date: 3 Jul 1997 18:59:55 -0400
From: clay@panix.com (Clay Irving)
Subject: Re: Day of the week.
Message-Id: <5phatb$5dr@panix.com>
In <33BAFE52.321A@sj.bigger.net> ray <raymond@sj.bigger.net> writes:
>Does anyone know a script or good algorithm for getting the day of the
>week given a month, day and year? For example, the day of the week is
>Wednesday for July 2nd, 1997.
Perl Modules are your friend.
#!/usr/local/bin/perl -w
use Date::DateCalc qw(day_name_tab day_of_week decode_month);
$special_day = "Jul 15 1997";
($month,$day,$year) = split / /,$special_day;
$mm = decode_month($month);
$weekday = day_of_week($year,$mm,$day);
$day_name = day_name_tab($weekday);
print "$special_day is $day_name\n";
The output produced is:
Jul 15 1997 is Tuesday
--
Clay Irving See the happy moron,
clay@panix.com He doesn't give a damn,
http://www.panix.com/~clay I wish I were a moron,
My God! Perhaps I am!
------------------------------
Date: 3 Jul 1997 20:29:46 GMT
From: sb@en.muc.de (Steffen Beyer)
Subject: Re: Day of the week.
Message-Id: <5ph23q$gs8$2@en1.engelschall.com>
ray <raymond@sj.bigger.net> wrote:
> Does anyone know a script or good algorithm for getting the day of the
> week given a month, day and year? For example, the day of the week is
> Wednesday for July 2nd, 1997.
>>Subject: comp.lang.perl.modules The Perl 5 Module List (Reusable Software)
>>Newsgroups: comp.lang.perl.modules,comp.answers,news.answers
>>From: andreas.koenig@franz.ww.tu-berlin.de (Andreas Koenig)
>>Reply-To: andreas.koenig@franz.ww.tu-berlin.de (Andreas Koenig)
Archive-name: perl-faq/module-list
Revision: 2.42
Posting-Frequency: bi-weekly
URL: http://www.perl.com/CPAN/modules/00modlist.long.html
The Perl 5 Module List Revision: 2.42 $Date: 1997/06/05 09:05:52 $
======================
Maintained by Tim Bunce and Andreas Kvnig <modules@perl.org>
Date::
::Convert cdpO Conversion between Gregorian, Hebrew, more? MORTY
::CTime adpf Updated ctime.pl with mods for timezones GBARR
::DateCalc Rdcf Gregorian calendar date calculations STBEY
::Format Rdpf Date formatter ala strftime GBARR
::GetDate adcf Yacc based free-format date parser in C TOMC
::Interval idpO Lightweight normalised interval data type TIMB
::Language adpO Multi-language date support GBARR
::Manip Rdpf Manipulate/parse international dates/times SBECK
::Parse Rdpf ASCII Date parser using regexp's GBARR
::Time idpO Lightweight normalised datetime data type TIMB
Time::
::CTime Rdpf Format Times ala ctime(3) with many formats MUIR
::DaysInMonth Rdpf Returns the number of days in a month MUIR
::HiRes Rdcf High resolution time, sleep, and alarm DEWEG
::JulianDay Rdpf Converts y/m/d into seconds MUIR
::Local Supf Implements timelocal() and timegm() P5P
::ParseDate Rdpf Parses many forms of dates and times MUIR
::Period Rdpf Code to deal with time periods PRYAN
::Timezone Rdpf Figures out timezone offsets MUIR
::Zone Rdpf Timezone info and translation routines GBARR
::gmtime adpf A by-name interface for gmtime TOMC
::localtime adpf A by-name interface for localtime TOMC
For example you can download "Date::DateCalc" from
http://www.engelschall.com/u/sb/download/
which does exactly what you want, plus more.
Yours,
--
Steffen Beyer <sb@sdm.de> http://www.engelschall.com/u/sb/
"There is enough for the need of everyone in this world,
but not for the greed of everyone." - Mahatma Gandhi
>> Unsolicited commercial email goes directly to /dev/null <<
------------------------------
Date: Mon, 7 Jul 1997 07:45:09 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: delete line in file directly(fixed length record)
Message-Id: <lcoqp5.a31.ln@localhost>
Pui Ming WONG (s11976@net2.hkbu.edu.hk) wrote:
: It's explained in the FAQ that there's no direct way of deleting
: a line in a file unless a new file is used for output and then
: renaming it to the old file afterwards.
: BUT, it's also said something like it is POSSIBLE to do it directly
: IF the file has all the lines of the same length.
: Now my file consists of all 8-bytes (9 if the \n is also counted)
: length records.
: What exactly should my statements be if i have to say, delete the
: 5th record from my file directly.
Do you want to delete the fifth record, making the sixth and subsequent
"move up" one record number? That is a little more involved, so I'll
get you started by showing how to *replace* the fifth record:
---------------------------
#! /usr/bin/perl -w
$recnum = 5; # change record number 5
open(FILE, "+<data") || die "could not open 'data' $!";
seek FILE, ($recnum-1) * 9, 0; # calculate the byte offset to the start
# of the record, and seek() to that pos
print FILE "87654321\n"; # write nine bytes
close(FILE);
---------------------------
--
Tad McClellan SGML Consulting
Tag And Document Consulting Perl programming
tadmc@flash.net
------------------------------
Date: 7 Jul 1997 16:51:03 GMT
From: Zenin <zenin@best.com>
Subject: Re: deleting a record...
Message-Id: <5pr6pn$i87$4@nntp2.ba.best.com>
Sergio Stateri Jr <serginho@alpha.hydra.com.br> wrote:
> Hi! How can I delete a line from a Text File in Perl ? Like this :
> line 1
> line 2
> line 3
> line 4
> <end of file>
> I'd like to delete the line 3.
RFTM&FAQ...
perl -nie 'print unless ($. == 3)' file
Untested of course, so use at your own risk.
--
-Zenin
zenin@best.com
------------------------------
Date: Mon, 07 Jul 1997 20:33:14 GMT
From: vertigo@like.it
Subject: Error compiling (missing
Message-Id: <33c1514d.2040750@psycho.like.it>
I'm trying to compile Perl 5.004_01. My system is a linux 2.0.30 kernel,
straight out of the box...
I run configure and everything looks fine (I've also tried running it with the
-d option to keep the defaults).
When I do a 'make' all is fine until compilation is aborted on 'miniperl' with
the following:
gcc -L/usr/local/lib -o miniperl miniperlmain.o libperl.a -lgdbm -ldbm -ldb
-ldl -lm -lc
pp_sys.o(.text+0x7aaf): undefined reference to 'herrno'
I've tried reading all the FAQ's and docs but no reference to this.
Note that 'configure' gives me a warning about 'NET/errno.h not found' but
keeps on running...
What is missing? Where is that 'herrno' supposed to be found?
I'm losing my sanity over this! Help!
Please reply by mail, if possible!
Thanks in advance!
--
Like It! - Internet Presence Provider
C.so Vittorio Emanuele 15 - 20122 Milano
e-mail: info@like.it
------------------------------
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 700
*************************************