Discussion:
searching for franken
(too old to reply)
George
2008-12-29 06:07:15 UTC
Permalink
I've written perl programs now for about a year and a half, and they have
usually focused on usenet. In some sense, this one does as well, in that
I'm developing material for my next 'nym shift, but the input from this is
the internet instead, probably an url.

I've never used perl to do this before, so I don't know where to start,
except with

# shebang windows meaningless

use warnings;
use strict;

I would like to test whether

http://www.co-array.org/

contains the following words:

distributed memory
Numerid Ried
OpenMP

Thanks for your comment, and thank you Santa for sending the cowgirls home
with George.
--
George

This way of life is worth defending.
George W. Bush

Picture of the Day http://apod.nasa.gov/apod/
Mirco Wahab
2008-12-29 10:11:36 UTC
Permalink
Post by George
I've written perl programs now for about a year and a half, and they have
usually focused on usenet. In some sense, this one does as well, in that
I'm developing material for my next 'nym shift, but the input from this is
the internet instead, probably an url.
I've never used perl to do this before, so I don't know where to start,
except with
I would like to test whether
http://www.co-array.org/
distributed memory
Numerid Ried
OpenMP
There is a module called LWP::Simple
http://search.cpan.org/~gaas/libwww-perl-5.822/lib/LWP/Simple.pm

which does exactly that, example:

...

use LWP::Simple;

my $url = 'www.co-array.org';
my $html = get 'http://' . $url;

my $what = qr'distributed.*?memory|Numerid.*?Ried|OpenMP';

while($html =~ /$what/mg) { # note the /m modifier
print '...' . substr($html, pos($html)-20, 40) . "...\n"
}

...

