[7559] in Perl-Users-Digest
Perl-Users Digest, Issue: 1185 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Oct 16 11:17:22 1997
Date: Thu, 16 Oct 97 08:00:27 -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: 1185
Today's topics:
Re: Any plans for Min and Max operators? (Andy Wardley)
Re: Any plans for Min and Max operators? <jefpin@bergen.org>
Re: Anyone use Servlets? (Jeremy D. Zawodny)
Re: Background execution? (Jeremy D. Zawodny)
Re: Background execution? <thomas@javanet.com>
Re: Bitmap Images & GIF Files (Jeremy D. Zawodny)
Re: Cannot Use use (David Efflandt)
Re: Cannot Use use (Jeremy D. Zawodny)
Re: CGI scripts to access client hard drives <NOSPAMcornelio@home.com>
cgi-lib.pl + upload + special characters <eT@nanoteq.com>
Re: Coping with backslashes in Win32 Perl? (Scott McMahan)
Re: DB on UNIX system. (Jeremy D. Zawodny)
Difference between local and my with typeglobs (J%org Knappen)
Re: Grabbing Arguements from the cgi call.??? (Martien Verbruggen)
HELP hash o'arrays setup? <7seas@ibm.net>
Re: Help on comparing files (Tad McClellan)
Re: HEX question <seay@absyss.fr>
Re: HEX question <Kick@IT.net>
Re: How do I skip \, in a split /,/ (Toutatis)
Re: How do I skip \, in a split /,/ (Magnus Bodin)
Re: How to make a word bold? <NOSPAMcornelio@home.com>
Re: Is there an FAQ (Clay Irving)
Newbie problem with regex mark.johns@dawson.com
PERL : diff utility for NT <bryan_oconnell@ins.com>
Perl and SQL? <hartleh1@westat.com>
Perl Libraries (Burt Lewis)
Replacing special chars with special chars <eT@nanoteq.com>
Re: split() question (Mick Farmer)
Re: statics or const in perl ? <seay@absyss.fr>
Re: statics or const in perl ? <rootbeer@teleport.com>
Re: String manipulation in Perl (David Alan Black)
Re: win32/sockets (Jeremy D. Zawodny)
Re: Writing/Reading Bin Files (need example) <seay@absyss.fr>
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 16 Oct 1997 12:13:03 GMT
From: abw@cre.canon.co.uk (Andy Wardley)
Subject: Re: Any plans for Min and Max operators?
Message-Id: <EI58Lr.AGH@cre.canon.co.uk>
Jahwan Kim <jahwan@supernova.math.lsa.umich.edu> wrote:
>
> 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.
Yes they would. They would break any code that defined a function
called min() or max().
min() and max() were discussed a few months ago on the perl porters
mailing list, but the general consensus was to not include them in
the core for this very reason.
As has already been said, the best approach is to write a perl module
to do it.
A
--
Andy Wardley <abw@kfs.org> http://www.kfs.org/~abw
Signature lost in transit. We apologise for any inconvenience caused.
------------------------------
Date: Thu, 16 Oct 1997 08:00:57 -0400
From: TechMaster Pinyan <jefpin@bergen.org>
To: "Brett W. Denner" <Brett.W.Denner@lmtas.lmco.com>
Subject: Re: Any plans for Min and Max operators?
Message-Id: <Pine.SGI.3.95.971016075748.15086C-100000@vangogh.bergen.org>
>Are there any plans for Min and Max operators in Perl? I'm thinking of
>the >? and <? operators in gcc, which return the greater or lesser
>of two scalars. For example,
How about:
$b = 10;
$c = 13;
$a = gt($b,$c);
# $a is 13
sub gt {
my ($var1,$var2,$diff,$retval) = (shift,shift,0,0);
$diff = $var1 - $var2;
$retval = ($diff < 0 ? $var2 : $var1);
}
sub lt {
my ($var1,$var2,$diff,$retval) = (shift,shift,0,0);
$diff = $var1 - $var2;
$retval = ($diff > 0 ? $var2 : $var1);
}
----------------
| "A bird in the hand leaves a nasty stain."
| - Me
----------------
Jeff Pinyan | http://users.bergen.org/~jefpin | jefpin@bergen.org
webXS - the new eZine for WebProgrammers! TechMaster@bergen.org
Visit us @ http://users.bergen.org/~jefpin/webXS
** I can be found on #perl on irc.ais.net as jpinyan **
- geek code -
GCS/IT d- s>+: a--- C+>++ UAIS+>$ P+++$>++++ L E--->---- W++$
N++ !o K--? w>+ !O M>- V-- PS PE+ !Y !PGP t+ !5 X+ R tv+ b>+
DI+++ D+>++ G>++ e- h- r y?
------------------------------
Date: Wed, 15 Oct 1997 11:43:19 GMT
From: zawodny@hou.moc.com (Jeremy D. Zawodny)
Subject: Re: Anyone use Servlets?
Message-Id: <3444ac24.151189118@igate.hst.moc.com>
[cc'd automagically to original author]
On 14 Oct 1997 22:22:59 GMT, hc@toraix1.torolab.ibm.com (Chan) wrote:
>I was wondering if anyone here used Servlets instead of
>CGI Perl scripts.
>If so, why?
They might, but why would they discuss it in a Perl newsgroup, then?
You might have a better targeted audience if you check the Java or
comp.infosystems.www.servers* groups.
Jeremy
--
Jeremy Zawodny
Internet Technology Group
Information Technology Services
Marathon Oil Company, Findlay Ohio
http://www.marathon.com/
Unless explicitly stated, these are my opinions only--not those of my employer.
------------------------------
Date: Thu, 16 Oct 1997 12:12:57 GMT
From: zawodny@hou.moc.com (Jeremy D. Zawodny)
Subject: Re: Background execution?
Message-Id: <34470498.239369244@igate.hst.moc.com>
[cc'd automagically to original author]
On Thu, 16 Oct 1997 05:53:27 GMT, a00lcj00@mail.dt.nchc.gov.tw (George
Lin) wrote:
>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?
Though it's not a Perl question and doesn't belong in this newsgroup,
I'll give you a hint. Look in your on-line docs for "start" and you'll
probably find what you're looking for.
Jeremy
--
Jeremy Zawodny
Internet Technology Group
Information Technology Services
Marathon Oil Company, Findlay Ohio
http://www.marathon.com/
Unless explicitly stated, these are my opinions only--not those of my employer.
------------------------------
Date: Thu, 16 Oct 1997 08:26:51 -0400
From: Mike Thomas <thomas@javanet.com>
Subject: Re: Background execution?
Message-Id: <3446080A.12CEDA7@javanet.com>
George Lin wrote:
> 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
Code like the following works for me:
use Win32::Process;
$cmd = "c:\\cron.bat";
Win32::Process::Create($child,$cmd, $cmd, 0, DETACHED_PROCESS,".");
Cheers,
...Mike
--
------------------------------------------------------------------
Mike Thomas Direct Line / Fax: (413)967-7610
Rarebit Digital Solutions Inc. E-mail: thomas@javanet.com
------------------------------
Date: Thu, 16 Oct 1997 12:11:35 GMT
From: zawodny@hou.moc.com (Jeremy D. Zawodny)
Subject: Re: Bitmap Images & GIF Files
Message-Id: <344603ee.239198539@igate.hst.moc.com>
[cc'd automagically to original author]
On Thu, 16 Oct 1997 01:07:01 -0400,
fenris@-REMOVETHIS-memphisonline.com wrote:
>I have two questions:
>Are Bitmap Files (like those used in page counters) the same as .BMP?
Maybe. The author can decide among several graphics formats s/he'd
like to use for counters. Check the file extension on the graphic in
question and see.
>And are there any docs out there for converting such files into .GIF
>format thru perl? (Or even general docs would work)
Uhm, if someone has written a module to do such a task, you're likely
to find it on CPAN.
Jeremy
--
Jeremy Zawodny
Internet Technology Group
Information Technology Services
Marathon Oil Company, Findlay Ohio
http://www.marathon.com/
Unless explicitly stated, these are my opinions only--not those of my employer.
------------------------------
Date: Thu, 16 Oct 1997 09:07:54 GMT
From: efflandt@xnet.com (David Efflandt)
Subject: Re: Cannot Use use
Message-Id: <344ed748.9804385@flood.xnet.com>
Rick <rbrewer@ccmail.dsccc.com> wrote:
>Hello,
> I am trying to make use of Perl modules but cannot get "use"
>to find the modules. Even when adding the command:
>push (@INC, "/usr/local/perl/lib");
>then
>use Carp;
>
> I still get the same error:
>Can't locate Carp.pm in @INC at test.pl line 14.
>BEGIN failed--compilation aborted at upload.pl line 14.
> I have read through the FAQ, Perl manpages, and am fixing to buy
>another book but suspect I have some small item out of place.
>
>Any suggestions would be appreciated,
>Rick
That is because the preprocessor processes any 'use' statements before
it processes the script. And the push statement is not interpretted
until then. Try:
use lib "/usr/local/perl/lib";
use Carp;
But isn't Carp.pm a standard module that should already be in a
default @INC path?
David Efflandt/Elgin, IL USA
efflandt@xnet.com http://www.xnet.com/~efflandt/
------------------------------
Date: Wed, 15 Oct 1997 11:45:47 GMT
From: zawodny@hou.moc.com (Jeremy D. Zawodny)
Subject: Re: Cannot Use use
Message-Id: <3445ac7d.151278036@igate.hst.moc.com>
[cc'd automagically to original author]
On Tue, 14 Oct 1997 16:09:43 -0700, Rick <rbrewer@ccmail.dsccc.com>
wrote:
> I am trying to make use of Perl modules but cannot get "use"
>to find the modules. Even when adding the command:
>push (@INC, "/usr/local/perl/lib");
>then
>use Carp;
>
> I still get the same error:
>Can't locate Carp.pm in @INC at test.pl line 14.
>BEGIN failed--compilation aborted at upload.pl line 14.
> I have read through the FAQ, Perl manpages, and am fixing to buy
>another book but suspect I have some small item out of place.
>
>Any suggestions would be appreciated,
How about:
#!/usr/local/bin/perl
BEGIN { push(@INC, "/usr/local/perl/lib"; }
Jeremy
--
Jeremy Zawodny
Internet Technology Group
Information Technology Services
Marathon Oil Company, Findlay Ohio
http://www.marathon.com/
Unless explicitly stated, these are my opinions only--not those of my employer.
------------------------------
Date: Thu, 16 Oct 1997 06:08:45 -0700
From: Michael Cornelio <NOSPAMcornelio@home.com>
To: praveen_s@trigent.com, praveen_s@trigent.com
Subject: Re: CGI scripts to access client hard drives
Message-Id: <344611DD.7437B822@home.com>
The short answer to your question is NO. That is, browsers in general
do not allow CGI scripts to read or write files on the client's drives.
This is a security precaution on the browser's part.
That said, there are ways that will allow your client to upload a file
to your server by specifying the file and, there are ways for your
client to save a file that you provide.
You can examine this file for information ...
http://search.netscape.com/eng/mozilla/Gold/relnotes/win32.html
The salient part that may be of interest to regarding uploading
of files to a web/ftp server is ...
-----(snip)-----
Access Improvements
Method 1.
HTTP File Upload:Previously, form input was limited to input boxes
and other simple elements like checkboxes and radio buttons. Now you
can write forms that ask for files as input, as described in the
IETF Internet Draft.
A new "ENCTYPE" attribute on the <FORM> tag allows you to write
forms that take files as input. An example of such a form would be:
<FORM ENCTYPE="multipart/form-data" ACTION="_URL_" METHOD=POST>
Send this file: <INPUT NAME="userfile" TYPE="file">
<INPUT TYPE="submit" VALUE="Send File">
</FORM>
Method 2.
FTP file upload: A new menu item is activated when you are browsing
FTP directories. Choose File | Upload File... and you will get a dialog
that asks you to choose a file to upload to the FTP server. You can
also
do this by dragging a file (or multiple files) from the File
Manager/Explorer,
to an FTP directory listing in the Netscape Window. Note: You need to
have write permission on the server where you are uploading the
file(s).
-----(snip)-----
Oh ... and one caveat ... I think this only works with Netscape
Regarding downloading (or saving) of files, on the client's hard drive,
the standard dialog box for saving is always presented whenever you
download
a file, so it seems redundant to provide another one.
One other solution presents itself, and that is to write a Java
application
that is downloaded to the client's drive then run directly from the
drive.
At that point, the Java application can read/write the local drive as
well
as access a remote URL on any HTTP or FTP or other TCP/IP daemon on a
remote
machine ...
The primary relationship of your question to this newsgroup is in how a
CGI
script can process the TYPE='file' input type on the server side.
You may want to read http://www.ics.uci.edu/pub/ietf/html/rfc1867.txt to
find an answer ...
As they say ... hope this helps ...
Michael Cornelio
praveen_s@trigent.com wrote:
>
> I am looking for help on Perl CGI scripts or mechanisms to pop up a
> file
> dialog box, read the selected file which resides on the clients hard
> drive and pass the data to the server for processing. Can this be done
> using Perl and HTML only? (Without any client side scripting).
>
> This also holds good for saving, say a text file on the clients hard
> drive.
>
> Responses will be helpfull in solving the above problem
>
> Thanks,
> Praveen
>
> -------------------==== Posted via Deja News ====-----------------------
> http://www.dejanews.com/ Search, Read, Post to Usenet
--
---------------------------------------------------
Michael Cornelio
I can eat SPAM, but don't like to read the stuff.
Remove NOSPAM from my email address to reply to me.
------------------------------
Date: Thu, 16 Oct 1997 11:59:13 +0200
From: eT <eT@nanoteq.com>
Subject: cgi-lib.pl + upload + special characters
Message-Id: <3445E571.C5356519@nanoteq.com>
Greets, i am using cgi-lib.pl as the cgi which receives
the upload files (sent from the browser). The special
chars seem to be translated to their \x values and stored.
Is there a way in which i can have the special characters
saved as the special characters and not have them converted
to \x?
Thanks
eT
------------------------------
Date: 16 Oct 1997 13:46:25 GMT
From: scott@lighthouse.softbase.com (Scott McMahan)
Subject: Re: Coping with backslashes in Win32 Perl?
Message-Id: <6255rh$e6h$1@mainsrv.main.nc.us>
:I'm writing some maintainance scripts using Win32 Perl for our Netware
:servers, which means I have to dereference all the backslashes when
:referring to directory paths (i.e. I have to use '\\\\fs1\\sys\\foo'
:instead of just '\\fs1\sys\foo')
Unless you are calling external programs which can't swallow
forward slashes, you do not need to use backslashes. Internally,
Windows can handle either. It is only the (default) command shell that
can't.
: My problem is with a subroutine which parses a list of pathnames,
: read from a user-maintained text file. The program chokes if I don't
: dereference the backslashes, and I'd rather not make the
: (perl-illiterate) users have to deal with the ugly syntax.
Okay, so just subsititute / for \ before processing. I don't know why
Perl is choking on these, since strings read from a file shouldn't be
interpolated anyway for escapes. Otherwise, any string you read
from a file with an @ in it would crash Perl.
Scott
PS: hint, type a UNIX path into Internet Explorer sometime.
file://g:/foo/bar/baz.html. Works like a charm.
------------------------------
Date: Thu, 16 Oct 1997 12:14:14 GMT
From: zawodny@hou.moc.com (Jeremy D. Zawodny)
Subject: Re: DB on UNIX system.
Message-Id: <344804e6.239446936@igate.hst.moc.com>
[cc'd automagically to original author]
On Thu, 16 Oct 1997 01:20:16 -0700, Amy Dorsett <adorsett@gonzaga.edu>
wrote:
>I was wondering if anyone knew if it was possible to use an Open Database
>Connectivity (ODBC) with a UNIX system??
In Perl, or in general?
If it's possible in general, it ought to be possible in Perl. So I
guess you should ask some Unix database folks if it can be done. Then
you'll have your answer and it'll be a matter of finding (or
developing) a module that can do it.
Jeremy
--
Jeremy Zawodny
Internet Technology Group
Information Technology Services
Marathon Oil Company, Findlay Ohio
http://www.marathon.com/
Unless explicitly stated, these are my opinions only--not those of my employer.
------------------------------
Date: 16 Oct 1997 10:05:59 GMT
From: knappen@iphcip1.Physik.Uni-Mainz.DE (J%org Knappen)
Subject: Difference between local and my with typeglobs
Message-Id: <624ou7$qnh$1@esmeralda.zdv.Uni-Mainz.DE>
I just stumbled over the following:
#! /usr/local/bin/perl
sub sprod{
local (*x,*y)=@_; # in this line, local works, but my causes an error
my ($sum)=0;
my $final=min(scalar(@x),scalar(@y));
my $i=0;
while($i<$final){
$sum = $sum+$x[$i]*$y[$i];
$i++;}
return $sum;}
The error message is:
[knappen@micky] sprod.pl
Can't declare ref-to-glob cast in my at ./sprod.pl line 4, near ")="
I have read the descriptions of local and my in the blue camel book,
but didn't see why this behaviour occurs.
The installed perl version is:
This is perl, version 5.003 with EMBED
built under dec_osf at Jul 5 1996 17:25:44
+ suidperl security patch
--J"org Knappen
------------------------------
Date: 13 Oct 1997 02:35:24 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Grabbing Arguements from the cgi call.???
Message-Id: <61s1dc$r7v$1@comdyn.comdyn.com.au>
In article <343986A8.6F3FC14A@well.com>,
Jack Stockholm <sphe@well.com> writes:
> Does anyone have an example of a script which uses an arguement as a
> variable?
use CGI.pm, perldoc CGI will give you the documentation, and some example
code.
> Please reply to sphe@well.com
post here, read here.
> as the {NOSPAM} in my reply to address will not work.
What NOSPAM?
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | I took an IQ test and the results were
Commercial Dynamics Pty. Ltd. | negative.
NSW, Australia |
------------------------------
Date: Thu, 16 Oct 1997 09:47:51 -0400
From: BetaMan <7seas@ibm.net>
Subject: HELP hash o'arrays setup?
Message-Id: <34461B07.48A5@ibm.net>
hello all;
I'm looking for some advice in handling a simple hash of arrays.
Problem is that the examples given on p267 of Programming Perl
deal with a database unlike any I have seen; namely one with
uneven field separators. My software handles only uniform record
separators (normally a return) and only uniform field separators
(normally tab, |, or comma). I prefer |'s or tabs.
I'm trying to make these examples work:
while (<>) {
next unless s/^(.*?):\s*//; # some comments here would have
helped
$HoL{$1} = [ split ]; # and here
}
foreach $family ( keys %HoL) {
print "$family: @{$HoL{$family}} \n";
}
involving a flatfile such as:
index1|field2|field3
index2|field2|fields3
index3|field2|field3
I think I understand the concept in that in involves a hashlist pointing
to the arrays consisting of the 'other 2 fields'. I would have thought
that
these arrays would include all the fields regardless of the contents
of the hashlist (even if it means duplication) and not just the 'other
fields'
as that would seem to make it easier to handle uniform separators.
This is not a problem so long as I can later access all data one way
or another.
As is, if I just substitute a '|' for the ':' (trying anything) in
the example then
the print shows all of but only the last record and beginning with a
':' i.e.
: index3|field2|field3
Thanks in advance for any suggestions. This is a neat formulation in
that it facilitates 'multidimentional hasharrays', if only I can set it
up.
cheers,
--
-|- Who, has loved us more? -|-
============================================
Please replace 7 with Seven in 7seas@ibm.net
============================================
------------------------------
Date: Thu, 16 Oct 1997 07:13:52 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Help on comparing files
Message-Id: <0e0526.mn.ln@localhost>
Wei Tang (wtang@cs.ualberta.ca) wrote:
: 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.
So, you have two sets (elements of each set are lines), and you
want to compute the set difference?
Perl FAQ, part 4:
"How do I compute the difference of two arrays?
How do I compute the intersection of two arrays?"
--
Tad McClellan SGML Consulting
tadmc@flash.net Perl programming
Fort Worth, Texas
------------------------------
Date: Thu, 16 Oct 1997 11:25:43 +0200
From: Doug Seay <seay@absyss.fr>
To: Kick@IT.net
Subject: Re: HEX question
Message-Id: <3445DD97.1853C94F@absyss.fr>
[posted and mailed]
Kick Fronenbroek 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 ?
>
> @classearray = (0x00..0xFF);
> $classe = $classearray[int(rand(@classearray))];
> print $classe;
perldoc -f printf
------------------------------
Date: Thu, 16 Oct 1997 11:55:54 -0700
From: Kick Fronenbroek <Kick@IT.net>
Subject: Re: HEX question
Message-Id: <3446633A.5936@IT.net>
Hello, I got some replies via mail (it should also be in the newsgroup
(but I still do not see them)) that I should use printf.
Kick Fronenbroek 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 ?
>
> @classearray = (0x00..0xFF);
> $classe = $classearray[int(rand(@classearray))];
> print $classe;
However, I need the hex code in a variable and (as far as I know) I
cannot give the output of printf to a variable.
I have solved this with the following code. I cannot believe this is the
best solution:
----
### The following code is only to get the values in HEX and not in
# hecimal values.
# For each value in @classearray:
open(hexfile,"/usr/local/home/users/staff/kick/perl/hex.file") || die
"Couldn't open file: $!\n";
foreach $value (@classearray) {
printf hexfile "0x%02X\n", $value;
}
close(hexfile);
...
open(hexfile,"/usr/local/home/users/staff/kick/perl/hex.file") || die
"Couldn't open file: $!\n";
while(<hexfile>) {
chop;
push(@hexclassearray, $_);
}
close(hexfile);
### END of special code for HEX values.
---
When I now print $classe (see below), I get the expected result (for
instance: 0x1B).
> $classe = $hexclassearray[int(rand(@hexclassearray))];
> print $classe;
I sthis realy the best way to accomplish this ?
Thanks in advance,
Kick Fronenbroek
------------------------------
Date: 16 Oct 1997 09:27:44 GMT
From: toutatis@_SPAMTRAP_toutatis.net (Toutatis)
Subject: Re: How do I skip \, in a split /,/
Message-Id: <toutatis-ya023180001610971127450001@news.euro.net>
Jeremy D. Zawodny wrote:
> Rick Delaney wrote:
>
> >Toutatis wrote:
> >
> >> $line = 'xxxx,xx\,xx,xxxx'
> >> How do I split this line into three fields, omitting the escaped comma?
> >>
> >> --
> >
> >split /\b,/, $line;How you would do the more generic case where the x's
> >weren't necessarily \w's, I have no idea. Anyone?
>
> Depending what one means by "omit", maybe:
>
> split(/[^x]\,/, $line);
>
> or something to that effect. :-)
Two *working* solutions for this interesting problem have been posted in
this same thread by Brendan O'Dea (hide and restore the escapes) and Tad
McClellan (reverse the string, then use negative lookahead).
Check dejanews if your newsserver has droppped these articles.
--
Toutatis
------------------------------
Date: 16 Oct 1997 09:56:13 GMT
From: mnemoni@aristotle.algonet.se (Magnus Bodin)
Subject: Re: How do I skip \, in a split /,/
Message-Id: <624obt$evt$1@cubacola.tninet.se>
Ty Cage Warren (tycage@infi.net) wrote:
: Toutatis wrote:
: > $line = 'xxxx,xx\,xx,xxxx'
: > How do I split this line into three fields, omitting the escaped comma?
: Try
:
: $line = 'xxxx,xx\,xx,xxxx';
: @fields = split(/[^\\],/,$line);
: The /[^\\],/ means match anything that isn't a literal \ followed by a
: comma.
It will fail on empty fields, though.
------------------------------
Date: Thu, 16 Oct 1997 06:09:09 -0700
From: Michael Cornelio <NOSPAMcornelio@home.com>
Subject: Re: How to make a word bold?
Message-Id: <344611F5.815EBF5A@home.com>
If you are bolding text in HTML, try ...
$paragraph =~ s#$word#<b>$word</b>#gs;
John Robson wrote:
>
> How do you make a word or pattern *bold* by using the substitution.
> Is it possible to do this in Perl?
--
---------------------------------------------------
Michael Cornelio
I can eat SPAM, but don't like to read the stuff.
Remove NOSPAM from my email address to reply to me.
------------------------------
Date: 16 Oct 1997 09:59:04 -0400
From: clay@panix.com (Clay Irving)
Subject: Re: Is there an FAQ
Message-Id: <6256j8$d05@panix.com>
In <3444E83E.41C6@mh.uk.sbphrd.com> "Naseem . Ramsahye" <ramsan00@mh.uk.sbphrd.com> writes:
>Can anyone please point me to an FAQ on using/installing PERL with
>DOS/Win3.2 Win95.
This is one place to look: http://reference.perl.com/query.cgi?windows
--
Clay Irving <clay@panix.com> http://www.panix.com/~clay/
------------------------------
Date: Thu, 16 Oct 1997 09:41:19 -0600
From: mark.johns@dawson.com
Subject: Newbie problem with regex
Message-Id: <877012651.18916@dejanews.com>
I hope this is the correct place to go with this. I don't want to clutter
up p5p with a question that is likely just my ignorance.
I want to search for particular paths in perl scripts, and insert a a
directory into the middle of the path.
I am using the following script, which doesn't work.
#!/opt/gnu/bin/perl -w -i.bak
use diagnostics;
s|(http://www.foo.com/)|$&test_zone/$'|;
s|(/export/bar/htdocs/)|$&test_zone/$'|;
I get the following errors:
$ ../munge_test.pl test_munger.pl
Use of uninitialized value at ../munge_test.pl line 24 (#1)
(W) An undefined value was used as if it were already defined. It was
interpreted as a "" or a 0, but maybe it was a mistake. To suppress
this
warning assign an initial value to your variables.
Use of uninitialized value at ../munge_test.pl line 25 (#1)
I am using, as a model, the example from Camel p.332, for the -i option.
What am I doing wrong?
-TIA
-Mark
=========================================================
Mark Johns, Quality Books, Inc. - " A Dawson Company "
mailto://mark.johns@dawson.com
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- --
mailto://johnsms@ix.netcom.com << Home
http://www.netcom.com/~johnsms/index.html << Addresses
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- --
Opinions expressed are my own, such as they are.
They are not those of Dawson, Inc. or Quality Books.
=========================================================
-------------------==== Posted via Deja News ====-----------------------
http://www.dejanews.com/ Search, Read, Post to Usenet
------------------------------
Date: Thu, 16 Oct 1997 09:02:46 -0400
From: Bryan OConnell <bryan_oconnell@ins.com>
Subject: PERL : diff utility for NT
Message-Id: <34461076.6550@ins.com>
I need a good UNIX-like diff utility for completing "diff -c" (unix
equiv) on text files from within a PERL script on a Windows NT 4.0 box.
Any suggestions?
thanx.
bryan.
------------------------------
Date: Thu, 16 Oct 1997 10:32:37 -0400
From: Henry Hartley <hartleh1@westat.com>
Subject: Perl and SQL?
Message-Id: <34462585.EDFDBBBB@westat.com>
I am relatively new to Perl but wanted to write some scripts to lookup,
modify, etc. records in an SQL database. I've managed to write a script
that will add records to the database but I'm not really sure about
getting data back out. I've been searching for anything documenting
this (SQL in Perl) but can't seem to find much. Any pointers, URLs or
other resources (online or not) would be appreciated.
Henry Hartley
Westat
------------------------------
Date: 16 Oct 1997 13:54:38 GMT
From: burt@ici.net (Burt Lewis)
Subject: Perl Libraries
Message-Id: <6256au$pam$1@bashir.ici.net>
I'm having a difficult time understanding how libraries work with Perl/Unix.
Some questions:
1. Do they all need to be installed?
I don't have acces to do that, so can I just put them in my cgi-bin
directory?
2. Is there a FAQ on libraries?
3. What is the difference between .pl and .pm
4. Why sometimes "USE xxx.pm" and sometimes "require xxx.pm"
5. How do I know what existing libraries are installed on my system?
Appreciate any help on this
Burt Lewis
burt@ici.net
www.eastonmass.com
------------------------------
Date: Thu, 16 Oct 1997 13:40:25 +0200
From: eT <eT@nanoteq.com>
Subject: Replacing special chars with special chars
Message-Id: <3445FD29.3BD9938A@nanoteq.com>
I would like to run through a file and replace a set of
special chars (i only have the hex values) with other
special chars..
trying to overcome the windows special char codes and
the unix special char codes difference.
eT
------------------------------
Date: Thu, 16 Oct 1997 13:44:05 GMT
From: mick@picus.dcs.bbk.ac.uk (Mick Farmer)
Subject: Re: split() question
Message-Id: <EI5CtH.47r@mail2.ccs.bbk.ac.uk>
Dear Richard,
You don't say whether the number 11 is in a fixed
position. However, the following will collect all your
fields into an array. You can then extract he element you
want.
@fields = split / +/, $input_record;
Regards,
Mick
------------------------------
Date: Thu, 16 Oct 1997 11:16:54 +0200
From: Doug Seay <seay@absyss.fr>
Subject: Re: statics or const in perl ?
Message-Id: <3445DB86.7C4DB7ED@absyss.fr>
dave wrote:
>
> But I do have an underlying concern about the growth of Perl modules and my
> work group's ability to keep up with them. I guess I feel the need to only
> adopt the modules that have a big impact.
True that there are lots of modules, so trying to keep up-to-date is
hitting a moving target. Personally, I don't bother with it. When I
upgrade perl itself, I get the latest and greatest of each module that
I'm using. Otherwise I just upgrade for bug fixes or new
functionality. Perhaps CPAN works too well.
But the module in question is a core module (it comes with the standard
distribution), so I wouldn't hestitat using it. Not only has it been
fairly well tested, any bugs are sure to get quick attention. That and
because it is one of Tom Phoenix's, you can ask the author about any
problems very easily.
> My group is almost exclusively HPUX, ANSI C and ksh scripts. I have recently
> implemented a user interface/test setup language using Perl and the Tk module.
> I started with 5.002 and upgraded to 5.004. I got egg on my face when, in
> front of a co-worker, the FileHandle module appeared (in perldoc) to be
> superceded by the IO module, right after I told him how great I thought
> FileHandle was.
I used FileHandle after IO::File came out. It wasn't until I needed to
do new socket stuff that I started using IO::Socket. After this it
seemed natural to use IO::File, but I haven't bothered changing the old
stuff. It works.
> I should have kept up a little better, but even if I had, it's a pretty scary
> thought to a lot of people that things can change so drastically between
> "minor" releases. And if a lot of the change can be eliminated by not adopting
> every new module, well ...
I wouldn't call 5.002 vs 5.004 minor. For me, when that second digit
changes, it is time to upgrade. When the first digit changes, it is
time to buy a new edition of the Camel :-)
- doug
------------------------------
Date: Thu, 16 Oct 1997 07:53:17 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Doug Seay <seay@absyss.fr>
Subject: Re: statics or const in perl ?
Message-Id: <Pine.GSO.3.96.971016063903.20497I-100000@usertest.teleport.com>
On Wed, 15 Oct 1997, Doug Seay wrote:
> dave wrote:
>
> > perldoc constant
> >
> > There are numerous cautions on use of them. I'm just wondering if they
> > provide enough benefit to warrant the additional complication?
>
> As far as I'm concerned, they rival sliced bread.
Thank you! :-)
I did document a number of "bugs" in the constant module, on the principle
that it's better to be upfront about the shortcomings - and anything has
shortcomings. (Perl's own manpage is the same way.)
Perhaps I could also have documented the shortcomings of other methods for
making constants. For example, in this code...
*FIVE = \5;
*FOUR = \4;
for (@list) {
$_ += $FOUR + $FIVE;
}
...the compiler has to add up $FOUR and $FIVE every time through the loop;
in general, it can't do constant folding. Or in this...
*DEBUGGING = \0;
if ($DEBUGGING) {
...
}
The code inside the block is compiled, then skipped at runtime.
Whereas, in this...
use constant DEBUGGING => 0;
if (DEBUGGING) {
...
}
The code in the block causes no runtime overhead.
"True" constants (from constant.pm) are better in those ways, at least.
Cheers!
--
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/
Ask me about Perl trainings!
------------------------------
Date: 16 Oct 1997 14:17:31 GMT
From: dblack@icarus.shu.edu (David Alan Black)
Subject: Re: String manipulation in Perl
Message-Id: <6257lr$d29@pirate.shu.edu>
zawodny@hou.moc.com (Jeremy D. Zawodny) writes:
>[cc'd automagically to original author]
>On 15 Oct 1997 10:56:49 -0500, John Goerzen
><jgoerzen+usenet@complete.org> wrote:
>You posted this to comp.lang.perl.misc, which is a dead newsgroup (and
>has been for a couple years). Please notify your news server
>administrator so that s/he can remove it.
Unless there's been a secret reorganization, clpm is still alive.
David Black
dblack@icarus.shu.edu
------------------------------
Date: Wed, 15 Oct 1997 11:48:26 GMT
From: zawodny@hou.moc.com (Jeremy D. Zawodny)
Subject: Re: win32/sockets
Message-Id: <3446acfe.151406811@igate.hst.moc.com>
[cc'd automagically to original author]
On Tue, 14 Oct 1997 19:33:16 -0500, Paul Walker <pwalker@email.net>
wrote:
Out of curiosity, how many times to you plan on posting this question?
According to my news server, you're already up to four. :-(
>Ok, I give. I have a script that when run interactivly (eg via a cmd window or
>telnet session)
>to my NT box(s), correctly allocates a port and waits patiently for a
>connection. Ala tcp-srv
>in the distribution (activeware 5.003_007 build 307). Sooo, sockets do work
>on both my NT3.51 and NT4.0 servers. However, when I call the script via
>the w3c jigsaw web server as a cgi script, it fails to allocate. Mainly because
>the getprotobyname() and other like functions seem to fail...hence you can not
>allocate/bind to the socket.
There was some flaky socket stuff in the 30? build series from
ActiveState. Have you tried build 110 or 111? Build 110 fixed a lot of
socket-related glitches on my system.
YMMV.
Jeremy
--
Jeremy Zawodny
Internet Technology Group
Information Technology Services
Marathon Oil Company, Findlay Ohio
http://www.marathon.com/
Unless explicitly stated, these are my opinions only--not those of my employer.
------------------------------
Date: Thu, 16 Oct 1997 11:25:06 +0200
From: Doug Seay <seay@absyss.fr>
Subject: Re: Writing/Reading Bin Files (need example)
Message-Id: <3445DD72.5CFE6298@absyss.fr>
Andrew M. Langmead wrote:
> unpack("A$namelenX$namepaddinglenLLLLLLA$reservedlen", $buffer);
^^^
shouldn't this X be lower case?
You should use ${variable} to avoid names running together with packing
letters, and perhaps some white space to make it readable.
- doug
------------------------------
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 1185
**************************************