[11917] in Perl-Users-Digest
Perl-Users Digest, Issue: 5517 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Apr 29 11:07:23 1999
Date: Thu, 29 Apr 99 08:00:20 -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, 29 Apr 1999 Volume: 8 Number: 5517
Today's topics:
Re: A simpler way to do this? (Bart Lateur)
Re: CGI testing (Tad McClellan)
extracting text <mario@alamar.net>
Re: extracting text <tim@timbury.com>
Re: FAQ not applicable (was: Eliminate elements from ar (Tad McClellan)
Free resources for developers <flanker@sonnet.ru>
Free resources <flanker@sonnet.ru>
Re: HELP! - A very simple problem, I'm sure... (Tore Aursand)
Re: Impythonating PERL? (I R A Aggie)
Re: Learning Perl (Tad McClellan)
Meeting Amsterdam.pm, May 11th (Johan Vromans)
Re: Need help on "hex($1)" (Tad McClellan)
Re: PERL & Y2K (I R A Aggie)
Re: PERL & Y2K (Bart Lateur)
Re: Perl Mongers - Glasgow, Scotland rory@guidesrv.socsci.gla.ac.uk
Re: perldoc HELP, Was How to use Net::FTP in perl?? (Bart Lateur)
Re: perldoc HELP, Was How to use Net::FTP in perl?? <lusol@Pandora.CC.Lehigh.EDU>
Re: pow() ? to the power of ? (Rob Sweet)
Re: problem <x30407@wrek1.mar.lmco.com>
Re: problem <gellyfish@gellyfish.com>
Re: Question: Opening and closing files. <gellyfish@gellyfish.com>
Re: Searching a Text File by key (Tad McClellan)
Re: What does this error message mean? (Bart Lateur)
Re: why doesn't redeclaring $i give warning/errors? <crb@highpoint.co.uk>
Re: why doesn't redeclaring $i give warning/errors? (Rob Sweet)
Re: why doesn't redeclaring $i give warning/errors? <gellyfish@gellyfish.com>
Re: Why paranthesis change logical expression (Tad McClellan)
Re: Why paranthesis change logical expression (Bart Lateur)
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 29 Apr 1999 13:56:29 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: A simpler way to do this?
Message-Id: <372862fd.3760000@news.skynet.be>
Steve Vertigan wrote:
>I'm trying load parse an array for the existence of variables so that the
>following text..
>
>Dear %firstname %lastname
>Thank you for your message regarding <b>%problem</b>...
>
>would create the following hash
>$DEFINED{'firstname'} = 1; # or true
>$DEFINED{'lastname'} = 1;
>$DEFINED{'problem'} = 1;
>At the moment I do the following.
>for (@_) {
> s/\n/ /g; s/\r//g;
> my @foo = split;
> my @bar = grep(/\%(\w+)/, @foo);
> for (@bar) { s/%//g; $DEFINED{$_} = 1; }
> }
>
>This works but it seems awful messy. Also it needs any "variable" to be
>surrounded by whitespace or I get things like $DEFINED{'problem</B>'}.
>Ideally I'd like to stop on any non alphanumeric character.
/\%(\w+)/ is the basic regex. But you could redo that as:
@bar = /\%(\w+)/g;
which would capture all the variable's names. You can then do
foreach(@bar) {
$DEFINED{$_}++;
}
which would actually count the occurences.
BTW no need to split your text into separate lines. The regexes gladly
skip any control characters such as newlines. Put this before the above
statements, and you're ready to test.
$_ = <<'_EOT_';
Dear %firstname %lastname
Thank you for your message regarding <b>%problem</b>...
_EOT_
Bart.
------------------------------
Date: Thu, 29 Apr 1999 04:21:25 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: CGI testing
Message-Id: <5q49g7.ng1.ln@magna.metronet.com>
David (diwidjaja@ucdavis.edu) wrote:
: Hi, i'm pretty new at this, but I'm just wondering, how can you test cgi
: scripts without posting it on the web?
You can easily test them from the command line if you are
using the CGI.pm module.
If you aren't, then why not?
You can also just install a free WWW server on your 'puter, and
test in a real CGI environment.
: i'm using Windows NT. and
: further than that, where do you put the cgi script on the server. I
: always see people saying that it should be in cgi-bin (or cgi/bin ?)
: directory, but where do I find the directory anyway?
That is not a Perl question, and is therefore off-topic in
the Perl newsgroup.
It is a server setup question best answered by whoever setup
your server.
Or at least ask in a newsgroup that is connected to WWW stuff
in some way, such as:
comp.infosystems.www.authoring.cgi
comp.infosystems.www.servers.ms-windows
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Thu, 29 Apr 1999 14:24:21 +0100
From: "Mario Anthony Thomas" <mario@alamar.net>
Subject: extracting text
Message-Id: <7g9mji$aon$1@lure.pipex.net>
How do I extract text from the middle of a string when I don't know what
that text is? For example,
in the string below i'd like to extract the bit that says 'Text To Extract'.
How do I do this - can I do
it with pattern matching or not?
.....<FONT><STRONG>Text To Extract</STRONG></FONT>.......
Hope someone can help with this.
Cheers
Mario
------------------------------
Date: Thu, 29 Apr 1999 09:57:00 -0400
From: "Tim" <tim@timbury.com>
Subject: Re: extracting text
Message-Id: <925394162.668.11@news.remarQ.com>
In the example you gave, you'll notice that the Text To Extract is the
only text in the string bounded by >< and not <>. Hope this gives a clue..
:-)
Tim K.
Mario Anthony Thomas wrote in message <7g9mji$aon$1@lure.pipex.net>...
>How do I extract text from the middle of a string when I don't know what
>that text is? For example,
>in the string below i'd like to extract the bit that says 'Text To
Extract'.
>How do I do this - can I do
>it with pattern matching or not?
>
>
>.....<FONT><STRONG>Text To Extract</STRONG></FONT>.......
>
>Hope someone can help with this.
>
>Cheers
>
>Mario
>
>
------------------------------
Date: Thu, 29 Apr 1999 03:48:25 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: FAQ not applicable (was: Eliminate elements from array with second array?)
Message-Id: <9s29g7.ng1.ln@magna.metronet.com>
Ronald J Kimball (rjk@linguist.dartmouth.edu) wrote:
: Ala Qumsieh <aqumsieh@matrox.com> wrote:
: > lou@visca.com writes:
: >
: > > My thanks to all who answered, but as Andrew Allen points out, the
: > > FAQ isn't applicable in my case.
: >
: > Then you probably misunderstood your own question :-)
: Not every question is answered in the FAQs, you know.
Good thing, or nobody would need to read clpmisc :-)
But I think Lou's question _was_ answered in the FAQs.
Not the FAQ that got cited though :-)
Perl FAQ, part 6:
"How do I efficiently match many regular expressions at once?"
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Thu, 29 Apr 1999 17:38:57 +0400
From: "Michael Yevdokimov" <flanker@sonnet.ru>
Subject: Free resources for developers
Message-Id: <7g9ni4$3iv$1@bison.rosnet.ru>
Hi
Download free resources for echo tag from Developer Network.. ;-)
http://www.developer.net.ru
--
Best wishes,
Michael
Email: flanker@sonnet.ru
------------------------------
Date: Thu, 29 Apr 1999 17:38:21 +0400
From: "Michael Yevdokimov" <flanker@sonnet.ru>
Subject: Free resources
Message-Id: <7g9nh0$3ce$1@bison.rosnet.ru>
Hi
Download free resources for echo tag from Developer Network.. ;-)
http://www.developer.net.ru
--
Best wishes,
Michael
Email: flanker@sonnet.ru
------------------------------
Date: Thu, 29 Apr 1999 13:32:07 GMT
From: tore@forumnett.no (Tore Aursand)
Subject: Re: HELP! - A very simple problem, I'm sure...
Message-Id: <37285e57.3526851@news.online.no>
On Sun, 11 Apr 1999 16:54:37 +0100, "Andrew Weller"
<p8e77@keele.ac.uk> wrote:
> head -26.27939 43.58512 14.08601 43.43750
#!/usr/bin/perl
#
use strict;
#
# Variable declaration
#
my $fileName = "filename.ext";
my $lines = 0;
# Main job
open(TXTFILE, "$fileName") || die "$!";
while (<TXTFILE>) {
chomp;
my ($text, $x, $y, $z, $intensity) = split();
print "$text, $x, $y, $z, $intensity\n";
$lines++;
}
close(TXTFILE) || die "$!";
print "\nNo. of lines: $lines\n";
--
Tore Aursand - tore@forumnett.no
<URL:http://www.forumnett.no/~tore/>
------------------------------
Date: 29 Apr 1999 13:04:31 GMT
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: Impythonating PERL?
Message-Id: <slrn7igmbt.2og.fl_aggie@stat.fsu.edu>
On 28 Apr 1999 17:15:04 -0700, Avery Andrews
<andrews@Turing.Stanford.EDU>, in <7g88a8$p36@Turing.Stanford.EDU> wrote:
+ Anyway, since you have to lay code out that way to make it readable
+ later, what's so dumb about using the whitespace to lose the
+ punctuation?
Additional overhead? using a crutch that will likely in the long run
limit your proficency in perl?
James
------------------------------
Date: Thu, 29 Apr 1999 04:11:29 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Learning Perl
Message-Id: <h749g7.ng1.ln@magna.metronet.com>
David Cassell (cassell@mail.cor.epa.gov) wrote:
: <waves arms> Hey Randal, does the subject line sound familiar?
: ITTE wrote:
: >
: > ***Accelerated Perl Programming Training, (Intro-Interm.)
: > [SNIP]
: > own. To our knowledge, no other training provides this much learning in
: > such a brief time.
: Presumptive, aren't they? Or is that the wrong adjective... :-)
: Do we know any of
: their trainers?
That is what I was wondering, so I went to their web site
to find out the qualifications of the instructor.
Found nothing about who will do the teaching.
<shrug>
I wouldn't sign up with a 'net abuser anyway...
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: 29 Apr 1999 15:47:17 +0200
From: JVromans@Squirrel.nl (Johan Vromans)
Subject: Meeting Amsterdam.pm, May 11th
Message-Id: <wl390bbpmhm.fsf@plume.nl.compuware.com>
[English version follows the dutch text]
Amsterdam.pm staat voor de "Amsterdamse Perl Mongers", een groep van
gebruikers van Perl. In tegenstelling tot wat de naam suggereert is
Amsterdam.pm niet beperkt tot alleen Amsterdam, maar functioneert, tot
er meer gebruikersgroepen in Nederland zijn, als Nederlandse
gebruikersgroep.
Amsterdam.pm organiseert informele bijeenkomsten waar Perl gebruikers
kunnen samenkomen en informatie en gebruikservaringen met betrekking
tot Perl kunnen uitwisselen. Deze bijeenkomsten vinden normaliter
plaats op elke eerste dinsdag van de maand. De voertaal binnen
Amsterdam.pm is in pricipe Nederlands, maar indien nodig zal Engels
worden gebruikt, b.v. om te communiceren met niet-Nederlandssprekende
aanwezigen.
De eerstvolgende bijeenkomst vindt plaats op 11 mei 1999. (Deze keer
dus de tweede dinsdag van de maand.)
De agenda voor deze bijeenkomst is, zoals gewoonlijk, informeel:
18:00-18:30 Verzamelen bij Maximiliaan op de Nieuwmarkt
19:00-20:30 Etentje in een restaurant ergens in de buurt
21:00-..... Voortzetting bij Maximiliaan's -- discussies, etc.
Bezoek onze Web site http://www.Amsterdam.pm.org voor meer details.
[English version]
Amsterdam.pm stands for the Amsterdam Perl Mongers. We're basically a
Perl user group. Despite its name, it is not local to the Amsterdam
environment, but it welcomes Perl mongers from all over the
Netherlands.
Amsterdam.pm organises informal meetings where Perl users can meet,
and exchange information and experiences with regard to using Perl.
The meetings are normally held every first Tuesday of the month.
Although the preferred language for communication is Dutch, English
will be spoken if necessary.
Our next meeting is May 11th, 1999. Note: second tuesday!
It will have the following informal agenda:
18:00-18:30 Gathering at Maximiliaan's on the Nieuwmarkt
19:00-20:30 Dinner in a restaurant somewhere near the Nieuwmarkt
21:00-..... Discussions and such at Maximiliaan's
See http://www.Amsterdam.pm.org for more details.
------------------------------
Date: Thu, 29 Apr 1999 04:34:20 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Need help on "hex($1)"
Message-Id: <ci59g7.8q1.ln@magna.metronet.com>
Jens Engelbrecht (engelbrecht@t-online.de) wrote:
: the following problem occurs by trying to encode an url.
The problem occurs because you are trying to encode a URL.
There are modules that will do that correctly...
: $part_of_url =~ s/[^A-Za-z0-9\s]/"%".hex($1)/eg;
^^
^^
refers to the first set of capturing parenthesis.
you do not _have_ any capturing parenthesis...
: => "Use of uninitialized value at the line above"
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: 29 Apr 1999 13:09:42 GMT
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: PERL & Y2K
Message-Id: <slrn7igmlk.2og.fl_aggie@stat.fsu.edu>
On Wed, 28 Apr 1999 21:36:25 -0400, Bill Jones
<bill@fccj.org>, in <3727b7a5.0@usenet.fccj.cc.fl.us> wrote:
+ What is REALLY scary is that I got e-mailed 'spam' from
+ some company (unravel.com, I believe) saying they had
+ a perl code scanner which helps you fix all perl Y2k issues.
+ They charge a $3,000 if I remember correctly.
+ I e-mailed them back and asked "So, it is a programmer mind reader?"
+ The guy mailed me back and said people are buying it.
OH DEER LORD.
James - apologies to rsfc...
------------------------------
Date: Thu, 29 Apr 1999 14:00:23 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: PERL & Y2K
Message-Id: <37296561.4372194@news.skynet.be>
I R A Aggie wrote:
>Sneex wrote:
>+ What is REALLY scary is that I got e-mailed 'spam' from
>+ some company (unravel.com, I believe) saying they had
>+ a perl code scanner which helps you fix all perl Y2k issues.
>
>+ They charge a $3,000 if I remember correctly.
>
>+ I e-mailed them back and asked "So, it is a programmer mind reader?"
>+ The guy mailed me back and said people are buying it.
>
>OH DEER LORD.
The *good thing* is that if it turns out that this thing failed to catch
a few Y2K bugs, you could probably succesfully prosecute the company for
not delivering what they promised.
Bart.
------------------------------
Date: 29 Apr 1999 14:03:17 +0100
From: rory@guidesrv.socsci.gla.ac.uk
Subject: Re: Perl Mongers - Glasgow, Scotland
Message-Id: <m390bbr33e.fsf@guidesrv.socsci.gla.ac.uk>
Hi Michael,
I tried emailing the owner of glasgow.pm about a month ago, and got
no reply. I'm also on the mailing list for glasgow.pm - last time
I checked I was the only one.
I am interested in a Glasgow group, so I think what should happen
is that a request be made to replace the current owner of glasgow.pm
with someone who is at all interested.
You up for the task?
Rory
Michael Cameron <Michael.Cameron@no.spam.technologist.com> writes:
> I am interested in the above group - I have tried contacting the address
> on the www.pm.org page (jer@onlymedia.com) a couple of times but to no
> avail.
>
> Is anyone else interested in a Glasgow group? Does it already exist?
> Are there any active groups elsewhere in Scotland?
>
> Thanks,
>
> Michael
------------------------------
Date: Thu, 29 Apr 1999 14:06:27 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: perldoc HELP, Was How to use Net::FTP in perl??
Message-Id: <372a6661.4627925@news.skynet.be>
Ed Bogart wrote:
>physio% perldoc Net::FTP
>No documentation found for "Net::FTP".
Nevertheless, THIS is the command line it should have understood.
>The
>Net::FTP _module_ has been installed, as have all the others I have
>tried. The problem is that when I try to Read The Documentation(tm)
>using the 'perldoc PageName|ModuleName|ProgramName' form I get an error
>msg. The 'perldoc -f perlterm' works fine. I hope that is clearer.
Does it fail for other modules as well? Try
perldoc CGI
and if THAT doesn't work, and it fails for other modules too, then I
guess your perldoc script is corrupted. Note that it *is* case
sensitive.
BTW what platform are you on? Maybe the command line gets corrupted
before the arguumeents get to the script. Try putting quotes around
them.
Bart.
------------------------------
Date: 29 Apr 1999 13:25:39 GMT
From: "Stephen O. Lidie" <lusol@Pandora.CC.Lehigh.EDU>
Subject: Re: perldoc HELP, Was How to use Net::FTP in perl??
Message-Id: <7g9mkj$1uo2@fidoii.cc.Lehigh.EDU>
Ed Bogart <e.h.bogart@larc.nasa.gov> wrote:
> Tony Curtis wrote:
>>
>> Re: perldoc HELP, Was How to use Net::FTP in perl??,
>> Ed <e.h.bogart@larc.nasa.gov> said:
>>
>> Ed> I have asked this before with no answers so here
>> Ed> goes again. I am using perl version 5.004_04
>> Ed> built for IP19-irix on an SGI 02 and have not
>> Ed> been able to get perldoc to work with any
>> Ed> modules. Trying the above, using all 3 forms
>> Ed> from perldoc perldoc, I get;
>>
>> Maybe this version of perl was built with no
>> documentation installed (you can do this during the
>> configuration with the reply "none" at the
>> appropriate point)?
>>
> As I explained in response to the IRA Aggie's post, it looks like all
> the modules are installed and perldoc works fine when used in the
> 'perldoc -f somefunction' form. It only returns an error when I as for
> _module_ information.
> I could understand in no docs were included in the build but can some be
> there and not others?
Try:
perldoc -v
That will list exactly where perldoc is searching. On IRIX 6.x perl is
bundled with the OS, so the IRIX perldoc may appear in your PATH earlier
than the perldoc you think you have, thus, missing all your local modules.
Yell if that doesn't help ....
------------------------------
Date: Thu, 29 Apr 1999 13:22:14 GMT
From: sweet@enterpriseusa.com (Rob Sweet)
Subject: Re: pow() ? to the power of ?
Message-Id: <37285cd0.602609@news1.mi.home.net>
The hat symbol / aka carat '^' is a bitwise exclusive or (XOR)
- Rob Sweet
On Wed, 28 Apr 1999 21:14:00 -0400, "Bill Jones" <bill@fccj.org>
wrote:
>In article <372727c6.64949187@news1.mi.home.net>, sweet@enterpriseusa.com
>(Rob Sweet) wrote:
>
>
>>
>>
>>
>> $x = 2 ;
>> $y = 3 ;
>>
>> print $x ** $y ;
>>
>> Rob Sweet
>>
>
>Interesting, I haven't been able to find what the ^ is for?
>
>In math is means: X raised to power y...
>
>But, in perl, 4 ^ 2 = 6 (not 16...)
>
>Curious,
>-Sneex- :]
>_________________________________________________________________________
>Bill Jones | Data Security Specialist | http://www.fccj.org/cgi/mail?dss
>FCCJ | 501 W State St | Jacksonville, FL 32202 | 1 (904) 632-3089
>
>Mentoring: http://tesla.fccj.cc.fl.us/cgi-bin/mentors.pl?cmd=show&uid=24
>
> Jacksonville Perl Mongers
> http://jacksonville.pm.org/Letter.cgi
> jax@jacksonville.pm.org
------------------------------
Date: Thu, 29 Apr 1999 09:15:27 -0400
From: Adam Dittmer <x30407@wrek1.mar.lmco.com>
Subject: Re: problem
Message-Id: <37285B6E.D7C47A7A@wrek1.mar.lmco.com>
Alastair wrote:
> Adam Dittmer <x30407@wrek1.mar.lmco.com> wrote:
> >with the second page i want to put it in part number order
> >but i am not sure how to search the html file and pull out what i need
> >for comparison. if someone could help me think of a way to get the
> >info out i would appreciate it.
>
> Is the problem searching a file, sorting by part number,..? What have you tried?
>
>
well the problem is inserting a part number into a html list. I use a form to get
the info and then generate a file for that is like a guestbook. I want to also be
able to stick the info into another file that is aranged by part number. but my
problem is get the other part numbers out of the html file to compare to the inputed
part number.
------------------------------
Date: 29 Apr 1999 14:59:44 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: problem
Message-Id: <372865d0@newsread3.dircon.co.uk>
Adam Dittmer <x30407@wrek1.mar.lmco.com> wrote:
> Alastair wrote:
>
>> Adam Dittmer <x30407@wrek1.mar.lmco.com> wrote:
>> >with the second page i want to put it in part number order
>> >but i am not sure how to search the html file and pull out what i need
>> >for comparison. if someone could help me think of a way to get the
>> >info out i would appreciate it.
>>
>> Is the problem searching a file, sorting by part number,..? What have you tried?
>>
>>
>
> well the problem is inserting a part number into a html list. I use a form to get
> the info and then generate a file for that is like a guestbook. I want to also be
> able to stick the info into another file that is aranged by part number. but my
> problem is get the other part numbers out of the html file to compare to the inputed
> part number.
>
I think you really need to give some serious thpought to the design of
your application. HTML is a document format and is not suitable for the
kind of thing that you are proposing - you probably want to keep your
part number info in some flat text file or even some SQL database and
not worry about the formatting whilst it is stored and do all of that stuff
on the fly.
/J\
--
Jonathan Stowe <jns@gellyfish.com>
------------------------------
Date: 29 Apr 1999 14:16:18 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Question: Opening and closing files.
Message-Id: <37285ba2@newsread3.dircon.co.uk>
Tony Bowden <tony@blackstar.co.uk> wrote:
> Abigail <abigail@fnx.com> wrote:
>> David Cassell (cassell@mail.cor.epa.gov) wrote on MMLXII September
>> MCMXCIII in <URL:news:37210A44.47C2D26A@mail.cor.epa.gov>:
>
> The 2562nd of September 1993?
>
Thats a FAQ ;-}
/J\
--
Jonathan Stowe <jns@gellyfish.com>
------------------------------
Date: Thu, 29 Apr 1999 04:17:41 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Searching a Text File by key
Message-Id: <5j49g7.ng1.ln@magna.metronet.com>
Carl Motors, Inc. (sales@carlmotors.com) wrote:
: I own
: "Programming Perl" (Wall/Christenson/Swhwartz) and
A new and unique way to misspell Randal's name?
: "Official guide to programming with cgi.pm" (Stein) as references.
: I have also had to use AWK in the past.
: I have successfully written a basic perl script using the cgi.pm module
There is no such module.
There is a CGI.pm module though...
: to output form data to a file. A handy module indeed, to get started
: anyway.
: Here is my question:
: What is the best way to search a text file with form parameters passed
: to a script?
It depends on what the form parameters are meant to be:
constant strings?
constant strings that might contain regex metacharacters?
regular expressions?
: Can i use the pattern matching?
Yes.
: If so how do I translate
: the parameter, which holds the search key, to a pattern?
We don't know because you have not told us how to interpret
the arguments.
If the first or third alternative above, then no translation
is needed:
print "matched\n" if /$FORM{pattern}/;
If the second one:
print "matched\n" if /\Q$FORM{pattern}/;
: I am looking for some jump-start suggestions. Perhaps it is not possible
: and I should proceed with an actual database file search instead?
If another program (RDBMS) can do it, then Perl can do it too.
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Thu, 29 Apr 1999 14:49:25 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: What does this error message mean?
Message-Id: <37286f5d.6664324@news.skynet.be>
Tad McClellan wrote:
>Bart Lateur (bart.lateur@skynet.be) wrote:
>
>: Actually, I would have preferred that "0" as a string would have been
>: considered as TRUE, so ANY string that isn't the null string (length=0)
>: is true.
>
>: print chr(48)?'true':'false';
>
> But then what number would perl DWIM a non-digit string into?
I don't understand your question. Please expand.
Usually Perl doesn't make a difference between numerical context and
string context. Sometimes it does. Take logical false, for example,
which returns zero in numerical context, and the empty string in string
context. Or notice the difference in result between:
print 16 | 2; # 18
and
print "16" | "2"; # "36"
So why wouldn't Perl be allowed to treat "0" as true, and 0 as false?
Bart.
------------------------------
Date: Thu, 29 Apr 1999 13:28:16 GMT
From: "Craig R. Belcham" <crb@highpoint.co.uk>
Subject: Re: why doesn't redeclaring $i give warning/errors?
Message-Id: <37285125.274E80EE@highpoint.co.uk>
> In which I redeclare $i 5 times. "my" declares the variable scoped for the
> enclosing brackets; in this case the while loop brackets. So why am I allowed
> to declare it 5 times in the same scope? It seems like the same case as in
> the first trial. Also, its a subtle bug as $i is invariant- its redeclared as
> 0 each pass.
>
PERL will define each loop as a seperate 'scope', a variable declared
with 'my' within the context of a while statement, is declared for that
loop... take the following peice of code.
my $j=0;
while ($j<5)
{
print "$i was carried" if $i;
my $i = $j;
print "$i\n";
$j++;
}
Note that $i is being declared in each loop, and at the start of each
loop a print statement is run if $i is true, the output of this:-
[root@dellion security]# perl test
0
1
2
3
4
Meaning that $i is null each time the loop runs, what you need is
something like this (it starts with 0 but otherwise does the
calculations you want...
#!/usr/local/bin/perl -w
my $j=1;
for ((my $i)=0;$j<6;$i+=$j++){
print "$i\n";
}
Hope this helps.
Craig
--
Craig R. Belcham. Internet Systems Management Consultant.
Email: crb@highpoint.co.uk, http://www.highpoint.co.uk/~crb
"The greatest trick the devil ever pulled was convincing the
world that he didn't exist" -- Kevin Spacey, Usual Suspects.
------------------------------
Date: Thu, 29 Apr 1999 13:31:38 GMT
From: sweet@enterpriseusa.com (Rob Sweet)
Subject: Re: why doesn't redeclaring $i give warning/errors?
Message-Id: <37285ec2.1100593@news1.mi.home.net>
You aren't redeclaring $i 5 times in the loop - because each time you
iterate the loop you re-enter the scope. This is functionally no
different than having a sub that delcares my $i and calling it five
times in a row.
-
Rob Sweet
On Thu, 29 Apr 1999 12:29:19 GMT, sstarre@my-dejanews.com wrote:
>
>
>
>If I try:
>
> #!/usr/local/bin/perl -w
> my $i=0;
> my $i=1;
>
>perl correctly identifies the redeclaration of $i and reports:
>
> "my" variable $i masks earlier declaration in same scope at x.pl line 3.
>
>however, I can use this without errors or warnings:
>
>#!/usr/local/bin/perl -w
>
> my $j=0;
> while ($j<5)
> {my $i+=++$j;
> print "$i\n";
> }
> perl x.pl
> 1
> 2
> 3
> 4
> 5
>
>
>In which I redeclare $i 5 times. "my" declares the variable scoped for the
>enclosing brackets; in this case the while loop brackets. So why am I allowed
>to declare it 5 times in the same scope? It seems like the same case as in
>the first trial. Also, its a subtle bug as $i is invariant- its redeclared as
>0 each pass.
>
>What I really want of course is more like:
> my $j=0;
> my $i=0;
> while ($j<5)
> {$j++;
> $i+=$j;
> print "$i\n";
> }
> perl x.pl
> 1
> 3
> 6
> 10
> 15
>
>But in this case, now I have $i scoped for the entire remainder of the
>program, which is also not quite what I want, but at least the results are
>correct.
>
>Anyhow, this seems inconsistent. If it warns in trial 1 it should warn in
>trial 2.
>
>HUG,
>S
>
>
>
>-----------== Posted via Deja News, The Discussion Network ==----------
>http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: 29 Apr 1999 15:31:45 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: why doesn't redeclaring $i give warning/errors?
Message-Id: <37286d51@newsread3.dircon.co.uk>
sstarre@my-dejanews.com wrote:
>
>
>
> If I try:
>
> #!/usr/local/bin/perl -w
> my $i=0;
> my $i=1;
>
> perl correctly identifies the redeclaration of $i and reports:
>
> "my" variable $i masks earlier declaration in same scope at x.pl line 3.
>
As it should.
> however, I can use this without errors or warnings:
>
> #!/usr/local/bin/perl -w
>
> my $j=0;
> while ($j<5)
> {my $i+=++$j;
> print "$i\n";
> }
> perl x.pl
>
As it should
>
> In which I redeclare $i 5 times. "my" declares the variable scoped for the
> enclosing brackets; in this case the while loop brackets. So why am I allowed
> to declare it 5 times in the same scope?
You are declaring it five times in a separate scope. Each iteration of
the loop being separate;
>
> What I really want of course is more like:
> my $j=0;
> my $i=0;
> while ($j<5)
> {$j++;
> $i+=$j;
> print "$i\n";
> }
> perl x.pl
> 1
> 3
> 6
> 10
> 15
>
> But in this case, now I have $i scoped for the entire remainder of the
> program, which is also not quite what I want, but at least the results are
> correct.
>
You can create an anonymous block around that so $i is only in scope for
as long as necessary. :
{
my $x ;
my $y ;
# do something with $x and $y;
}
# neither $x or $y now in scope
Bear in mind that if you declare a lexical variable with 'my' then you
dont have to set its initial value to 0.
> Anyhow, this seems inconsistent. If it warns in trial 1 it should warn in
> trial 2.
>
Nope.
/J\
--
Jonathan Stowe <jns@gellyfish.com>
------------------------------
Date: Thu, 29 Apr 1999 03:44:29 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Why paranthesis change logical expression
Message-Id: <tk29g7.ng1.ln@magna.metronet.com>
Georg Raming (raming@ewh.uni-hannover.de) wrote:
: No I want to read in 5 line at once, trying
: this example for 2 lines:
: while (($line[0],$line[1]) = <Fin>)
: {
: print Fout $line[0] $line[1]
: }
: and my problem is, that this reads in only once, and then the expression
: after while gets false due to the paranthesis around $line[0...
: Why?
Because the <input operator> has different behavior in
scalar context and in list context.
You have given it a list context in your second one.
In list context the input operator reads _all_ of the
remaining lines.
The first two lines go into the list you provided, the
rest of the lines are discarded.
: What is a better way?
If you are _certain_ that you won't hit the end of file
you can just:
while ($line[0] = <Fin>) {
$line[1] = <Fin>;
$line[2] = <Fin>;
$line[3] = <Fin>;
$line[4] = <Fin>;
}
If you might hit end of file, then it depends on what you
want to do if there are not 5 lines left.
To just skip processing unless you get your 5 lines, you
can change them to:
last unless defined $line[1] = <Fin>;
last unless defined $line[2] = <Fin>;
...
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Thu, 29 Apr 1999 14:09:49 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Why paranthesis change logical expression
Message-Id: <372b67ba.4972525@news.skynet.be>
Georg Raming wrote:
>
>while ($line = <Fin>) {
> print Fout $line;
> }
>and this worked quite fine. Now I want to read in 5 line at once...
BTW you might try this:
while((@line = map { scalar <Fin> } 1 .. 5 ), defined $line[-1]) { ...
Bart.
------------------------------
Date: 12 Dec 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Special: Digest Administrivia (Last modified: 12 Dec 98)
Message-Id: <null>
Administrivia:
Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing.
]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body. Majordomo will then send you instructions on how to confirm your
]subscription. This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.
The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V8 Issue 5517
**************************************