[13717] in Perl-Users-Digest
Perl-Users Digest, Issue: 1127 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Oct 20 09:05:47 1999
Date: Wed, 20 Oct 1999 06:05:10 -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: <940424709-v9-i1127@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Wed, 20 Oct 1999 Volume: 9 Number: 1127
Today's topics:
Re: $ is sneaky, point me to a faq or help please (Bart Lateur)
Re: $ is sneaky, point me to a faq or help please (Abigail)
Re: %hash array problem (Bart Lateur)
Abigail Markov (was Re: Ignore the idiots) <jeffp@crusoe.net>
Re: Card shuffling <sjohns17@uic.edu>
Re: Card shuffling <nospam@nospam.com>
Re: Card shuffling (Abigail)
comparing to html files <mauro@franchisetech.com>
Re: comparing to html files (Eric Bohlman)
Re: fork (????) <camerond@mail.uca.edu>
Re: How to print password by "crypt" ? (Bart Lateur)
Re: How to print password by "crypt" ? <hmaster@factory.co.kr>
Re: Ignore the idiots <csaba.raduly@sophos.com>
Re: Ignore the idiots emlyn_a@my-deja.com
Re: Ignore the idiots (Sam Holden)
Re: Manipulating variables <skilchen@swissonline.ch>
Re: Manipulating variables (Bart Lateur)
Re: newbie - counting data lines <rhomberg@ife.ee.ethz.ch>
Re: News Script? <greenej@my-deja.com>
Re: parsewords <umungo01@shafika.vetri.com>
Parsing <nospam@nospam.com>
Passing function as parameter. xxaxx@my-deja.com
Re: Problems adding to and deleting from an array (Eric Bohlman)
Re: problems with proxy protocol sceme <gellyfish@gellyfish.com>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 20 Oct 1999 09:54:50 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: $ is sneaky, point me to a faq or help please
Message-Id: <3812913f.3940374@news.skynet.be>
Thomas B. Holdren wrote:
>($mess, @attach) = split (/\-\-$boundary/, $message);
>
>But MS puts a '$' in the boundary, and I can't match the boundaries on
>messages with $ in the boundary.
look up "quotemeta" aor "\Q".
($mess, @attach) = split /\-\-\Q$boundary/, $message;
--
Bart.
------------------------------
Date: 20 Oct 1999 07:39:41 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: $ is sneaky, point me to a faq or help please
Message-Id: <slrn80rdvn.fji.abigail@alexandra.delanet.com>
Bart Lateur (bart.lateur@skynet.be) wrote on MMCCXLI September MCMXCIII
in <URL:news:3812913f.3940374@news.skynet.be>:
:: Thomas B. Holdren wrote:
::
:: >($mess, @attach) = split (/\-\-$boundary/, $message);
:: >
:: >But MS puts a '$' in the boundary, and I can't match the boundaries on
:: >messages with $ in the boundary.
::
:: look up "quotemeta" aor "\Q".
::
:: ($mess, @attach) = split /\-\-\Q$boundary/, $message;
Why the backwacking of the dashes? Dashes aren't special, unless in
character classes.
($mess, @attach) = split /--\Q$boundary/ => $message;
Abigail
--
package Just_another_Perl_Hacker; sub print {($_=$_[0])=~ s/_/ /g;
print } sub __PACKAGE__ { &
print ( __PACKAGE__)} &
__PACKAGE__
( )
-----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
http://www.newsfeeds.com The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including Dedicated Binaries Servers ==-----
------------------------------
Date: Wed, 20 Oct 1999 09:53:11 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: %hash array problem
Message-Id: <3811907a.3743138@news.skynet.be>
Jon Shemitz wrote:
>Seems like
>
> my ($key, $value);
> while (($key, $value) = each %mydata) {print "$key == $value\n";}
>
>is better.
No it's not. Not if you like some order in your printout that makes some
sense to human beings. Try looking up a name in a list of 200 names when
they're pseudo-randomly shuffled!
--
Bart.
------------------------------
Date: Wed, 20 Oct 1999 08:03:38 -0400
From: Jeff Pinyan <jeffp@crusoe.net>
Subject: Abigail Markov (was Re: Ignore the idiots)
Message-Id: <Pine.GSO.4.10.9910200754560.21020-100000@crusoe.crusoe.net>
On Oct 20, Csaba Raduly blah blah blah:
> Ala Qumsieh wrote:
> >
> > "Nolen Johnson" <nolenj@worldnet.att.net> writes:
> >
> > > Is Abigail a "he"?
> >
> > No body knows for sure, the subject is highly open to debate. Some
> > theories indicate that Abigail is an alien from Venus. I personally am
> > convinced that Abigail is a really cool robot.
>
> Are you listening up there, Alan Turing ?
Abigail is a Markov chain program written in Perl. Abigail has had posts
by the following persons sent through itself:
Person Weighting
====== =========
Randal Schwartz 15%
Tom Christiansen 37%
Tom Phoenix 12%
Larry Wall 9%
Larry Rosler 11%
Ilya Z. 8%
Others 8%
The weighting shows why some of Abigail's answers seem like something
someone else would say. Abigail has had some very fine teachers. The
Foundation for Abigail Research and Coding Experimentation has already
dispatched several other Abigail-like programs to 50,430 other newsgroups,
many in the comp.* hierarchy.
--
MIDN 4/C PINYAN, USNR, NROTCURPI
jeff pinyan japhy@pobox.com
perl stuff japhy+perl@pobox.com
CPAN ID: PINYAN http://www.perl.com/CPAN/authors/id/P/PI/PINYAN
------------------------------
Date: Wed, 20 Oct 1999 05:03:06 -0500
From: Seth David Johnson <sjohns17@uic.edu>
Subject: Re: Card shuffling
Message-Id: <Pine.A41.4.10.9910200445520.184824-100000@tigger.cc.uic.edu>
On 20 Oct 1999, Mikko Saari wrote:
> I need a perl script to handle decks of cards. My first and most obvious
> problem is shuffling, a problem which has bothered me previously. How do I
> arrange an array in random order?
First,
perldoc -f rand
perldoc -f splice
It's pretty trivial to grab a random element from a list. Assuming you
have an array of cards designated by @deck,
$card = $deck[rand(@deck)];
should return a random card. To get a random card and remove it from the
deck,
$card = splice(@deck,rand(@deck),1);
should work (I haven't tested this).
Keep in mind there are some "perlsumtions" occuring here. Note the '@deck'
in 'rand(@deck)' is equivalent to 'rand(scalar(@deck)),' and that
'$deck[rand(@deck)]' is equivalent to '$deck[int(rand(@deck))]', and
therefore is equivalent to '$deck[int(rand(scalar(@deck)))]'. Whew! This
is just off the top of my head; somebody speak up if I'm off-by-one. :)
-Seth
www.pdamusic.com
------------------------------
Date: Wed, 20 Oct 1999 07:50:34 -0400
From: "Corey Martin" <nospam@nospam.com>
Subject: Re: Card shuffling
Message-Id: <7ukaav$2b1$1@nntp4.atl.mindspring.net>
http://www.perl.com/pub/v/faqs
--
Corey Martin
the web designer's centre
http://www.martin-web.com/centre/
Mikko Saari <msaari@tukki.cc.jyu.fi> wrote in message
news:7uk2m0$2n@tukki.cc.jyu.fi...
> Abigail <abigail@delanet.com> wrote:
> > Your zeroth and most serious problem is your inability to read.
> > If you can't read the faq, you wouldn't be able to read my answer
either.
>
> And where this faq might be found? I tried looking around in the perl.com
> but I didn't find any help.
>
>
> --
> --
> for more info msaari
> finger msaari@tukki.jyu.fi @jyu.fi
> 262 "quantum physics: the dreams that stuff is made of"
------------------------------
Date: 20 Oct 1999 07:33:25 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: Card shuffling
Message-Id: <slrn80rdk1.fji.abigail@alexandra.delanet.com>
Mikko Saari (msaari@tukki.cc.jyu.fi) wrote on MMCCXLI September MCMXCIII
in <URL:news:7uk2m0$2n@tukki.cc.jyu.fi>:
'' Abigail <abigail@delanet.com> wrote:
'' > Your zeroth and most serious problem is your inability to read.
'' > If you can't read the faq, you wouldn't be able to read my answer either.
''
'' And where this faq might be found? I tried looking around in the perl.com
'' but I didn't find any help.
Well, perl.com is a silly place to look, as all the faqs come with Perl,
so if you have Perl installed, you already have the faq. But I guess it
would be absurd to look for instructions in the box. If you buy a toaster,
instructions are to be found on the web!
Nevertheless, something has to be wrong with your reading skills.
There is a link called "FAQs" on the top half of http://www.perl.com.
Granted, it's an image, but it does have a decent ALT attribute.
Abigail
--
perl -we '$@="\145\143\150\157\040\042\112\165\163\164\040\141\156\157\164".
"\150\145\162\040\120\145\162\154\040\110\141\143\153\145\162".
"\042\040\076\040\057\144\145\166\057\164\164\171";`$@`'
-----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
http://www.newsfeeds.com The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including Dedicated Binaries Servers ==-----
------------------------------
Date: Wed, 20 Oct 1999 12:09:02 +0200
From: "Mauro Quartini" <mauro@franchisetech.com>
Subject: comparing to html files
Message-Id: <380d991b_4@news.vic.com>
Hi all,
I need a perl code to compare 2 html files and to highlight the differences.
Let's say I need to mark (using an image or a comment) in the 2nd file
_only_ the changes.
I need to distinguish between html tag changes and simple text changes.
Does anyone know if this perl script exists?
Thank you all in advance
Mauro Quartini
mauro@franchisetech.com
------------------------------
Date: 20 Oct 1999 10:38:51 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: comparing to html files
Message-Id: <7uk63r$553$4@nntp3.atl.mindspring.net>
Mauro Quartini (mauro@franchisetech.com) wrote:
: I need a perl code to compare 2 html files and to highlight the differences.
: Let's say I need to mark (using an image or a comment) in the 2nd file
: _only_ the changes.
: I need to distinguish between html tag changes and simple text changes.
The way I'd do it would be to use James Clark's nsgmls (available for all
major platforms) to parse both html files into ESIS format, run the ESIS
files through a diff utility (which you'll already have on a Unix
platform; you'll have to look around for one if you're on a Windows
platform, but I'm pretty sure it's been ported), and then use some Perl
code to take the diff output and the second ESIS file and recreate the
second HTML file from them. ESIS format basically puts each HTML
"thingy" (start tag, end tag, attribute, text, etc.) on a line of its
own, with the first character indicating what type of "thingy" it is.
This will require that both HTML files be valid HTML.
------------------------------
Date: Wed, 20 Oct 1999 07:43:37 -0500
From: Cameron Dorey <camerond@mail.uca.edu>
To: Dimitrios Kremmydas <lzu99dk@rdg.ac.uk>
Subject: Re: fork (????)
Message-Id: <380DB8F9.4BEBA80F@mail.uca.edu>
[cc'd to dk]
Dimitrios Kremmydas wrote:
>
> I want to do something (e.g Open an FTP Connection, open an SMTP
> connection) but I WANT TO HAVE IT MANY TIMES SIMULTANEOUSLY ...
> I know how to make FTP or SMTP (Net::*) through Perl, but I don't know
> how to make child processes (that means ... make something
> simultaneously) ...
> I know it has something to do with fork and pid and etc.
> But since I cannot understand them very well, can somebody send me a
> simple examples, explaining what is going on on th code ? Even locations
> of Internet Resources would be happily acceptable ...
>
> cheers
Your headers say you are using Windows 95. If that's the case, and you
are using ActiveState's ActivePerl, forget it. Fork just isn't here.
Cameron
--
Cameron Dorey
Associate Professor of Chemistry
University of Central Arkansas
Phone: 501-450-5938
camerond@mail.uca.edu
------------------------------
Date: Wed, 20 Oct 1999 09:53:09 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: How to print password by "crypt" ?
Message-Id: <38108f78.3484826@news.skynet.be>
Yeong Mo/Director Hana co. wrote:
>$passwd = crypt($password, salt);
There is that "salt" again, and here even without "$". You need to
provide a pretty random string of at least two characters. Two randomly
chosen letters is alright.
>`mv htpasswd .htpasswd`;
>
>I tried this, But access was denied.
Then you have a permission problem. CGI programs usually have the least
privileged status possible ("nobody" or "other"). So your ".htaccess"
file must be writable for "other". Try doing an appropriate chmod using
Telnet or FTP.
--
Bart.
------------------------------
Date: Wed, 20 Oct 1999 21:07:27 +0900
From: "Yeong Mo/Director Hana co." <hmaster@factory.co.kr>
Subject: Re: How to print password by "crypt" ?
Message-Id: <JPkMCIvG$GA.220@news.thrunet.com>
Thanks,
Everyone.
Now, It works fine.
Thanks again..
Bart Lateur ÀÌ(°¡) <38108f78.3484826@news.skynet.be> ¸Þ½ÃÁö¿¡¼
ÀÛ¼ºÇÏ¿´½À´Ï´Ù...
>Yeong Mo/Director Hana co. wrote:
>
>>$passwd = crypt($password, salt);
>
>There is that "salt" again, and here even without "$". You need to
>provide a pretty random string of at least two characters. Two randomly
>chosen letters is alright.
>
>>`mv htpasswd .htpasswd`;
>>
>>I tried this, But access was denied.
>
>Then you have a permission problem. CGI programs usually have the least
>privileged status possible ("nobody" or "other"). So your ".htaccess"
>file must be writable for "other". Try doing an appropriate chmod using
>Telnet or FTP.
>
>--
> Bart.
------------------------------
Date: Wed, 20 Oct 1999 12:05:02 +0100
From: Csaba Raduly <csaba.raduly@sophos.com>
Subject: Re: Ignore the idiots
Message-Id: <380DA1DE.3B3F96A6@sophos.com>
Ala Qumsieh wrote:
>
> "Nolen Johnson" <nolenj@worldnet.att.net> writes:
>
> > Is Abigail a "he"?
>
> No body knows for sure, the subject is highly open to debate. Some
> theories indicate that Abigail is an alien from Venus. I personally am
> convinced that Abigail is a really cool robot.
>
> --Ala
Are you listening up there, Alan Turing ?
Csaba
--
-----BEGIN GEEK CODE BLOCK-----
Version 3.1
GCS/>GMU d- s:- a30 C++$ UL+ P+>+++ L++ E- W+ N++ o? K? w++>$ O++$ M-
V- PS PE Y PGP- t+ 5 X++ R* tv++ b++ DI+++ D++ G- e+++ h-- r-- !y+
-----END GEEK CODE BLOCK-----
Csaba Raduly, Software Developer (OS/2), Sophos Anti-Virus
mailto:csaba.raduly@sophos.com http://www.sophos.com/
US Support +1 888 SOPHOS 9 UK Support +44 1235 559933
Life is complex, with real and imaginary parts.
------------------------------
Date: Wed, 20 Oct 1999 12:04:13 GMT
From: emlyn_a@my-deja.com
Subject: Re: Ignore the idiots
Message-Id: <7ukb3n$1fc$1@nnrp1.deja.com>
In article <380B5917.CB0CFDD3@home.com>,
Kenneth Bandes <kbandes@home.com> wrote:
> > Ignore Abigail - People like him make this place a whole lot more
> > intimidating to use (which is their intent, I think). I mean what
hell
> > is this forum for if you can't ask a simple Perl question like you
did?
>
> Maybe for not-so-simple questions that you can't easily answer
> yourself.
>
> I used to feel that way too - I was quite taken aback at first at
> the nastiness, and I still feel it's kind of over-the-top.
>
> But right now, my news reader tells me I've 785 unread posts in clpm.
> That's a lot of dirt to root through to get to the few truffles of
> really intelligent, thoughtful posts (and by the way, many of those
> come from Abigail among others). Just taking the time to figure out
> which posts are worthwhile and which are not would probably lose me
> my job or my marriage. A little more homework and self-editing by
> people with simple Perl questions would make this a much more
> useful group.
>
> Ken Bandes
>
This is comp.lang.perl.misc right? Maybe there should be a
comp.lang.perl.peoplewhoknowitallalready so that us newbies don't feel
like we're encroaching on the elitists' turf.
You must remember that although some of the questions we have could be
answered with a book, we're not always sure which is the BEST way to do
something, and the only way to find that out is by asking people who
use the language all the time. I've found that the online references
and books on the subject are over-rated: they cram too much information
into a single explanation (often including other stuff in an example
that is unneccessary), so we never actually find out what the CORE of
the function/expression/whatever is.
Maybe I just speak for myself here, but I doubt it.
Just because Abigail is posting questions that engage YOU, it does not
exclude anyone else from posting for legitimate questions they have.
E.
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 20 Oct 1999 12:55:33 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: Ignore the idiots
Message-Id: <slrn80reu5.dlt.sholden@pgrad.cs.usyd.edu.au>
On Wed, 20 Oct 1999 12:04:13 GMT, emlyn_a@my-deja.com wrote:
>
>Just because Abigail is posting questions that engage YOU, it does not
>exclude anyone else from posting for legitimate questions they have.
Except when those questions are answered in an obvious place in the
documentation.
--
Sam
The most exciting phrase to hear in science, the one that heralds new
discoveries, is not "Eureka!" (I found it!) but "That's funny ..."
--Isaac Asimov
------------------------------
Date: Wed, 20 Oct 1999 10:11:15 GMT
From: "Samuel Kilchenmann" <skilchen@swissonline.ch>
Subject: Re: Manipulating variables
Message-Id: <7zgP3.25593$m4.92786061@news.magma.ca>
APS <pollayil20@yahoo.com> wrote in:
news:380CA913.3787063F@yahoo.com...
>
> Please help in to set this:
>
> if ($weight <= "$n_weight") {
[ something ]
> }
>
> Where, $n_weight and $charge are taken from a flt. file db., for eg:
> 500,50.00
> 1000,75.00
> 1500,99.00
> 2000,124.00
>
> The problem is that, the print shows all the charge values greater
> than the $weight
>
> Is there any solution whereby I could take just the value that matches
> (less than or equal to) the $weight
>
If your weight values in the flat file are multiples of a fixed number,
then you could use something like get_category_direct below.
Otherwise try either a linear or a binary search on the weight values in
the flat file as in get_category_linear or get_category_binary below.
#!wherever/perl -w
use strict;
sub get_charge {
my $category = shift;
my $charges = shift;
return $charges->{$category};
}
# select category via linear search from a
# sorted category list
sub get_category_linear {
my $weight = shift;
my $categories = shift;
my $category;
foreach (@{$categories}) {
$category = $_;
if ($weight <= $_) {
last;
}
}
return $category;
}
# select category via binary search from a
# sorted list of categories
sub get_category_binary {
my $weight = shift;
my $categories = shift;
my $upper = $#$categories;
my $lower = 0;
my $current;
while ($lower <= $upper) {
$current = int(($upper + $lower) / 2);
if ($weight < $categories->[$current]) {
$upper = $current - 1;
} elsif ($weight > $categories->[$current]) {
$lower = $current + 1;
} else {
last;
}
}
if ($current < $#$categories) {
if ($categories->[$current] < $weight) {
$current++;
}
}
return $categories->[$current];
}
# select category directly from a sorted
# list of categories with a constant
# interval between categories
sub get_category_direct {
my $weight = shift;
my $categories = shift;
my $interval;
my $largest = $categories->[-1];
if ($#$categories >= 1) {
$interval = abs($categories->[1] - $categories->[0]);
} else {
$interval = $categories->[0];
}
if (int($weight) != $weight) {
$weight = int($weight) + 1;
}
$weight = (int(($weight - 1) / $interval) + 1) * $interval;
return $weight > $largest ? $largest : $weight;
}
my %charges = ( 500 => 50,
1000 => 75,
1500 => 99,
2000 => 124,
);
my @categories = sort { $a <=> $b } (keys %charges);
# @charges{@categories} = map { rand(10000) } @categories;
# @categories = sort { $a <=> $b } (keys %charges);
# take the weight to be charged from the command line
my $weight = abs($ARGV[0]);
print "Weight: $weight, Charge: ",
get_charge(get_category_linear($weight,
\@categories),
\%charges),
"\n";
print "Weight: $weight, Charge: ",
get_charge(get_category_binary($weight,
\@categories),
\%charges),
"\n";
print "Weight: $weight, Charge: ",
get_charge(get_category_direct($weight,
\@categories),
\%charges),
"\n";
------------------------------
Date: Wed, 20 Oct 1999 11:23:46 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Manipulating variables
Message-Id: <380da403.715782@news.skynet.be>
APS wrote:
>Where, $n_weight and $charge are taken from a flt. file db., for eg:
>500,50.00
>1000,75.00
>1500,99.00
>2000,124.00
>
>The problem is that, the print shows all the charge values greater than
>the $weight
>
>Is there any solution whereby I could take just the value that matches
>(less than or equal to) the $weight
Well... I propose that you create a sub, that checks it's list of
weights in srted order, and which *returns* as soon as it finds one.
Something like:
@tariff = sort { $a->[0] <=> $b->[0] } ( [ 500, 50.00 ],
[ 2000, 124.00 ], [ 1000, 75.00 ], [ 1500, 99.00] );
my $maxtariff = 200.00; # or whatever; if weight exceeds maximum
sub charge {
my($weight) = @_;
foreach (@tariff) {
if($_->[0]>=$weight) {
return $_->[1];
}
}
return $maxtariff;
}
print charge(780); # prints "75"
--
Bart.
------------------------------
Date: Wed, 20 Oct 1999 13:54:13 +0200
From: Alex Rhomberg <rhomberg@ife.ee.ethz.ch>
Subject: Re: newbie - counting data lines
Message-Id: <380DAD65.B1B04BD5@ife.ee.ethz.ch>
Noira Hadi wrote:
>
> Let say I want to have the script processing something when line number is
> less than 29. I use the script below in addition to your script. However, it
> does not print anything inside the innermost 'if' statement which should
> print ' do something' and count the line number. Here's the script that I
> altered.
>
> #!/usr/local/bin/perl -wl
> use strict;
> my @buf;
> my @count_sbr;
> open(INF,"data") || die "no datafile" ;
>
> while (<INF>)
> {
> chomp;
> push @buf, $_;
> if (/MRR/)
> {
$_ contains a line with MRR
> my $length = @buf;
> if ($length < 29)
> {
> print "oops...";
> chomp;
> push @count_sbr, $_;
$_ still contains line with MRR in it
You probably want to do something else than push $_ into this array.
Like doing something with the stuff in @buf
> if (/SBR/)
you test if there is also SBR in addition to MRR in $_
none of your lines have this, therefore this never matches
You have to use your debugging skills a bit.
Add prints, use a debugger or perl debugging mode to examine the
variables
- Alex
------------------------------
Date: Wed, 20 Oct 1999 12:29:49 GMT
From: JAG <greenej@my-deja.com>
Subject: Re: News Script?
Message-Id: <7ukcji$2bh$1@nnrp1.deja.com>
In article <zw9P3.2086$3_5.74937@news2.rdc1.on.home.com>,
"Slackware Genius" <slackware@home.com> wrote:
> Hi Everyone,
>
> I am relatively new to Perl, and am looking to create a web-based
form for
> posting news updates to my site. What I am looking to do is have it
so you
> can enter the date, and some comments then have it submitted to the
webpage
> in a specific font/color/etc ..
>
> ie :
>
> Date: (input date)
> Comments: (input comments)
> SUBMIT <-- upon clicking will update my page(s) with the news in the
proper
> format ....
>
> ANY suggestions/help/links would be greatly appreciated. Thanks
everyone.
How about searching CPAN or any of the numerous script archives for an
existing script, rather than re-inventing the wheel? A quick look at
www.scripts.com lists 70 different bulletin-board scripts. I'm sure
that one of these would get you started...
--
# James Greene - Informatics Consulting - D-79539 Loerrach, Germany
# http://www.informatics-consulting.com
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Wed, 20 Oct 1999 10:45:06 GMT
From: Govindaraj <umungo01@shafika.vetri.com>
Subject: Re: parsewords
Message-Id: <s0r79i9hr0162@corp.supernews.com>
Hi,
Here is the Piece of Code to parse your text:
$Line = "0041-7332 353250 070199 24761";
print "Original Line: $Line\n";
@Fields = split(/ /, $Line);
$Line = "";
$Line .= "$Fields[0] ";
$Fields[1] = sprintf "%010d", $Fields[1];
$Line .= " $Fields[1] ";
$Line .= join(" ", @Fields[2..$#Fields]);
print "Converted Line: $Line\n";
Use sprintf fuctions to pad zeros before the Strings or Numeric.
Govindaraj M.
email: umungo01@shafika.vetri.com
Etruscan wrote:
>
>
> Hi,
> I am trying to pasre a text file.
> 0041-7332 353250 070199 24761
> 0041-7332 353854 070199 12479
> I am trying to load these four fields into an array and the parse them.
The
> second field should be ten character long. 0000353250 and so on. If the
> second field is 7 chars long then it should be preceded by three zeros.
> This is what I have read and cannot apply successfully
> @F array auotmatically loads all the fields into an array. $[0] $[1]
> $[2]$[3] are the four fields.
> The end result should look like
> 0041-7332 000035250 07019924761
> Please let me know what I should look up (new to perl).
> Please help and Thanks
>
>
>
> -**** Posted from RemarQ, http://www.remarq.com/?a ****-
> Search and Read Usenet Discussions in your Browser - FREE -
--
Posted via CNET Help.com
http://www.help.com/
------------------------------
Date: Wed, 20 Oct 1999 07:23:11 -0400
From: "Corey Martin" <nospam@nospam.com>
Subject: Parsing
Message-Id: <7uk8nh$het$1@nntp4.atl.mindspring.net>
I have an HTML file I'm retreieving with the following code:
#!/usr/bin/perl
print "Content-type: text/html";
use strict;
use LWP::UserAgent;
$|++;
my $ua = new LWP::UserAgent;
$ua->agent("Gellzilla/666");
my $url =
'http://cgi.ebay.com/aw-cgi/eBayISAPI.dll?ViewItem&item=178605262';
my $req = new HTTP::Request 'GET',$url;
my $res = $ua->request($req);
print $res->status_line,"\n";
print $res->content;
I want to parse the results by finding all of the US prices in the document
(for example, $3.04 or $45.00). Also, I would want to use the first price I
find, because there is more than one price on the page. How do I do this?
Thanks
--
Corey Martin
the web designer's centre
http://www.martin-web.com/centre/
------------------------------
Date: Wed, 20 Oct 1999 12:19:12 GMT
From: xxaxx@my-deja.com
Subject: Passing function as parameter.
Message-Id: <7ukbvn$1uo$1@nnrp1.deja.com>
I am attempting to write a generic directory scan subroutine which will
run a specified function for each file found.
The recursive directory scan works fine. And I can do stuff to each of
the files found. But at the moment I have to write a different set of
subroutines for each type of job I want to accomplish.
In c I would just pass in the point to the function, then after a few
minutes (or hours) of syntax chasing the routine would use the parameter
passed function on each occurance of the found files.
How would this be done in perl?
Thanks in advance.
Claude
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 20 Oct 1999 10:26:52 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: Problems adding to and deleting from an array
Message-Id: <7uk5dc$553$3@nntp3.atl.mindspring.net>
M B (mb1010@hotmail.com) wrote:
: I am unable to add to an array and delete from an array. I'm
: adding at the end of the array and deleting from the beginning
: of the array (first-in-first-out).
:
: Everytime I add to the array:
: - the array length increases by 2 and not 1
: - the data is in the odd-numbered offset of the array and not at
: every offset.
:
: You can use the program below to check this out.
:
: @array = (); # Initialize array
: $length = @array; # Get length of array
: print "Length = $length\n"; # Prints 0
:
:
: $x = "abc def"; # Add string to end of array
: $array [@array + 1] = $x;
This is a classic case where the comment says one thing and the code does
something else. Since arrays are zero-based, $array[@array] is the
element right after the last element, and $array[@array+1] is two elements
past the last element. Since Perl arrays grow dynamically, assigning to
the second element past the end of the array causes the length of the
array to increase by two.
The idiomatic way to add an element on to the end of an array is to use
push(), and the idiomatic way to remove an element from the beginning of
an array is to use shift(). Look those two functions up in perlfunc,
along with pop() and unshift(). Using those four functions in the right
combination, you can implement a queue (like you're trying to), a stack,
or a dequeue ("double-ended queue").
------------------------------
Date: 20 Oct 1999 13:22:37 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: problems with proxy protocol sceme
Message-Id: <380db40d_2@newsread3.dircon.co.uk>
Karsten Priegnitz <Karsten.Priegnitz@stud.fh-hannover.de> wrote:
> hi,
>
> the command:
>
> perl -MLWP::Simple -e 'getprint "http://www.hallo.de/index.htm"'
>
> returns the message:
>
> 501 Protocol scheme 'proxy.inform.fh-hannover.de' is not supported
> <URL:http://www.hallo.de/index.htm>
>
Your HTTP_PROXY *(or whatever) env variable needs http:// in front of it
please read the lwpcook again ...
/J\
--
"Tony Blair. Make it so" - Patrick Stewart
------------------------------
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 1127
**************************************