[7558] in Perl-Users-Digest
Perl-Users Digest, Issue: 1184 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Oct 16 05:07:20 1997
Date: Thu, 16 Oct 97 02:00:36 -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 Thu, 16 Oct 1997 Volume: 8 Number: 1184
Today's topics:
Re: "Attaching" a zipped file (Philip)
(DBD::Oracle) test error <vingo@dnal.co.kr>
Re: An SMTPD in Perl <bholzman@mail.earthlink.net>
Re: Any plans for Min and Max operators? (brian d foy)
Background execution? (George Lin)
Bitmap Images & GIF Files fenris@-REMOVETHIS-memphisonline.com
Build a confirmation screen in Perl <Jason.Hogg@worldnet.att.net>
Re: Build a confirmation screen in Perl <rra@stanford.edu>
Re: Bulk email solution needed that works with Linux, P <nelson@crynwr.com>
Re: Bulk email solution needed that works with Linux, P (again)
Re: click on cgi script to download file (David Efflandt)
Re: Creating Arrays on the fly (Philip)
DB on UNIX system. <adorsett@gonzaga.edu>
Re: do function prototypes work for object methods? <bholzman@mail.earthlink.net>
Format Question <ahecker@interport.net>
Help on comparing files (Wei Tang)
Re: Help on comparing files <rra@stanford.edu>
HEX question <Kick@IT.net>
Re: HEX question (brian d foy)
Let parent process wait for all children <Kick@IT.net>
Multiple substitutions <gbh@middlemarch.net>
Re: Multiple substitutions (brian d foy)
perl on win95, inc environment (Jim Burdorf)
require and use? <jimmy.oh@icommerce.com.sg>
Re: require and use? (brian d foy)
Re: Saving "on-the-fly" built form (Philip)
Re: Searching Perl(5) grammar (Chip Salzenberg)
Sockets & Perl310/NT ? (C Carr)
split() question (Richard Drake)
Re: split() question (brian d foy)
Re: split() question <rra@stanford.edu>
strange questions ^_^ <wweng@attila.stevens-tech.edu>
Re: strange questions ^_^ (brian d foy)
Re: strange questions ^_^ <ghowland@hotlava.com>
Re: String manipulation in Perl <seay@absyss.fr>
Re: Trying to pass a file handle under strict mode <bholzman@mail.earthlink.net>
Re: We're targets. <seay@absyss.fr>
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 16 Oct 1997 08:23:50 GMT
From: fil_nospam@login.net (Philip)
Subject: Re: "Attaching" a zipped file
Message-Id: <3445cdfd.31464931@nntphost.login.net>
On Wed, 15 Oct 1997 17:25:44 -0400, Stacy Hunter <synex@snx.com>
wrote:
>I have a perl script that successfully "attaches" an hqx application and
>
>sends it to an email address. When I try the same script with a zipped
>file it arrives garbled and when I save it onto my desktop (mac) it is 0
>
>k (no content).Additionally, if I don't use my scritp but attach it
>using Pine it loads and downloads fine (as is true when I attach it
>using Netscape. What are these two methods ddoing to encrypt it that I
>am not seeing? The headers are identical and the one I used to transmit
>(applicaation; x-zip) and Base64.
>
>Any help would be most appreciated.
Are you encoding the ZIP file with MIME::Base64? hqx is an ASCII
format, unless I'm mistaken, so it doesn't need to be. But all binary
files such as zip have to be encoded.
-Philip
------------------------------
Date: Thu, 16 Oct 1997 17:22:52 +0900
From: Kim Jong Ho <vingo@dnal.co.kr>
Subject: (DBD::Oracle) test error
Message-Id: <3445CEDC.750902@dnal.co.kr>
Hi perl-users
I have some problem to install DBD::Oracle
But There is no problem to compile DBD module(DBD 0.47)
Below is the result of 'make test'
As reference
My Box : dynix/ptx 4.0
Oracle Server : 7.2.3.0.0 (OPS)
Perl :5.004_01
DBD :0.47
DBI :0.90
Comfiler :cc
Thanks any reply in advance .
# make test
PERL_DL_NONLAZY=1 /usr/bin/perl -I./blib/arch -I./blib/lib
-I/usr/local/lib/perl5/i386-dynixptx/5.00401 -I/usr/local/lib/perl5 -e
'use Test::Harness qw(&runtests $verbose); $verbose=0; runtests @ARGV;'
t/*.t
t/base..............install_driver(Oracle) failed: Can't load
'./blib/arch/auto/DBD/Oracle/Oracle.so' for module DBD::Oracle: dynamic
linker: /usr/bin/perl: relocation error: symbol not found: vfork at
/usr/local/lib/perl5/i386-dynixptx/5.00401/DynaLoader.pm line 155.
at (eval 1) line 2
DBI::install_driver('DBI', 'Oracle') called at t/base.t line 17
dubious
Test returned status 2 (wstat 512)
DIED. FAILED tests 4-5
Failed 2/5 tests, 60.00% okay
t/plsql.............install_driver(Oracle) failed: Can't load
'./blib/arch/auto/DBD/Oracle/Oracle.so' for module DBD::Oracle: dynamic
linker: /usr/bin/perl: relocation error: symbol not found: vfork at
/usr/local/lib/perl5/i386-dynixptx/5.00401/DynaLoader.pm line 155.
at (eval 1) line 2
DBI::install_driver('DBI', 'Oracle') called at
/usr/local/lib/perl5/site_perl/DBI.pm line 324
DBI::connect('DBI', '', 'scott/tiger', '', 'Oracle') called at
t/plsql.t line 18
dubious
Test returned status 2 (wstat 512)
Failed Test Status Wstat Total Fail Failed List of failed
------------------------------------------------------------------------------
t/base.t 2 512 5 2 40.00% 4-5
t/plsql.t 2 512 ?? ?? % ??
Failed 2/2 test scripts, 0.00% okay. 2/5 subtests failed, 60.00% okay.
*** Error code 2
Make: . Stop.
--
------------------------------
Date: Wed, 15 Oct 1997 23:08:11 -0400
From: Benjamin Holzman <bholzman@mail.earthlink.net>
To: Joseph Turian <XturianX@fas.harvard.edu>
Subject: Re: An SMTPD in Perl
Message-Id: <3445851B.110F83C1@mail.earthlink.net>
[posted & mailed]
Joseph Turian wrote:
>
> I was interested in writing a no-frills smtpd that would merely receive local
> mail and reject anything else. For fun, I thought that it would be cool to
> write the thing in Perl.
>
> How exactly would I go about writing a server? If the answer in RTFM, which
> FM? I have RFC 821, but what FM is there for writing a server in general?
> Like for, example, I never would have imagined without anyone having told me
> that when a server receives a connection that it should fork.
>
Well, Chapter 6 of the camel book ("Programming Perl" by Larry Wall, Tom
Christiansen, Randal Schwartz et al) has lots of information about
writing a TCP server. Most of the text of that chapter is in the
perlipc manpage.
> --
> Joseph Turian
> XturianX@fas.harvard.edu
> http://wish.student.harvard.edu
>
> Home address: Wigglesworth B-22
> Mailing address: 2507 Harvard Yard Mail Center
> Cambridge, MA 02138
> Home phone: (617) 493-3917
>
> In an attempt to reduce junk email I display an invalid email address.
> My correct email address can be determined by removing the Xs.
------------------------------
Date: Thu, 16 Oct 1997 00:34:19 -0400
From: comdog@computerdog.com (brian d foy)
Subject: Re: Any plans for Min and Max operators?
Message-Id: <comdog-ya02408000R1610970034190001@news.panix.com>
In article <slrn64b32m.6n3.jahwan@supernova.math.lsa.umich.edu>, jahwan@supernova.math.lsa.umich.edu (Jahwan Kim) wrote:
>On Wed, 15 Oct 1997 19:27:17 -0500, Tad McClellan <tadmc@flash.net> wrote:
>> Brett W. Denner (Brett.W.Denner@lmtas.lmco.com) wrote:
>[snip]
>
> What about adding functions, min and max?
>
>print min $a,$b;
>print max $a,$b,$c,$d;
>
>Adding these wouldn't do any harm but hopefully tiny amount of good.
no need to add them to the core. if you need it, write a module and
upload it to CPAN :)
--
brian d foy <comdog@computerdog.com>
NY.pm - New York Perl M((o|u)ngers|aniacs)* <URL:http://ny.pm.org/>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
use NumberTheory; #wouldn't that be cool...
------------------------------
Date: Thu, 16 Oct 1997 05:53:27 GMT
From: a00lcj00@mail.dt.nchc.gov.tw (George Lin)
Subject: Background execution?
Message-Id: <3445aa4f.80830718@netnews.nchc.gov.tw>
Hello all,
In unix platform, I can execute an external command backgroundly
by using `myprogram &` in perl.
But how can I do the same thing in Windows 95 or DOS envirement?
Thanks!
George
------------------------------
Date: Thu, 16 Oct 1997 01:07:01 -0400
From: fenris@-REMOVETHIS-memphisonline.com
Subject: Bitmap Images & GIF Files
Message-Id: <3445A0F5.2DAC@-REMOVETHIS-memphisonline.com>
I have two questions:
Are Bitmap Files (like those used in page counters) the same as .BMP?
And are there any docs out there for converting such files into .GIF
format thru perl? (Or even general docs would work)
Thanx!
------------------------------
Date: 16 Oct 1997 06:42:53 GMT
From: "Jason Hogg" <Jason.Hogg@worldnet.att.net>
Subject: Build a confirmation screen in Perl
Message-Id: <01bcd9fe$c8e4f520$c57c440c@hal>
Hello,
I would like to build a confirmation screen in Perl. Basically when the
user presses SUBMIT on a form, I would like all the data to be sent to a
Perl script that redisplays the data on one screen, and then asks the user
to confirm that they want that data saved, or whether they want to go back
and update what they entered.
(1) The later I assume is easy, simply by doing a javascript go.history(-1)
or something similar. I assume that will redisplay the form with the data
intact. If I am wrong please correct me!
(2) But, how do I send the data that was on the form to a second (or the
same) Perl program, from the confirmation screen. When building the
confirmation screen should I create Hidden form fields and put the data in
there. Or is there a way to 'magically' send the data from the first Perl
script to a second one.
I would appreciate any suggestions!
Cheers
Jason
------------------------------
Date: 16 Oct 1997 00:22:58 -0700
From: Russ Allbery <rra@stanford.edu>
Subject: Re: Build a confirmation screen in Perl
Message-Id: <m3zpoanpd9.fsf@windlord.Stanford.EDU>
Jason Hogg <Jason.Hogg@worldnet.att.net> writes:
> I would like to build a confirmation screen in Perl. Basically when the
> user presses SUBMIT on a form, I would like all the data to be sent to a
> Perl script that redisplays the data on one screen, and then asks the
> user to confirm that they want that data saved, or whether they want to
> go back and update what they entered.
[snip]
> (2) But, how do I send the data that was on the form to a second (or the
> same) Perl program, from the confirmation screen.
Use CGI.pm. Read the documentation with perldoc CGI. Look for references
to sticky fields. Yes, you want to save all of the data in hidden fields
and make them press another button to actually submit, because unless you
keep the data with you on each page you present to the user, you'll lose
it (CGI is stateless). CGI.pm makes this trivial.
--
#!/usr/bin/perl -- Russ Allbery, Just Another Perl Hacker
$^=q;@!>~|{>krw>yn{u<$$<[~||<Juukn{=,<S~|}<Jwx}qn{<Yn{u<Qjltn{ > 0gFzD gD,
00Fz, 0,,( 0hF 0g)F/=, 0> "L$/GEIFewe{,$/ 0C$~> "@=,m,|,(e 0.), 01,pnn,y{
rw} >;,$0=q,$,,($_=$^)=~y,$/ C-~><@=\n\r,-~$:-u/ #y,d,s,(\$.),$1,gee,print
------------------------------
Date: 16 Oct 1997 00:24:30 -0400
From: Russell Nelson <nelson@crynwr.com>
Subject: Re: Bulk email solution needed that works with Linux, Perl
Message-Id: <m2hgais5c1.fsf@desk.crynwr.com>
brad@his.com (Brad Knowles) writes:
> In article <m2sou2so2x.fsf@desk.crynwr.com>, Russell Nelson
> <nelson@crynwr.com> wrote:
>
> > > We have a email subscription service for the users of one of our
> > > client's websites. The user can specify the information which appears in
> > > their email, which results in all the email contents being unique.
> >
> > Problems with sendmail are best solved by installing qmail.
> > http://www.qmail.org.
>
> You will notice that the largest "private subscription email" service
> in the world (InfoBeat, was Mercury Mail) is *not* using QMail. They're
> using sendmail, properly configured. I'd say that's a pretty big vote
> against qmail in that kind of environment.
I would believe that only if you had some evidence that they evaluated
qmail and chose sendmail over it. I can't imagine anyone comparing
qmail to sendmail and still picking sendmail. Let's see:
________________qmail___|_____sendmail________
the standard not yet | check
time-tested 1.5 yrs | check
secure check | not yet
efficient check | no
fast check | no
reliable check | maybe
understandable check | no
uniform APIs check | man dot-forward; "no manual entry...."
I will give sendmail this: with sendmail, you can do anything without
invoking an external program, for vanishingly small values of "you".
--
-russ <nelson@crynwr.com> http://www.crynwr.com/~nelson | Freedom is the
Crynwr Software supports freed software | PGPok | primary cause of peace.
521 Pleasant Valley Rd. | +1 315 268 1925 voice | Taxes feed the naked
Potsdam, NY 13676-3213 | +1 315 268 9201 FAX | and clothe the hungry.
------------------------------
Date: Thu, 16 Oct 1997 09:32:28 +0100
From: "John Hartnup (again)" <slim@ladle.demon.co.uk>
Subject: Re: Bulk email solution needed that works with Linux, Perl
Message-Id: <3445D11B.70571F22@ladle.demon.co.uk>
Brad Knowles wrote:
>
> In article <m2sou2so2x.fsf@desk.crynwr.com>, Russell Nelson
> <nelson@crynwr.com> wrote:
>
> > > We have a email subscription service for the users of one of our
> > > client's websites. The user can specify the information which appears in
> > > their email, which results in all the email contents being unique.
> >
> > Problems with sendmail are best solved by installing qmail.
> > http://www.qmail.org.
>
> You will notice that the largest "private subscription email" service
> in the world (InfoBeat, was Mercury Mail) is *not* using QMail. They're
> using sendmail, properly configured. I'd say that's a pretty big vote
> against qmail in that kind of environment.
Surely the MTA is irrelevant to the poster's original problem, which was
that he was running a program in a tight loop which repeatedly opened a
pipe to sendmail, until the computer complained of too many open pipes.
The answer which someone posted (pipe all the mail into one instance of
sendmail -bs) looks sound enough to me. Qmail may be better (I haven't
investigated -- yet) but it wouldnt' have solved this particular
problem.
John
------------------------------
Date: Thu, 16 Oct 1997 08:51:31 GMT
From: efflandt@xnet.com (David Efflandt)
Subject: Re: click on cgi script to download file
Message-Id: <344dd413.8983033@flood.xnet.com>
dwaters@delphi.co.uk (David Waters) wrote:
>Hi all,
>
>I've seen on some web pages, where you click a script
>and it downloads an appropriate file.
>
>How is this done within the script to tell the browser
>to download a file.
>
>Preferably in perl please
>
>Thanks
>
>David
print "Content-type: application/octet-stream\n\n";
Means that a file should be saved rather than displayed.
Unfortunately MSIE and other Mosaic based browsers ignore most MIME
headers and base their actions on filename extension. So for those
browsers the user should be instructed to right click (or select
download file from the menu in X-Mosaic). Also MSIE ignores any
attempt to send a suggested filename, so the file would be saved as
the name of the script, possibly with a random file extension instead
of .cgi.
David Efflandt/Elgin, IL USA
efflandt@xnet.com http://www.xnet.com/~efflandt/
------------------------------
Date: Thu, 16 Oct 1997 08:23:50 GMT
From: fil_nospam@login.net (Philip)
Subject: Re: Creating Arrays on the fly
Message-Id: <3445cc13.30974904@nntphost.login.net>
On Tue, 14 Oct 1997 22:28:47 -0700, ryanr <ryanr@poolpros.com> wrote:
>How would I go about creating a 2 dimensional array on the fly?
>
>right now I am creating my arrays, according to the way Tom Christiansen
>says in FMTEYEWTK, such as:
>@Table = ([1,2,3,4],
> [5,6,7,8],
> [9,0,1,2]);
>
>This works o.k.. but what I would really like to do is read my values
>in from a file
>and build the array. I realize that I would have to use push(), but I'm
>not sure how I would go about adding to the 2nd dimension..
>
You want to create an array of references to arrays. So, assuming CSV
with each line as a row in your table :
foreach (<FILE>) # read a line into $_ (this is bad style)
{
@temp=split /,/ $_; # split line on commas
push @table, [@temp]; # turn array into array ref, then push
}
(Or code to that effect.)
Read perlref, perldsc and perllol. It takes a while to get grok it,
but once you do, it's second nature.
-Philip
------------------------------
Date: Thu, 16 Oct 1997 01:20:16 -0700
From: Amy Dorsett <adorsett@gonzaga.edu>
Subject: DB on UNIX system.
Message-Id: <Pine.HPP.3.95.971016011820.28076A-100000@barney.gonzaga.edu>
I was wondering if anyone knew if it was possible to use an Open Database
Connectivity (ODBC) with a UNIX system??
Thank You in advance...
------------------------------
Date: Wed, 15 Oct 1997 23:26:34 -0400
From: Benjamin Holzman <bholzman@mail.earthlink.net>
To: Thad Welch <tw36027@glaxowellcome.com>
Subject: Re: do function prototypes work for object methods?
Message-Id: <3445896A.9F5FC40A@mail.earthlink.net>
[posted & mailed]
[snip]
> When I try this, perl gives me an error:
> Can't use subscript on subroutine entry at x.pl line 11, near ""obj =
> $_\n" }".
>
> I thought the foreach prototype would allow me to pass a block without
> the function
> parens and sub {}?
>
> This does work:
> $objs->foreach ( sub { print "obj = $_\n" } );
> doesn't look as nice.
>
> Thanks,
> Thad
As the documentation points out, prototypes can't work for methods
because inheritance is dynamic in perl; at compile-time, perl doesn't
know what class your method is defined in, so how could it enforce or
use prototypes?
------------------------------
Date: Thu, 16 Oct 1997 01:37:43 -0400
From: Alan <ahecker@interport.net>
Subject: Format Question
Message-Id: <3445A827.8FA648D4@interport.net>
Folks,
You were all so helpful last time, I thought I'd ask you for your help
once more.
I now have to output information via the format command. I have two
formats that I wish to utput, 1 called LONG & 1 called SHORT. I know
that doing $~ = SHORT and $~ = LONG will assign the formats to STDOUT,
but I need to have multiple lines print under one heading, like so:
changed filename
------- --------
25 myfile1
142 myfile2
I've tried putting a @* in my format declaration, but that doesn't seem
to work, so for now I'm stuck with:
changed filename
------- --------
25 myfile1
changed filename
------- --------
142 myfile2
You can imagine what this is doing to my already shredded sanity....
Thanx in advance for any & all help,
- Alan
--
"Never send a Monster to do the work of an Evil Scientist."
------------------------------
Date: 16 Oct 1997 06:36:43 GMT
From: wtang@cs.ualberta.ca (Wei Tang)
Subject: Help on comparing files
Message-Id: <624clr$n05$1@scapa.cs.ualberta.ca>
Hi, there:
I want to compare two files (or two scalers if they store the contents
of the two files) to get the result of file1 - file2, i.e., just like
the SQL "minus" operation.
I have preformatted the file like this:
$field1\t$field2\t...$fieldn\n
$field1\t$field2\t...$fieldn\n
...
Is there an efficient way to do it without having to parse the files
several times? The simplest and stupidest way is to take each row from
file2 and use a grep in file1, if there is a match, get rid of it from
file1.
Could someone help me out?
Thanks a lot.
------------------------------
Date: 16 Oct 1997 00:27:37 -0700
From: Russ Allbery <rra@stanford.edu>
Subject: Re: Help on comparing files
Message-Id: <m3wwjenp5i.fsf@windlord.Stanford.EDU>
Wei Tang <wtang@cs.ualberta.ca> writes:
> I want to compare two files (or two scalers if they store the contents
> of the two files) to get the result of file1 - file2, i.e., just like
> the SQL "minus" operation.
[snip]
> Is there an efficient way to do it without having to parse the files
> several times?
There are two methods that occur to me. In the order that I'd personally
try them:
1) Use diff and parse the output, basically looking for things that are
only in the first file but not in the second (which will be lines
preceded with a < if you use the default diff options). This is
should be fairly trivial to pull off.
2) Read the entire second file into memory in the form of a hash (with
keys of each line of the file and values of 1). Then read in the
first file and for each line try to look it up in the hash, and if
the value of that line as a key in the hash is true, discard the line.
--
#!/usr/bin/perl -- Russ Allbery, Just Another Perl Hacker
$^=q;@!>~|{>krw>yn{u<$$<[~||<Juukn{=,<S~|}<Jwx}qn{<Yn{u<Qjltn{ > 0gFzD gD,
00Fz, 0,,( 0hF 0g)F/=, 0> "L$/GEIFewe{,$/ 0C$~> "@=,m,|,(e 0.), 01,pnn,y{
rw} >;,$0=q,$,,($_=$^)=~y,$/ C-~><@=\n\r,-~$:-u/ #y,d,s,(\$.),$1,gee,print
------------------------------
Date: Wed, 15 Oct 1997 15:35:30 -0700
From: Kick Fronenbroek <Kick@IT.net>
Subject: HEX question
Message-Id: <34454531.ADE@IT.net>
When I run the following program, I get decimal output.
I can only find in the FAQ's to convert from HEX or Octal to decimal.
Can somebody tell me what is wrong and/or how I can get output in Hex,
like: 0x10 or 0x1B ?
@classearray = (0x00..0xFF);
$classe = $classearray[int(rand(@classearray))];
print $classe;
Thanks in advance,
Kick Fronenbroek
------------------------------
Date: Thu, 16 Oct 1997 04:23:51 -0400
From: comdog@computerdog.com (brian d foy)
Subject: Re: HEX question
Message-Id: <comdog-ya02408000R1610970423510001@news.panix.com>
In article <34454531.ADE@IT.net>, Kick@IT.net wrote:
>When I run the following program, I get decimal output.
>I can only find in the FAQ's to convert from HEX or Octal to decimal.
>
>Can somebody tell me what is wrong and/or how I can get output in Hex,
>like: 0x10 or 0x1B ?
you can do something like:
#!/usr/bin/perl
foreach( 0..15 )
{
printf "0x%02X\n", $_; #or use sprintf()
}
__END__
0x00
0x01
0x02
0x03
0x04
0x05
0x06
0x07
0x08
0x09
0x0A
0x0B
0x0C
0x0D
0x0E
0x0F
--
brian d foy <comdog@computerdog.com>
NY.pm - New York Perl M((o|u)ngers|aniacs)* <URL:http://ny.pm.org/>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
------------------------------
Date: Wed, 15 Oct 1997 15:54:59 -0700
From: Kick Fronenbroek <Kick@IT.net>
Subject: Let parent process wait for all children
Message-Id: <344549C3.7BA8@IT.net>
I am using the following code (fork part taken from "programming perl"
book of O'reilly) :
-----
$childsrequested = 10; $actchilds = 0;
while($childsrequested > $actchilds) {
$actchilds++;
if ($pid = fork) {
# print "I am the parent, with PID:", $pid, "\n";
} elsif (defined $pid) {
#### Actual child !
....
exit; # child exit
##### END CHILD CODE !!!!!
} elsif ($! =~ /No more process/) {
# EAGAIN, supposedly recoverable fork error
print "I have a problem\n";
sleep 5;
} else {
# weird fork error
die "Can't fork: $!\n";
}
wait;
...
------------
The childs are doing all the same job. I am measuring the time for each
child process and want the parent to do calculations on the results
after the childs finished their job.
What happens is that the parent is already finished, before one child
has finished his/her job.
I have checked the FAQ, but cannot find the answer (or I am looking at
the wrong place).
Thanks in advance for any help.
Ps. I know that the $actchilds++; row is in a wrong/strange place. But
it works (as long as I do not have fork problems of course).
Kick Fronenbroek
------------------------------
Date: Thu, 16 Oct 1997 00:34:57 -0400
From: <gbh@middlemarch.net>
Subject: Multiple substitutions
Message-Id: <Pine.GSO.3.96.971016002037.10500A-100000@clark.net>
I'm trying to make a couple of global substitutions
to a file and then be able to print the modified
version while keeping the original version unchanged.
I've tried
open (FILE, "file.name");
FILE =~ s/regex_1/$sub_1/g,
s/regex_2/$sub_2/g;
print FILE;
But I get the error 'Can't modify constant item in substitution...'.
How can this be done?
--Greg
------------------------------
Date: Thu, 16 Oct 1997 02:24:09 -0400
From: comdog@computerdog.com (brian d foy)
Subject: Re: Multiple substitutions
Message-Id: <comdog-ya02408000R1610970224090001@news.panix.com>
In article <Pine.GSO.3.96.971016002037.10500A-100000@clark.net>, <gbh@middlemarch.net> wrote:
>I'm trying to make a couple of global substitutions
>to a file and then be able to print the modified
>version while keeping the original version unchanged.
if the changes don't cross line boundaries (however you define a
line boundary) you can do something like
open FILE, $filename or die "$filename: $!\n";
while( <FILE> ) #read in one line
{
s/net/glue/g;
s/glue/dead horse/g;
s/dead horse/angel horse/g;
#and so on
print;
}
close FILE;
if changes do cross word boundaries, you might want to slurp the
whole file into a scalar and perform changes on that:
local $/ = undef; #undefine the input record separator
open FILE, $filename or die "$filename: $!\n";
$_ = <FILE>; #all of the file in now in $_
#don't beat a dead horse - see the above substitutions
--
brian d foy <comdog@computerdog.com>
NY.pm - New York Perl M((o|u)ngers|aniacs)* <URL:http://ny.pm.org/>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
no animals were harmed in the typing of this message.
------------------------------
Date: Wed, 15 Oct 1997 23:08:37 -0600
From: burdorf@micron.net (Jim Burdorf)
Subject: perl on win95, inc environment
Message-Id: <burdorf-ya02408000R1510972308370001@news.micron.net>
all,
i'm not sure if i'm being dense here or not, but here it is.
i'm fairly new to win95, and i'm trying to get perl (tk flavor) up and
running. i've downloaded two versions from cpan, the latest release, and
the tk version. i installed both (in different dir's) and i'm trying to
run some of the examples. the tk widget example seems to run fine, but
when i try to run the ole examples (excel1.pl or excel2.pl) from the non-tk
install, i get bizarre behavior.
first, it couldn't find ole.pm, and gave an error message with the current
inc path. i located ole.pm and made sure it was in the inc path. then it
seemed to find it, but died with an error about unable to locate object
CreateObject. i looked at all ole.pm files on the machine, and found that
it was trying to use the ole.pm from the second install (non-tk) which was
not in the inc path indicated earlier.
if i type set from the command line, inc does not show up in the environment.
am i fighting a win95 problem, or a perl install problem?
where does the inc environment get set and what is the behavior? it almost
seems like there is some modality to it that i've not been able to figure
out. i've edited the autoexec.bat, but it looks like that's not the only
influance on inc.
is there a good referance book for perl and perltk on win32? the camel
doesn't have much to say.
if it's convienent, please email responses to burdorf@micron.net.
thanks in advance.
jimb
------------------------------
Date: Wed, 15 Oct 1997 12:26:41 +0800
From: Jimmy Oh <jimmy.oh@icommerce.com.sg>
Subject: require and use?
Message-Id: <34444601.674B@icommerce.com.sg>
hi,
what is the difference 'require' and 'use'? when do i use 'require'
and when do i use 'use'? thanx.
jimmy
------------------------------
Date: Thu, 16 Oct 1997 02:13:13 -0400
From: comdog@computerdog.com (brian d foy)
Subject: Re: require and use?
Message-Id: <comdog-ya02408000R1610970213130001@news.panix.com>
In article <34444601.674B@icommerce.com.sg>, Jimmy Oh <jimmy.oh@icommerce.com.sg> wrote:
> what is the difference 'require' and 'use'? when do i use 'require'
>and when do i use 'use'? thanx.
these things and more are explained at length in the perlfunc manual
page which comes with the perl distribution. you can also find
these explanations in the blue Camel [1], chapter 3.
good luck :)
[1]
Programming Perl, Larry Wall
Tom Christensen, & Randal L. Schwartz
ISBN 1-56592-149-6.
<http://www.oreilly.com>
--
brian d foy <comdog@computerdog.com>
NY.pm - New York Perl M((o|u)ngers|aniacs)* <URL:http://ny.pm.org/>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
------------------------------
Date: Thu, 16 Oct 1997 08:23:46 GMT
From: fil_nospam@login.net (Philip)
Subject: Re: Saving "on-the-fly" built form
Message-Id: <3445c73b.29735086@nntphost.login.net>
On 9 Oct 1997 15:00:48 GMT, mizenin@bgnet.bgsu.edu (Pavel V. Mizenin)
wrote:
>Hi,
>I'm writing a form builder for quiz/survey creation. The user has a whole
>host of options. Therefore, the "building" process will involve a lot of
>going back and forth between the options form and the preview form. At some
>point the user is content with the questionnaire and wants to save it (on
>the server). Is there any way to save the entire form (html code) in a file
>on the server machine without presaving it every time the user previews the
>form?
How about a button marked "Save now"?
-Philip
------------------------------
Date: 16 Oct 1997 00:29:24 -0400
From: chip@rio.atlantic.net (Chip Salzenberg)
Subject: Re: Searching Perl(5) grammar
Message-Id: <97-10-087@comp.compilers>
Keywords: parse
According to Gerd Weishaar <weishaar@soft.uni-linz.ac.at>:
>I'm searching for a Perl grammar with the purpose to develope an
>analysis tool for perl programs. The yacc-file included in the
>perl5 package is quite tricky and difficult to read.
That's because Perl itself is tricky and difficult to parse.
>[I'd be surprised if anything much simpler than the parser in perl5 could
>correctly parse perl5. -John]
Good call. Some parser decisions depend on such factors as whether
a given package (class) has been defined yet.
--
Chip Salzenberg - a.k.a. - <chip@pobox.com>
--
Send compilers articles to compilers@iecc.com,
meta-mail to compilers-request@iecc.com.
------------------------------
Date: Thu, 16 Oct 1997 05:06:44 GMT
From: clint@netcom.com (C Carr)
Subject: Sockets & Perl310/NT ?
Message-Id: <clintEI4ov8.GGw@netcom.com>
Keywords: socket build 310
I have some socket networking code that works fine under perl
build 110 and NT. The code bombs on the socket create under
build 310 and NT. I can't locate the bug in my code which
is listed below. Any clues as it works in 110 but not 310?
use Socket;
$ip = pack ('C4', split (/\./, '192.168.0.20'));
$tcp_port = 1212;
$saddr = pack('S n a4 x8', AF_INET, $tcp_port, $ip);
print "It fails here\n" unless socket(SOCK, PF_INET, SOCK_STREAM, 6) ;
print "Connection Bombed\n" unless connect(SOCK, $saddr) ;
close(SOCK);
thanks
------------------------------
Date: 16 Oct 1997 05:54:16 GMT
From: drake@scapa.cs.ualberta.ca (Richard Drake)
Subject: split() question
Message-Id: <624a68$lbm$1@scapa.cs.ualberta.ca>
Hi.
I have a line like this:
R 9 fname lname 4 6 11 7 8 32
What I want to do is get the number '11' into a variable by itself.
There is no guarantee about the spacing between the numbers and no
guarantee about the number of digits in each number. It is guaranteed
that there is at least one space between each number though. Also,
these numbers are just examples..they could be any integer < 200.
Now I have tried many permutations of split(), but my limited
knowledge doesn't take me far enough.
Any help is _greatly_ appreciated!
Thanks.
-richard
------------------------------
Date: Thu, 16 Oct 1997 02:32:24 -0400
From: comdog@computerdog.com (brian d foy)
Subject: Re: split() question
Message-Id: <comdog-ya02408000R1610970232240001@news.panix.com>
In article <624a68$lbm$1@scapa.cs.ualberta.ca>, me@nospam.com wrote:
>R 9 fname lname 4 6 11 7 8 32
>
>What I want to do is get the number '11' into a variable by itself.
>There is no guarantee about the spacing between the numbers and no
>guarantee about the number of digits in each number. It is guaranteed
>that there is at least one space between each number though.
presuming that you want the 7th column of data and that this line
is stored in $line, you could do something like
@array = split /\s+/, $line, 10;
$seventh_column = $array[6];
you could also do all sorts of ugly things with regular expressions
if you really wanted to.
good luck :)
--
brian d foy <comdog@computerdog.com>
NY.pm - New York Perl M((o|u)ngers|aniacs)* <URL:http://ny.pm.org/>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
------------------------------
Date: 16 Oct 1997 00:19:30 -0700
From: Russ Allbery <rra@stanford.edu>
Subject: Re: split() question
Message-Id: <m33em2p43h.fsf@windlord.Stanford.EDU>
Richard Drake <drake@scapa.cs.ualberta.ca> writes:
> I have a line like this:
> R 9 fname lname 4 6 11 7 8 32
> What I want to do is get the number '11' into a variable by itself.
$value = (split (' ', $line))[6];
--
#!/usr/bin/perl -- Russ Allbery, Just Another Perl Hacker
$^=q;@!>~|{>krw>yn{u<$$<[~||<Juukn{=,<S~|}<Jwx}qn{<Yn{u<Qjltn{ > 0gFzD gD,
00Fz, 0,,( 0hF 0g)F/=, 0> "L$/GEIFewe{,$/ 0C$~> "@=,m,|,(e 0.), 01,pnn,y{
rw} >;,$0=q,$,,($_=$^)=~y,$/ C-~><@=\n\r,-~$:-u/ #y,d,s,(\$.),$1,gee,print
------------------------------
Date: 16 Oct 1997 04:37:31 GMT
From: Wei Weng <wweng@attila.stevens-tech.edu>
Subject: strange questions ^_^
Message-Id: <6245mb$28m$1@apocalypse.dmi.stevens-tech.edu>
hi
Here is my strange question: I have a string and I want to locate the
exact position of a pattern in the string. Say if string is @string and
the pattern is /href/ what should I do?
thanks in advance.
ja ne
--
************************************************************
Wei Weng & A N NIIIM MEEEE *
Box s-1398 & A A NN N I MM MM *
Stevens Institute of Technology& A A N N N I M M MEEEE *
Hoboken, NJ 07030 & AAAAAAAN NN I M M *
wweng@stevens-tech.edu &A A NIIIM MEEEE *
************************************************************
------------------------------
Date: Thu, 16 Oct 1997 02:14:55 -0400
From: comdog@computerdog.com (brian d foy)
Subject: Re: strange questions ^_^
Message-Id: <comdog-ya02408000R1610970214550001@news.panix.com>
In article <6245mb$28m$1@apocalypse.dmi.stevens-tech.edu>, Wei Weng <wweng@attila.stevens-tech.edu> wrote:
>Here is my strange question: I have a string and I want to locate the
>exact position of a pattern in the string. Say if string is @string and
>the pattern is /href/ what should I do?
the index() function was made just for this. see the perlfunc manual
page for more details.
good luck :)
--
brian d foy <comdog@computerdog.com>
NY.pm - New York Perl M((o|u)ngers|aniacs)* <URL:http://ny.pm.org/>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
------------------------------
Date: Thu, 16 Oct 1997 09:06:59 +0100
From: Gary Howland <ghowland@hotlava.com>
Subject: Re: strange questions ^_^
Message-Id: <3445CB23.6C68@hotlava.com>
brian d foy wrote:
>
> In article <6245mb$28m$1@apocalypse.dmi.stevens-tech.edu>, Wei Weng <wweng@attila.stevens-tech.edu> wrote:
>
> >Here is my strange question: I have a string and I want to locate the
> >exact position of a pattern in the string. Say if string is @string and
> >the pattern is /href/ what should I do?
>
> the index() function was made just for this. see the perlfunc manual
> page for more details.
You may want to take a look at 'pos' too.
Gary
--
pub 1024/C001D00D 1996/01/22 Gary Howland <gary@hotlava.com>
Key fingerprint = 0C FB 60 61 4D 3B 24 7D 1C 89 1D BE 1F EE 09 06
------------------------------
Date: Thu, 16 Oct 1997 10:32:19 +0200
From: Doug Seay <seay@absyss.fr>
To: John Goerzen <jgoerzen+usenet@complete.org>
Subject: Re: String manipulation in Perl
Message-Id: <3445D113.28E788F3@absyss.fr>
[posted and mailed]
[reference to dead comp.lang.perl deleted]
John Goerzen wrote:
>
> Hello,
>
> I am a C programmer moving over to Perl. I have really enjoyed some
> of Perl's powerful string manipulation features such as regexps, the
> "x" and "." operators, the "eq" (and similar) operators, etc.
> However, there is something that C excels at that I seem to be unable
> to do with like ease in Perl.
Going out on a limb, there is _nothing_ dealing with strings in C that
cannot be done in Perl. Most of the time it is easier in Perl.
> In C, since every string is an array, I can reference each individual
> character as I need to. I can also say things like:
>
> string[3] = 'Q';
> string[3] = 32; (same as string[3] = ' ';)
> string[3] = 'a' + 5;
>
> I cannot seem to find an easy way to to this in Perl. It appears that
> I can split a string into an array using unpack and then use pack to
> move it back. But -- this still doesn't give me the ease of mixing
> characters with ASCII values that I get in C. How can I do this sort
> of thing in Perl? And is it even possible? If not, will it ever be?
Last question first: no, I don't think that Perl will ever adopt C's
"strings are just arrays of characters" approach. IMnsHO, that would be
a step in the wrong direction.
substr() produces a lvalue. Yes, you can assign _to_ a substr().
#!/usr/local/bin/perl -w
use strict;
my $string = "abcdefg";
substr($string,3,1) = 'Q';
print "string($string)\n";
substr($string,3,1) = chr 32;
print "string($string)\n";
substr($string,3,1) = chr 5 + ord 'a';
print "string($string)\n";
Of course, you can do much more than just that, try
substr($string, 0,3) = "HOWDY";
substr($string, -5) = '';
All of this is documented in "perldoc -f substr".
- doug
------------------------------
Date: Wed, 15 Oct 1997 23:28:54 -0400
From: Benjamin Holzman <bholzman@mail.earthlink.net>
To: Allen Choy <achoy@us.oracle.com>
Subject: Re: Trying to pass a file handle under strict mode
Message-Id: <344589F6.DF217E18@mail.earthlink.net>
Allen Choy wrote:
>
> Hi,
>
> I'm trying to pass a file handle to a function using strict mode,
> but I keep on getting a BAREWORD warning when I run the script
> with -wc options enabled. Adding the * to each file handle
> seems to do the trick, but is this the right way of doing it?
>
> Thanks--Allen
Yes and no. You should probably use the IO:: family of modules if
you're going to be passing filehandles around; they'll give you an OO
interface to files, sockets, etc...
------------------------------
Date: Thu, 16 Oct 1997 10:50:22 +0200
From: Doug Seay <seay@absyss.fr>
To: "Mark A. Lehmann" <mlehmann@prismnet.com>
Subject: Re: We're targets.
Message-Id: <3445D54E.46556C1A@absyss.fr>
[posted and mailed]
[followups redirected]
Mark A. Lehmann wrote:
>
> I typically only post to this news group. The email blasters tend to pick up
> my email from this newsgroup. Then I get all types of email enticing me to
> spend money and use my computer to do things that are either immoral, illegal,
> or annoying.
Yeah, they only seem to want to sell sex, pyramid schemes, multi-level
marketing, cable descramblers or software that lets you blast email the
same as they do. But this isn't too bad in the c.l.perl.* groups. Post
to news.admin.net-abuse.* to see how much crap you can really get.
> What are techniques that you are using to be able to effectively contribute
> to this news group and not be targeted for them e-trash? Is there another
> group that discusses anti-e-trash infiltration?
>
> Can we do something as a group to tell the companies searching for email
> address targets to stay out of our perl newsgroups?
The easiest thing to do is to "munge" your address to something
invalid. Then whenever someone harvests your address, they just get a
bunch of crap. Many people don't like munging (TomC being a well known
case) because it cuts down on the ease of regular communication. It is
one of those "personal choice" sorts of things. I don't like it, but I
understand the frustration level caused by all this UBE. Also, this
won't help against UBEers who already have your valid address.
The prefered solution is to use something like procmail and filter out
all this crap. Store it in some holding directory and once in a while
look for any false positives. You'd hate to miss something important
because of an over agressive filter.
The long term solution is to have society realize that this is wrong.
Junk faxes were outlawed, so junk email can be too (in the US at
least). There are a number of bills in the US Congress about this. The
Smith Bill being fairly popular in the news.admin.net-abuse.* groups
(this is where spam/abuses of all sorts are discussed/flammed/trolled).
There is also a group called CAUCE working to eliminate UBE of all sort,
but I don't keep up with them, so I don't know the details.
- doug
PS - This is way off-topic for a Perl group, so I set the follow-up to
news.admin.net-abuse.email. Posters in this group are often harvested
for UBE. You have been warned.
------------------------------
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 1184
**************************************