[22491] in Perl-Users-Digest
Perl-Users Digest, Issue: 4712 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Mar 15 09:05:52 2003
Date: Sat, 15 Mar 2003 06:05:08 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Sat, 15 Mar 2003 Volume: 10 Number: 4712
Today's topics:
Re: [Probably] a stupid question about REGEX (Mark Healey)
Re: [Probably] a stupid question about REGEX <uri@stemsystems.com>
file parse into hash and writing output with certain fo (david)
FILEHANDLE and search and replace question <mstep@t-online.de>
Re: FILEHANDLE and search and replace question <bart.lateur@pandora.be>
Re: FILEHANDLE and search and replace question <mstep@t-online.de>
Find&Replace only in a certain scope <mstep@t-online.de>
Re: frames without files ? (Alan Barclay)
Re: frames without files ? <s.patterson@freeuk.com>
Re: Getting list of files from Win32 clipboard (Jay Tilton)
Re: Getting list of files from Win32 clipboard <noreply@gunnar.cc>
how to create NULL character in perl <xiamen2@hotmail.com>
Re: how to create NULL character in perl <kalinabears@hdc.com.au>
I want to: include 'right.php' (Francesco Moi)
Re: Interpolation problem? (Paul)
Re: it's true but can I say so ? <goldbb2@earthlink.net>
Re: it's true but can I say so ? <mgjv@tradingpost.com.au>
Re: it's true but can I say so ? <goldbb2@earthlink.net>
Re: it's true but can I say so ? <bart.lateur@pandora.be>
Re: it's true but can I say so ? <bart.lateur@pandora.be>
Re: Lightweight CGI module? (Caesar_Ancheta)
Re: Math::Pari, Win32 and gcc <kalinabears@hdc.com.au>
Re: my $x = 100 for 1..3 why is $x undef <bernie@fantasyfarm.com>
problem printing multi-dimensional lists <raquel@rdccc.com>
Re: problem printing multi-dimensional lists <krahnj@acm.org>
Re: Question about the filehandle example in the perl F <bwalton@rochester.rr.com>
Re: Send files from FORM to Mail in Outlook <me@privacy.net>
Re: Send files from FORM to Mail in Outlook <dorward@yahoo.com>
Re: Stupid Perl Questions (Caesar_Ancheta)
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 14 Mar 2003 21:54:10 -0600
From: die@spammer.die (Mark Healey)
Subject: Re: [Probably] a stupid question about REGEX
Message-Id: <VP2SpNyJrzMZ-pn2-JggccZdEcHSM@adsl-63-207-135-60.dsl.sndg02.pacbell.net>
On Sat, 15 Mar 2003 00:59:33 UTC, Gunnar Hjalmarsson
<noreply@gunnar.cc> wrote:
> Mark Healey wrote:
> > For the life of me I can't figure out how to do a regex comparison
> > between $_ and $anyVariable.
>
> You'd better give us a couple of example strings, and explain (in
> English) which kind of comparison(s) you want to do.
What I'm trying to do is filter some Garage sale listings. The search
engine on the original site is a simple keyword search. This gives me
lots of false positves. If I'm looking for sales in the neighborhood
"mission hills" I get adds that contain "mission" and "hills"
anywhere in them.
I have an array @searchTerms that has the original search terms. I'd
like to compare every element in the array to the line previous to the
one being currently examined in @lines (the line after the one I want
always has the "> at the beginning where the line I want has no
stereotypical text.)
So I look for ">. That means that the previous line ($last) has the
relevant text.
I'd like to look for all the search terms in $last and only place them
in descriptions.
------------------------------
Date: Sat, 15 Mar 2003 08:49:57 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: [Probably] a stupid question about REGEX
Message-Id: <x78yvh8157.fsf@mail.sysarch.com>
>>>>> "MH" == Mark Healey <die@spammer.die> writes:
MH> For the life of me I can't figure out how to do a regex comparison
MH> between $_ and $anyVariable.
MH> You can see my attempt on line 54. I've tried $last =~ /$_/i as well
MH> with no results.
MH> I'm probably missing something simple but can't seem to find it.
MH> 48 foreach(@lines)
MH> 49 {
MH> 50 if (/\A">/)
MH> 51 {
MH> 52 foreach(@searchTerms)
MH> 53 {
MH> 54 if (/$_/i =~ $last)
i am surprised no one else has mentioned you have those arguments
backwards. that is being parsed as /$_/i by itself and the result of
that (a boolean) being compared to the regex in $last.
it should be
if ( $last =~ /$_/i )
you claim you tried that but there is no way the current line makes
sense. now if you change it back to this and show some data and regexes
then the real bug could be found.
swapping arguments around for no reason is not a good debugging technique.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
----- Stem and Perl Development, Systems Architecture, Design and Coding ----
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
Damian Conway Perl Classes - January 2003 -- http://www.stemsystems.com/class
------------------------------
Date: 14 Mar 2003 21:18:45 -0800
From: dwlepage@yahoo.com (david)
Subject: file parse into hash and writing output with certain format to new file
Message-Id: <b09a22ae.0303142118.489851f2@posting.google.com>
I am new to perl as im sure my code will show, which is partly the
reason for this post. What im trying to do a replace a one field in a
file with another, write a second file with this modification, store
these two fields in a hash, and use them to populate data into a 3rd
file.
Here is what I have so far, which works, but im sure could use
improvements.
#!/usr/bin/perl
use strict;
my @seperate = ();
my %records;
my ($fields, $ser, $key, $value);
open (FILE, "<import0.dat") || die "Couldn't open file; $!\n";
open (OUT, ">output.dat") || die "Couldn't create file; $!\n";
open (NEWOUT, ">newout.dat") || die "Couldn't create; $!\n";
while ( <FILE> ) {
my @fields = split ( /\Q,\E/ );
if ( $fields[7] =~ m/^(\$\$)(S\/N:)(\w+)/ ) {
my @ser = "$1$3$1";
( $fields[1], $ser[0] ) = ( $ser[0], $fields[1] );
push ( @seperate, join (',', @fields) );
$records{"@ser"} = $fields[1];
foreach my $records (keys %records) {
}
}
#while ( ($key,$value ) = each %records ) {
# print OUT "$key --> $value\n";
}
print OUT "@seperate\n";
close(FILE);
close (OUT);
close (NEWOUT);
Is there a better way to do this?
My second question is once I have these values in the hash table what
is the best way to use these values to populate a third file?
For example, I want to create a third file (sent to "NEWOUT") which
has the format:
User = $fields[1]
Number = @ser
User = $fields[1]
Number = @ser
etc.
Im sure there is an easier way to do this - any suggestions?
Thanks!
------------------------------
Date: Sat, 15 Mar 2003 10:19:42 +0100
From: Marek Stepanek <mstep@t-online.de>
Subject: FILEHANDLE and search and replace question
Message-Id: <BA98AEBE.4995%mstep@t-online.de>
Hello,
I am new to perl and have a question about a search and replace, which is
not working in my script.
How do I open the file correctly (with < or > or +< or +>) to make a search
and replace? If I understand well, first the script has to read in the lines
and than replace them. So I opt for "+<" - but I tried every combination ...
open GLOBALRESULT_HTM, "+<$bearbeitetverzeichnis/resultsglobal.htm" or die
"could not open your genious resultsglobal.htm_file $!";
#The path is correct, creating with it in the script
a .htm file, which is working perfectly
how to make correctly the search and replace in this opened file, I tried in
vain many variants of the following:
while (my @alle_zeilen=<GLOBALRESULT_HTM>){
for (@alle_zeilen) {
print GLOBALRESULT_HTM s/ohne|mit/<SPAN CLASS=\"wichtich\">$&<SPAN>/g;
}
}
or
for (@alle_zeilen=<GLOBALRESULT_HTM>) {
print GLOBALRESULT_HTM s/ohne|mit/<SPAN CLASS=\"wichtig\">$&<SPAN>/g;
}
but it is not working :-( I feel I am missing something obviously.
Thank you in advance for your help and patience !
marek
______________________________________________________________________
___PODIUM_INTERNATIONAL_//_the_embassy_for_talented_young_musicians___
_______Marek_Stepanek__mstep_[at]_PodiumInternational_[dot]_de________
__________________http://www.PodiumInternational.de___________________
______________________________________________________________________
------------------------------
Date: Sat, 15 Mar 2003 09:41:56 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: FILEHANDLE and search and replace question
Message-Id: <b0t57v885t7b0rjq489pn56gk4v0u0k3ig@4ax.com>
Marek Stepanek wrote:
>How do I open the file correctly (with < or > or +< or +>) to make a search
>and replace?
Use the -i command line option (see "perlrun") to make an inplace
replacement using the original file as a backup.
#! perl -i.bak
while(<>) {
s/(\w+)/\u$1/g;
print;
}
This will rename the original file, which you pass through the command
line parameters (you can set @ARGV in the script), attaching ".bak" to
it, and create another file with the original name, with the modified
contents.
Alkternatively, indeed you can use the "+<" mode to open the file, read
*everything* into memory, modify the contents, do
seek HANDLE, 0, 0;
truncate HANDLE, 0;
and then print the modified contents to the same handle.
seek() rewinds the file pointer to the start of the file, truncate()
shortens the length of the file to 0.
Sop make sure no two programs try to access/modify the same file at the
same time. You'll get massive loss of data that way.
--
Bart.
------------------------------
Date: Sat, 15 Mar 2003 14:26:09 +0100
From: Marek Stepanek <mstep@t-online.de>
Subject: Re: FILEHANDLE and search and replace question
Message-Id: <BA98E881.4D36%mstep@t-online.de>
On 15.03.2003 10:41 Uhr, in article
b0t57v885t7b0rjq489pn56gk4v0u0k3ig@4ax.com, "Bart Lateur"
<bart.lateur@pandora.be> wrote:
> Marek Stepanek wrote:
>
>> How do I open the file correctly (with < or > or +< or +>) to make a search
>> and replace?
>
> Use the -i command line option (see "perlrun") to make an inplace
> replacement using the original file as a backup.
>
> #! perl -i.bak
> while(<>) {
> s/(\w+)/\u$1/g;
> print;
> }
>
> This will rename the original file, which you pass through the command
> line parameters (you can set @ARGV in the script), attaching ".bak" to
> it, and create another file with the original name, with the modified
> contents.
>
> Alkternatively, indeed you can use the "+<" mode to open the file, read
> *everything* into memory, modify the contents, do
>
> seek HANDLE, 0, 0;
> truncate HANDLE, 0;
>
> and then print the modified contents to the same handle.
>
> seek() rewinds the file pointer to the start of the file, truncate()
> shortens the length of the file to 0.
>
> Sop make sure no two programs try to access/modify the same file at the
> same time. You'll get massive loss of data that way.
Thanx Bart,
Inspired from your answer, I found _my_ solution, after two weeks of
desperate search.
Two mistakes:
for (<GLOBALRESULT_BAK_HTM>) {
print GLOBALRESULT_HTM s/ohne|mit/<SPAN CLASS=\"wichtig\">$&<SPAN>/g;
}
should be:
for (<GLOBALRESULT_BAK_HTM>) {
s/ohne|mit/<SPAN CLASS=\"wichtig\">$&<SPAN>/g;
print GLOBALRESULT_HTM;
}
<provocation>
And in fact I doubted about it: you need a second (!!!) file to replace
something in the original, which gives me three files to have an result in
html: first file, comma separated Database-file resulting from a huge
perl-program, second the results in a big table in an temporarily html-file,
and a third one to change some tiny little html in it :-(
I have nearly every Perl-Book meanwhile, but nobody is telling us newbies
that s///g is not working "in place" on one file. Why is it not possible to
read in a file treat the content, and write the changed text back to the
same file??? Or probably I oversaw a footnote ??? Or probably I did not
understand how to do it elegantly. Astonishing that Perl is said to be a
powerful language to treat text files ...
</provocation>
greetings from Munich
marek
______________________________________________________________________
___PODIUM_INTERNATIONAL_//_the_embassy_for_talented_young_musicians___
_______Marek_Stepanek__mstep_[at]_PodiumInternational_[dot]_org_______
__________________http://www.PodiumInternational.org__________________
______________________________________________________________________
------------------------------
Date: Sat, 15 Mar 2003 10:44:08 +0100
From: Marek Stepanek <mstep@t-online.de>
Subject: Find&Replace only in a certain scope
Message-Id: <BA98B478.4BEF%mstep@t-online.de>
Hello all,
one beginner question more:
************************Original in structure*******************************
<TABLE>
<TR>
<TD>
some stuff comes here, pretty complicate, and there comes a
_keyword_ with an index _01 or _02 or _03
</TD>
<TD>
some stuff comes here, pretty complicate, and there comes a
_keyword_ with an index _01 or _02 or _03
</TD>
</TR>
</TABLE>
<TABLE>
<TR>
<TD>
some stuff comes here, pretty complicate, and there comes a
_keyword_ with an index _01 or _02 or _03
</TD>
<TD>
some stuff comes here, pretty complicate, and there comes a
_keyword_ with an index _01 or _02 or _03
</TD>
</TR>
</TABLE>
********With replaced patterns becomes:*************************************
<TABLE>
<TR>
<TD>
some stuff comes here, pretty complicate, and there comes a
_keyword_ with an index _01
</TD>
<TD>
some stuff comes here, pretty complicate, and there comes a
_keyword_ with an index _01
</TD>
</TR>
</TABLE>
<TABLE>
<TR>
<TD>
some stuff comes here, pretty complicate, and there comes a
_keyword_ with an index _02
</TD>
<TD>
some stuff comes here, pretty complicate, and there comes a
_keyword_ with an index _02
</TD>
</TR>
</TABLE>
***********************************END of changed tables********************
In each table are many many _keyword_ and many different _01 and _02 _03 ...
first table has to have only _01, the second one _02 the third _03 ... etc
What I needed in my Perl-script is the following:
1. search _keyword_
2. search backwards with EXTEND SELECTION <TABLE
3. search with EXTEND SELECTION next </TABLE
4. replace with grep in SELECTION _0\d with _0$number
5. increment $number++
5. again 1. until not found of _keyword_
I cannot find an equivalent to SELECTION and replace in SELECTION (linke in
BBEdit or Applescript) in Perl ??? Or do I have to look for "seek" look
backwards for the nearest "<table" put the offset in a variable $start_of_SR
and look forwards searching for the closest "</table" putting the position
to a variable $end_of_SR - making the search and replace only between
$start_of_SR and $end_of_SR ? Really I looked through all my Perl-Books, but
no clue, how to achieve it. The loop is not my problem but the scope ...
greetings from Munich
marek
------------------------------
Date: 15 Mar 2003 03:10:21 GMT
From: gorilla@elaine.furryape.com (Alan Barclay)
Subject: Re: frames without files ?
Message-Id: <1047697821.446502@elaine.furryape.com>
In article <3E723797.8090601@rcn.com>, Eric Osman <ericosman@rcn.com> wrote:
>But if I want my Perl to generate a frameset page pointing at two other
>pages (the table of contents and the body), is there a way I can do this
>without writing auxiliary disk files ?
Yes. Exactly the same way as you'd do it in any other language.
------------------------------
Date: 15 Mar 2003 08:40:34 GMT
From: Stephen Patterson <s.patterson@freeuk.com>
Subject: Re: frames without files ?
Message-Id: <slrnb75pn0.18e.s.patterson@eccles.localdomain>
On Fri, 14 Mar 2003 20:56:33 -0500, Mina Naguib wrote:
>> Now I want to enhance the Perl so that it adds a table of contents
>> frame. Because of SECURITY I'd rather not write any files.
>>
>> When it was just the one page being written back, it was simple, as
>> I just put in "print" lines in Perl to write HTML code back to the
>> browser.
>>
>> But if I want my Perl to generate a frameset page pointing at two other
>> pages (the table of contents and the body), is there a way I can do this
>> without writing auxiliary disk files ?
I've done this once before in pure server-side (perl) CGI, I can't
remember how though except that it took a lot of working out.
*wanders off to RTFM*
There's a -target option you can pass to each start_html()
invocation, and in the CGI module docs, there's a whole section on
working with frames. See perldoc CGI for info.
--
Stephen Patterson http://www.lexx.uklinux.net http://patter.mine.nu
steve@SPAM.lexx.uklinux.net remove SPAM to reply
Linux Counter No: 142831 GPG Public key: 252B8B37
Last one down the pub's an MCSE
------------------------------
Date: Sat, 15 Mar 2003 02:58:30 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: Getting list of files from Win32 clipboard
Message-Id: <3e729506.32033080@news.erols.com>
Gunnar Hjalmarsson <noreply@gunnar.cc> wrote:
: Phil Hibbs wrote:
: > I have a perl script that does this:
: >
: > use Win32::Clipboard;
: > my $CLIP = Win32::Clipboard();
: > if ($CLIP->IsFiles()) {
: > $CLIP->Set($CLIP->GetFiles);
:
: $CLIP->GetFiles is an array. Maybe you may want to try:
:
: $CLIP->Set(join "\n", $CLIP->GetFiles);
:
: > } else {
: > $CLIP->Set($CLIP->GetText);
:
: What's the point with that? As far as I understand, it just pastes the
: very same text string to the clipboard as was just copied from the
: clipboard...
Eh. Not really the same. What is on the clipboard is a set of file
objects, which is more than just a text string of filenames.
FWIW to the OP, Microsoft's "Windows 95 Power Toys Set" includes a
"send to clipboard as name" whizbang that gets the task done in one
step instead of two. I haven't tried it with more recent windows
versions.
------------------------------
Date: Sat, 15 Mar 2003 13:45:12 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Getting list of files from Win32 clipboard
Message-Id: <b4v7it$238srm$1@ID-184292.news.dfncis.de>
Jay Tilton wrote:
> Gunnar Hjalmarsson <noreply@gunnar.cc> wrote:
> : > $CLIP->Set($CLIP->GetText);
> :
> : What's the point with that? As far as I understand, it just pastes the
> : very same text string to the clipboard as was just copied from the
> : clipboard...
>
> Eh. Not really the same. What is on the clipboard is a set of file
> objects, which is more than just a text string of filenames.
That question refers only to the
$CLIP->Set($CLIP->GetText);
statement, which seems to be executed only when the clipboard does *not*
contain files.
/ Gunnar
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Sat, 15 Mar 2003 17:43:26 +0800
From: "news.pacific.net.sg" <xiamen2@hotmail.com>
Subject: how to create NULL character in perl
Message-Id: <b4use5$ntq$1@nobel.pacific.net.sg>
I'm trying to get a NULL character in perl.
my $null = Win32::OLE::Variant->new(VT_NULL,undef);
This doesn't work and cause me memory error, does anybody know how to create
a NULL?
Thx, GF
------------------------------
Date: Sat, 15 Mar 2003 23:57:46 +1100
From: "Sisyphus" <kalinabears@hdc.com.au>
Subject: Re: how to create NULL character in perl
Message-Id: <3e732422$0$25078@echo-01.iinet.net.au>
"news.pacific.net.sg" <xiamen2@hotmail.com> wrote in message
news:b4use5$ntq$1@nobel.pacific.net.sg...
> I'm trying to get a NULL character in perl.
>
> my $null = Win32::OLE::Variant->new(VT_NULL,undef);
>
> This doesn't work and cause me memory error, does anybody know how to
create
> a NULL?
>
> Thx, GF
>
$null = chr(0);
or
$null = "\0";
Cheers,
Rob
------------------------------
Date: 15 Mar 2003 06:03:19 -0800
From: francescomoi@europe.com (Francesco Moi)
Subject: I want to: include 'right.php'
Message-Id: <5b829932.0303150603.6ca779f0@posting.google.com>
Hello
I've got some pages made with PHP. On those pages, I repeat
the same structure, with a menu bar on the right.
Now, I'm traslating some of those pages into Perl (Apache module),
but I would like to keep 'right.php'.
In PHP, the method was:
-----------
include 'right.php';
--------------
Is there something similar in Perl? Thank you very much.
------------------------------
Date: 15 Mar 2003 04:17:00 -0800
From: ppopour@coastalnow.net (Paul)
Subject: Re: Interpolation problem?
Message-Id: <8ba68739.0303150417.704e8b36@posting.google.com>
Steve May <stevenm@bogus.blackwater-pacific.com> wrote in message news:<b4qunn$6fi$1@quark.scn.rain.com>...
> Paul wrote:
> > I've tried every combination I could think of in this regex and read
> > the perlre and perlop material and search for post on the problem but
> > I must be missing the obvious.
> >
> > I'm traversing an IIS server directory structure comparing file sizes.
> > I want to strip my root path off of a fully qualified file name that
> > is being compiled as the structure is traversed.
> >
> > $root = '//server4/k\$/inetpub';
> ^ escape not needed w/single quotes
>
> > $entry = '//server4/k\$/inetpub/Wwwroot/sub1/filename.ext';
> > $entry =~ s/$root//;
> > print "$entry\n";
> >
> > I've changed $root to the server name and the results are as expected.
> > I've tried double quoting with double backslashes and that didn't
> > seem to make any difference. I've changed the delimiter to | and #
> > that didn't seem to make any difference. Any help would be
> > appreciated.
> >
> > Paul
>
> The other suggestions given are good ones (modules to use) but maybe
> you're annoyed because you can't make the substitution above work?
>
> You might try to 'quote' the pattern scalar:
>
> my $root = '/some/path/to/foo';
> my $entry = '/some/path/to/foo/foo.txt';
>
> $entry =~ s/\Q$root\E//;
> ^ ^ trailing \E is not mandatory (in this case)
>
> print "$entry\n";
>
> Didn't test this, but it's so brain dead simple that I don't *think* I
> screwed it up. :-)
>
> s.
Braindead is an exactly appropriate decription. I guess I just flat
missed the meaning of "disable pattern metacharacters till \E" from
perlre. Thanks for the helping hand.
------------------------------
Date: Fri, 14 Mar 2003 21:40:40 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: it's true but can I say so ?
Message-Id: <3E7292A8.30FC57F5@earthlink.net>
Martien Verbruggen wrote:
>
> On 15 Mar 2003 00:27:52 GMT,
> Abigail <abigail@abigail.nl> wrote:
> > Martien Verbruggen (mgjv@tradingpost.com.au) wrote on MMMCDLXXXII
> > September MCMXCIII in <URL:news:slrnb74obm.j8t.mgjv@martien.heliotrope.home>:
> > -:
> > -: But, again, I've seen many people try it. And in languages where boolean
> > -: truth and falseness isn't a bipolar situation, that's really broken.
> >
> >
> > Many people, including myself, wouldn't call SQL really broken.
>
> But in SQL, truth and falseness _is_ a bipolar situation.
What about NULL?
--
$a=24;split//,240513;s/\B/ => /for@@=qw(ac ab bc ba cb ca
);{push(@b,$a),($a-=6)^=1 for 2..$a/6x--$|;print "$@[$a%6
]\n";((6<=($a-=6))?$a+=$_[$a%6]-$a%6:($a=pop @b))&&redo;}
------------------------------
Date: Sat, 15 Mar 2003 16:59:00 +1100
From: Martien Verbruggen <mgjv@tradingpost.com.au>
Subject: Re: it's true but can I say so ?
Message-Id: <slrnb75g94.j8t.mgjv@martien.heliotrope.home>
On Fri, 14 Mar 2003 21:40:40 -0500,
Benjamin Goldberg <goldbb2@earthlink.net> wrote:
>
>
> Martien Verbruggen wrote:
>>
>> On 15 Mar 2003 00:27:52 GMT,
>> Abigail <abigail@abigail.nl> wrote:
>> > Martien Verbruggen (mgjv@tradingpost.com.au) wrote on MMMCDLXXXII
>> > September MCMXCIII in <URL:news:slrnb74obm.j8t.mgjv@martien.heliotrope.home>:
>> > -:
>> > -: But, again, I've seen many people try it. And in languages where boolean
>> > -: truth and falseness isn't a bipolar situation, that's really broken.
>> >
>> >
>> > Many people, including myself, wouldn't call SQL really broken.
>>
>> But in SQL, truth and falseness _is_ a bipolar situation.
>
> What about NULL?
NULL is neither true nor false. It is null, and has its own sematics.
In C, NULL is a false value. In Perl, undef is a false value. In SQL
null is simply null, and it depends mainly on the application what
nullness of a field means.
Martien
--
|
Martien Verbruggen | Unix is user friendly. It's just selective
| about its friends.
|
------------------------------
Date: Sat, 15 Mar 2003 03:21:19 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: it's true but can I say so ?
Message-Id: <3E72E27F.BA24C94B@earthlink.net>
Martien Verbruggen wrote:
> Benjamin Goldberg wrote:
> > Martien Verbruggen wrote:
> >> Abigail wrote:
> >> > Martien Verbruggen wrote:
> >> > -:
> >> > -: But, again, I've seen many people try it. And in languages
> >> > -: where boolean truth and falseness isn't a bipolar situation,
> >> > -: that's really broken.
> >> >
> >> > Many people, including myself, wouldn't call SQL really broken.
> >>
> >> But in SQL, truth and falseness _is_ a bipolar situation.
> >
> > What about NULL?
>
> NULL is neither true nor false. It is null, and has its own sematics.
Precisely. In other words, in SQL truth and falseness _is not_ a
bipolar situation -- it's tripolar: true, false, and NULL.
--
$a=24;split//,240513;s/\B/ => /for@@=qw(ac ab bc ba cb ca
);{push(@b,$a),($a-=6)^=1 for 2..$a/6x--$|;print "$@[$a%6
]\n";((6<=($a-=6))?$a+=$_[$a%6]-$a%6:($a=pop @b))&&redo;}
------------------------------
Date: Sat, 15 Mar 2003 09:31:28 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: it's true but can I say so ?
Message-Id: <bms57vshaucomnk72vf9ta3utoba2oq2r5@4ax.com>
Andras Malatinszky wrote:
>sub true{
> return (1==1)
>};
>sub false{
> return (1==0)
>};
use constant TRUE => 1==1;
use constant FALSE => !TRUE;
--
Bart.
------------------------------
Date: Sat, 15 Mar 2003 09:34:03 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: it's true but can I say so ?
Message-Id: <dps57vg8c39g3ra8qc99najlsl2k4qbhs5@4ax.com>
Eric Osman wrote:
>I want to ask here : Does Perl provide some builtin way to declare
>something to be "true" or "false" ? Or must some representative
>expressions such as 0 and 1 be used instead ?
Whatever solution you find, please don,'t mùake the mistake of comparing
values to TRUE and FALSE. Most true values are not 1, and not all false
values are !1. Saying cond==TRUE or cond==FALSE will miss some likely
equivalences.
--
Bart.
------------------------------
Date: 15 Mar 2003 03:46:58 -0800
From: caesar_ancheta@yahoo.com (Caesar_Ancheta)
Subject: Re: Lightweight CGI module?
Message-Id: <5d34f091.0303150346.741e595d@posting.google.com>
use strict;
use DBI;
use CGI;
#get on with life
I agree with alex that CGI is a minor contributor to latency. The
advantage to using Lincoln Stein's work is that many people have used
it, it's well de-bugged, cross-platform, etc.
The DBI connect to ODBC is also minor compared to the Client-side
Think time. I use the 5-second rule of thumb; Clients will ignore 1 to
3 second latency. 5 seconds is acceptable. The ODBC is essential
because it allows us to use Perl and SQL rather than the Unspeakable.
If we discard ODBC, we then lose the possibility of cross-platform
usage.
In other words, there are bigger problems than producing a Lightweight
CGI module. The industrial-strength solution is to produce the
software in time, and to scale-up the hardware if the response is
wanting, not to question Lincoln Stein's winning standard, CGI.pm .
"alex" <ntnewsNOSPAM@hrz3.hrz.tu-darmstadt.de> wrote in message news:<b4d5s4$1p6$03$1@news.t-online.com>...
>DBI ...
> ODBC connect... ..takes about 0.22 seconds!!! if i remove it and for e.g.
> use CGI and a param it takes about 0.01sec.
------------------------------
Date: Sun, 16 Mar 2003 00:30:11 +1100
From: "Sisyphus" <kalinabears@hdc.com.au>
Subject: Re: Math::Pari, Win32 and gcc
Message-Id: <3e732bba$0$25074@echo-01.iinet.net.au>
"Ilya Zakharevich" <nospam-abuse@ilyaz.org> wrote in message
news:b4rgup$2ps7$1@agate.berkeley.edu...
> [A complimentary Cc of this posting was sent to
> Sisyphus
> <kalinabears@hdc.com.au>], who wrote in article
<3e70434c$0$22385@echo-01.iinet.net.au>:
> > Hi,
> > I have perl5.6.1 built with mingw32 (gcc and dmake) on Windows 2000.
> >
> > Been trying to build Math::Pari for a couple of days.
> >
> > I was getting 'unresolved references' to 'geteuid', 'getpwnam' and 4
other
> > nixy-type functions - so I amended the makefile.pl's (there are 2) to
link
> > to libcygwin.a by using the '-L' and '-l' switches.
>
> Instead find where these functions are called, and look for the symbol
> to define so that they are not called. Let me know the details.
>
> BTW, are you sure you've read README/INSTALL? I would think that this
> problem should be fixed by giving "Configure" option to Makefile.PL...
> Again, let me know.
>
> These function calls should not have any relevance to how the library
> is used. If anything else fails, find how to #ifdef them out. Again,
> let me know. [Now you got the drift, right? ;-]
>
> Hope this helps,
> Ilya
Here's a brief account of the solution. If anyone requires further
information, post here or email me. (If you want me to be sure of seeing the
post, probably best to cc me.) I've emailed a more detailed account to Ilya.
Firstly, my compiler (gcc) currently has the following additional includes,
copied from the MSYS source distribution:
sys/times.h
sys/config.h
machine/types.h
_ansi.h
pwd.h
'pwd.h' is currently necessary - though there may exist a workaround that
avoids it. I'll be looking at that over the next few days. I haven't yet
checked to see which (if any) of the other additional includes are needed.
The nix-type functions getpwnam, getpwuid, getuid and geteuid were all
introduced in language/es.c. As Ilya suggested it wasn't difficult to #ifdef
them out.
Only other problem was with language/init.c. There's a block of code
starting '#elif USE_TIMES' and I was ending up in that block. This resulted
in a fatal 'unresolved reference to 'times''. I changed 'USE_TIMES' to '0'
and everything then ran smoothly.
Cheers,
Rob
------------------------------
Date: Sat, 15 Mar 2003 07:03:07 -0500
From: Bernie Cosell <bernie@fantasyfarm.com>
Subject: Re: my $x = 100 for 1..3 why is $x undef
Message-Id: <12DFE4D479096176.CC09355528DBA814.E734F035207122C4@lp.airnews.net>
Abigail <abigail@abigail.nl> wrote:
} Martien Verbruggen (mgjv@tradingpost.com.au) wrote on MMMCDLXXX September
} MCMXCIII in <URL:news:slrnb6t9av.79p.mgjv@verbruggen.comdyn.com.au>:
} ##
} ## It is not a bug, because it is documented to result in undefined
} ## behaviour.
}
} I'm not quite sure I agree with that.
}
} When people started trying this construct ('my $foo = 1 if 0;'),
} people argued whether that was a feature or not. ...
I was one such ... for those who weren't around for that, at least in some
versions of perl [haven't tried it in 5.8] the construct:
my $foo = 1 if 0;
gave you a cheap static lexical variable: $foo is defined lexically, but
doesn't get anything assigned to it, and [as it turns out] it *retains* the
last value it had. And so if you write:
> perl -e 'sub a {my $x = 0 if 0;
print "\$x is $x\n";
$x= $_[0]};
a(1); a(2); a(3);'
$x is
$x is 1
$x is 2
I thought that was pretty cool [especially since it is a mile cleaner and
simpler (at least from the outside..:o)) than the 'official' way of getting
a local-static-variable]...
} ...Only after p5p
} couldn't decide what to do with it, they decided to at least
} document it as having undefined behaviour.
Interesting. I didn't hear that. What'd be neater than supporting this
rather hacky usage, IMO, would be to take advantage of the way it actually
works and enshrine it in a real 'static' declaration [which ought not take
much work, since it already *functions* as a static --- all that's missing
is an 'approved' connection to the existing behavior]
/Bernie\
--
Bernie Cosell Fantasy Farm Fibers
bernie@fantasyfarm.com Pearisburg, VA
--> Too many people, too few sheep <--
------------------------------
Date: Fri, 14 Mar 2003 22:04:22 -0500
From: Raquel Mangual <raquel@rdccc.com>
Subject: problem printing multi-dimensional lists
Message-Id: <BA980265.276D%raquel@rdccc.com>
Hello Everyone,
I'm trying to print the contents of a multi-dimensional list one column at a
time. The size of the list is 5 rows by N columns. The syntax check is fine,
but when I run the script, I get a "Use of uninitialized value in
concatenation (.) or string, <STDIN> line 5" error message.
Following is my code for printing the first column of each row. Any
pointers/suggestions would be greatly appreciated. Also, if anyone knows of
a general format for printing multi-dimensional lists, please send me a link
or sample. Thanks!
****************************************************************************
# display the requests individually
$count = 0;
foreach $i (@AllRequests)
{
print "Request $count is:\n";
print "Input file: " . $AllRequests[$count][$i] . "\n";
print "Ouput file: " . $AllRequests[$count][$i] . "\n";
print "Output file size: " . $AllRequests[$count][$i] . "\n";
print "Prefix size: " . $AllRequests[$count][$i] . "\n";
print "Modification Formula Number: " . $AllRequests[$count][$i] . "\n";
$count++;
}
------------------------------
Date: Sat, 15 Mar 2003 07:18:47 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: problem printing multi-dimensional lists
Message-Id: <3E72D3CB.F8E63706@acm.org>
Raquel Mangual wrote:
>
> I'm trying to print the contents of a multi-dimensional list one column at a
> time. The size of the list is 5 rows by N columns. The syntax check is fine,
> but when I run the script, I get a "Use of uninitialized value in
> concatenation (.) or string, <STDIN> line 5" error message.
> Following is my code for printing the first column of each row. Any
> pointers/suggestions would be greatly appreciated. Also, if anyone knows of
> a general format for printing multi-dimensional lists, please send me a link
> or sample. Thanks!
>
> ****************************************************************************
> # display the requests individually
> $count = 0;
> foreach $i (@AllRequests)
Since @AllRequests is a multi-dimensional array the value in $i is an
array reference like ARRAY(0x12345678) Using this value to index the
array will probably NOT do what you intended.
> {
> print "Request $count is:\n";
> print "Input file: " . $AllRequests[$count][$i] . "\n";
^^^^^^^^^^^^^^^^^^^^^^^^
This is the same as: $i->[$i] You probably want to use $i->[$count]
instead.
Perhaps you should read up Perl's references and data structures.
perldoc perllol
perldoc perldsc
perldoc perlreftut
perldoc perlref
John
--
use Perl;
program
fulfillment
------------------------------
Date: Sat, 15 Mar 2003 02:59:25 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: Question about the filehandle example in the perl FAQ
Message-Id: <3E72970C.6080803@rochester.rr.com>
Steve Grazzini wrote:
> Bob Walton <bwalton@rochester.rr.com> wrote:
>
...
>>>
>>No, it was attempting to glob the literal filename pattern
>>$FHArray[0]. So if you had a file named '$FHArray[0]', it
>>would match and return that name. Just like if you did:
>>
>> $v='$FHArray[0]';
>> ... <$v> ...
>>
>
> The angle bracket glob does interpolation -- which probably
> makes little difference here, but if $FHArray[0] contained a
> matchable wildcard...
>
> $ perl -le '$a[1] = "/etc/*"; print for <$a[1]>'
> /etc/adjtime
> /etc/aliases
> ...
>
>
Oops, yes, you are correct. Sorry about the wrong statement. I didn't
realize that -- thanks!
--
Bob Walton
------------------------------
Date: Sat, 15 Mar 2003 17:25:36 +1100
From: "Tintin" <me@privacy.net>
Subject: Re: Send files from FORM to Mail in Outlook
Message-Id: <b4uh11$23qdbu$1@ID-172104.news.dfncis.de>
"timgbp" <timgbp@tims.ericsson.se> wrote in message
news:3E726659.1010501@tims.ericsson.se...
> Hi;
>
> How I can send archives by means of a Form in attachment, for example
> documents of Word, Excel, pdf.
>
> With a cgi.
http://search.cpan.org/author/ERYQ/MIME-Lite-2.117/lib/MIME/Lite.pm
------------------------------
Date: Sat, 15 Mar 2003 08:30:07 +0000
From: David Dorward <dorward@yahoo.com>
Subject: Re: Send files from FORM to Mail in Outlook
Message-Id: <b4uo5b$h5f$2$8300dec7@news.demon.co.uk>
timgbp wrote:
> How I can send archives by means of a Form in attachment, for example
> documents of Word, Excel, pdf.
http://www.akadia.com/services/email_attachments_using_perl.html
--
David Dorward http://david.us-lot.org/
"You cannot rewrite history, not one line."
- The Doctor (Dr. Who: The Aztecs)
------------------------------
Date: 15 Mar 2003 02:48:19 -0800
From: caesar_ancheta@yahoo.com (Caesar_Ancheta)
Subject: Re: Stupid Perl Questions
Message-Id: <5d34f091.0303150248.6b8ae652@posting.google.com>
Although the answers were freely given, you may have enabled a crack
attack. The most questionable technology is the TinyPerl,TinyWeb on a
floppy. I suggest that one misuse of this thread would be to zip the
above and take over a file system.
j0hnfr0g@yahoo.com (JohnFrog) wrote in message news:<16008e62.0303130636.5d55706c@posting.google.com>...
> 1) Can I call and run DOS executables from a Perl script?
> 2) Can I easily create a standalone program (1 file) that runs under
> DOS (command prompt) that contains my script and the Perl interpreter
> (or just what is needed for my script), so that from an end-user
> perspective it just looks like a DOS executable?
> 3) Is there a preferred place to download a Perl interpreter from?
------------------------------
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 4712
***************************************