If you need to pass headers and cookies to the
site, please study the other libwww functions
(http://search.cpan.org/~gaas/libwww-perl-5.822/lib/Net/HTTP.pm)

or copy/paste the complete http query from your browser
and send it via IO::Socket::INET.

Regards

M.
Tad J McClellan
2008-12-29 14:07:39 UTC
Permalink
Post by Mirco Wahab
Post by George
I would like to test whether
http://www.co-array.org/
distributed memory
Numerid Ried
OpenMP
my $what = qr'distributed.*?memory|Numerid.*?Ried|OpenMP';
while($html =~ /$what/mg) { # note the /m modifier
Note that the /m modifier does absolutely nothing for the pattern
being used, and so is not needed at all.

You probably meant the /s modifier instead?
--
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"
George
2008-12-30 06:10:52 UTC
Permalink
Post by Tad J McClellan
Post by Mirco Wahab
Post by George
I would like to test whether
http://www.co-array.org/
distributed memory
Numerid Ried
OpenMP
my $what = qr'distributed.*?memory|Numerid.*?Ried|OpenMP';
while($html =~ /$what/mg) { # note the /m modifier
Note that the /m modifier does absolutely nothing for the pattern
being used, and so is not needed at all.
You probably meant the /s modifier instead?
I think this is a significant issue and is where I'm stumbling right now:

# shebang doesn't work on windows

use strict;
use warnings;

use Net::HTTP;
use LWP::Simple;

my $url = 'www.alfrankensense.com/al_franken_quotes.html';
my $html = get 'http://' . $url;

#my $what = qr'*?-Al*?';
my $what = qr'distributed.*?memory|Al.*?Franken|OpenMP';

while($html =~ /$what/mg) { # note the /m modifier
print '...' . substr($html, pos($html)0, 40) . "...\n"
}

# perl wahab5.pl

I've tried /m /s /mg and struck out.

This is the page that I want to work on. Ultimately, I want the quotes to
be of the form where dialog can use them as randomquotes, which is:

I believe the most solemn duty of the American president is to protect the
American people. If America shows uncertainty and weakness in this decade,
the world will drift toward tragedy. This will not happen on my watch.
George W. Bush
%
I can hear you, the rest of the world can hear you and the people who
knocked these buildings down will hear all of us soon.
George W. Bush
%
I have a different vision of leadership. A leadership is someone who brings
people together.
George W. Bush
%
I just want you to know that, when we talk about war, we're really talking
about peace.
George W. Bush
--
George

The thing that's wrong with the French is that they don't have a word for
entrepreneur.
George W. Bush

Picture of the Day http://apod.nasa.gov/apod/
Dr.Ruud
2008-12-30 09:51:14 UTC
Permalink
Post by George
# shebang doesn't work on windows
Stop putting that in your scripts. Start reading the documentation.

In short: the path or even the name of the binary don't matter, but the
options do.

Unless of course you would bind .pl to a shebang.com that would just do
what you once expected.
--
Ruud
Hans Mulder
2008-12-30 20:48:11 UTC
Permalink
Post by Dr.Ruud
Unless of course you would bind .pl to a shebang.com that would
just do what you once expected.
My copy of perlrun says that perl.exe does exactly that: it reads
the shebang line and redispatches to the path stated there (unless
the word "perl" occurs on that line).

When Perl was young, this was useful on Unix versions that didn't
support shebang; these days it is perhaps useful on Windows.

Hope this helps,

-- HansM
George
2009-01-01 00:50:15 UTC
Permalink
Post by Hans Mulder
Post by Dr.Ruud
Unless of course you would bind .pl to a shebang.com that would
just do what you once expected.
My copy of perlrun says that perl.exe does exactly that: it reads
the shebang line and redispatches to the path stated there (unless
the word "perl" occurs on that line).
When Perl was young, this was useful on Unix versions that didn't
support shebang; these days it is perhaps useful on Windows.
Hope this helps,
-- HansM
But it can hurt.

If you do -w
and
use warnings;
, you have trouble.

Windows has no trouble located perl.exe. It's a very simple situation,
with target and platform the same, 1 machine, and one operator.
--
George

America must not ignore the threat gathering against us. Facing clear
evidence of peril, we cannot wait for the final proof, the smoking gun that
could come in the form of a mushroom cloud.
George W. Bush

Picture of the Day http://apod.nasa.gov/apod/
s***@netherlands.com
2009-01-01 01:14:46 UTC
Permalink
Post by George
Post by Hans Mulder
Post by Dr.Ruud
Unless of course you would bind .pl to a shebang.com that would
just do what you once expected.
My copy of perlrun says that perl.exe does exactly that: it reads
the shebang line and redispatches to the path stated there (unless
the word "perl" occurs on that line).
When Perl was young, this was useful on Unix versions that didn't
support shebang; these days it is perhaps useful on Windows.
Hope this helps,
-- HansM
But it can hurt.
If you do -w
and
use warnings;
, you have trouble.
Windows has no trouble located perl.exe. It's a very simple situation,
with target and platform the same, 1 machine, and one operator.
Stop the bullshit. You got nothing but shit for brains.

sln
George
2009-01-02 09:11:38 UTC
Permalink
Post by s***@netherlands.com
Post by George
Post by Hans Mulder
Post by Dr.Ruud
Unless of course you would bind .pl to a shebang.com that would
just do what you once expected.
My copy of perlrun says that perl.exe does exactly that: it reads
the shebang line and redispatches to the path stated there (unless
the word "perl" occurs on that line).
When Perl was young, this was useful on Unix versions that didn't
support shebang; these days it is perhaps useful on Windows.
Hope this helps,
-- HansM
But it can hurt.
If you do -w
and
use warnings;
, you have trouble.
Windows has no trouble located perl.exe. It's a very simple situation,
with target and platform the same, 1 machine, and one operator.
Stop the bullshit. You got nothing but shit for brains.
sln
Stop de onzin. Je hebt alleen maar troep voor hersenen.

Wenn snacken du willst, snacken ik kann.
--
George

America is a Nation with a mission - and that mission comes from our most
basic beliefs. We have no desire to dominate, no ambitions of empire. Our
aim is a democratic peace - a peace founded upon the dignity and rights of
every man and woman.
George W. Bush

Picture of the Day http://apod.nasa.gov/apod/
Mirco Wahab
2008-12-30 11:17:44 UTC
Permalink
Post by Tad J McClellan
Post by Mirco Wahab
while($html =~ /$what/mg) { # note the /m modifier
Note that the /m modifier does absolutely nothing for the pattern
being used, and so is not needed at all.
It prevents the dot from matching across line
boundaries, as you surely know.
Post by Tad J McClellan
You probably meant the /s modifier instead?
not really
George, what you probably intend to do is, as anybody
noted, "web scraping" which has to be applied (in your
case) to some ill structured html source. What I'd use
here is a kind of 'quick and dirty' regular expression
search.


I looked into your html source and conceived something
that does the job somehow. Please try to learn some
basics of regular expressions, eg.: from here:
http://oreilly.com/catalog/9781565922570/

my hack on your problem:

use strict;
use warnings;
use LWP::Simple;

# load the complete content of the url in question
# via LWP::Simple::get(...)
my $t = get 'http://www.alfrankensense.com/al_franken_quotes.html';

# inspect the web site and look at what "marker"
# your stuff usually starts, in your case - it's the tag:
# <center>Al Franken Quotes</center>

my @quotes; # array, where the quotes are to be collected

# *If* we got there:
if($t =~ /<center>Al Franken Quotes<\/center>/g) { # the inner / is ecscaped
# then we write a quick & dirty regular expression
# to map on the quote (look in the html for hints)
my $q = qr{ \t # the quote is always preceeded by a tab
"([^"]+)" # find ", save all (saved to $1), to another "
.+? # fine, now look up a '-' followed by whitespace
\-\s+ # which comes here (escaped -) ..
([^<]+) # this has to be the quote source until next html tag
}sx; # the /s lets the .(dot) match across lines
# the /x allows us to format and comment this expression

# apply this expression to the text
while($t=~ /$q/g) { # /g in scalar context (look it up)
push @quotes, [$1, $2]; # save found quote on array
} # quote in $1, source in $2
}

print "total: " . scalar @quotes . " quotes found\n";

for my $q (@quotes) { # now show what quotes we found
print_nice($q->[0], $q->[1]) # and format them however you want
}
# thats it

# we need to provide our special formatting subroutine
sub print_nice {
my($q, $s) = @_; # shift actual arguments into variables
$q =~ s/\s+/ /g; # quote: transfer multiple whitespace to a single space
$q =~ s/<[^>]+>//g; # quote: remove html formatting
$s =~ s/\s+/ /g; # source: same here
$s =~ s/<[^>]+>//g; # source: same here
print "$q" # print quote, followed by ...
. "\n" . '-'x40 ."\n" # new line + 40 x '-' + new line
. "- $s\n\n" # '-' + quote source + double \n
}



Regards

M.
Mirco Wahab
2008-12-30 13:15:39 UTC
Permalink
Post by Mirco Wahab
T.J.McC
Post by Tad J McClellan
Post by Mirco Wahab
while($html =~ /$what/mg) { # note the /m modifier
Note that the /m modifier does absolutely nothing for the pattern
being used, and so is not needed at all.
sorry for
Post by Mirco Wahab
It prevents the dot from matching across line
boundaries, as you surely know.
providing BS explanations. Seems like I'm getting old
and/or suffer from missing opportunities to practice
Perl Regex enough (as compared to Boost and PHP).


Thanks for your initial correction,

Mirco
George
2009-01-02 09:53:39 UTC
Permalink
Post by Mirco Wahab
Post by Mirco Wahab
T.J.McC
Post by Tad J McClellan
Post by Mirco Wahab
while($html =~ /$what/mg) { # note the /m modifier
Note that the /m modifier does absolutely nothing for the pattern
being used, and so is not needed at all.
sorry for
Post by Mirco Wahab
It prevents the dot from matching across line
boundaries, as you surely know.
providing BS explanations. Seems like I'm getting old
and/or suffer from missing opportunities to practice
Perl Regex enough (as compared to Boost and PHP).
Thanks for your initial correction,
Mirco
You might note that the camel text prefers to define the area as pattern
matching.

It's been fun doing the web scrape for Minnesota's next junior senator.

[minnesota stuff] ... and Carl, who knew I needed you at home? A happy
new year to you and your sexy bride.
--
George

The terrorists and their supporters declared war on the United States - and
war is what they got.
George W. Bush

Picture of the Day http://apod.nasa.gov/apod/
George
2008-12-31 00:36:23 UTC
Permalink
On Tue, 30 Dec 2008 12:17:44 +0100, Mirco Wahab wrote:


[snipped and reordered, for thematic reasons]
Post by George
use strict;
use warnings;
use LWP::Simple;
# load the complete content of the url in question
# via LWP::Simple::get(...)
my $t = get 'http://www.alfrankensense.com/al_franken_quotes.html';
# inspect the web site and look at what "marker"
# <center>Al Franken Quotes</center>
if($t =~ /<center>Al Franken Quotes<\/center>/g) { # the inner / is ecscaped
# then we write a quick & dirty regular expression
# to map on the quote (look in the html for hints)
my $q = qr{ \t # the quote is always preceeded by a tab
"([^"]+)" # find ", save all (saved to $1), to another "
.+? # fine, now look up a '-' followed by whitespace
\-\s+ # which comes here (escaped -) ..
([^<]+) # this has to be the quote source until next html tag
}sx; # the /s lets the .(dot) match across lines
# the /x allows us to format and comment this expression
# apply this expression to the text
while($t=~ /$q/g) { # /g in scalar context (look it up)
} # quote in $1, source in $2
}
print_nice($q->[0], $q->[1]) # and format them however you want
}
# thats it
# we need to provide our special formatting subroutine
sub print_nice {
$q =~ s/\s+/ /g; # quote: transfer multiple whitespace to a single space
$q =~ s/<[^>]+>//g; # quote: remove html formatting
$s =~ s/\s+/ /g; # source: same here
$s =~ s/<[^>]+>//g; # source: same here
print "$q" # print quote, followed by ...
. "\n" . '-'x40 ."\n" # new line + 40 x '-' + new line
. "- $s\n\n" # '-' + quote source + double \n
}
We're getting real close here.

use strict;
use warnings;
use LWP::Simple;

# load the complete content of the url in question
# via LWP::Simple::get(...)
my $t = get 'http://www.alfrankensense.com/al_franken_quotes.html';

# inspect the web site and look at what "marker"
# your stuff usually starts, in your case - it's the tag:
# <center>Al Franken Quotes</center>

my @quotes; # array, where the quotes are to be collected

# *If* we got there:
if($t =~ /<center>Al Franken Quotes<\/center>/g) { # the inner / is
ecscaped
# then we write a quick & dirty regular expression
# to map on the quote (look in the html for hints)
my $q = qr{ \t # the quote is always preceeded by a tab
"([^"]+)" # find ", save all (saved to $1), to another "
.+? # fine, now look up a '-' followed by
whitespace
\-\s+ # which comes here (escaped -) ..
([^<]+) # this has to be the quote source until next
html tag
}sx; # the /s lets the .(dot) match across lines
# the /x allows us to format and comment this
expression

