[15719] in Perl-Users-Digest
Perl-Users Digest, Issue: 3132 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue May 23 09:05:32 2000
Date: Tue, 23 May 2000 06:05:12 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <959087111-v9-i3132@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Tue, 23 May 2000 Volume: 9 Number: 3132
Today's topics:
? Modules & Version <boxrec@uklinux.net>
Re: A definition of true? <hmerrill@my-deja.com>
Re: about sending HTML email from perl <abc@def.com>
Re: Any Perl Programmers For Hire? (David H. Adler)
apache document_root and virtualHost <alejandro.eluchans@umb.edu>
Autoload order (WAS Re: Haiku) (Gwyn Judd)
Re: Basic scripting question (brian d foy)
Re: Basic scripting question <red_orc@my-deja.com>
Re: Building a hash array jimmy_mcnamara@my-deja.com
Re: cut off text after a <br> <lancelotboyle@hotmail.com>
Re: cut off text after a <br> <bill.kemp@wire2.com>
Re: cut off text after a <br> <hmerrill@my-deja.com>
Re: file locking (Michel Dalle)
Re: file locking <rick.delaney@home.com>
Re: HELP MEEEEEE <blah@nospam.com>
Re: join " ", do {$x++}, do {$x++}, do {$x++}; <bchauvet@capgemini.fr>
Re: join " ", do {$x++}, do {$x++}, do {$x++}; (Gwyn Judd)
Re: join " ", do {$x++}, do {$x++}, do {$x++}; <Tbone@pimpdaddy.com>
Re: Mail attachments: filtering out <iltzu@sci.invalid>
my algorythms suck <klidge@mailbox.gr>
Re: New to Perl: Having Issues with Hashes nobull@mail.com
Re: New to Perl: Having Issues with Hashes <hmerrill@my-deja.com>
param prob <avidbkdNOavSPAM@netscape.net.invalid>
Re: read in a file and delete first 8 lines <boxrec@uklinux.net>
Re: SDBM_File - %HASH not returning all records ? <miguel_thomasNOmiSPAM@hotmail.com.invalid>
Search&Match-script problem (Rajmannar)
Server Push <laoxiu100@hotmail.com>
Re: Tanspose rows to columns <iltzu@sci.invalid>
Re: Visibility of package lexicals in debugger nobull@mail.com
Vs: ? Modules & Version <marko.nikulainen@etela-savo.com>
Re: What happened to Mail::Internet? <gellyfish@gellyfish.com>
Re: What's this line which Perl added to AUTOEXEC.BAT? <rjh@cyberscience.com>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 23 May 2000 11:51:03 GMT
From: "John" <boxrec@uklinux.net>
Subject: ? Modules & Version
Message-Id: <392a7f8d.0@news2.cluster1.telinco.net>
I only have ftp access to my host.
Often a script which runs fine on my Linux box fails on the host.
Usually it is a local config prob but sometimes it's module related.
I would like to know if there is a simple command/way of listing all the
modules/versions on the host.
Much obliged, JohnShep.
------------------------------
Date: Tue, 23 May 2000 12:23:57 GMT
From: Hardy Merrill <hmerrill@my-deja.com>
Subject: Re: A definition of true?
Message-Id: <8gdt8i$bml$1@nnrp1.deja.com>
> Is there a Perl-recommended way to assign TRUE or FALSE to a variable?
I =
> thought I saw a comment from Larry on not re-assigning the values TRUE
=
> and FALSE.
>
> Script:
> use strict;
> my $var =3D true;
>
> Error:
> Bareword "true" not allowed while "strict subs" in use at C:\temp\t.pl
=
> line 2.
>
> My solution:
> my $true =3D 1;
> my $false =3D 0;
>
> Any other solutions?
In "Programming Perl - 2nd Edition" by Wall, Christiansen, & Schwartz,
pages 20-21 contain the section labelled "What Is Truth?". Here is one
small snippet:
"Truth in Perl is always evaluated in a scalar context. (Other
than that, no type coercion is done.) So here are the rules
for the various kinds of values that a scalar can hold:
1. Any string is true except for "" and "0".
2. Any number is true except for 0.
3. Any reference is true.
4. Any undefined value is false."
As far as I know, there are *NO* predefined values of "True" and/or
"False" - variables are evaluated according to these rules to determine
true/false. I sometimes use the numbers 0 and 1 to mean true and false,
like this:
my $found = 0;
foreach $one (@many) {
if ($one =~ /some regex/) {
$found = 1;
}
}
if ($found) { ### This is testing for true ###
blah blah
}
But this is just one of the ways that I use it.
Hope this helps.
--
Hardy Merrill
Mission Critical Linux
http://www.missioncriticallinux.com
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Tue, 23 May 2000 19:18:17 +0800
From: "Nice" <abc@def.com>
Subject: Re: about sending HTML email from perl
Message-Id: <8gdrqv$c9s4@imsp212.netvigator.com>
Thx Gwyn Judd,
thx for help, it works :)
Gwyn Judd ¼¶¼g©ó¤å³¹ ...
>I was shocked! How could Nice <abc@def.com>
>say such a terrible thing:
>>hi all,
>>I am newbie to UNIX, I tried to write a Perl program for email sending,
the
>>mailing program I am using is sendmail, my question is how can I send a
HTML
>>format email by sendmail?? what is the param or instruction, thx
>
>well I'm guessing you will have to format the HTML yourself unless there
>is some module that will format text or whatever into HTML for you (I
>know of none (disclaimer: I Am Not A Guru (tm))). As for sending it
>though you can use MIME::Lite to format multipart emails which I guess
>should work.
>
>--
>Gwyn "IANAG" Judd (tjla@guvfybir.qlaqaf.bet)
>My return address is rot13'ed
>"sic transit discus mundi"
>(From the System Administrator's Guide, by Lars Wirzenius)
------------------------------
Date: 23 May 2000 02:23:56 GMT
From: dha@panix.com (David H. Adler)
Subject: Re: Any Perl Programmers For Hire?
Message-Id: <slrn8ijqts.l7.dha@panix6.panix.com>
On Mon, 22 May 2000 17:41:18 GMT, Norm <ncharette@earthlink.net> wrote:
>I am overloaded with custom Perl programming orders.
In that case, it's really too bad that you've done something that will
make a number of the good ones not respond.
You have posted a job posting or a resume in a technical group.
Longstanding Usenet tradition dictates that such postings go into
groups with names that contain "jobs", like "misc.jobs.offered", not
technical discussion groups like the ones to which you posted.
Had you read and understood the Usenet user manual posted frequently
to "news.announce.newusers", you might have already known this. :)
Please do not explain your posting by saying "but I saw other job
postings here". Just because one person jumps off a bridge, doesn't
mean everyone does. Those postings are also in error, and I've
probably already notified them as well.
If you have questions about this policy, take it up with the news
administrators in the newsgroup news.admin.misc.
There is a Perl Jobs Announce list that may be more helpful to you. See
<http://www.pm.org/mailing_lists.shtml> for details.
Yours for a better usenet,
dha
--
David H. Adler - <dha@panix.com> - http://www.panix.com/~dha/
Free Randal Schwartz! <http://www.rahul.net/jeffrey/ovs/>
(ok, maybe not free, but competitively priced!)
------------------------------
Date: Mon, 22 May 2000 15:09:50 -0500
From: Alejandro Eluchans <alejandro.eluchans@umb.edu>
Subject: apache document_root and virtualHost
Message-Id: <3929940B.B2D146CD@umb.edu>
Using PERL and a web form. The server is Linix/apache/mod_perl
I'm trying to get a virtual Host's DOCUMENT_ROOT from a cgi activated by
a form belonging to another host. All this in the same server.
Help
alejandro eluchans
------------------------------
Date: Tue, 23 May 2000 13:01:40 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Autoload order (WAS Re: Haiku)
Message-Id: <slrn8inkpn.81p.tjla@thislove.dyndns.org>
I was shocked! How could Brad Baxter <bmb@dataserv.libs.uga.edu>
say such a terrible thing:
>Okay, here's my haiku entry. (I forget the rules.)
>It probably doesn't qualify as Perl poetry.
nice poem :) thank you. So from running this in the debugger it seems
that functions are "autoloaded" in reverse order for some weird reason.
Is that correct? I confess I don't understand the autoload process.
--
Gwyn Judd (tjla@guvfybir.qlaqaf.bet)
My return address is rot13'ed
Television is a medium because anything well done is rare.
-- attributed to both Fred Allen and Ernie Kovacs
------------------------------
Date: Mon, 22 May 2000 22:45:01 -0400
From: brian@smithrenaud.com (brian d foy)
Subject: Re: Basic scripting question
Message-Id: <brian-ya02408000R2205002245010001@news.panix.com>
In article <3929D379.F183BF97@stomp.stomp.tokyo>, "Godzilla!" <godzilla@stomp.stomp.tokyo> posted:
> This test script contains a lot more programming
> than ever needed. However, I enjoy writing playful
> scripts like this. In looking this over, you will
> discover why I never use pragma hints, warnings
> and all that. I don't need them and, they are
> nothing but a nuisance to me.
never mind the errors in the script that the warnings
would have told you about. they wouldn't be such a
nuisance if you would learn to be a better coder and
avoided them because you didn't use questionable or
incorrect constructs.
> $line_counter = 1;
>
> open (NEW, ">test.txt");
check your return values.
> foreach $new_line (@Test)
no need to take up a bunch of memory when you can
read a file (or STDIN) line by line
> {
> if ($line_counter < 3)
> {
> print NEW $new_line;
> $line_counter++;
> }
> elsif ($line_counter = 3)
hmmm... useless test, or bad programming?
> {
> $line_counter = 1;
> next;
> }
> }
of course, all of this is much more simply written as
while( <LINES> )
{
print unless ++$line_counter % 3;
}
--
brian d foy
CGI Meta FAQ <URL:http://www.smithrenaud.com/public/CGI_MetaFAQ.html>
Perl Mongers <URL:http://www.perl.org/>
------------------------------
Date: Tue, 23 May 2000 12:53:45 GMT
From: Rodney Engdahl <red_orc@my-deja.com>
Subject: Re: Basic scripting question
Message-Id: <8gdv0h$cvl$1@nnrp1.deja.com>
In article <3929D379.F183BF97@stomp.stomp.tokyo>,
"Godzilla!" <godzilla@stomp.stomp.tokyo> wrote:
> foreach $new_line (@Test)
> {
> if (!($new_line))
> {
> print "OH NO! New File Print Is FUBAR!";
> exit;
> }
> if ($line_counter < 3)
> {
> print NEW $new_line;
> print $new_line;
> $line_counter++;
> }
> elsif ($line_counter = 3)
This code probably works (or you would not have posted it). Since the
conditional assignment expression $line_counter = 3 is always true, the
elseif ($line_counter = 3) is effectively an else, ensuring that
$line_counter never gets larger than 3 by executing the code within the
elseif block. I'm also certain that the assignement was intended to be
a numeric equal check '==' and sufferred from a typo.
It's probably more efficient to use $. (input line number) and perform a
modulo 3 check on it, but as I say, the above code probably works.
> {
> $line_counter = 1;
> next;
> }
> }
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Tue, 23 May 2000 12:29:03 GMT
From: jimmy_mcnamara@my-deja.com
Subject: Re: Building a hash array
Message-Id: <8gdti2$bpd$1@nnrp1.deja.com>
Hi Folks,
Just like to say thanks for the responses the split function works
perfectly and I was looking to form an arrayref rather than a hash
array(sorry for the confusion).
Cheers
Jimmy
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Tue, 23 May 2000 12:58:34 +0100
From: "Lance Boyle" <lancelotboyle@hotmail.com>
Subject: Re: cut off text after a <br>
Message-Id: <8gdru7$s6p$1@uranium.btinternet.com>
> And perhaps you should take into account the possibility that the
> string we're working on contains newline characters.
and perhaps you should also take into account that I am thick as two short
planks and more confused than ever.
I have include the full subroutine below.
sub DoHeadlineHTML {
$newshtml = qq~<a href="http://www....../viewnews.cgi?newsid$newsid"><img
src="$uservar1"><br>$newssubject</a> - $newsdate
~;
unless( $NPConfig{'moo'} ) { $NPConfig{'moo'} = 1; }
if( $NPConfig{'moo'} < 11 )
{
if( length( $newstext ) > 256 ) {
$tmpnewshtml = substr( $newstext, 0, 138 );
$tmpnewshtml = $newstext =~ m/(.*)?<br>/;
$tmpnewshtml =~ s/(.*)\s.*/$1/;
$newshtml .= $tmpnewshtml . qq~
~;
}
else
{
$newshtml .= $newstext;
}
$newshtml .= qq~
<br><br><HR width="50%"><br><br>~;
}
$NPConfig{'moo'} += 1;
if( $newsnum == 0 ) { delete $NPConfig{'moo'}; }
}
All this does is leave a number 1 where text used to be.
Could someone please explain it a bit simpler.
Cheers
Lance
------------------------------
Date: Tue, 23 May 2000 13:16:05 +0100
From: "W Kemp" <bill.kemp@wire2.com>
Subject: Re: cut off text after a <br>
Message-Id: <959084257.25335.0.nnrp-02.c3ad6973@news.demon.co.uk>
This line looks odd to me, I would have thought it just gives '1' for match
'0' for no match.
$tmpnewshtml = $newstext =~ m/(.*)?<br>/;
If you want to do it this way rather than the two other suggestions
$newstext =~ m/(.*)?<br>/;
$tmpnewshtml =$1;
------------------------------
Date: Tue, 23 May 2000 12:09:38 GMT
From: Hardy Merrill <hmerrill@my-deja.com>
Subject: Re: cut off text after a <br>
Message-Id: <8gdsdr$auq$1@nnrp1.deja.com>
In article <8gd106$hvb$1@plutonium.btinternet.com>,
"Lance Boyle" <lancelotboyle@hotmail.com> wrote:
> Somebody provided a hack below within a perl script to cut off text
after
> certain amount of characters
>
> if( length( $newstext ) > 256 ) {
> $tmpnewshtml = substr( $newstext, 0, 128 );
> $tmpnewshtml =~ s/(.*)\s.*/$1/;
> $newshtml .= $tmpnewshtml . qq~
>
> However is it possible to modify this to cut off text after a line
break
> <br> instead ?
I'll take a shot at this, but this is off the top of my head, and
untested! You can do an "index" to find the position(call it maybe
$pos) in the string where "<br>" occurs(which will be the position of
the "<") - then take the "substr" of the string from 0 to $pos+3.
$pos_br = index(newstext,"<br>");
$tmpnewshtml = substr($newstext,0,$pos_br+3)
There's also an "rindex" function which is the same as "index", but it
searches from right to left - so to speak. Look up documentation on
these by doing
perldoc -f index
perldoc -f rindex
Hope this helps.
--
Hardy Merrill
Mission Critical Linux
http://www.missioncriticallinux.com
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Tue, 23 May 2000 11:25:37 GMT
From: michel.dalle@usa.net (Michel Dalle)
Subject: Re: file locking
Message-Id: <8gdpuf$hbg$1@news.mch.sbs.de>
In article <v2eW4.89858$hT2.379447@news1.rdc1.ct.home.com>, Dan Sugalski <dan@tuatha.sidhe.org> wrote:
>Randal L. Schwartz <merlyn@stonehenge.com> wrote:
>> But if you are using print()
>> instead of syswrite(), you might possibly get a two-write write() if
>> you cross a STDIO boundary, and then your atomic write is blown to
>> bits.
>
>You can be bit hard by buffering with print in a number of ways, which is
>always fun. Interleaved output, garbage, missing bits--way fun. :)
Hmmm, guess I've been relying too much on the O.S. lately. :(
I noticed the 'garbled' output too, but only when larger pieces of
data are appended - hence my remark about the 'larger chunks'.
I've never seen any problems with appending a single line to a
logfile, though... Have I been lucky so far, or would that qualify
as a single write() operation ?
Michel.
------------------------------
Date: Tue, 23 May 2000 12:47:25 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: file locking
Message-Id: <392A7F32.47E4770@home.com>
Michel Dalle wrote:
>
> Hmmm, guess I've been relying too much on the O.S. lately. :(
> I noticed the 'garbled' output too, but only when larger pieces of
> data are appended - hence my remark about the 'larger chunks'.
Can you produce an example program that will reproduce this behaviour?
I've never been able to get garbled output, despite numerous attempts.
> I've never seen any problems with appending a single line to a
> logfile, though... Have I been lucky so far, or would that qualify
> as a single write() operation ?
<aol>I'd like to know the answer to this too.</aol>
--
Rick Delaney
rick.delaney@home.com
------------------------------
Date: Tue, 23 May 2000 14:11:53 +0200
From: Marco Natoni <blah@nospam.com>
Subject: Re: HELP MEEEEEE
Message-Id: <392A7589.40BF48C3@nospam.com>
Jonathan,
Jonathan Stowe wrote:
>>> Obsolete ? Care to explain that comment which seems to be at
>>> variance with the perlstyle document for 5.6.0 :
>> Your PERL itself should explain that
>> <cite>
>> Use of bare << to mean <<"" is deprecated at ... line ....
>> </cite>
> Ah. Sorry. I thought you meant heredocs in general.
I was not clear enough: How can we live *without* heredocs? :)
Best regards,
Marco
------------------------------
Date: Tue, 23 May 2000 13:16:43 +0200
From: "Orabīg" <bchauvet@capgemini.fr>
Subject: Re: join " ", do {$x++}, do {$x++}, do {$x++};
Message-Id: <8gdoip$rnh$1@heraut.schneider.fr>
Larry Rosler <lr@hpl.hp.com> a écrit dans le message :
MPG.1393cc183550e5c098aab7@nntp.hpl.hp.com...
> In article <8gcstu$2hiq$1@news.enteract.com>, Tbone@pimpdaddy.com says...
> Before answering, try to explain the output of this program:
>
>
> #!/usr/local/bin/perl -w
> use strict;
>
> my $x;
>
> print join " ", do {$x++}, do {$x++}, do {$x++};
> print "\n";
>
> foo($x, $x++, $x++, $x++);
>
> sub foo { print "@_\n" }
> __END__
>
> Output:
>
> 0 1 2
> 6 3 4 5
>
OK, could someone explain this one for me ? I just give up... :s
--
Orabīg
------------------------------
Date: Tue, 23 May 2000 12:18:36 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: join " ", do {$x++}, do {$x++}, do {$x++};
Message-Id: <slrn8ini90.81p.tjla@thislove.dyndns.org>
I was shocked! How could Intergalactic Denizen of Mystery <Tbone@pimpdaddy.com>
say such a terrible thing:
>I seem to have lost the ability to RTFM... could someone point me
>to where it says that the above (see subject line) will guarantedly
>produce "1 2 3"?
did you try it? I got:
[gwyn@thislove:~]$ perl -e 'print join " ", do {$x++}, do {$x++}, do
{$x++};'
0 1 2
--
Gwyn Judd (tjla@guvfybir.qlaqaf.bet)
My return address is rot13'ed
"His great aim was to escape from civilization, and, as soon as he had
money, he went to Southern California."
------------------------------
Date: 23 May 2000 12:55:35 GMT
From: Intergalactic Denizen of Mystery <Tbone@pimpdaddy.com>
Subject: Re: join " ", do {$x++}, do {$x++}, do {$x++};
Message-Id: <8gdv47$op7$1@news.enteract.com>
tjla@guvfybir.qlaqaf.bet writes:
>I was shocked! How could Intergalactic Denizen of Mystery <Tbone@pimpdaddy.com>
>say such a terrible thing:
The internet gave me the courage.
>>I seem to have lost the ability to RTFM... could someone point me
>>to where it says that the above (see subject line) will guarantedly
>>produce "1 2 3"?
>
>did you try it? I got:
>
>[gwyn@thislove:~]$ perl -e 'print join " ", do {$x++}, do {$x++}, do
>{$x++};'
>0 1 2
True... the question was, is this just an accident?
------------------------------
Date: 23 May 2000 12:28:44 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: Mail attachments: filtering out
Message-Id: <959084802.29426@itz.pp.sci.fi>
In article <8gbs6u$3nl$1@sshuraaa-i-1.production.compuserve.com>, A Pietro wrote:
>I'm looking into procmail -- its supposed to be good for this sort of thing.
>But I would prefer something I could slot into my Perl code...
http://search.cpan.org/search?dist=Mail-Audit
--
Ilmari Karonen - http://www.sci.fi/~iltzu/
Please ignore Godzilla and its pseudonyms - do not feed the troll.
------------------------------
Date: Tue, 23 May 2000 15:31:48 +0300
From: "klidge" <klidge@mailbox.gr>
Subject: my algorythms suck
Message-Id: <8gdtlo$2h78$1@ulysses.noc.ntua.gr>
so i have an index file for a forum i want to create on the web
1?1?0?subject 1?nick1?10?02?00
2?2?0?subject 2?nick2?15?02?00
3?2?2?subject 2-1?nick1?23?02?00
4?3?0?subject 3?nick3?13?03?00
5?2?2?subject 2-2?nick4?16?03?00
6?3?4?subject 3-1?nick4?28?03?00
7?3?6?subject 3-1-1?nick5?06?04?00
8?3?4?subject 3-2?nick6?16?04?00
9?3?6?subject 3-1-2?nick2?23?04?00
10?1?1?subject 1-1?nick7?24?04?00
11?3?8?subject 3-2-1?nick4?26?04?00
field 1 -> post id
field 2 -> subject id
field 3 -> the id of the post that the current post is a reply to(zero
totally new subject)
field 4 -> subject
field 5 -> senders name/nick
field 6,7,8 -> date,month,year
i want an algorythm which using the above data can create this output:
subject 3
|->subject 3-1
|->subject 3-1-1
|->subject 3-1-2
|->subject 3-2
|->subject 3-2-1
of course i don't have any problem with the html code.i just can't find
how can i make perl to do it.i 'm open to ANY suggestions :)
thanks
------------------------------
Date: 23 May 2000 08:47:15 +0100
From: nobull@mail.com
Subject: Re: New to Perl: Having Issues with Hashes
Message-Id: <u94s7po8tq.fsf@wcl-l.bham.ac.uk>
"StevenJesseUlbrich" <sjutmp@msn.com> writes:
Subject: New to Perl: Having Issues with Hashes
"New to Perl" in subject lines usually translates as "I have a problem
would go away if I'd followed the basic advice that is given to all
newbies posting to this group". (That's use strict, enable warnings,
check success of file operations, read the FAQ, read any obviously
relevant bits of the manual).
There is only one word in your subject line that contains any real
information "Hashes". And that bit of information is wrong since
your problem has nothing to do with hashes, it has to do with
references.
Please check out this helpful information on choosing good subject
lines. It will be a big help to you in making it more likely that your
requests will be answered.
http://www.perl.com/CPAN/authors/Dean_Roehrich/subjects.post
Your problem is one that comes up here every week or two. Consider
reading the group before you post.
> if(/\bRoutingInformation -[0-9]{1,2}\W/){
>
> @Routing = RoutingExtraction(m/RoutingInformation -(.*)/);
>
> $KeyIndex = $KeyBase.@Routing[1];
> unshift(@Routing,$KeyIndex); #Add the primary key to the array.
>
> $FlightData{$KeyIndex} = \@Routing;
> }
> }
If you take a reference to a variable (in this case @Routing) and then
change the contents of the variable the reference now points to the
new contents of the variable.
To avoid this declare @Routing my() so that each time through the
above block gets a separate instance of @Routing. If for some reason
you don't want to do this then change "\@Routing" to "[ @Routing ]" so
as to create a reference to an anonymous copy of the array.
Please get into the habit of making proper use of my() pre-emptively
without waiting for your code to go wrong. Putting "use strict" at
the top of your code will force you to use my(). Remember to enable
warnings too while you are about it.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Tue, 23 May 2000 12:39:14 GMT
From: Hardy Merrill <hmerrill@my-deja.com>
Subject: Re: New to Perl: Having Issues with Hashes
Message-Id: <8gdu5g$c6o$1@nnrp1.deja.com>
In article <sik36aqso1135@news.supernews.com>,
"StevenJesseUlbrich" <sjutmp@msn.com> wrote:
> I have subroutine, RoutingExtraction, that is passed a string of data.
> The subroutine will do a series of REGEX processes and return:
>
> return ($KeyIndex, $GroupNumber, $RowNumber, $AirlineCode,
$FlightNumber,
> $DepartureAirport, $ArrivalAirport,
> $DepartureDate, $DepartureTime, $DTime,$ArrivalDate,
> $ArrivalTime, $ATime,
> $AirCraft, $ShareCode, $OnTime, $Stops, $FClass, $BClass,
> $CClass, $BSegment);
>
> It was my hope that by apply it to a array. It could be handled a
little
> easier.
>
> The @Routing is assigned by reference to the FlightData hash, but when
I
> review the contents of the array each entry
> only shows the last referenced array X amount of times.
>
> I have tried to review the various source of documentation with any
clear
> answer. It might be a combination of frustration
> and exhaustion.
>
> What I am doing wrong?
>
> Any advice would be appreciated.
>
> Code snippet:
> if(/\bRoutingInformation -[0-9]{1,2}\W/){
>
> @Routing = RoutingExtraction(m/RoutingInformation -(.*)/);
>
> $KeyIndex = $KeyBase.@Routing[1];
What is $KeyBase? Remember that array indexes start at zero(0), so when
you refer to @Routing[1], you're actually referring to the 2nd element
in that array($GroupNumber) that is returned from RoutingExtraction.
> unshift(@Routing,$KeyIndex); #Add the primary key to the
array.
This $KeyIndex is already included in @Routing that gets returned in the
code above as the 1st element of @Routing. Why are you trying to
extract $KeyIndex, and then put it back in at the front of the array?
It's already at the front of the array - that's the way it was returned
in the code above(???).
>
> $FlightData{$KeyIndex} = \@Routing;
> }
> }
> foreach $Reference1(keys %FlightData){
> #Build a portion of the SQL insert statement
> $ArrayElement = $FlightData{$Reference1};
> $strTest = join "', '", @$ArrayElement;
> $strTest = "'".$strTest."'";
>
> }
> print "$strTest\n";
>
>
I'm not completely clear on what the problem is, or what your intent is.
If you're still having problems, please post a few more details about
the problem(s), and maybe a little more code.
Hope this helps.
--
Hardy Merrill
Mission Critical Linux
http://www.missioncriticallinux.com
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Tue, 23 May 2000 05:12:31 -0700
From: mc <avidbkdNOavSPAM@netscape.net.invalid>
Subject: param prob
Message-Id: <1f1a5ad0.fb9b1cb6@usw-ex0104-026.remarq.com>
How do you pass a variable via the param command.
The line: $ADate = $foo->param('Jan.30');
works great, but if I try:
$AString = "Jan.30";
$ADate = $foo->param('$AString');
It does not work. Any suggestions?
* Sent from RemarQ http://www.remarq.com The Internet's Discussion Network *
The fastest and easiest way to search and participate in Usenet - Free!
------------------------------
Date: Tue, 23 May 2000 12:00:55 GMT
From: "John" <boxrec@uklinux.net>
Subject: Re: read in a file and delete first 8 lines
Message-Id: <392a81d8.0@news2.cluster1.telinco.net>
Clemmons, David [NGC:B995:EXCH] <clemmons@nSoPrAtMelnetworks.com> wrote in
message news:39296350.C003C77B@nSoPrAtMelnetworks.com...
> I need to read in a html file, then delete the first 8 lines (html tags)
> of the file. I also want to delete the
> last two html tags. The files that I will be reading in, were
> previously saved by another script I wrote... so
> I know exactly what the files will look like.
>
> Here is what the file will look like:
>
> <html>
> <head>
> <title>ISSUE</title>
> </head>
> <body bgcolor=#efefef text=#000000 link=#000000 vlink=#000000
alink=#000000>
> <base href="http://nodename/">
> <form action="/usr/local/script" method="post">
> <input type="submit" value="UPDATE">
> <pre>
>
> body of html file
>
> </pre>
> </body>
> </html>
>
What about:-
use HTML::Parser ();
print <pre>
parse file
print file
print </pre>
JohnShep
(Assuming that you haven't got another pair of <pre> tags in the body)
------------------------------
Date: Tue, 23 May 2000 04:39:14 -0700
From: Miggy <miguel_thomasNOmiSPAM@hotmail.com.invalid>
Subject: Re: SDBM_File - %HASH not returning all records ?
Message-Id: <278b4230.642065c5@usw-ex0102-016.remarq.com>
Bob, you are a bloody life-saver. I've been trying all kinds of
key sizes and values to narrow down the problem, and yes,
whatever I did, a percentage of the records never came back !
I am surprised that this isn't more fully documented - I mean, I
downloaded ActivePerl 613 for Windows 95/98/NT. I would have
expected somewhere in the SDBM_File docs a header with big
bloody letters - BTW THIS DOES NOT WORK ON FAT, ONLY NTFS !
Now, regarding DB_File. I did download the DB_File module from
CPAN, but one of the prerequisites IS to have a copy of Berkeley
DB on the computer. Berkeley will give me a source code for
their latest version (3.xx ?), but not a pre-compiled Windows 98
SE .EXE file. And as my VC++ CD is now a coffee mug holder after
I got angry with it, I have no VC++ on my box - so I can't
compile the damn source.
So, I'm now looking for a nice helpful type person who would
download the Berkeley DB source from www.sleepycat.com, compile
it on a Windows 98 (NOT NT) box, ZIP or TAR/GZIP it, and mail it
to me ?
Any volunteers ?
Failing that, are there any other modules available for database
creation and access that don't require a working copy of the
underlying database application on the system. The scripts I'm
working on are intended for different flavour UNIX boxes, I'd
like them to be as portable as possible, but the database must
also work on Windows 98, as that's what I'm using here at home
to test and debug them.
More Ideas Please !
* Sent from RemarQ http://www.remarq.com The Internet's Discussion Network *
The fastest and easiest way to search and participate in Usenet - Free!
------------------------------
Date: 23 May 2000 12:50:00 GMT
From: rajmannar@aol.com (Rajmannar)
Subject: Search&Match-script problem
Message-Id: <20000523085000.01671.00000659@ng-fh1.aol.com>
Hi,
I am facing problems while running a script for the following problem:
Problem: There are two data files, basically insert statements from
two different tables with the following format.
First file has the format: Insert into TableName1 (Param1, "Param2", "Param3",
Param4, Param5)
Second file has the format: Insert into TableName2 (Param6, Param1, Param7,
Param8,.........Param25)
*** Note: the second file has "Param1" in the second
parameter of the insert statement, which is the same as the first parameter
of the insertstatement of the first file
The files have over 1000's of insert statements. I need to scan through
the first file, pick up the five parameters and then scan through the
second file looking for a match on the second parameter. If it matches,
i need to save all the corresponding 5+25 parameters in a third file .
Here is a sample of two files: .
File1:
--------------------
INSERT INTO NC_LODUCTS VALUES (999, "Big Dude", "Z", 3956, "FZ","O")
INSERT INTO NC_LODUCTS VALUES (502, "Nice Sack", "Y", 3071, "FX","O")
INSERT INTO NC_LODUCTS VALUES (531, "Custom Feature Package - 2 Features AB/CD
only", "Y", 9999, "FP","C")
.....
.....
--------------
File2:
-------
INSERT INTO RC_LOD_DETAIL VALUES ('GY',1001,1,"01N", "All-values MM", 0.00,
0.00, 0.00, 0.00, NULL, "You get what you want after one hour of browsing at,
"http://www.zzz.com", "Y", "N", "N", "N", "N", "N", "Y","N", 0, "
MY-NXYY",NULL)
INSERT INTO RC_LOD_DETAIL VALUES ('MC',531,1,'ER3','Custom Feature (2
Feature)', 0.00, 0.00, 0.00, 0.00,"",'Custom Package',"",'Y', 'N', 'Y', 'N',
'Y', 'N', 'Y', 'Y', 0,' ABC_TBD',NULL)
....
...
-------------
I have written the following script:
#!/usr/sbin/perl
$source1="/home/rmannar/perl/source1";
$source2="/home/rmannar/perl/source2";
$dest="/home/rmannar/perl/dest";
open(SOURCE1,$source1) || die "cannot open file $source1 \n";
open(SOURCE2,$source2) || die "cannot open file $source2 \n";
open(DEST, >$dest) || die "cannot open file $dest \n";
$count = 0;
while (<SOURCE1>)
{
$count = $count + 1;
chop;
/.*\((.*)\,(.*)\,(.*)\,(.*)\,(.*)\,(.*)\)/; ->> using Comma as a delimiter
for pattern
search
$ID = $1;
$NAME = $2 ;
$PACK_FLAG = $3;
$CT_ID = $4;
$RC_CAT = $5;
$FET_TYPE = $6;
$KEY = ID ;
open(SOURCE2,$source2) || die "cannot open file $source2 \n";
while (<SOURCE2>)
{
chop;
/([A-Z\_\s+])*\((.*)\,(\d+)\,(\d+)\,(.*)\)/;
if ($3 eq $KEY)
{
print("$KEY Matched !!! Processing Please wait \n");
/([A-Z\_\s+])*\((.*)\,(\d+)\,(\d+)\,(.*)\,(.*)\,(.*)\,(.*)\,(.*)\,(.*)
\,(.*)\,(.*)\,(.*)\,(.*)\,(.*)\,(.*)\,(.*)\,(.*)\,(.*)\,(.*)\,(.*)\,(.*)\,
(.*)\,(.*)\)/; -->> comma delimiter for search
$STATE = $2 ;
$AAA = $3;
$BBB = $5 ;
...
$ZZZ = $23;
$RRR = $24 ;
...
print DEST ("Values for $KEY are : \n");
print DEST (" $STATE , $3, $4 ... ");
}
else
{
#print ("$KEY did not match \n");
}
}
close(SOURCE2);
}
close(SOURCE1);
close(DEST);
****************
The script seems to work, but the problem is it is toooo slow.
Is there a better way to implement this???
thanks
raj
------------------------------
Date: Tue, 23 May 2000 21:00:25 +0900
From: "sang" <laoxiu100@hotmail.com>
Subject: Server Push
Message-Id: <8gdrju$m62$1@nn-os105.ocn.ad.jp>
Hi,alls
I search for some perl samples used of server push.
Any advice ?
Thanks in advance.
------------------------------
Date: 23 May 2000 12:02:52 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: Tanspose rows to columns
Message-Id: <959080427.17650@itz.pp.sci.fi>
In article <B54F38DA.A2B0%xah@xahlee.org>, Xah wrote:
>What i asked is simple: write the _stand along_ Transpose function as i have
>spec'ed it out in my earlier message. (or on my website
>http://xahlee.org/PerlMathematica_dir/perlMathematica.html
>
>You may filch my algorithm/methodology, but not copy/rely from my
>subroutines. If anyone can do it without using 'eval', then i'd be
>_extremely_ impressed.
Hmmph - it appears the target has moved. Normally I wouldn't have
bothered, but I'd already done what you're now asking for right after
posting my previous suggestion.
This is tested code, and you can test it yourself by pasting it into a
file and running it. Don't include my signature unless you wish to
transpose it too..
#!/usr/bin/perl -w
use strict;
sub _transpose {
my ($tree, $perm, $new, @pos) = @_;
if (@pos < @$perm) {
my $i = 0;
_transpose($_, $perm, $new, @pos, $i++) for @$tree;
} else {
$new = \$$new->[$_] for map $pos[$_ - 1] => @$perm;
$$new = $tree;
}
}
sub Transpose {
my ($tree, $perm) = @_;
$perm ||= [2,1];
_transpose($tree, $perm, \my $new);
return $new;
}
# test 3-level transpose:
my @matrix = map [map [split//] => split] => <DATA>;
print join(" " => map join("" => @$_) => @$_), "\n" for @matrix;
print "--\n";
print join(" " => map join("" => @$_) => @$_), "\n" for @{Transpose(\@matrix, [3,1,2])};
__DATA__
abc def ghi
jkl mno pqr
stu vwx yz.
--
Ilmari Karonen - http://www.sci.fi/~iltzu/
Please ignore Godzilla and its pseudonyms - do not feed the troll.
------------------------------
Date: 23 May 2000 08:29:35 +0100
From: nobull@mail.com
Subject: Re: Visibility of package lexicals in debugger
Message-Id: <u966s5oaf9.fsf@wcl-l.bham.ac.uk>
msouth@fulcrum.org writes:
> Just for the record, what I was expecting was that
> any time the debugger is in a subroutine that is
> in the package, the debugger would be able to see
> any package-scoped lexicals regardless of whether
> the subroutine referred to those lexicals
> explicitly or not.
Paging Tom Pheonix...
Paging Tom Pheonix...
Didn't I just say to you just the other day that lots of people use
file-scoped lexical variables in modules and don't realise that this
means that the subroutines declared in the module act as closures?
sub foo { bar() };
is approximately the same as:
BEGIN { *foo = sub { bar() } };
With this in mind (and assuming you understand closures) the behaviour
seems natural (or at least reasonable).
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Tue, 23 May 2000 15:30:21 +0300
From: "Marko Nikulainen" <marko.nikulainen@etela-savo.com>
Subject: Vs: ? Modules & Version
Message-Id: <jLuW4.211$Zc6.6996@read2.inet.fi>
John <boxrec@uklinux.net> kirjoitti
viestissä:392a7f8d.0@news2.cluster1.telinco.net...
> I only have ftp access to my host.
> Often a script which runs fine on my Linux box fails on the host.
> Usually it is a local config prob but sometimes it's module related.
> I would like to know if there is a simple command/way of listing all the
> modules/versions on the host.
>
> Much obliged, JohnShep.
>
>
http://www.scriptsolutions.com/programs/free/perldiver/index.html
Here you can find a free script that prints enviroment variables, installed
modules and server program paths.
Marko
------------------------------
Date: Tue, 23 May 2000 11:18:45 GMT
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: What happened to Mail::Internet?
Message-Id: <pOtW4.694$6T1.111551@news.dircon.co.uk>
On 22 May 2000 22:44:40 -0700, Andrew Perrin - Demography Wrote:
> I can't find it on cpan or activestate.
Its still where its always been as part of Mailtools :
Mail::Internet 1.32 GBARR/MailTools-1.1401.tar.gz
/J\
------------------------------
Date: Tue, 23 May 2000 12:49:18 +0100
From: Richie <rjh@cyberscience.com>
Subject: Re: What's this line which Perl added to AUTOEXEC.BAT?
Message-Id: <a5rkis8a9nkhvr2h38go0dti4i3te9nhpv@4ax.com>
[ rather off-topic for c.l.p.m but relevant to the thread ]
> I was told to use
> "SET" with the %Path% command as a way of appending the
> directory to the Path list, but I didn't see the point of that
> since I could type it into the path statement myself.
It can be useful to use %PATH% instead of just entering the path yourself,
because other installers that need to add to the path can be more
intelligent about it. For instance, if your autoexec says:
set PATH=%PATH%;c:\perl\bin
and another installer comes along and adds a line before that one like
this:
set PATH=%PATH%;c:\some-other-program
then all will be fine - both c:\some-other-program and c:\perl\bin will
end up on the path. However, if your original autoexec had said:
set PATH=c:\windows;c:\perl\bin
then the new installer's line, added before that one, would have no effect
since that line would override it.
Admittedly, the new installer should add its line at the end of all other
'path' lines, but as Bart said, "on Win boxes, no screw-up is impossible".
If you can help to prevent future dumb software from breaking things, you
should. Using %PATH% is one of the ways you can do that.
[ As an aside, your path should probably be:
c:\windows;c:\windows\command;c:\perl\bin
The 'command' directory is not strictly necessary but various things
won't work properly without it. It was almost certainly in there before
the original line was lost. ]
--
| Richie Hindle, rjh@cyberscience.com
| All opinions are mine and not necessarily those of my employer.
| "A woman walks into a bar and asks for a double entendre,
| so the barman gives her one."
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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.
| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
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 V9 Issue 3132
**************************************