[22493] in Perl-Users-Digest
Perl-Users Digest, Issue: 4714 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Mar 15 18:06:47 2003
Date: Sat, 15 Mar 2003 15: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: 4714
Today's topics:
Re: [Probably] a stupid question about REGEX <uri@stemsystems.com>
Re: DBI Resources <spam@thecouch.homeip.net>
Re: DBI Resources <will@com.yahoo>
Re: file parse into hash and writing output with certai (david)
Re: Find&Replace only in a certain scope <will@com.yahoo>
Re: how to create NULL character in perl (David Efflandt)
Re: How to find a word which is palindromica using REGE (Anno Siegel)
Re: How to find a word which is palindromica using REGE <mpapec@yahoo.com>
Re: How to find a word which is palindromica using REGE <jurgenex@hotmail.com>
Re: How to find a word which is palindromica using REGE <garry@ifr.zvolve.net>
Re: How to find a word which is palindromica using REGE <grazz@nyc.rr.com>
Re: How to find a word which is palindromica using REGE (Anno Siegel)
Re: I want to: include 'right.php' <will@com.yahoo>
Re: it's true but can I say so ? <abigail@abigail.nl>
Re: it's true but can I say so ? <mgjv@tradingpost.com.au>
Re: problem printing multi-dimensional lists <tzeng@pacbell.net>
Re: problem printing multi-dimensional lists <will@com.yahoo>
Question: What's the proper way to retrieve last mod da <linkseer@yahoo.com>
Re: Question: What's the proper way to retrieve last mo <tony_curtis32@yahoo.com>
Sorting using DB_FILE/DB_BTREE <anandks@optonline.net>
Re: Sorting using DB_FILE/DB_BTREE <jurgenex@hotmail.com>
Re: Sorting using DB_FILE/DB_BTREE (Anno Siegel)
Re: Stupid Perl Questions (Caesar_Ancheta)
Re: What's wrong with the Perl docs <abigail@abigail.nl>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sat, 15 Mar 2003 21:29:51 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: [Probably] a stupid question about REGEX
Message-Id: <x78yvg71yp.fsf@mail.sysarch.com>
>>>>> "MH" == Mark Healey <die@spammer.die> writes:
MH> All I want to do is determine if $_ is a substring of $last, ignoring
MH> case.
MH> For example I submitted "mission hills" to the website and got these
MH> three responses. It is an ORed keyword search which gives me the
MH> false positive third line because it contains "hills". I'd like to
MH> filter the false positives.
MH> MISSION HILLS Sat 8-12. Multi-fam. Fun items, good prices. 3760 Hawk
MH> St. off University btween Sutter & Bush
MH> MISSION HILLS Moving sale Sat-Sun 9-5. Furniture, clothing, pictures &
MH> more. 4126 ARDEN WAY
MH> MOUNT HELIX, Sat 7-1. Multi-Family. Rolling Hills/ Sunrise Hills.
MH> Furn, appls, toys, antiques, clothes, misc
so make it an ANDed search. what is the problem? just loop over the keys
and bail out if any fail. if you fall through then all the keys matched
and you have a matched line.
you seem to be running in a strange circle to get a simple search done.
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: Sat, 15 Mar 2003 14:35:01 -0500
From: Mina Naguib <spam@thecouch.homeip.net>
Subject: Re: DBI Resources
Message-Id: <HfLca.22323$6L3.347330@wagner.videotron.net>
-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1
Buck Turgidson wrote:
> I have been looking for some good material on how to implement DBI for
> Oracle, but can't find anything of much use.
>
> I want to learn more about Perl, and I figure that going against a live
> database will give me something more interesting to do that write "hello
> world" programs all day.
>
> Can someone suggest any sites or books on how to get up and running using
> DBI?
See DBI documentation:
http://search.cpan.org/author/TIMB/DBI-1.35/DBI.pm
And DBD::Oracle documentation:
http://search.cpan.org/author/TIMB/DBD-Oracle-1.13/Oracle.pm
-----BEGIN xxx SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQE+c4BoeS99pGMif6wRAlbgAJ98C/lFcuLqDXwzIWzoUDU268lqrACfcbY0
MwCb1MhkgQINZwuRNMwL8+I=
=RNU1
-----END PGP SIGNATURE-----
------------------------------
Date: Sat, 15 Mar 2003 22:16:37 GMT
From: w i l l <will@com.yahoo>
Subject: Re: DBI Resources
Message-Id: <4i977v88ojk616us7b1d961e4k520t6uft@4ax.com>
I have oreilly's dbi book..... you can find similar stuff for FREE all
over the web. don't waste your money on the book.
- w i l l
On Fri, 14 Mar 2003 13:56:39 GMT, "Buck Turgidson" <jc_va@hotmail.com>
wrote:
>I have been looking for some good material on how to implement DBI for
>Oracle, but can't find anything of much use.
>
>I want to learn more about Perl, and I figure that going against a live
>database will give me something more interesting to do that write "hello
>world" programs all day.
>
>Can someone suggest any sites or books on how to get up and running using
>DBI?
>
------------------------------
Date: 15 Mar 2003 15:01:35 -0800
From: dwlepage@yahoo.com (david)
Subject: Re: file parse into hash and writing output with certain format to new file
Message-Id: <b09a22ae.0303151501.507b9a8f@posting.google.com>
anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) wrote in message news:<b4vp2u$s2o$1@mamenchi.zrz.TU-Berlin.DE>...
> david <dwlepage@yahoo.com> wrote in comp.lang.perl.misc:
> > 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;
>
> "use strict" is fine, but where is "use warnings"? If you're not sure
> about the quality of your code, one of the first things is to look for
> warnings it may produce. These are often a sign that something works
> for the wrong reason.
>
> > my @seperate = ();
> > my %records;
> > my ($fields, $ser, $key, $value);
>
> No need (and not good) to declare these here. They are used only
> in the loop, where you correctly declare them.
>
> > 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/ );
>
> "," isn't special in a regex, you don't need \Q and \E.
>
> > if ( $fields[7] =~ m/^(\$\$)(S\/N:)(\w+)/ ) {
>
> This can be simplified. The first two parentheses capture fixed strings,
> which is unnecessary. $2 is not used anyway.
>
> > my @ser = "$1$3$1";
>
> Why is @ser an array? You only ever store a single scalar in it.
>
> > ( $fields[1], $ser[0] ) = ( $ser[0], $fields[1] );
>
> Make the last three lines
>
> if ( $fields[7] =~ m{^\$\$S/N:(\w+)} ) {
> my $ser = '$$' . $1;
> ( $fields[1], $ser ) = ( $ser, $fields[1] );
>
> > push ( @seperate, join (',', @fields) );
> > $records{"@ser"} = $fields[1];
>
> Weird indentation. The last line becomes
>
> $records{$ser} = $fields[1];
>
> > foreach my $records (keys %records) {
> >
> > }
>
> The "foreach" loop does nothing. Throw it out.
>
> > }
> >
> > #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?
>
> Not fundamentally. Many details could be improved.
>
> > 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
>
> Then write them as soon as you have the data. Add
>
> print NEWOUT "User = $fields[1]\n";
> print NEWOUT " Number = @ser\n";
>
> to the loop body. I don't see the need for the hash from what you have now.
>
> Anno
Thank you for the feedback. I have changed my code using your
suggestions, and here is where I am.
#!/usr/bin/perl -w
use strict;
my %records;
my (@ser, @seperate, @fields);
my $ser;
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 ( /,/ );
if ( $fields[7] =~ m{^\$\$S\/N:(\w+)} ) {
my $ser = '$$' . $1 . '$$';
( $fields[1], $ser ) = ( $ser, $fields[1] );
push (@seperate, join (',', @fields));
$records{$ser} = $fields[1];
}
print NEWOUT "User =$fields[1]\n";
print NEWOUT "Number =$ser\n";
}
#while ( ($key,$value ) = each %records ) {
# print OUT "$key --> $value\n"
#}
print OUT "@seperate\n";
close(FILE);
close (OUT);
close (NEWOUT);
My 'print OUT "@seperate\n";' properly replaces the two fields in the
original file.
My 'print NEWOUT' statements do properly capture the "User =
$fields[1]\n"; value, but the 'print NEWOUT "Number = $ser\n"; ends up
blank:
i.e.
User =$$HMJ0001$$
Number =
User =$$U23567$$
Number =
User =$$U23571$$
Number =
Can you tell what may be wrong? I had the same problem when I tried
loading the $fields[7] and $ser scalars into a hash.
Also - I do appreciate the feedback, this is all new to me but I will
be shoulders deep in it until I get my arms around it, any feedback
appreciated.
------------------------------
Date: Sat, 15 Mar 2003 22:15:26 GMT
From: w i l l <will@com.yahoo>
Subject: Re: Find&Replace only in a certain scope
Message-Id: <6g977vg5jfo283mjj316pu93d8b3ais9on@4ax.com>
id first look at HTML::TableExtract or HTML::TokeParser to seperate
your data from your HTML.
-w i l l
On Sat, 15 Mar 2003 10:44:08 +0100, Marek Stepanek <mstep@t-online.de>
wrote:
>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: Sat, 15 Mar 2003 21:33:29 +0000 (UTC)
From: efflandt@xnet.com (David Efflandt)
Subject: Re: how to create NULL character in perl
Message-Id: <slrnb77719.94a.efflandt@typhoon.xnet.com>
On Sat, 15 Mar 2003 23:57:46 +1100, Sisyphus <kalinabears@hdc.com.au> wrote:
>
> "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";
I thought a null string ($null = '') was the same, but apparently NOT the
same as a null character. So I guess it really depends whether you are
looking for null character or null string:
#!/usr/bin/perl -w
my $null1 = '';
my $null2 = chr(0);
my $null3 = "\0";
if (defined($null1)) { print "\$null1 is defined\n"; }
if ($null1 eq $null2) { print "1 & 2 same string value\n"; }
else { print "1 & 2 different string value\n"; }
if ($null2 eq $null3) { print "2 & 3 same string value\n"; }
if ($null1 == 0) { print "\$null1 equals zero\n"; }
if ($null2 == 0) { print "\$null2 equals zero\n"; }
if ($null3 == 0) { print "\$null3 equals zero\n"; }
if (($null1 == $null2) && ($null1 == $null3)) {
print "all 3 same numeric value\n";
}
OUTPUT:
$null1 is defined
1 & 2 different string value
2 & 3 same string value
Argument "" isn't numeric in numeric eq (==) at ./mytest line 9.
$null1 equals zero
Argument "" isn't numeric in numeric eq (==) at ./mytest line 10.
$null2 equals zero
Argument "" isn't numeric in numeric eq (==) at ./mytest line 11.
$null3 equals zero
all 3 same numeric value
--
David Efflandt - All spam ignored 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: 15 Mar 2003 19:33:09 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: How to find a word which is palindromica using REGEXP
Message-Id: <b4vv5l$2l2$1@mamenchi.zrz.TU-Berlin.DE>
Garry Williams <garry@zvolve.com> wrote in comp.lang.perl.misc:
> On 15 Mar 2003 23:08:11 +0800, qin jiang wei <qin@freebsd.lzu.edu.cn>
> wrote:
>
> > How can I find the palindromica words in /usr/share/dict/words
> > For example , the word 'level'.
>
> #!/usr/bin/perl -n
> use warnings;
> use strict;
>
> my $half = (length() - 1) / 2;
>
> my $re = '(.)' x $half;
>
> $re .= '.' if length % 2;
>
> $re .= join '', map "\\$_", reverse 1 .. $half;
>
> print if /^$re$/;
This doesn't work right (and "(length() - 1)/2" looks suspect). But
it doesn't look like a good solution, even if it were debugged.
If you know the string, there is no need to use a regex to see if is a
palindrome. Just compare the (reverse of) the appropriate substrings.
It takes as much (or more) effort to build the regex that tells you
the same thing.
It might be another matter to pre-build regexes for all likely lengths
(in @pal_rex, say), and then match /$pal_rex[ length()]/. This could
be extended to a memoizing scheme (with no pre-building, and no guess
about maximal length required):
/@{ [ $pal_rex[ length()] ||= build_rex( length())]}/
Kind of fun, but only Benchmark would tell if it pays.
Anno
------------------------------
Date: Sat, 15 Mar 2003 21:13:13 +0100
From: Matija Papec <mpapec@yahoo.com>
Subject: Re: How to find a word which is palindromica using REGEXP
Message-Id: <st177v47ladgp2vdjntu9qep880eb2eti6@4ax.com>
X-Ftn-To: Garry Williams
Garry Williams <garry@ifr.zvolve.net> wrote:
>On 15 Mar 2003 23:08:11 +0800, qin jiang wei <qin@freebsd.lzu.edu.cn>
>wrote:
>
>> How can I find the palindromica words in /usr/share/dict/words
>> For example , the word 'level'.
>
> #!/usr/bin/perl -n
> use warnings;
> use strict;
>
> my $half = (length() - 1) / 2;
>
> my $re = '(.)' x $half;
>
> $re .= '.' if length % 2;
>
> $re .= join '', map "\\$_", reverse 1 .. $half;
IMHO, it's more natural and cleaner to use foreach instead of joining with
''
$re .= "\\$_" for reverse 1 .. $half;
--
Matija
------------------------------
Date: Sat, 15 Mar 2003 20:29:50 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: How to find a word which is palindromica using REGEXP
Message-Id: <23Mca.12910$Ad6.2521@nwrddc01.gnilink.net>
Matija Papec wrote:
>> my $half = (length() - 1) / 2;
[...]
> $re .= "\\$_" for reverse 1 .. $half;
I do not understand why people are so focussed on first splitting the string
in half. There is no need for it! A palindrome is defined a s a text that is
the same regardless if read forward or backward.
So why not implement this literally:
if ($text eq reverse($text)) {
print "$text is a palindrome\n";
}
Yes, this does twice as many comparisons as are really necessary.
But I do not believe that it is one jota slower because of all the overhead
for computation and splitting needed for the solutions above. And surely it
is easier to read and there no danger of a one-off mistake with the index.
In my view those algorithms are optimizing in the wrong place.
jue
------------------------------
Date: Sat, 15 Mar 2003 20:46:33 -0000
From: Garry Williams <garry@ifr.zvolve.net>
Subject: Re: How to find a word which is palindromica using REGEXP
Message-Id: <slrnb77499.b10.garry@zfw.zvolve.net>
On 15 Mar 2003 19:33:09 GMT, Anno Siegel
<anno4000@lublin.zrz.tu-berlin.de> wrote:
> Garry Williams <garry@zvolve.com> wrote in comp.lang.perl.misc:
>> On 15 Mar 2003 23:08:11 +0800, qin jiang wei <qin@freebsd.lzu.edu.cn>
>> wrote:
>>
>> > How can I find the palindromica words in /usr/share/dict/words
>> > For example , the word 'level'.
>>
>> #!/usr/bin/perl -n
>> use warnings;
>> use strict;
>>
>> my $half = (length() - 1) / 2;
>>
>> my $re = '(.)' x $half;
>>
>> $re .= '.' if length % 2;
Oops. That was supposed to be:
$re .= '.' if (length() - 1) % 2;
>> $re .= join '', map "\\$_", reverse 1 .. $half;
>>
>> print if /^$re$/;
>
> This doesn't work right (and "(length() - 1)/2" looks suspect). But
> it doesn't look like a good solution, even if it were debugged.
The use of length() - 1 avoids chomp().
See above.
> If you know the string, there is no need to use a regex to see if is a
> palindrome. Just compare the (reverse of) the appropriate substrings.
> It takes as much (or more) effort to build the regex that tells you
> the same thing.
Yes, but the subject asks for a regular expression.
--
Garry Williams
------------------------------
Date: Sat, 15 Mar 2003 20:51:27 GMT
From: Steve Grazzini <grazz@nyc.rr.com>
Subject: Re: How to find a word which is palindromica using REGEXP
Message-Id: <jnMca.2142$5I6.694294@twister.nyc.rr.com>
"Jürgen Exner" <jurgenex@hotmail.com> wrote:
> Matija Papec wrote:
>>> my $half = (length() - 1) / 2;
> [...]
>> $re .= "\\$_" for reverse 1 .. $half;
>
> I do not understand why people are so focussed on first
> splitting the string in half. There is no need for it!
Yours is the best solution, of course, but it may
not help the OP, whose homework assignment seems to
require use of "REGEXP".
--
Steve
perldoc -qa.j | perl -lpe '($_)=m("(.*)")'
------------------------------
Date: 15 Mar 2003 21:41:18 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: How to find a word which is palindromica using REGEXP
Message-Id: <b506lu$7lr$1@mamenchi.zrz.TU-Berlin.DE>
Garry Williams <garry@zvolve.com> wrote in comp.lang.perl.misc:
> On 15 Mar 2003 19:33:09 GMT, Anno Siegel
> <anno4000@lublin.zrz.tu-berlin.de> wrote:
> > Garry Williams <garry@zvolve.com> wrote in comp.lang.perl.misc:
> >> On 15 Mar 2003 23:08:11 +0800, qin jiang wei <qin@freebsd.lzu.edu.cn>
> >> wrote:
> >>
> >> > How can I find the palindromica words in /usr/share/dict/words
> >> > For example , the word 'level'.
> >>
> >> #!/usr/bin/perl -n
> >> use warnings;
> >> use strict;
> >>
> >> my $half = (length() - 1) / 2;
> >>
> >> my $re = '(.)' x $half;
> >>
> >> $re .= '.' if length % 2;
>
> Oops. That was supposed to be:
>
> $re .= '.' if (length() - 1) % 2;
>
> >> $re .= join '', map "\\$_", reverse 1 .. $half;
> >>
> >> print if /^$re$/;
> >
> > This doesn't work right (and "(length() - 1)/2" looks suspect). But
> > it doesn't look like a good solution, even if it were debugged.
>
> The use of length() - 1 avoids chomp().
Oh, right.
> See above.
>
> > If you know the string, there is no need to use a regex to see if is a
> > palindrome. Just compare the (reverse of) the appropriate substrings.
> > It takes as much (or more) effort to build the regex that tells you
> > the same thing.
>
> Yes, but the subject asks for a regular expression.
That appears to be an XY problem. What the OP had in mind was probably
a single regex that matches all palindromes. The answer is that it doesn't
exist (unless we bring in match-time code). The best we can do is a regex
for each length of a candidate, which isn't quite the same.
Anno
------------------------------
Date: Sat, 15 Mar 2003 22:12:38 GMT
From: w i l l <will@com.yahoo>
Subject: Re: I want to: include 'right.php'
Message-Id: <s8977v8lpojkhln6iv7srvnqh83iun0h0m@4ax.com>
is the php file straight html, or is there code in it. If there is
code in it you will need apache to run the code to get the outputted
Html, I'm sure there's a better way, but you could always use
LWP::Simple to actually hit the php file then bring it in to your perl
script.
best of luck,
Will
On 15 Mar 2003 06:03:19 -0800, francescomoi@europe.com (Francesco Moi)
wrote:
>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 22:31:11 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: it's true but can I say so ?
Message-Id: <slrnb77ade.6og.abigail@alexandra.abigail.nl>
Martien Verbruggen (mgjv@tradingpost.com.au) wrote on MMMCDLXXXIII
September MCMXCIII in <URL:news: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.h
{} >> > -:
{} >> > -: But, again, I've seen many people try it. And in languages where boo
{} >> > -: 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.
Indeed. So, you have 'false', 'true' and 'NULL'. Not *bi*polar.
Abigail
--
perl -we 'print split /(?=(.*))/s => "Just another Perl Hacker\n";'
------------------------------
Date: Sun, 16 Mar 2003 09:46:02 +1100
From: Martien Verbruggen <mgjv@tradingpost.com.au>
Subject: Re: it's true but can I say so ?
Message-Id: <slrnb77b9a.j8t.mgjv@martien.heliotrope.home>
On Sat, 15 Mar 2003 03:21:19 -0500,
Benjamin Goldberg <goldbb2@earthlink.net> wrote:
> 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.
But you can't use NULL (or something evaluating to NULL) in a spot where
a boolean expression is expected.
Martien
--
|
Martien Verbruggen | If it isn't broken, it doesn't have enough
| features yet.
|
------------------------------
Date: Sat, 15 Mar 2003 22:12:27 GMT
From: Ted Zeng <tzeng@pacbell.net>
Subject: Re: problem printing multi-dimensional lists
Message-Id: <3E73A694.FEBDA17C@pacbell.net>
You didn't say clearly what @AllRequests is like.
It looks like @Allrequests has N elements, each of which is a reference
to an array of 5?
In that case, your code should look like this:
>>>>>>
# display the requests individually
$count = 0;
{
print "Request $count is:\n";
print "Input file: " . $AllRequests[$count][0] . "\n";
print "Ouput file: " . $AllRequests[$count][1] . "\n";
print "Output file size: " . $AllRequests[$count][2] . "\n";
print "Prefix size: " . $AllRequests[$count][3] . "\n";
print "Modification Formula Number: " . $AllRequests[$count][4] . "\n";
$count++;
}
>>>>>
Loop through $count from 0 to N-1 and you should have printed all.
Your code is wrong because
$i is an reference to an array of 5.
and $AllRequests[0][$i] is not defined.
hth.
-ted zeng
Raquel Mangual wrote:
> 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 22:19:59 GMT
From: w i l l <will@com.yahoo>
Subject: Re: problem printing multi-dimensional lists
Message-Id: <gn977v425dpda338l9gbsc53084mltd0l2@4ax.com>
read camel book, chapter 9, Data Structures.
Read it now, then in a few months wen you're trying to tackle
references it won't be so bad ;)
w i l l
On Fri, 14 Mar 2003 22:04:22 -0500, Raquel Mangual <raquel@rdccc.com>
wrote:
>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 22:22:59 GMT
From: LinkSeer <linkseer@yahoo.com>
Subject: Question: What's the proper way to retrieve last mod dates for all files in a directory?
Message-Id: <j7877vckstgaisrp056n5m04lo39it84ab@4ax.com>
If I use something like:
opendir(html, 'e:/inetpub/wwwroot/cgi-bin/listings') or die "can't
opendir directory: $!";
@dirlist = readdir(html);
foreach $f(@dirlist){
if(-f $f){
($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) =
localtime((stat($f))[9]);
When the path points to the directory where the script is located all
is well, I get a list of all files and their last modification
date/time but if the path is changed, say backed up to be:
e:/inetpub/wwwroot/cgi-bin then only a couple of files located in
that directory are listed. If I do away with the -f test all of the
files get listed but their last mod dates are shown as : 11/31/69.
Any assistance will be greatly appreciated! : ) Thank You
------------------------------
Date: Sat, 15 Mar 2003 16:26:18 -0600
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: Question: What's the proper way to retrieve last mod dates for all files in a directory?
Message-Id: <87bs0cnu5x.fsf@limey.hpcc.uh.edu>
>> On Sat, 15 Mar 2003 22:22:59 GMT,
>> LinkSeer <linkseer@yahoo.com> said:
> If I use something like: opendir(html,
> 'e:/inetpub/wwwroot/cgi-bin/listings') or die "can't
> opendir directory: $!"; @dirlist = readdir(html);
> foreach $f(@dirlist){ if(-f $f){ ($sec, $min, $hour,
> $mday, $mon, $year, $wday, $yday, $isdst) =
> localtime((stat($f))[9]);
> When the path points to the directory where the script
> is located all is well, I get a list of all files and
> their last modification date/time but if the path is
readdir() returns the *name* of the files in the
directory. It doesn't mean that the *path* to the file
with that name is equal to the name. You will need to
prefix the path to the name in order to perform operations
on the file. Or chdir() there first (which is the same
thing, really).
hth
t
------------------------------
Date: Sat, 15 Mar 2003 21:16:04 GMT
From: "Anand Kandasamy" <anandks@optonline.net>
Subject: Sorting using DB_FILE/DB_BTREE
Message-Id: <oKMca.53660$b8.9161934@news4.srv.hcvlny.cv.net>
Hi
I have four huge arrays (with 22986152 numbers), that needs to be sorted
to extract the min and the max. Posting this question earlier, it is
understood that
I should use the Berkley DB to strore my array and sort them.
My array is not an associative array, so no keys are involved. It contains
floating point
numbers. How can I solve my problem of sorting this huge array and obtaining
the min & max
Thanks
Anand
------------------------------
Date: Sat, 15 Mar 2003 21:54:18 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Sorting using DB_FILE/DB_BTREE
Message-Id: <eiNca.12950$Ad6.8629@nwrddc01.gnilink.net>
Anand Kandasamy wrote:
> I have four huge arrays (with 22986152 numbers), that needs to be
> sorted to extract the min and the max.
Don't sort them! Sorting is expensive!
Just loop through the array, searching for the smallest and the largest
value.
my $min = $a[0];
my $max = $a[0];
for (@a) {
$min = $_ if $_ < $min;
$max = $_ if $_ > $max;
}
I believe there is also a module on CPAN that will compute the smallest and
largest values of an array.
jue
------------------------------
Date: 15 Mar 2003 22:01:22 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Sorting using DB_FILE/DB_BTREE
Message-Id: <b507ri$9ce$1@mamenchi.zrz.TU-Berlin.DE>
[Newsgroups reduced. comp.lang.perl doesn't exist]
Anand Kandasamy <anandks@optonline.net> wrote in comp.lang.perl.misc:
> Hi
>
> I have four huge arrays (with 22986152 numbers), that needs to be sorted
> to extract the min and the max. Posting this question earlier, it is
> understood that
> I should use the Berkley DB to strore my array and sort them.
>
> My array is not an associative array, so no keys are involved. It contains
> floating point
> numbers. How can I solve my problem of sorting this huge array and obtaining
> the min & max
Yikes! You don't need to sort an array to extract the maximum and minimum.
This is *sometimes* done for short arrays because it is quickly written,
but never when the array is large.
my ( $min, $max) = @array[ 0, 0];
$min < $_ or $min = $_ for @array;
$max > $_ or $max = $_ for @array;
I don't see what this has to do with DB_FILE/DB_BTREE. Is that DB_File
and Btrees?
Anno
------------------------------
Date: 15 Mar 2003 14:22:55 -0800
From: caesar_ancheta@yahoo.com (Caesar_Ancheta)
Subject: Re: Stupid Perl Questions
Message-Id: <5d34f091.0303151422.132a933c@posting.google.com>
"Knowledge is Power" __ Francis Bacon
"William Alexander Segraves" <wsegrave@mindspring.com> wrote in message news:<b4vnht$r6e$1@slb3.atl.mindspring.net>...
> > "Caesar_Ancheta" <caesar_ancheta@yahoo.com> wrote in message
> > news:5d34f091.0303150248.6b8ae652@posting.google.com...
...
> Oops! I see this issue has nothing to do with Perl.
> Bill Segraves
...
Bill,
You are quite right that Perl by itself on a Server is innocuous,
because control on the Server is understood. I wonder what technology
can be used to offset the threat posed by total control passed from a
Server to a Client. Java solved it by limiting the facilities passed
to the Client, by delegating execution to the JVM. At the very least,
disabling back-tick and exec() at the Client, if those facilities
exist in the TinyPerl. Perhaps also a way to detect tainting, ought to
be layered on top of the TinyPerl. The issue is the size of the
executable. Current Perl's are large enough to detect and deal with.
But a floppy-sized "Perl" with an attendant Web "Server" which can be
downloaded to a Client, is like a plastic gun; Congress disallowed
plastic guns.
It is best that this information be dealt with wisely. I am not sure
that posting it elsewhere is responsible. We are dealing with the
obverse of:
"Clothes by themselves are unhealthy. Bathing by itself is unhealthy.
But the combination of Clothes and Bathing is healthy." __ Bertrand
Russell
Caesar
It occurs to me that the provenance of the Provider needs to be sent
to the Client. That way, the size is immaterial, and could even be an
advantage when competing with a 20MB .Net runtime.
------------------------------
Date: 15 Mar 2003 22:36:37 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: What's wrong with the Perl docs
Message-Id: <slrnb77anl.6og.abigail@alexandra.abigail.nl>
Benjamin Goldberg (goldbb2@earthlink.net) wrote on MMMCDLXXXIII September
MCMXCIII in <URL:news:3E727CCF.E73CD426@earthlink.net>:
""
"" Outside of the Windows world, how many perl programmers download
"" precompiled perls?
A lot actually. Many commercial Unix systems come with Perl. Most, if
not all, Linux distributions come with Perl. Compiling your own stuff
seems to rapidly become a rare thing, even in the Linux world. People
prefer to get RPM files, deb files, depot files, SUN packages, etc.
Of course, it's still common in the Unix world to have access to the
system manuals.
Abigail
--
$; # A lone dollar?
=$"; # Pod?
$; # The return of the lone dollar?
{Just=>another=>Perl=>Hacker=>} # Bare block?
=$/; # More pod?
print%; # No right operand for %?
------------------------------
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 4714
***************************************