# apply this expression to the text
while($t=~ /$q/g) { # /g in scalar context (look it up)
push @quotes, [$1, $2]; # save found quote on array
} # quote in $1, source in $2
}

print "total: " . scalar @quotes . " quotes found\n";

for my $q (@quotes) { # now show what quotes we found
print_nice($q->[0], $q->[1]) # and format them however you want
}
# thats it

# we need to provide our special formatting subroutine
sub print_nice {
my($q, $s) = @_; # shift actual arguments into variables
$q =~ s/\s+/ /g; # quote: transfer multiple whitespace to a single
space
$q =~ s/<[^>]+>//g; # quote: remove html formatting
$s =~ s/\s+/ /g; # source: same here
$s =~ s/<[^>]+>//g; # source: same here
print "$q" # print quote, followed by ...
. "\n" # new line
. "~~ $s\n" # '-' + quote source + double \n
. "% \n" # a percentage sign between quotes
}



# perl wahab7.pl >\Program Files\40tude Dialog\sigs\frank1.txt
# perl wahab7.pl >frank1.txt

The output is really close. I can't see any difference between the format
of the two following files

%
A dictatorship would be a heck of a lot easier, there's no question about
it.
George W. Bush
%
After the chaos and carnage of September 11th, it is not enough to serve
our enemies with legal papers.
George W. Bush
%
America is a friend to the people of Iraq. Our demands are directed only at
the regime that enslaves them and threatens us. When these demands are met,
the first and greatest benefit will come to Iraqi men, women and children.
George W. Bush
%
America is a Nation with a mission - and that mission comes from our most
basic beliefs. We have no desire to dominate, no ambitions of empire. Our
aim is a democratic peace - a peace founded upon the dignity and rights of
every man and woman.
George W. Bush

and

%
The biases the media has are much bigger than conservative or liberal.
They're about getting ratings, about making money, about doing stories that
are easy to cover.
~~ Al Franken,
%
[G. W. Bush's] pro-air pollution Clear Skies Initiative is designed to
clear the skies of birds.
~~ Al Franken,
%
And just like in 1984, where the enemy is switched from Eurasia to
Eastasia, Bush switched our enemy from al Qaeda to Iraq. Bush's War on
Terror is a war against whomever Bush wants to be at war with.
~~ Al Franken,
%
Mistakes are a part of being human. Appreciate your mistakes for what they
are: precious life lessons that can only be learned the hard way. Unless
it's a fatal mistake, which, at least, others can learn from.
~~ Al Franken,
%

, but right now, dialog doesn't think that these quotes are delimited by a
percentage sign. Also, we need to remove the commas after Al Franken, when
inappropriate. I think I can manage that tonight.

$s =~ s/\s+/ /g; # source: same here
$s =~ s/<[^>]+>//g; # source: same here

I don't understand what these statements do.
Post by George
I looked into your html source and conceived something
that does the job somehow. Please try to learn some
http://oreilly.com/catalog/9781565922570/
Thanks for your response, M., I'll read up tonight.
--
George

The terrorists and their supporters declared war on the United States - and
war is what they got.
George W. Bush

Picture of the Day http://apod.nasa.gov/apod/
Mirco Wahab
2008-12-31 00:58:05 UTC
Permalink
Post by George
[snipped and reordered, for thematic reasons]
Post by Mirco Wahab
if($t =~ /<center>Al Franken Quotes<\/center>/g) { # the inner / is ecscaped
# then we write a quick & dirty regular expression
# to map on the quote (look in the html for hints)
my $q = qr{ \t # the quote is always preceeded by a tab
"([^"]+)" # find ", save all (saved to $1), to another "
.+? # fine, now look up a '-' followed by whitespace
\-\s+ # which comes here (escaped -) ..
([^<]+) # this has to be the quote source until next html tag
}sx; # the /s lets the .(dot) match across lines
# the /x allows us to format and comment this expression
BTW, there is an error in above expression. Replace everything
from
my $q {
...
to
}sx

