[18912] in Perl-Users-Digest
Perl-Users Digest, Issue: 1080 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jun 7 03:05:50 2001
Date: Thu, 7 Jun 2001 00:05:15 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <991897514-v10-i1080@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Thu, 7 Jun 2001 Volume: 10 Number: 1080
Today's topics:
[ANNOUNCE] Perl Guru and Author to Speak in Toronto, On <tpm.NOSPAM@to.pm.NOSPAM.org>
Re: Best way to do this? <bcoon@sequenom.com>
Re: Binary files, any suggestions? (David Efflandt)
Re: Binary files, any suggestions? <gamtci@mpinet.net>
Re: Calling programs from a cgi (David Efflandt)
Re: Calling programs from a cgi (E.Chang)
Re: Date of Halloween (for Date::Calc module)? <pne-news-20010607@newton.digitalspace.net>
Re: Flame,help or killfile ? <pne-news-20010607@newton.digitalspace.net>
Re: format/write with alternate linefeeds ? <pne-news-20010607@newton.digitalspace.net>
Re: GROUP TAKEOVER IN PROGRESS (krakle)
Re: GROUP TAKEOVER IN PROGRESS <whisper@oz.nospamnet>
Re: Having a difficult time expanding file names - Than <mondotrasho@home.com>
Re: How does Perl handle multiple users? <mischief@velma.motion.net>
Re: Is this Perl??? (Bernard El-Hagin)
Need help parsing data <zydas@home.com>
Re: Newb needs help with input from forms (Jon Bell)
Re: Newbie: $ character end string? What is wrong? <pne-news--20010607@newton.digitalspace.net>
Re: Perl is dead! Long live Perl! (krakle)
Re: Perl Tattoo <pne-news-20010607@newton.digitalspace.net>
regular exp replacement question <keng@spinalfluid.com>
Re: Required or executed? <skilchen@swissonline.ch>
Re: taint + netstat = error <joe+usenet@sunstarsys.com>
Re: The FlakeyMind Thaddes FAQ (v0.1) <Attila.Feher@lmf.ericsson.se>
Re: Urgent : control code sequences?!?! <pne-news-20010607@newton.digitalspace.net>
Re: variable in variable name (Tad McClellan)
Re: variable in variable name (Damian James)
WebForm Processing With 2 File Attachments - Script <citrusoft@lycos.com>
When renaming files is this agood idea to flock them ? <helpmeplese@helpmeplese.com>
Re: When renaming files is this agood idea to flock the <buggs-clpm@splashground.de>
Re: When renaming files is this agood idea to flock the (Zeljko Vrba)
Re: xterm backspace character? (David Efflandt)
Re: xterm backspace character? r1ckey@home.com
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 07 Jun 2001 05:40:05 GMT
From: "TPM" <tpm.NOSPAM@to.pm.NOSPAM.org>
Subject: [ANNOUNCE] Perl Guru and Author to Speak in Toronto, Ontario.
Message-Id: <VsET6.35369$W02.517490@news1.rdc2.on.home.com>
Keywords: Toronto Perl
If you are interested in Perl the programming language, and you will be in
Toronto, Ontario, Canada, in mid-June, you may like to know:
Damian Conway will be presenting two lectures in Toronto on June 17th and
June 18th.
These lectures are open to the public.
June 17th (Sunday afternoon): Univerity of Toronto, Sanford Flemming (10
King's College Road).
Room 1105 (aka. The Blue Room, seats 159 )
1500-1730 hours
June 18th (Monday evening): Seneca@York, York University Campus.
Room 1206 (seats 160)
1900-2200 hours
More information, including the subject of the lectures and maps of the
campuses, is available at:
http://to.pm.org/talks.html
Damian is a senior lecturer at Monash University in Australia, is the author
of "Object Oriented Perl", an excellent and noteworthy book
(http://www.manning.com/Conway/), and is currently on sabbatical as the
programmer in residence for the Perl community at large (vide the Conway
channel at http://yetanother.org/damian/). You can visit Damian online at:
http://www.csse.monash.edu.au/~damian/
On behalf of
The Toronto Perl Mongers
------------------------------
Date: Wed, 06 Jun 2001 18:54:33 -0700
From: BCC <bcoon@sequenom.com>
Subject: Re: Best way to do this?
Message-Id: <3B1EDED9.A202B81F@sequenom.com>
> And what were the solutions???
>
> Point being, that you should summarise the answers in your reply. Remember
> that not everyone has been following the thread, so I've potentially missed
> out on some useful information.
For those that engage in shotgun method newspost reading :) :
The question was how to build the @align array:
@array = (1, 0, 0, 0, 2, 2, 0, 0, 3, 0, 4, 0, 0, 0);
@align = ("A", "A", "A", "A", "B", "B", "B", "B", "A", "A", "B", "B",
"B", "B");
Where the logic assigns the same switch for any value and anything that
follows it that is either an equal value or a 0. And the switch
alternates....
The solutions were:
@switch = qw(B A);
@array = (1, 0, 0, 0, 2, 2, 0, 0, 3, 0, 4, 0, 0, 0);
@align = ();
push @align, $_ ? $x = $switch[ $_ % 2 ] : $x for @array;
and:
my @array = qw(1 0 0 0 2 2 0 0 3 0 4 0 0 0);
my @switch = qw(A B);
my @align;
push @align, $switch[0];
foreach (1 .. $#array) {
@switch = reverse @switch
if $array[$_] > 0 && $array[$_] != $array[$_ - 1];
push @align, $switch[0];
}
------------------------------
Date: Thu, 7 Jun 2001 01:42:05 +0000 (UTC)
From: see-sig@from.invalid (David Efflandt)
Subject: Re: Binary files, any suggestions?
Message-Id: <slrn9htmvd.c8f.see-sig@typhoon.xnet.com>
On Wed, 06 Jun 2001 22:47:23 GMT, Gary <gamtci@mpinet.net> wrote:
> I have a need to read and write binary files (no expectation
> of any sensible text in them). I'm new to perl, although I've
> finished the Perk/Tk aspect of the program and it works fine.
>
> I've gone through several of my Perl books and there's really
> never any information on dealing with strictly binary files.
> I found "binmode" which I plan to use.
>
> I was wondering if there are any hints or suggestions before I go
> and write this program 15 times before finally figuring it out.
> The data in the files are strings and single chars of binary data,
> some ASCII strings, and 32-bit and 16-bit integers.
On a system with Perl type:
perldoc -f binmode
--
David Efflandt (Reply-To is valid) http://www.de-srv.com/
http://www.autox.chicago.il.us/ http://www.berniesfloral.net/
http://cgi-help.virtualave.net/ http://hammer.prohosting.com/~cgi-wiz/
------------------------------
Date: Thu, 07 Jun 2001 02:14:48 GMT
From: Gary <gamtci@mpinet.net>
Subject: Re: Binary files, any suggestions?
Message-Id: <3B1EE3E2.4456@mpinet.net>
Yes, thanks, I saw that. I was refering to any less obvious
potential "gotchas" of working on strictly binary data.
On input and output to the file I intend to use binmode. But,
I'm not that familiar with the internal workings of Perl.
Particularly in the area of its "context-sensitive" interpretation
of variables, I was curious if anyone had any tips on "things
known to fail", "never do" or "always do" type items.
------------------------------
Date: Thu, 7 Jun 2001 01:49:37 +0000 (UTC)
From: see-sig@from.invalid (David Efflandt)
Subject: Re: Calling programs from a cgi
Message-Id: <slrn9htndh.c8f.see-sig@typhoon.xnet.com>
On 6 Jun 2001 15:22:54 -0700, Igal Corcos <corcos@metalink.com> wrote:
> Hi,
>
> Can anyone tell me how to call another program from a cgi script.
> For example, I have a program in my /bin directory that I want to call
> from a cgi script.
>
> I've tried the system(LIST) command but this does not seem to work. I
> get an error saying my program did not produce a valid http header.
This question is not Perl specific since the general answer is the same
regardless of programming language and likely covered by the CGI FAQ in
the *.cgi newsgroup.
Print a valid http header before running your external program. The last
header line should end with a blank line (or double newline). For example
if the external program outputs plain text, first do:
print "Content-type: text/plain\n\n";
--
David Efflandt (Reply-To is valid) http://www.de-srv.com/
http://www.autox.chicago.il.us/ http://www.berniesfloral.net/
http://cgi-help.virtualave.net/ http://hammer.prohosting.com/~cgi-wiz/
------------------------------
Date: Thu, 07 Jun 2001 04:25:10 GMT
From: echang@netstorm.net (E.Chang)
Subject: Re: Calling programs from a cgi
Message-Id: <Xns90B94B4873A3echangnetstormnet@207.106.93.86>
see-sig@from.invalid (David Efflandt) wrote in
<slrn9htndh.c8f.see-sig@typhoon.xnet.com>:
>On 6 Jun 2001 15:22:54 -0700, Igal Corcos <corcos@metalink.com>
>wrote:
>> Hi,
[snip]
>> I've tried the system(LIST) command but this does not seem to
>> work. I get an error saying my program did not produce a valid
>> http header.
[snip]
>Print a valid http header before running your external program. The
>last header line should end with a blank line (or double newline).
>For example if the external program outputs plain text, first do:
>
>print "Content-type: text/plain\n\n";
You may also need to autoflush STDOUT to ensure that the content type
header comes before any output from the other program you are calling
with system(). Just add $| = 1; at the beginning of your script.
--
EBC
------------------------------
Date: Thu, 07 Jun 2001 07:05:06 +0200
From: Philip Newton <pne-news-20010607@newton.digitalspace.net>
Subject: Re: Date of Halloween (for Date::Calc module)?
Message-Id: <sb2uhtk2ijcqqicf5agfgdobsmoar8al1j@4ax.com>
On Wed, 06 Jun 2001 15:40:10 GMT, "Todd Smith" <todd@designsouth.net>
wrote:
> "Steffen Beyer" <sb@engelschall.com> wrote in message
> news:p9alf9.72b.ln@imperia.net...
> >
> > In order to complete my holidays profiles, I'd need to know when
> > exactly is Halloween in the United States (and possibly elsewhere
> > as well) commemorated?
>
> It's always October 31
Specifically, it's "Hallowe'en" < "All Hallows Eve[n]", so it's the
evening (or, by extension, the whole day) before All Hallows [Day], or
All Saints [Day] ("Allerheiligen" in German), which is 1 November.
Incidentally, the day after that, 2 November, is another "all": All
Souls [Day] ("Allerseelen").
http://www.loc.gov/folklife/halloween.html may also be interesting.
(There are also tons of other links you could look for with "Halloween
All Hallows All Saints" or similar keywords, for example,
http://www.ewtn.com/library/MARY/HALLWEEN.HTM .)
Cheers,
Philip
--
Philip Newton <nospam.newton@gmx.li>
That really is my address; no need to remove anything to reply.
If you're not part of the solution, you're part of the precipitate.
------------------------------
Date: Thu, 07 Jun 2001 07:12:27 +0200
From: Philip Newton <pne-news-20010607@newton.digitalspace.net>
Subject: Re: Flame,help or killfile ?
Message-Id: <1l1uht4pnb01o9efgorc9tfoc8ccfrr9l6@4ax.com>
On Wed, 6 Jun 2001 22:17:14 +0200, "Stefan Weiss" <der.prinz@gmx.net>
wrote:
> Last time I looked, my news provider did not have anything like a
> comp.lang.perl.beginners group, but I can't be sure that such a group
> does not exist.
alt.perl?
> Most of the newbies coming here know that they still
> have a lot to learn, and they would probably have looked there first.
On the other hand, a lot of the newbies want help from "gurus" (they say
so in their subject lines), so if there's a "beginner" group and an
"advanced" group, they'll post to the "advanced" group because that's
where they hope the cool Perl wizards will hang out, who dispense wisdom
and finished parts of code they can just cut-n-paste into their scripts
without understanding them.
It also kind of depends on how many experienced Perlers there will be in
comp.lang.perl.beginners. If it's just the blind leading the blind, that
may not be very helpful. Bad memes will be repeated over and over again,
cargo-cult code will be passed around, and incomplete not-solutions
offered. Experienced Perlers there may feel the onus to set those
misguided attempts at help straight, and we're nearly back to where we
are already.
Cheers,
Philip
--
Philip Newton <nospam.newton@gmx.li>
That really is my address; no need to remove anything to reply.
If you're not part of the solution, you're part of the precipitate.
------------------------------
Date: Thu, 07 Jun 2001 06:41:52 +0200
From: Philip Newton <pne-news-20010607@newton.digitalspace.net>
Subject: Re: format/write with alternate linefeeds ?
Message-Id: <o40uhts61st03thm7ormbna84b16cqoqmt@4ax.com>
On 6 Jun 2001 10:53:58 GMT, ebohlman@omsdev.com (Eric Bohlman) wrote:
> The general rule in URLs is that "//" introduces the name of a server.
> Since the news: protocol doesn't specify a server, there's no "//".
Some clients use a scheme of 'nntp' to specify a server as well as a
group, and then there is a //, as in
nntp://news.example.com/example.internal . But in news:alt.news.group
(newsgroup name) or news:1234567abcdef@example.com (message ID), there's
no "//", as you said.
Cheers,
Philip
--
Philip Newton <nospam.newton@gmx.li>
That really is my address; no need to remove anything to reply.
If you're not part of the solution, you're part of the precipitate.
------------------------------
Date: 6 Jun 2001 19:35:37 -0700
From: krakle@visto.com (krakle)
Subject: Re: GROUP TAKEOVER IN PROGRESS
Message-Id: <237aaff8.0106061835.4af3a551@posting.google.com>
You are an idiot... Enough said...
------------------------------
Date: 7 Jun 2001 04:52:28 GMT
From: David LeBlanc <whisper@oz.nospamnet>
Subject: Re: GROUP TAKEOVER IN PROGRESS
Message-Id: <9fn1ac$9d3$2@216.39.170.247>
Don' you just hate it when they don't get their lithium?
------------------------------
Date: Thu, 07 Jun 2001 03:07:50 GMT
From: "MondoTrasho" <mondotrasho@home.com>
Subject: Re: Having a difficult time expanding file names - Thanks for the great responses!
Message-Id: <20010606.200807.1789366143.2102@home.com>
In article <20010606.014210.2086206725.1422@home.com>, "MondoTrasho"
<mondotrasho@home.com> wrote:
.
------------------------------
Date: Thu, 07 Jun 2001 02:24:27 -0000
From: Chris Stith <mischief@velma.motion.net>
Subject: Re: How does Perl handle multiple users?
Message-Id: <thtperid52m11c@corp.supernews.com>
Steve <cochise@sky.net> wrote:
> When data gets sent to a Perl script to be processed, what happens when
> other users submit data to the same script. Do they wait until the
> person in front of them is done? Or can more than one person use the
> same script at the same time? If so, is there a limit?
Perl is not an OS shell or an API. It is a full-blown programming
language. A program runs as a process (or more than one) under the
OS. It is up to the programmer to write the program so that it
handles multiple users safely if that is a requirement.
Perl does offer file locking, forking, select(), etc. to make
it possible to write programs which deal with multiple users
either through multiple instances of the same program or through
other means.
Pick up some documentation on Perl for more info. http://www.perldoc.com
Chris
--
Product shown enlarged to make you think you're getting more.
------------------------------
Date: Thu, 7 Jun 2001 06:29:45 +0000 (UTC)
From: bernard.el-hagin@lido-tech.net (Bernard El-Hagin)
Subject: Re: Is this Perl???
Message-Id: <slrn9hu74g.com.bernard.el-hagin@gdndev25.lido-tech>
On Wed, 6 Jun 2001 09:57:57 -0600, sas <saras@gj.net> wrote:
>Is this a Perl Script?
>++++++++
>1: r+ERROR: Tried to open %s . %s. (error number %d)
>2: ./newnum.lst-d%s %d
>3: PLEASE ENTER EMPLOYEES' FULL NAME: "%s", Is this correct [y/n] :
>4: "%s" is already in list file with number %d.
>5:
>6: New number for "%s" is %d. Adding new number to list.
>7: %s,%d
>8: ~
>++++++++
[snipped rest of "script"]
If it's Perl then Abigail must have written it. :)
Cheers,
Bernard
--
perl -l54e's yyw q q tvmrx "h\ywx ersxliv zivp legoiv"qiy;y #a-zA-Z#d-gu-z#
chefghijklmnopqrstuvwxyzcJab-def-uPwxyzc;s j j s u u s t t s r r s
ppevalpereeteueje'
------------------------------
Date: Thu, 07 Jun 2001 06:33:34 GMT
From: Zydas <zydas@home.com>
Subject: Need help parsing data
Message-Id: <th3uhtkrtu8ic9m8ddph3kk8phr55m74fc@4ax.com>
Hello everyone. I'm writing my first Perl script and I'm stuck. It's
driving me crazy.
My scipt:
#!/usr/bin/perl
while (<STDIN>){
@line = split(/,/);
printf
"%-2.2s%-15.15s%-3.3s%-30.30s%-7.7s%-8.8s%-5.5s%-2.2s%-4.4s%-10.10s%-30.30s%-8.8s%-2.2s%-30.30s%-5.5s%-35.35s%-35.35s%-35.35s%-19.19s%-2.2s%-9.9s\n%-2.2s%-9.9s%-8.8s%-7.7s%-8.8s%-6.6s%-5.5s%-30.30s%-30.30s\n%-2.2s%-20.20s\n%-2.2s%-20.20s%-30.30s%-13.13s%-10.10s%-9.9s%-2.2s%-9.9s%-2.2s%-30.30s%-25.25s%-25.25s\n",
$line[0], $line[1], $line[2], $line[3], $line[4], $line[5], $line[6],
$line[7], $line[8], $line[9], $line[10], $line[11], $line[12],
$line[13], $line[14], $line[15], $line[16], $line[17], $line[18],
$line[19], $line[20], $line[21], $line[22], $line[23], $line[24],
$line[25], $line[26], $line[27], $line[28], $line[29], $line[30],
$line[31], $line[32], $line[33], $line[34], $line[35], $line[36],
$line[37], $line[38], $line[39], $line[40], $line[41], $line[42],
$line[43];
}
My data:
S,031XXXX,856,193718,,0,VNDR,U,,,,2001-05-21,CC,REI,36-41,500 MAIN
STREET,,,NEW
ROCHELLE,NY,10801,O,36-412316,,,0,,,193,718,P,053329410203,I,,336298001-7,,053329410203,4006110,3,EA,,,TRIFOLD
WALLET, BLACK,,
Result: (It does exactly what I want it to do ;)
S 031XXXX 856193718 0 VNDR
U 2001-05-CCREI
36-41500 MAIN STREET
NEW ROCHELLE NY10801
O 36-412316 0 193
718
P 053329410203
I 336298001-7
05332941024006110 3 EA TRIFOLD
WALLET BLACK
Here's my problem. I need to have the script process several lines of
text at the same time. The first line should be processed the way it
currenty is. However line 2 and on should not display/process the
first 20 fields of the list. Thus, if I process two lines of data:
S,031XXXX,856,193718,,0,VNDR,U,,,,2001-05-21,CC,REI,36-41,500 MAIN
STREET,,,NEW
ROCHELLE,NY,10801,O,36-412316,,,0,,,193,718,P,053329410203,I,,336298001-7,,053329410203,4006110,3,EA,,,TRIFOLD
WALLET, BLACK,,
S,031XXXX,856,193718,,0,VNDR,U,,,,2001-05-21,CC,REI,36-41,500 MAIN
STREET,,,NEW
ROCHELLE,NY,10801,O,36-412316,,,0,,,193,718,P,053329410203,I,,336298007-4,,053329410203,4006144,1,EA,,,TRIFOLD
WALLET, DEEP FOREST,,
It should look like this:
S 031XXXX 856193718 0 VNDR
U 2001-05-CCREI
36-41500 MAIN STREET
NEW ROCHELLE NY10801
O 36-412316 0 193
718
P 053329410203
I 336298001-7
05332941024006110 3 EA TRIFOLD
WALLET BLACK
O 36-412316 0 193
718
P 053329410203
I 336298007-4
05332941024006144 1 EA TRIFOLD
WALLET DEEP FOREST
TIA!
------------------------------
Date: Thu, 7 Jun 2001 03:53:13 GMT
From: jtbell@presby.edu (Jon Bell)
Subject: Re: Newb needs help with input from forms
Message-Id: <GEJK4p.38L@presby.edu>
In article <d8fa40ef.0106060555.2e23f90a@posting.google.com>,
Shawn Michael Taub <shawntaub@yahoo.ca> wrote:
>Uh, I don't think I made myself clear enough. I've been working with
>perl for a few months and I still don't understand anything
>whatsoever.
OK... writing a CGI script like the one you showed us is like building a
car from scratch when all you really want to do is go somewhere. The code
you showed is the sort of thing that *every* Perl CGI script has to do.
Why should you or anyone else have to write it over and over again? All
that stuff has been "encapsulated" into a module of functions, named
CGI.pm, that is included with the standard distribution of Perl, and
should be available on any server that you want to run CGI script on.
To see how much work CGI.pm saves you, here's a complete script that uses
it, with lots of comments:
------ (begin script) ------
#!/usr/bin/perl -w
#-------------------------------------------------------------------------
# A trivial example of a CGI script that uses CGI.pm. It receives two
# parameters, the names of a person and a color, and displays them on a
# Web page.
#-------------------------------------------------------------------------
use strict; # Does a lot of error checking on your Perl code.
use CGI qw/:standard/; # Enables the CGI.pm module, and tells it you
# want to use the "standard" set of functions
# from it.
# Get the values of the CGI parameters. It doesn't matter whether they
# came from GET or POST. This contains all the dinking around with
# environment variables, parsing their contents with regular expressions
# etc., which your sample script showed in all its naked and ugly glory.
my $Name = param ('name');
my $Color = param ('color');
# Send the default HTTP headers, including the all-important
# "Content-Type:" which is set to text/plain by default.
print header;
# Send the HTML code for the page that the user sees. This is what we
# call a "here document." Everything between the "print" statement and
# the line with MYHTML all by itself, gets sent out literally, except for
# interpolating the values of the embedded variables $Name and $Color.
print <<MYHTML;
<html>
<head>
<title>JB's Example</title>
</head>
<body>
<h1>JB's Example</h1>
<p> Hello, $Name! Your favorite color is $Color. </p>
</body>
</html>
MYHTML
------ (end script) -------
You can actually invoke this script on my server using this URL
(substitute anything you like for the values of the parameters):
http://web.presby.edu/cgi-bin/jb-example.cgi?name=Shawn&color=purple
which of course uses the GET method to transmit the parameters. I could
have also made up a Web page with a form that has the user enter the
parameters, then transmits them using POST, but I'm leaving that as an
exercise for the student. ;-)
CGI.pm also provides functions which can do the HTML for you.
Instead of printing a here-document literally, I could have done this:
print start_html("JB's Example"),
h1("JB's Example"),
p("Hello, $Name! Your favorite color is $Color."),
end_html;
This would have sent out all the appropriate HTML tags along with the
given text.
I can't give you specific advice on where to look for tutorials for real
beginners to this stuff, because I had already been programming in Perl,
and writing simple HTML (no forms), as completely separate activities for
years before I wrote my first CGI script a couple of months ago. So I
didn't learn Perl and CGI together. I learned how to do CGI scripts
basically by looking at the CGI.pm examples in the "Perl Cookbook"
published by O'Reilly & Associates, and looking at the examples of forms
in an HTML book.
--
Jon Bell <jtbell@presby.edu> Presbyterian College
Dept. of Physics and Computer Science Clinton, South Carolina USA
------------------------------
Date: Thu, 07 Jun 2001 06:41:52 +0200
From: Philip Newton <pne-news--20010607@newton.digitalspace.net>
Subject: Re: Newbie: $ character end string? What is wrong?
Message-Id: <1v0uht4scpierh2fehalnuos3pdb71r5i5@4ax.com>
On 06 Jun 2001 08:00:59 GMT, vek@pharmnl.ohout.pharmapartners.nl (Villy
Kruse) wrote:
> Isn't that one of the DWIM features in Perl? If it looks like a variable,
> $Hello, then it is a variable. If it looks like the end of a string then
> it is the end of a string.
Kind of. However, it only looks like the end of the string if it's
before the regex closing delimiter (often '/', but can be other stuff as
well), before a ')', '(', or '|' (I think). So you can't easily
interpolate the magic variable $) or $| , but you can match /foo$|bar/
for "foo at the end of the string, or bar anywhere" or /foo$(?!\n)/ for
"foo at the end of the string, without a newline coming after it" or
/bar(?:foo$)?/ for "bar, optionally followed by foo and end-of-string".
/foo$bar/ never looks like "foo, then end-of-string, then bar" to Perl,
regardless of whether $bar exists or has ever been seen before.
> In either case a backslash before $ will turn it into itself.
True.
Cheers,
Philip
--
Philip Newton <nospam.newton@gmx.li>
That really is my address; no need to remove anything to reply.
If you're not part of the solution, you're part of the precipitate.
------------------------------
Date: 6 Jun 2001 19:27:03 -0700
From: krakle@visto.com (krakle)
Subject: Re: Perl is dead! Long live Perl!
Message-Id: <237aaff8.0106061827.2862e8af@posting.google.com>
There are ups and downs in every language. Bottom line is, You get to
choose which lnaguage you want to program in. Dont like perl, Dont use
Perl. DOnt like Java, DOnt use Java... Makes no sense once so ever to
post in a newsgroup trying to get people to learn the language that
interests you.
------------------------------
Date: Thu, 07 Jun 2001 06:41:53 +0200
From: Philip Newton <pne-news-20010607@newton.digitalspace.net>
Subject: Re: Perl Tattoo
Message-Id: <kd1uht0hilcbideqpagd25rplr9unc7169@4ax.com>
On 5 Jun 2001 23:51:10 -0700, chrisl_ak@hotmail.com (Chris) wrote:
> I do like the two line version:
>
> print pack"C*",split/\D+/,`echo
> "16iII*o\U@{$/=$z;[(pop,pop,unpack"H*",<>
> )]}\EsMsKsN0[lN*1lK[d2%Sa2/d0<X+d*lMLa^*lN%0]dsXx++lMlN/dsM0<J]dsJxp"|dc`
^^
which, of course, is cheating -- calling an external command to save you
lines-of-code.
Cheers,
Philip
--
Philip Newton <nospam.newton@gmx.li>
That really is my address; no need to remove anything to reply.
If you're not part of the solution, you're part of the precipitate.
------------------------------
Date: Thu, 7 Jun 2001 14:16:40 +0800
From: "keng" <keng@spinalfluid.com>
Subject: regular exp replacement question
Message-Id: <9fn66j$hnu$1@coco.singnet.com.sg>
dear all,
suppose
i have a $x = 123, "123,000,00", 124; taken from a csv file.
how do i strip the double quotes and the commas in the double quotes
and change it to 123, 12300000, 124
pls help
thanks in advance
--
regards
keng
------------------------------
Date: Thu, 7 Jun 2001 03:24:21 +0200
From: "Samuel Kilchenmann" <skilchen@swissonline.ch>
Subject: Re: Required or executed?
Message-Id: <9fml82$53181$1@ID-13368.news.dfncis.de>
"Stefan Weiss" <der.prinz@gmx.net> schrieb im Newsbeitrag
news:3b1eb8fa$1@e-post.inode.at...
>
> Is there a way to test if a script has been started either
>
> - directly form a shell: ./script.pl
> - passed to perl as parameter: perl script.pl
> - called from some other script: system(), exec(), ...
>
> or
>
> - require()d from inside a perl script?
>
>
> I only need to seperate the first three from the last. I tried to
> ckeck if STDIN/STDOUT were terminals, but that did not help.
>
>
perldoc -f caller
example:
package Foo;
sub bar {
print "a very useful function\n";
return 42;
}
unless (caller()) {
print bar();
}
1;
If you store this as Foo.pm and call perl Foo.pm it will execute the
bar() function.
If you use/require this Package in another script it will make the
Foo::bar() function available but it won't call it.
For a more reasonable example see e.g. the file lib/Pod/Functions.pm in
the Perl distribution.
------------------------------
Date: 06 Jun 2001 23:27:26 -0400
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: taint + netstat = error
Message-Id: <m3r8wxgeap.fsf@mumonkan.sunstarsys.com>
Ryan Travis Tate <ryantate@OCF.Berkeley.EDU> writes:
> Joe Schaefer <joe+usenet@sunstarsys.com> wrote:
>
> | Now that you know what "idio-matic Perl" really means, you can just
> | drop the hyphen in your real code's comment.
>
> i am not familiar with the term "idio-matic" -- does the hyphen give
> the term a meaning opposite of idiomatic?
Forget it- just another lame attempt at sarcasm. Although the
quirkiness of the language is something we are supposed to embrace,
sometimes it's just too revulsive to endure without some benign mockery
here and there. If you can't express yourself well by writing decent
Perl, be sure your comments make up for it :-)
Best wishes and continued success.
--
Joe Schaefer "Whatever you are, be a good one."
-- Abraham Lincoln
------------------------------
Date: Thu, 07 Jun 2001 09:58:31 +0300
From: Attila Feher <Attila.Feher@lmf.ericsson.se>
Subject: Re: The FlakeyMind Thaddes FAQ (v0.1)
Message-Id: <3B1F2617.5942BE0F@lmf.ericsson.se>
Topmind wrote:
>
> >
> > I guess it is fairly simple. He is not your employee to work instead of
> > you. You are free to make such FAQ. Will help to proove your level of
> > (not) understanding OO anyways. Your behaviour and empty agruments here
> > did not create you friends... so you can expect fed up people to do
> > things like this. Say thanx to yourself... and go away.
> >
> > A
> >
>
> So he is simply *venting* rather than trying to achieve anything
> real?
You are a grown man. Try to decide yourself. After you went away.
> Well, I am frusted by the high hype-to-proof ratio of OOP.
I am sure that you can find a good specialist treating frustration.
Until you get cured please (now that you see you need cure) go away and
let people work here!
> Can I vent too by complaining about which radio stations
> OO fans listen to?
Yes. Anytime! But not here. People try to work here. Don't push up
the noise ratio. Make your own NG, or whatever you want: just go away
from here and let people live and work.
Nobody here owes here you anything. Nobody did anything against you
here. Everybody else here went through this stage where you are:
questioning whether or not they need to use OO. They went through their
struggles and decided to use it. They would (and even try) to help you:
if you would ask for help. But what you do is a mad crusade with no
other purpose than rationalize, to prove that your mind has no problems
but the world (OO) is evil. Now in this mental state you are in now
nobody here can help you. You need to see a professional. Not-OO but
(top)mind repairer. You hate OO because your high reputation was lost
due to its hype or whatever else reasons you have... But noone here has
_anything_ to do with it. You might get help here if you want to
understand OO and decide it for yourself whether or not you want to use
it. If you have already decided you don't want: what are you doing
here? So. Step 1: get yourself "unfrustrated". In this state of mine
you are as objective and listening as an angry pitbull or a girfriend
when she decided to break up. So get away, settle the issues inside
your head - because that is not the purpose of this forum. And if you
can get back as openminded (instead of arrogant and
too-hogh-self-respect-implying topmind) and want to listen to peoples
advices - you can be a member of a community. Right now you are just
destroying. People's time here and your own dignity. So for now: go
away.
A
------------------------------
Date: Thu, 07 Jun 2001 07:58:52 +0200
From: Philip Newton <pne-news-20010607@newton.digitalspace.net>
Subject: Re: Urgent : control code sequences?!?!
Message-Id: <mo3uhto1sk1u78rgl0bdr14sn4trh85q7r@4ax.com>
On Wed, 6 Jun 2001 18:02:13 -0500, "Brien Wankel"
<brien@discover-net.net> wrote:
> once i'm logged into the equipment i have to send <esc>[<esc>0 to get
> to the command prompt that i need.
So send <esc>[<esc>0.
> i've tried
> @result = $session->cmd(String => "\033 [ \033 0", Prompt => '/MAX>/');
> and it doesn't work.
Well, you're sending <esc><space>[<space><esc><space>0 (unless 'cmd'
already strips spaces for you). Why are you sending spaces?
You could also use "\e[\e0", since "\e" is already an escape character.
See the section on "Quote and Quote-like Operators" in perlop.
> i've also tried to set up the key sequence as a string like this:
> $escseq = sprintf("\033","[", "\033", "0");
This uses "\033" (ESC) as the template to print the other strings. Since
there are no percent-sequences in the template, the other three strings
are ignored. sprintf ("%s%s%s%s", "\033", "[", "\033", "0") would work,
but it seems like too much work.
> another workaround would be to send a ctrl-d as the command but i
> haven't figured that one out either.
Read the same part of perlop; it tells you about control characters. In
this case, "\cD" for ctrl-d.
> please help!!
Please read the docs. (And capitalisation would be nice, too; it makes
things easier to read.)
Cheers,
Philip
--
Philip Newton <nospam.newton@gmx.li>
That really is my address; no need to remove anything to reply.
If you're not part of the solution, you're part of the precipitate.
------------------------------
Date: Wed, 6 Jun 2001 20:44:44 -0400
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: variable in variable name
Message-Id: <slrn9htjjs.7cr.tadmc@tadmc26.august.net>
John Hall <jhall@ifxonline.com> wrote:
>Ooh, you were getting all ready to yell at me weren't you?
>
>I know how to use Deja News.. Anyway, I read the faq, and got this code
>working,
Yes, but it uses symbolic references.
>but it seems like a ridiculous way to do it! Is there a simpler
>way?
Simpler way to do what, exactly?
>___________________________________
>#!/usr/bin/perl
>
>%database1 = (
> 1 => 'one',
> );
>
>$db = 'database1';
>&open_db($db);
>
>sub open_db {
>
>%USER_VARS = ( 1 => @_ );
>
> print ${$USER_VARS{'1'}} {'1'};
>
>}
>___________________________________
>
>Like, for example, why am I going to get a spanking from you kids if I do it
>this way?:
They both use symrefs. They both earn you a spanking, you naughty boy.
>___________________________________
>#!/usr/bin/perl
>
>%database1 = (
> 1 => 'one',
> );
>
>$db = 'database1';
>&open_db($db);
>
>sub open_db {
>
> print ${"@_"} {'1'};
>
>}
>___________________________________
>
Using hard references seems simpler:
----------------------------
#!/usr/bin/perl -w
use strict;
my %database1 = (
1 => 'one',
);
my $db = \%database1;
&open_db($db);
sub open_db {
my($db) = @_;
print $db->{'1'};
}
----------------------------
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 7 Jun 2001 01:58:54 GMT
From: damian@qimr.edu.au (Damian James)
Subject: Re: variable in variable name
Message-Id: <slrn9htnuj.5qk.damian@puma.qimr.edu.au>
John Hall chose Thu, 07 Jun 2001 00:39:21 GMT to say this:
>...
>Like, for example, why am I going to get a spanking from you kids if I do it
>this way?:
>...
Tad has already shown where you were going wrong. If you are interested in
why you don't want to be using symrefs, see MJD's (3 part) article at:
http://perl.plover.com/varvarname.html
Cheers,
Damian
--
@:=grep!($;+=m!$/|#!),split//,<DATA>;@;=0..$#:;while(@;){for($;=@;;--$;;)
{@;[$;,$:]=@;[$:,$;]if($:=rand$;+$|)!=$;}push@|,shift@;if$;[0]==@|;select
$,,$,,$,,1/80;print qq x\bxx((@;+@|)*$|++),@:[@|,@;],!@;&&$/} __END__
...ceci ne pas un(e?) JAPH
------------------------------
Date: Tue, 5 Jun 2001 10:58:19 +0600
From: "CitruSoft" <citrusoft@lycos.com>
Subject: WebForm Processing With 2 File Attachments - Script
Message-Id: <9fmrr0$6ar$3@proxy2.nursat.net>
What is Mail-A-File ?
Mail-A-File is a web-based email program (written in Perl) with file
attachment features. The program allows any user to send an email from a
web-based form to any recipient with a valid email address plus the ability
to attach a file to the email message. This is a great feature to add to
both business and personal web sites.
It Features:
+ No PERL knowledge to install
+ 4 step configuration, installs in minutes
+ Easy to modify Variables
+ Indicate required fields for data entry completeness
+ E-mail format validation on sender
+ Unlimited number of different forms can be called from this one script
+ Up to of 2 files attachments
+ And more...
If you interested please visit at:
http://citrusoft.tripod.com
Andrew
WebDeweloper
CitruSoft - Software for the Internet
------------------------------
Date: Thu, 7 Jun 2001 00:15:23 -0400
From: "helpmeplease" <helpmeplese@helpmeplese.com>
Subject: When renaming files is this agood idea to flock them ?
Message-Id: <9fmv4v$csv$1@sshuraab-i-1.production.compuserve.com>
When renaming files is this a good idea to Flock them?
open (LABLE,"current.dat") || &Error("$state - ERROR");
flock(LABLE, 2);
rename("current.dat", "current.old" );
rename($new, "current.dat" );
flock(LABLE, 8);
close (LABLE);
is there a better way to Flock them ?
Opposed to opening with a lable in read mode
just to be able to flock.
------------------------------
Date: Thu, 7 Jun 2001 06:45:33 +0200
From: buggs <buggs-clpm@splashground.de>
Subject: Re: When renaming files is this agood idea to flock them ?
Message-Id: <9fn0u6$4t8$01$1@news.t-online.com>
helpmeplease wrote:
> When renaming files is this a good idea to Flock them?
Why would you want to flock them?
Buggs
------------------------------
Date: 7 Jun 2001 06:14:13 GMT
From: mordor@fly.srk.fer.hr (Zeljko Vrba)
Subject: Re: When renaming files is this agood idea to flock them ?
Message-Id: <slrn9hu6ti.904.mordor@fly.srk.fer.hr>
On Thu, 7 Jun 2001 00:15:23 -0400, helpmeplease <helpmeplese@helpmeplese.com> wrote:
> When renaming files is this a good idea to Flock them?
>
No need. The processes hold the file descriptor to the file which doesn't change
when you rename the file. You can even delete the file and any process which
holds it open won't even notice..
------------------------------
Date: Thu, 7 Jun 2001 02:20:46 +0000 (UTC)
From: see-sig@from.invalid (David Efflandt)
Subject: Re: xterm backspace character?
Message-Id: <slrn9htp7u.c8f.see-sig@typhoon.xnet.com>
E-mailed too, since apparently has nothing to do with Perl
(been there, done that)
On Wed, 06 Jun 2001 14:56:55 GMT, r1ckey@home.com <r1ckey@home.com> wrote:
> How can the backspace charter in xterm be changed. In gnome-terminal there's
> an option to swap backspace and delete and this meets my needs as far as
> using the correct backspace character. But I prefer to use xterm. thanks...
To get correct backspace key in xterm type:
stty erase <backspace key><enter>
If this is for another box, edit your ~/.profile (.bash_profile) or
~/.login there (depending upon shell). Example:
stty erase "^?" (or comment out statement that sets it to "^H")
--
David Efflandt (Reply-To is valid) http://www.de-srv.com/
http://www.autox.chicago.il.us/ http://www.berniesfloral.net/
http://cgi-help.virtualave.net/ http://hammer.prohosting.com/~cgi-wiz/
------------------------------
Date: Thu, 07 Jun 2001 04:22:59 GMT
From: r1ckey@home.com
Subject: Re: xterm backspace character?
Message-Id: <DkDT6.61839$ko.1034238@news1.frmt1.sfba.home.com>
r1ckey@home.com wrote:
> How can the backspace charter in xterm be changed. In gnome-terminal there's
> an option to swap backspace and delete and this meets my needs as far as
> using the correct backspace character. But I prefer to use xterm. thanks...
> --
Sorry about the off-topic post, it was posted to this news group by mistake.
Thanks for the reply though...
--
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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.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.
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 V10 Issue 1080
***************************************