by this slight modification:

my $q = qr{ \t # the quote is always preceeded by a tab
"([^"]+)" # find ", save all (saved to $1), to another "
.+? # fine, now look up a '-' followed by whitespace
\-\s+ # which comes here (escaped -) ..
(.+?) # this has to be the quote source ($2) until
</b> # <== the terminal html (closing) tag which is a </b>
}sx; # the /s lets the .(dot) match across lines
# the /x allows us to format and comment this expression

The alfranken-page has sometimes html within he quote source,
the <== part of the expression makes the difference.
(The stray commas will be gone too, this was the reason.)

...
Post by George
We're getting real close here.
...
sub print_nice {
$q =~ s/\s+/ /g; # quote: transfer multiple whitespace to a single
$q =~ s/<[^>]+>//g; # quote: remove html formatting
$s =~ s/\s+/ /g; # source: same here
$s =~ s/<[^>]+>//g; # source: same here
print "$q" # print quote, followed by ...
. "\n" # new line
. "~~ $s\n" # '-' + quote source + double \n
. "% \n" # a percentage sign between quotes
}
...
but right now, dialog doesn't think that these quotes are delimited by a
percentage sign. Also, we need to remove the commas after Al Franken, when
inappropriate. I think I can manage that tonight.
OK, your quotes should probably *start* with the %, so replace
the print_nice by this one:

sub print_nice {
my($q, $s) = @_; # shift actual arguments into variables
$q =~ s/\s+/ /g; # quote: transfer multiple whitespace to a single
$q =~ s/<[^>]+>//g; # quote: remove html formatting
$s =~ s/\s+/ /g; # source: same here
$s =~ s/<[^>]+>//g; # source: same here
print "%\n$q\n" # print $, newline, quote, newline
. "~~ $s\n" # '~~' + quote source + \n
}

Furthermore, "remove" the line (further above)
# print "total: " . scalar @quotes . " quotes found\n";
by commenting out with '#'.
Post by George
$s =~ s/\s+/ /g; # source: same here
$s =~ s/<[^>]+>//g; # source: same here
I don't understand what these statements do.
This is (line one) substitution (s/) of any count
of successive whitespace (\s+) by a single space ' '
and (second line) substitution of a html tag of
any kind like <stuff within brackets> by 'emptiness'.

See: http://www.anaesthetist.com/mnm/perl/Findex.htm#regex.htm

Regards

M.
Tad J McClellan
2008-12-30 14:51:16 UTC
Permalink
Post by George
Post by Tad J McClellan
Post by Mirco Wahab
Post by George
distributed memory
I expect you really meant "phrases" rather than "words" there?

That is, you want to match when "memory" follows "distributed",
with some whitespace in between?
Post by George
Post by Tad J McClellan
Post by Mirco Wahab
my $what = qr'distributed.*?memory|Numerid.*?Ried|OpenMP';
Should instead be:

my $what = qr'distributed\s+memory|Numerid\s+Ried|OpenMP';

Now you will need neither m//m nor m//s...

Note that this will NOT match if the page instead contains

distributed&nbsp;memory
or
distributed<br>memory

etc ...
Post by George
Post by Tad J McClellan
Post by Mirco Wahab
while($html =~ /$what/mg) { # note the /m modifier
Note that the /m modifier does absolutely nothing for the pattern
being used, and so is not needed at all.
You probably meant the /s modifier instead?
m//m modifies the meaning of the "^" and "$" anchors. It is useless
on patterns that do not make use of those anchors.

m//s modifies the meaning of ".". It is useless on patterns that
do not make use of the dot metacharacter (like in the amended
pattern above).
Post by George
my $url = 'www.alfrankensense.com/al_franken_quotes.html';
This is the page that I want to work on.
Getting this deep into a thread before the subject of the article
correlates with the Subject of the article is plain silly.

Please exercise more care in choosing the contents of your Subject header.
--
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"
Frank
2008-12-31 07:37:09 UTC
Permalink
Post by Tad J McClellan
Now you will need neither m//m nor m//s...
Tonight's reading in the camel book might be the best place to start with
regex's. It's chapter 5, and the camel book prefers to call the topic
"patterns."

So \ | ( ) [ { ^ $ * + ? . are the miscreants.

Not also ] / } /?
Post by Tad J McClellan
Post by George
Post by Mirco Wahab
while($html =~ /$what/mg) { # note the /m modifier
Pattern modifiers is where you get traction on this.

pg 147 :

The m//,s///, and qr// operators all accept the following modifers after
their final delimiter:

/i
/s
/m
/x
/o


# end excerpt

There's a lot of ways to get the m's and the s's backwards there.
Post by Tad J McClellan
m//m modifies the meaning of the "^" and "$" anchors. It is useless
on patterns that do not make use of those anchors.
Let ^ and $ match next imbedded \n.
Post by Tad J McClellan
m//s modifies the meaning of ".". It is useless on patterns that
do not make use of the dot metacharacter (like in the amended
pattern above).
Let . match newline and ignore $* .
Post by Tad J McClellan
Post by George
my $url = 'www.alfrankensense.com/al_franken_quotes.html';
This is the page that I want to work on.
Getting this deep into a thread before the subject of the article
correlates with the Subject of the article is plain silly.
Please exercise more care in choosing the contents of your Subject header.
I didn't know the url existed before yesterday. I disagree with your
opinion about the subject, and, as OP, think myself relevant.

Any ideas why this sig goes wild?
--
Frank

The biases the media has are much bigger than conservative or liberal.
They're about getting ratings, about making money, about doing stories that
are easy to cover.
~~ Al Franken,
%
[G. W. Bush's] pro-air pollution Clear Skies Initiative is designed to
clear the skies of birds.
~~ Al Franken,
%
And just like in 1984, where the enemy is switched from Eurasia to
Eastasia, Bush switched our enemy from al Qaeda to Iraq. Bush's War on
Terror is a war against whomever Bush wants to be at war with.
~~ Al Franken,
%
Mistakes are a part of being human. Appreciate your mistakes for what they
are: precious life lessons that can only be learned the hard way. Unless
it's a fatal mistake, which, at least, others can learn from.
~~ Al Franken,
%
In many ways I'm still a Hubert Humphrey Democrat -- someone who believes
in afflicting the comfortable and comforting the afflicted. A society is
judged by how it treats the elderly, the sick, the impoverished. To me it's
a matter of ethics and compassion.
~~ Al Franken, Playboy interview
%
When you encounter seemingly good advice that contradicts other seemingly
good advice, ignore them both.
~~ Al Franken,
%
And by the way, a few months ago, I trademarked the word 'funny.' So when
Fox calls me 'unfunny,' they're violating my trademark. I am seriously
considering a countersuit.
~~ Al Franken, in response to Fox's copyright infringement lawsuit
%
The irony upon irony of this lawsuit was great. First, Fox having the
trademark 'fair and balanced' -- a network which is anything but fair and
balanced. Then there's the irony of a news organization trying to suppress
free speech.
~~ Al Franken, CNN interview
%
[Roger Ailes, Fox News Founder, Chairman and CEO, and former
Nixon-Reagan-Bush strategist, is] a cynical Republican ideologue with no
regard for fairness and balance.
~~ Al Franken,
%
I once asked the most fabulous couple I know, Madonna and Guy Ritchie, how
they kept things fresh despite having been married for almost seven months.
'It's a job, Al,' Guy told me. 'We work at it every day.'
~~ Al Franken,
%
A brief digression on whether that suspicious-looking mole is actually
cancer. ... Take this simple test called the ABC test. 'A' is for age. What
is your age? Is it over thirteen? If so, it's cancer. That's how the ABC
test works.
~~ Al Franken,
%
[Newt Gingrich] is the most unpopular politician in America. His favorable
rating is only four points higher than the Unabomber.
~~ Al Franken, 1996
%
I said that Sean Hannity took residence up Newt Gingrich's butt from 94 to
98. I got that from British intelligence. It turns out he only took up
residence in 95.
~~ Al Franken
%
I do personal attacks only on people who specialize in personal attacks..
~~ Al Franken, Playboy interview
%
There's no liberal echo chamber in this country. There's a right-wing echo
chamber. I want to create a countervailing echo chamber.
~~ Al Franken, Chicago Tribune interview, on
%
I think some people hold [G.W.Bush] in high esteem because they watch Fox.
And they get their news from Rush Limbaugh. And they are fooled.
~~ Al Franken, in response to the 2004 SOTU address
%
No Child Left Behind is the most ironically named act, piece of legislation
since the 1942 Japanese Family Leave Act.
~~ Al Franken, in response to the 2004 SOTU address
%
I think if you're going to do a movie about Reagan you do it about the fact
that he created the huge deficit, that he armed the mujahadeen, that he
armed Saddam, that he armed Iran, he armed 2/3s of the Axis of Evil, he
funded terrorists in Central America, he was in my mind a terrible
president.
~~ Al Franken, Book TV, on CBS's Reagan movie
%
During the Reagan Administration, Bob Dole was present at a ceremony that
included each living ex-president. Looking at a tableau of Ford, Carter and
Nixon, Dole said, 'There they are: Hear No Evil, See No Evil and Evil.'
~~ Al Franken,
%
If you put the two Bushs together in their over seven years of their two
presidencies, not one new job has been created. Numbers do not lie. If you
extrapolated from that, if the Bushs had run this country from its very
beginning to the current time, not one American would have ever worked.
We'd be hunter-gatherers.
~~ Al Franken, in response to the 2004 SOTU address
%
Most of us here in the media are what I call infotainers...Rush Limbaugh is
what I call a disinfotainer. He entertains by spreading disinformation.
~~ Al Franken
%
Drug war, well, as Rush Limbaugh said, anyone who uses drugs illegally
should be prosecuted and put away. I don't agree with him; I think they
should be treated, but that's what Rush believes and so, you know, we're
praying for Rush because he's in recovery and you take responsibilities for
your actions so I'm sure any day now Rush will demand to be put away for
the maximum sentence and ask for the most dangerous prison and we'll be
praying for maybe an African American cellmate who saw the Donovan McNabb
comments on ESPN. So we're prayin'.
~~ Al Franken, Book TV, on Rush Limbaugh's illegal drug arrest and racist
remarks
%
If [Stuart Saves His Family] had actually been successful it would have
been a lot better teacher for me than the failure that it was, because it
would have given me the opportunity to do more movies,
~~ Al Franken, CNN interview
%
It's the Power of the Almighty, the Splendor of Nature, and then you.
~~ Al Franken
%
A concussion.
~~ Al Franken, Playboy interview, when asked what it would take for his
name to appear on the masthead of National Review or The Weekly Standard.
%
Oh, What Doesn't Kill You Can Have Lingering Aftereffects!
~~ Al Franken,
%
That's just stinkin' thinkin!
~~ Al Franken,
%
Listen to me. I'm should-ing all over myself.
~~ Al Franken
%
Whining is anger through a small opening.
~~ Al Franken
%
I'm good enough, I'm smart enough, and doggone it, people like me.
~~ Al Franken
%
I'm going to die homeless, penniless, and 30 pounds overweight.
~~ Al Franken
%
It's easier to put on slippers than to carpet the whole world.
~~ Al Franken
%
I would never ordinally say this, but... is there any way you can get to a
pound cake?
~~ Al Franken
%
I'm a perfectionist and if I start making changes, I'll never stop.
~~ Al Franken
%
My father grew up in the Great Depression - his mother's.
~~ Al Franken
%
...it's obviously how his disease manifests itself, any kind of substance
dependency is very deep, issues of self esteem, you can just tell that he's
a really insecure and vulnerable person -- and I love him. You know,
sometimes I listen to him on the radio, and he's very judgmental, he's a
very angry person, and I just want to remind him that anytime you have a
finger pointing at someone else, there's three pointing back at you.
~~ Al Franken
%



Picture of the Day http://apod.nasa.gov/apod/
Tad J McClellan
2008-12-31 08:01:08 UTC
Permalink
Post by Frank
Tonight's reading in the camel book might be the best place to start with
regex's. It's chapter 5, and the camel book prefers to call the topic
"patterns."
Probably because they no longer meet the definition of being "regular".
Post by Frank
So \ | ( ) [ { ^ $ * + ? . are the miscreants.
Not also ] / } /?
] and } don't become meta until they appear after their
corresponding opening char.

I am always thrilled whenever I need to match square bracket chars
because then I can write:

/[][]/; # which are meta and which are literal?


slash is not special in patterns, though it is often
special with the pattern match *operator*.

You can choose to use some delimiter other than /, then that
other character becomes meta (to the operator, not to patterns).

/\/etc\/passwd/; # leaning toothpick syndrome

can also be written:

m#/etc/passwd#;

to keep your eyes from crossing...


I don't know what you mean by the fourth one, "/?"...
Post by Frank
Post by Tad J McClellan
Post by George
Post by Mirco Wahab
while($html =~ /$what/mg) { # note the /m modifier
Pattern modifiers is where you get traction on this.
The m//,s///, and qr// operators all accept the following modifers after
/i
/s
/m
/x
/o
Wa' happened to /g ?

I like to use Damian Conway's mnemonic: gym sox (gim sox).
Post by Frank
Post by Tad J McClellan
m//m modifies the meaning of the "^" and "$" anchors. It is useless
on patterns that do not make use of those anchors.
Let ^ and $ match next imbedded \n.
No, that is not correct.

Anchors are "zero width", they do not match _any_ characters (they
match positions instead).

^ and $ normally mean "match at begining/end of string".

with m//m, ^ and $ mean "match at begining/end of line".
Post by Frank
Post by Tad J McClellan
Post by George
my $url = 'www.alfrankensense.com/al_franken_quotes.html';
This is the page that I want to work on.
Getting this deep into a thread before the subject of the article
correlates with the Subject of the article is plain silly.
Please exercise more care in choosing the contents of your Subject header.
I didn't know the url existed before yesterday. I disagree with your
opinion about the subject,
Then what did "franken" mean when you wrote it?
Post by Frank
and, as OP, think myself relevant.
You are not the OP.

You are Frank.

The OP was George.
--
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"
Tim Greer
2008-12-31 08:13:07 UTC
Permalink
Post by Tad J McClellan
You are not the OP.
You are Frank.
The OP was George.
He expects you to keep up with his posting personalities, I guess?
--
Tim Greer, CEO/Founder/CTO, BurlyHost.com, Inc.
Shared Hosting, Reseller Hosting, Dedicated & Semi-Dedicated servers
and Custom Hosting. 24/7 support, 30 day guarantee, secure servers.
Industry's most experienced staff! -- Web Hosting With Muscle!
John W. Krahn
2008-12-31 08:33:04 UTC
Permalink
Post by Tad J McClellan
Post by Frank
Post by Mirco Wahab
while($html =~ /$what/mg) { # note the /m modifier
Pattern modifiers is where you get traction on this.
The m//,s///, and qr// operators all accept the following modifers after
/i
/s
/m
/x
/o
Wa' happened to /g ?
You can't use /g with qr//.



John
--
Those people who think they know everything are a great
annoyance to those of us who do. -- Isaac Asimov
Jürgen Exner
2008-12-31 09:35:05 UTC
Permalink
Post by Tad J McClellan
Then what did "franken" mean when you wrote it?
Some possibilities:
- the former currency of France, Belgium, Luxembourg, ... (in German)
- the currency of Switzerland (in German)
- the northern part of Bavaria
- the inhabitants of said part of Bavaria
- the people of the Carolingian Empire (called Fränkisches Reich in
German, most famous ruler Carolus Magnus)
- the duchy of Franken
- ....

jue
George
2009-01-01 01:06:37 UTC
Permalink
Post by Jürgen Exner
Post by Tad J McClellan
Then what did "franken" mean when you wrote it?
- the former currency of France, Belgium, Luxembourg, ... (in German)
- the currency of Switzerland (in German)
- the northern part of Bavaria
- the inhabitants of said part of Bavaria
- the people of the Carolingian Empire (called Fränkisches Reich in
German, most famous ruler Carolus Magnus)
- the duchy of Franken
- ....
jue
You're from right around there, maybe a scoch north. Because you've
written so much on usenet and our experience overlaps somewhat, I seem to
have read quite a bit about you including sailing in the first appropriate
body of water north of Franken.

They wouldn't let us go near the water, but one fine night in Hamburg,
Mister Minit took us to a sub sunk in the Nordsee.

The crescent moon rests above Venus. 3.3 hands right on the ecliptic is
Jupiter, and Mercury rides 2 fingers to his left and parallel on the
horizon. It may have been the prettiest day all year, and it is the last.

Tomorrow, Mercury will rise above Jupiter.
--
George

I am mindful not only of preserving executive powers for myself, but for
predecessors as well.
George W. Bush

Picture of the Day http://apod.nasa.gov/apod/
George
2008-12-29 22:37:19 UTC
Permalink
Post by Mirco Wahab
There is a module called LWP::Simple
http://search.cpan.org/~gaas/libwww-perl-5.822/lib/LWP/Simple.pm
...
use LWP::Simple;
my $url = 'www.co-array.org';
my $html = get 'http://' . $url;
my $what = qr'distributed.*?memory|Numerid.*?Ried|OpenMP';
while($html =~ /$what/mg) { # note the /m modifier
print '...' . substr($html, pos($html)-20, 40) . "...\n"
}
...
If you need to pass headers and cookies to the
site, please study the other libwww functions
(http://search.cpan.org/~gaas/libwww-perl-5.822/lib/Net/HTTP.pm)
# shebang doesn't work on windows

use strict;
use warnings;

use Net::HTTP;
use LWP::Simple;

my $url = 'www.co-array.org';
my $html = get 'http://' . $url;

my $what = qr'distributed.*?memory|Numerid.*?Ried|OpenMP';

while($html =~ /$what/mg) { # note the /m modifier
print '...' . substr($html, pos($html)-20, 40) . "...\n"
}

my $s = Net::HTTP->new(Host => "www.co-array.org") || die $@;
$s->write_request(GET => "/", 'User-Agent' => "Mozilla/5.0");
my($code, $mess, %h) = $s->read_response_headers;

while (1) {
my $buf;
my $n = $s->read_entity_body($buf, 1024);
die "read failed: $!" unless defined $n;
last unless $n;
print $buf;
}


# perl wahab3.pl

# end script begin abridged output

C:\MinGW\source>perl wahab3.pl
...n distributed memory machines but also o...
...ranslate into OpenMP Fortran</A>
...
...ay Fortran to OpenMP Fortran translator<...
...uivalent SPMD OpenMP Fortran 90/95 progr...
...w.openmp.org">OpenMP Fortran</A> compile...
...tectures
than OpenMP Fortran, programs s...
...anslated into OpenMP as part of the comp...
...ntrinsics for OpenMP is bundled with the...
...anslates into OpenMP Fortran.
<L...
...mp99.ps">SPMD OpenMP vs MPI for Ocean Mo...
...y Fortran and OpenMP Fortran for SPMD Pr...
<HTML>
<HEAD>
<TITLE>Co-Array Fortran</TITLE>
<LINK REL="shortcut icon" HREF="favicon.ico" />
</HEAD>

<BODY BACKGROUND="" BGCOLOR="#ffff99" TEXT="#000000" LINK="#0000ff"
VLINK="#8000
00" ALINK="#ff0000">

<HR WIDTH="30%" ALIGN=CENTER>
<CENTER><B><H1>Co-Array Fortran</H1></B></CENTER>
<HR WIDTH="30%" ALIGN=CENTER>

<P>
Co-array Fortran is a small extension to
Fortran 95.

# end abridged output

Wow, Mirco, with a little guidance, a person can go from square one to
cruising speed *so quickly*. I think this gives me the tools I need to
move my token forward. Thanks so much.
Post by Mirco Wahab
or copy/paste the complete http query from your browser
and send it via IO::Socket::INET.
Regards
M.
Do you mean that I would use the mouse or imitate the events?
--
George

Great tragedy has come to us, and we are meeting it with the best that is
in our country, with courage and concern for others because this is
America. This is who we are.
George W. Bush

Picture of the Day http://apod.nasa.gov/apod/
s***@netherlands.com
2008-12-29 23:18:23 UTC
Permalink
Post by George
Post by Mirco Wahab
There is a module called LWP::Simple
http://search.cpan.org/~gaas/libwww-perl-5.822/lib/LWP/Simple.pm
...
use LWP::Simple;
my $url = 'www.co-array.org';
my $html = get 'http://' . $url;
my $what = qr'distributed.*?memory|Numerid.*?Ried|OpenMP';
while($html =~ /$what/mg) { # note the /m modifier
print '...' . substr($html, pos($html)-20, 40) . "...\n"
}
...
If you need to pass headers and cookies to the
site, please study the other libwww functions
(http://search.cpan.org/~gaas/libwww-perl-5.822/lib/Net/HTTP.pm)
# shebang doesn't work on windows
use strict;
use warnings;
use Net::HTTP;
use LWP::Simple;
my $url = 'www.co-array.org';
my $html = get 'http://' . $url;
my $what = qr'distributed.*?memory|Numerid.*?Ried|OpenMP';
while($html =~ /$what/mg) { # note the /m modifier
print '...' . substr($html, pos($html)-20, 40) . "...\n"
}
$s->write_request(GET => "/", 'User-Agent' => "Mozilla/5.0");
my($code, $mess, %h) = $s->read_response_headers;
while (1) {
my $buf;
my $n = $s->read_entity_body($buf, 1024);
die "read failed: $!" unless defined $n;
last unless $n;
print $buf;
}
# perl wahab3.pl
# end script begin abridged output
C:\MinGW\source>perl wahab3.pl
...n distributed memory machines but also o...
...ranslate into OpenMP Fortran</A>
...
...ay Fortran to OpenMP Fortran translator<...
...uivalent SPMD OpenMP Fortran 90/95 progr...
...w.openmp.org">OpenMP Fortran</A> compile...
...tectures
than OpenMP Fortran, programs s...
...anslated into OpenMP as part of the comp...
...ntrinsics for OpenMP is bundled with the...
...anslates into OpenMP Fortran.
<L...
...mp99.ps">SPMD OpenMP vs MPI for Ocean Mo...
...y Fortran and OpenMP Fortran for SPMD Pr...
<HTML>
<HEAD>
<TITLE>Co-Array Fortran</TITLE>
<LINK REL="shortcut icon" HREF="favicon.ico" />
</HEAD>
<BODY BACKGROUND="" BGCOLOR="#ffff99" TEXT="#000000" LINK="#0000ff"
VLINK="#8000
00" ALINK="#ff0000">
<HR WIDTH="30%" ALIGN=CENTER>
<CENTER><B><H1>Co-Array Fortran</H1></B></CENTER>
<HR WIDTH="30%" ALIGN=CENTER>
<P>
Co-array Fortran is a small extension to
Fortran 95.
# end abridged output
Wow, Mirco, with a little guidance, a person can go from square one to
cruising speed *so quickly*. I think this gives me the tools I need to
move my token forward. Thanks so much.
Post by Mirco Wahab
or copy/paste the complete http query from your browser
and send it via IO::Socket::INET.
Regards
M.
Do you mean that I would use the mouse or imitate the events?
This is no more than grabbing html and searching for patterns using
regexp withing it. The result is not something neither reliable nor
formattable. You will still have to parse it before searches.
No parsing, no reliable content. Its still a mixed bag of junk.

sln
George
2008-12-30 05:44:51 UTC
Permalink
Post by s***@netherlands.com
This is no more than grabbing html and searching for patterns using
regexp withing it. The result is not something neither reliable nor
formattable. You will still have to parse it before searches.
No parsing, no reliable content. Its still a mixed bag of junk.
I tried to address this issue with the following:

# shebang doesn't work on windows

use strict;
use warnings;
use LWP::Simple;
use HTML::Parser;
use HTML::FormatText;
my ($html, $ascii);
$html = get("http://www.co-array.com/");
defined $html
or die "Can't fetch HTML from http://www.perl.com/";
$ascii = HTML::FormatText->new->format(parse_html($html));
print $ascii;




# perl wahab4.pl

This yields:


C:\MinGW\source>perl wahab4.pl
Can't locate HTML/FormatText.pm in @INC (@INC contains: C:/Perl/site/lib
C:/Perl
/lib .) at wahab4.pl line 7.
BEGIN failed--compilation aborted at wahab4.pl line 7.

C:\MinGW\source>

Unfortunately, I get no matches when I search for Format in the PPM for
activestate, which sounds unlikely but clearly indicates that I'm over my
head.
--
George

This way of life is worth defending.
George W. Bush

Picture of the Day http://apod.nasa.gov/apod/
Randal L. Schwartz
2008-12-29 11:11:14 UTC
Permalink
George> I would like to test whether

George> http://www.co-array.org/

George> contains the following words:

George> distributed memory
George> Numerid Ried
George> OpenMP

Go to google. Enter:

site:co-array.org ("distributed memory" OR "Numerid Ried" OR OpenMP)

and see the results.

This is not a Perl problem.
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<***@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
See http://methodsandmessages.vox.com/ for Smalltalk and Seaside discussion
George
2008-12-29 21:37:48 UTC
Permalink
Post by Randal L. Schwartz
George> I would like to test whether
George> http://www.co-array.org/
George> distributed memory
George> Numerid Ried
George> OpenMP
site:co-array.org ("distributed memory" OR "Numerid Ried" OR OpenMP)
and see the results.
This is not a Perl problem.
Thanks all for replies. It looks like I have some reading to do.

I'm stipulating that this is something I would like to work up in perl, not
that perl is the only means to get it done. I think it could save a hell
of a lot of keystrokes and mouse clicks.

I've got the page open in a browser and have read it, and I think it makes
a good guinea pig for the task.

I did try what you suggest above. Was I to paste in the above where I
would otherwise do a keyword search?
--
George

Leadership to me means duty, honor, country. It means character, and it
means listening from time to time.
George W. Bush

Picture of the Day http://apod.nasa.gov/apod/
Randal L. Schwartz
2008-12-29 22:17:26 UTC
Permalink
Post by Randal L. Schwartz
site:co-array.org ("distributed memory" OR "Numerid Ried" OR OpenMP)
George> I did try what you suggest above. Was I to paste in the above where I
George> would otherwise do a keyword search?

Like this:

http://letmegooglethatforyou.com/?q=site%3Aco-array.org+(%22distributed+memory%22+OR+%22Numerid+Ried%22+OR+OpenMP)

Watch and learn.

/me sighs
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<***@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
See http://methodsandmessages.vox.com/ for Smalltalk and Seaside discussion
George
2008-12-29 22:58:29 UTC
Permalink
Post by Randal L. Schwartz
Post by Randal L. Schwartz
site:co-array.org ("distributed memory" OR "Numerid Ried" OR OpenMP)
George> I did try what you suggest above. Was I to paste in the above where I
George> would otherwise do a keyword search?
http://letmegooglethatforyou.com/?q=site%3Aco-array.org+(%22distributed+memory%22+OR+%22Numerid+Ried%22+OR+OpenMP)
Watch and learn.
/me sighs
That's hilarious. I'll use that in my other discussion forums where people
are willfully ignorant of facts.

Loading Image...

It correctly prompts for a respelling of Reid to reflect the person who has
been most identified with making co-arrays part of standard fortran.

Ultimately, it's a google keyword search, and that's not what I'm after.
--
George

Hundreds of thousands of American servicemen and women are deployed across
the world in the war on terror. By bringing hope to the oppressed, and
delivering justice to the violent, they are making America more secure.
George W. Bush

Picture of the Day http://apod.nasa.gov/apod/
s***@netherlands.com
2008-12-29 23:05:19 UTC
Permalink
Post by Randal L. Schwartz
Post by Randal L. Schwartz
site:co-array.org ("distributed memory" OR "Numerid Ried" OR OpenMP)
George> I did try what you suggest above. Was I to paste in the above where I
George> would otherwise do a keyword search?
http://letmegooglethatforyou.com/?q=site%3Aco-array.org+(%22distributed+memory%22+OR+%22Numerid+Ried%22+OR+OpenMP)
Watch and learn.
/me sighs
"Enable javascript to use LMGTFY."

Doesen't work.

sln
Jürgen Exner
2008-12-29 12:33:14 UTC
Permalink
George <***@example.invalid> wrote:
["searching for franken"]

You can find Franken in the northern part of Bavaria.
Post by George
I would like to test whether
http://www.co-array.org/
distributed memory
Numerid Ried
OpenMP
To check if A is an anagram of B you would treat both strings as
multi-sets of characters and check if they are equal.
To check for "contains" simply check for subset instead of equality.

jue
Tad J McClellan
2008-12-29 14:20:43 UTC
Permalink
Post by George
I've written perl programs now for about a year and a half, and they have
usually focused on usenet. In some sense, this one does as well, in that
I'm developing material for my next 'nym shift, but the input from this is
the internet instead, probably an url.
Errr, usenet is on the "internet" too.

I expect that you meant that the input is to be from a WWW page.
Post by George
I've never used perl to do this before, so I don't know where to start,
Start with the Perl Frequently Asked Questions.

Since you are interested in getting an HTML page:

perldoc -q HTML

might hand you the answer in response to this FAQ:

How do I fetch an HTML file?
Post by George
I would like to test whether
http://www.co-array.org/
distributed memory
Numerid Ried
OpenMP
--------------------
#!/usr/bin/perl
use warnings;
use strict;
use LWP::Simple;

$_ = get 'http://www.co-array.org/';

print "yes\n" if /distributed/ and /memory/
and /Numerid/ and /Ried/ and /OpenMP/;
--------------------
--
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"
Continue reading on narkive:
Loading...