[24205] in Perl-Users-Digest
Perl-Users Digest, Issue: 6397 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Apr 13 18:05:49 2004
Date: Tue, 13 Apr 2004 15:05:08 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Tue, 13 Apr 2004 Volume: 10 Number: 6397
Today's topics:
Re: 3x3 simple puzzle ctcgag@hotmail.com
Re: 3x3 simple puzzle <perl@my-header.org>
a socket example in perl (bad_knee)
Re: a socket example in perl <tony_curtis32@_SPAMTRAP_yahoo.com>
Re: a socket example in perl <spamtrap@dot-app.org>
Re: die-ing within functions ctcgag@hotmail.com
Re: die-ing within functions <spamtrap@dot-app.org>
Re: die-ing within functions <tadmc@augustmail.com>
foreach loop test <robin @ infusedlight.net>
Re: foreach loop test <perl@my-header.org>
Hey, Corporate America! Show Taxpayers Some Appreciatio susie@votenader.org
Hey, Corporate America! Show Taxpayers Some Appreciatio genevieve@votenader.org
Re: need to find word, and comment out next 5 lines <tadmc@augustmail.com>
OT: Re: Writing to STDIN <1usa@llenroc.ude>
Re: the code for bbs 3 <kirk@strauser.com>
Re: Tough (for me) regex case <rob_perkins@hotmail.com>
Re: Tough (for me) regex case <rob_perkins@hotmail.com>
Re: Why are arrays and hashes this way? ctcgag@hotmail.com
why does this not work <lkirsh@cs.ubc.ca>
Re: why does this not work <trammell+usenet@hypersloth.invalid>
Re: why does this not work <postmaster@castleamber.com>
Re: why does this not work <lkirsh@cs.ubc.ca>
Re: why does this not work <1usa@llenroc.ude>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 13 Apr 2004 18:58:07 GMT
From: ctcgag@hotmail.com
Subject: Re: 3x3 simple puzzle
Message-Id: <20040413145807.814$4q@newsreader.com>
Matija Papec <perl@my-header.org> wrote:
> Ok, there are two solutions for these turtles,
> http://globalnet.hr/~mpapec/perl/turtles3x3.jpg
> They have to be in 3x3 matrix so that colors and body parts match
> (head/tail).
>
> I wrote a perl script which finds them in 8min (Duron 750mhz); anyone
> interested in some turtle solving?
Do you get to move tiles around, or only rotate them in place?
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
------------------------------
Date: Tue, 13 Apr 2004 22:35:36 +0200
From: Matija Papec <perl@my-header.org>
Subject: Re: 3x3 simple puzzle
Message-Id: <auio70pjeao731d6464ol2nk31n88ch5j0@4ax.com>
X-Ftn-To: ctcgag@hotmail.com
ctcgag@hotmail.com wrote:
>> Ok, there are two solutions for these turtles,
>> http://globalnet.hr/~mpapec/perl/turtles3x3.jpg
>> They have to be in 3x3 matrix so that colors and body parts match
>> (head/tail).
>>
>> I wrote a perl script which finds them in 8min (Duron 750mhz); anyone
>> interested in some turtle solving?
>
>Do you get to move tiles around, or only rotate them in place?
Both. :)
However one can use optimization when rotating so you don't need to get
through all rotating possibilities. This also saves time as you don't have
to check for body parts, only for colors.
So, you can rotate leftmost and rightmost column by 90 deg. ccw, or top and
bottom row by 90 deg. cw.
If you only move them around you'll find only one solution (that's a good
start, I've used perldoc -q permute).
--
Matija
------------------------------
Date: 13 Apr 2004 14:27:15 -0700
From: bl8n8r@yahoo.com (bad_knee)
Subject: a socket example in perl
Message-Id: <e817ca4d.0404131327.5e4ced91@posting.google.com>
This is an example for all the folks new to perl that are
looking for a way to connect to a server and retrieve some
data.
This program will connect to a newserver, download the list
of newsgroups, and then print it to the screen.
Note: You may not want to do this on a dialup connection.
cheers,
bl8n8r
###############################################################################
#!/usr/bin/perl -w
use strict;
use IO::Socket;
#
# server to contact must be first arg from command line
# eg: getnews news.creativelabs.com
#
my $NewsServer = $ARGV[0];
# make sure an argument was given
if (length ($NewsServer) < 1)
{
die ("arg0 == server to connect to. quitting");
}
# the main subroutine returns the list of newsgroups
sub Main()
{
my $buf = "";
my $sock = new IO::Socket::INET (PeerAddr => $NewsServer, PeerPort
=> '119', Proto => 'tcp') || die "$!\n";
my $data = "";
my $bytes = 0;
# connect to news server
print "connecting to $NewsServer\n";
# send list command
$sock->send("list\r\n");
# read list
while (1)
{
# read a chunk of data
$data = "";
$sock->recv ($data, 1024, 0);
$bytes = length ($data);
# append data to buffer
$buf = $buf.$data;
# read until "dot" all by itelf as in RFC0977
# we search for \r\n.\r\n cuz the buffer itself
# may end with a dot in the middle of the listing
if ($data =~ m/\x0d\x0a.\x0d\x0a$/)
{
last;
}
}
# send quit command to server
$sock->send("quit\r\n");
# close socket to server
close($sock);
return ($buf);
}
# print buffer results
print "".Main();
------------------------------
Date: Tue, 13 Apr 2004 16:29:02 -0500
From: Tony Curtis <tony_curtis32@_SPAMTRAP_yahoo.com>
Subject: Re: a socket example in perl
Message-Id: <87oepvsh29.fsf@limey.hpcc.uh.edu>
>> On 13 Apr 2004 14:27:15 -0700,
>> bl8n8r@yahoo.com (bad_knee) said:
> This is an example for all the folks new to perl that are
> looking for a way to connect to a server and retrieve some
> data.
> This program will connect to a newserver, download the list
> of newsgroups, and then print it to the screen.
Net::NNTP would be a lot easier.
hth
t
------------------------------
Date: Tue, 13 Apr 2004 17:40:21 -0400
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: a socket example in perl
Message-Id: <j9GdnY4KHdShw-HdRVn-sQ@adelphia.com>
bad_knee wrote:
> This is an example for all the folks new to perl that are
> looking for a way to connect to a server and retrieve some
> data.
Nice of you to post an example of using raw sockets, but it's also worth
mentioning that quite often, the protocol you want to use is already
wrapped up in a nice, simple CPAN module.
> This program will connect to a newserver, download the list
> of newsgroups, and then print it to the screen.
So will this one:
#!/usr/bin/perl
use strict;
use warnings;
use News::NNTPClient;
my $c = new News::NNTPClient('news.example.com');
print $c->list;
sherm--
--
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org
------------------------------
Date: 13 Apr 2004 19:13:53 GMT
From: ctcgag@hotmail.com
Subject: Re: die-ing within functions
Message-Id: <20040413151353.177$vd@newsreader.com>
"Stevens" <auto87829@hushmail.com> wrote:
> Hi,
>
> I'm looking for some advice on programming style ... is is considered bad
> practice to die within your own functions as opposed to using a bare
> return statement?
If death is the appropriate response, then death is the appropriate
response.
If returning an undef or an empty list is reasonable for the function to do
under some non-error conditions, then it would be very bad form to have it
simply do that under error conditions as well.
It all depends on what the function will be used for.
> What about displaying error messages within perl
> functions, is this frowned (as it tends to be in unix systems
> programming) upon?
Do you anticipate your code being ported to another (human) language
without needing a major re-write for other reasons? If so, then you may
want to abstract the error messages into one place. Otherwise, it's
probably just a pain in the butt to do so.
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
------------------------------
Date: Tue, 13 Apr 2004 17:26:34 -0400
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: die-ing within functions
Message-Id: <_bSdnSwAt7Fix-HdRVn-jg@adelphia.com>
Anno Siegel wrote:
> Now one could argue that Perl has eval(), and hence dying is never truly
> unconditional
That's one down... when's Larry going to get to work on taxes? ;-)
sherm--
--
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org
------------------------------
Date: Tue, 13 Apr 2004 17:50:15 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: die-ing within functions
Message-Id: <slrnc7orl7.9ev.tadmc@magna.augustmail.com>
Sherm Pendley <spamtrap@dot-app.org> wrote:
> Anno Siegel wrote:
>
>> Now one could argue that Perl has eval(), and hence dying is never truly
>> unconditional
>
> That's one down... when's Larry going to get to work on taxes? ;-)
We should just be thankful that we don't get all the government we pay for.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 13 Apr 2004 14:46:23 -0700
From: "Robin" <robin @ infusedlight.net>
Subject: foreach loop test
Message-Id: <c5ho9l$cgt$1@reader2.nmix.net>
foreach (@test)
{
print;
}
for this code, I'd like some way to test if $_ is the last first or middle
of the array without having to use a while loop....any suggestions?
Thanks.
--
Regards,
-Robin
--
robin @ infusedlight.net
------------------------------
Date: Tue, 13 Apr 2004 23:59:20 +0200
From: Matija Papec <perl@my-header.org>
Subject: Re: foreach loop test
Message-Id: <9coo70h48jp0g1dqrcgiodv90e5rhrsa21@4ax.com>
X-Ftn-To: Robin
"Robin" <robin @ infusedlight.net> wrote:
>foreach (@test)
>{
>print;
>}
>
>for this code, I'd like some way to test if $_ is the last first or middle
>of the array without having to use a while loop....any suggestions?
for my $i (0 .. $#test) {
my $element = $test[$i];
print "$i. element is $element\n";
...
}
p.s how would while loop show array index?
--
Matija
------------------------------
Date: Tue, 13 Apr 2004 21:29:04 GMT
From: susie@votenader.org
Subject: Hey, Corporate America! Show Taxpayers Some Appreciation!
Message-Id: <ebdc8bd0.8f2bf2c7@host-69-48-73-244.roc.choiceone.net>
Hey, Corporate America! Show Taxpayers Some Appreciation!
By Ralph Nader
If you work for a corporation, ask your own employer to support
Taxpayer Appreciation Day. (We’ve included contact information at the
end of the article.)
Take Action Now! April 15 is just around the corner. Please let us know
what action you’ve taken and what type of response you receive at
taxday@votenader.org
I'm going to go out on a limb here and suggest that April 15th of each
year be designated Taxpayer Appreciation Day, a day when corporations
receiving taxpayer subsidies, bailouts, and other forms of corporate
welfare can express their thanks to the citizens who provide them.
Though it may not be evident, quite a few industries -- and the profits
they generate -- can be traced back to taxpayer-financed programs whose
fruits have been given away to (mostly) larger businesses.
Taxpayer dollars have often funded discoveries made by NASA, the
Department of Defense, and the National Institutes of Health and other
federal agencies. In many instances the rights to those discoveries were
later given away to companies that brag about them as though they were
the fruits of their own investments. Taxpayer dollars have played a
major role in the growth of the aviation and aerospace, biotechnology,
pharmaceutical, and telecommunications industries -- to name only a few.
Though corporate America insists it must file yearly income taxes just
like everyone else, it is responsible for a sharply decreasing portion
of federal tax dollars -- despite record profits. Despite record
profits, corporate tax contributions to the federal budget have been
steadily declining for fifty years and now stand at a mere 7.4% of the
federal government income because of the loopholes they driven into our
tax laws. The average citizen pays more than four to five times that in
federal income tax revenues (with the single exception of payroll
taxes).
Clearly corporations that believe they are self-reliant are often, in
fact, dependent on taxpayer funds to maintain their financial viability.
The least they could do is thank us. Which is why we need something like
Taxpayer Appreciation Day. Consider the following:
General Electric bought RCA (which owned NBC) in the mid-1980s with
funds it was able to save by using an outrageous tax loophole passed by
Congress in 1981. That loophole allowed GE to pay no federal taxes on
three years of profits, totaling more than $6 billion dollars. It also
gave them a $125 million refund! That gave GE the money to buy RCA. GE
should arrange a media extravaganzas on NBC to say "Thank you,
taxpayers.” Pharmaceutical companies constantly ballyhoo their
discoveries in advertisements. What they don't tell us is that many of
the important nonredundant therapeutic drugs -- including most
anticancer drugs -- were developed, in whole or in part, with taxpayer
money and then given to them by the NIH and the Defense Department.
Bristol-Meyers Squibb, for example, controls the rights to Taxol, an
anticancer drug developed all the way through human clinical trials at
the National Institutes of Health with $31 million of taxpayer moneys.
Pharmaceutical companies spend billions on advertisements each year.
Perhaps they should consider a big "Thank You, Taxpayers" ad campaign
every April 15, if only to remind them where their drug research and
development subsidies come from.
Mining companies often receive vast sweetheart deals from taxpayers.
Under the 1872 Mining Act hard rock mining companies are allowed to
purchase mining rights to public land for only $5 an acre, no matter how
valuable the minerals on (or in) that land might be. A Canadian company
recently mined $9 billion in gold on federal land in Nevada after using
the Mining Act to purchase the mining rights to it for about $30,000.
Mining companies owe the taxpayers their gratitude.
Television broadcasters were given free license to use public airwaves
(worth around $70 billion) by a supine Congress in 1997. They too should
thank us. What about all those professional sports corporations that
play and profit in taxpayer-funded stadiums and arenas? The owners and
players should thank the fans/taxpayers who -- in spite of their largess
-- still must pay through the nose for tickets. For years McDonalds
received taxpayer subsidies to promote its products overseas as part of
a foreign market access program. Now McDonalds is a ubiquitous brand
name worldwide, but has it ever thanked the taxpayers who underwrote its
efforts? Then there are the HMOs, hospitals, and defense contractors
that have had their legal fees reimbursed by the taxpayers when our
government prosecutes them for fraud or cost overruns. Those companies
have great public relations firms that can help them show us their
gratitude. Corporate America has taken too much from us for too long.
It's time it shows us a little bit of appreciation.
Corporate Contacts:
General Electric (NBC):
David Frail
Financial Communications
1--203-373-3387
david.frail@corporate.ge.com
Bristol-Meyers Squibb:
Peter R. Dolan, CEO
345 Park Avenue
New York, New York, USA 10154-0037
1-212-546-4000
peter.dolan@bms.com
Viacom (CBS, MTV, Nickelodeon, VH1, BET, Paramount Pictures, Viacom Outdoor, Infinity, UPN, Spike TV, TV Land, CMT: Country Music Television, Comedy Central, Showtime, Blockbuster, and Simon & Schuster):
Sumner M. Redstone , Chairman and CEO
1515 Broadway
New York, NY 10036
1-212-258-6000
(refused to provide email addresses)
Walt Disney Co. (ABC):
David Eisner, CEO
500 S. Buena Vista Street
Burbank, CA 91521 ABC, Inc.
1-818-460-7477
netaudr@abc.com
McDonalds USA:
Jim Cantalupo, Chairman and CEO
McDonald’s Plaza
Oak Brook, IL 60523
1-800-244-6227
Email on-line form.
Halliburton (Kellogg Brown & Root):
David J. Lesar, Chairman, President & CEO
5 Houston Center
1401 McKinney, Suite 2400
Houston, TX 77010
1-713-759-2600
communityrelations@halliburton.com
In addition to these, pursue your favorite and let us know what they say!
--
by IFCO means Not In Our Name
receives donations that are tax deductible because of IFCO's 501c(3)
(charitable, federal tax-exempt) status. IFCO charges a fee for this
service.
Why is NION not a 501c(3)?
Donations to NION/IFCO are then mailed to the Women's International League
for Peace and Freedom (WILPF), which is located at 339 Lafayette Street in
New York City. The address is the same as NION's. The intimate nature of a
financial partnership shows how closely aligned these two organizations are.
And that's scary, because the Women's International League for Peace and
Freedom has been associated with Communist causes since its inception. Molly
Klopot of the WILPF is a NION organizer. The WILPF is related to IFCO as
well as NION. Marilyn Clement, who is the Executive Director of WIPLF, is
the Treasurer of IFCO.
The building where the offices of NION, the WILPF and the War Resisters
League are located is known as the "Peace Pentagon," and is owned by the
A.J. Muste Memorial Institute. A.J. Muste was a "peace" advocate who
compiled frequent flier miles visiting Hanoi during the Vietnam War era. The
Muste Foundation funds groups like the War Resisters League, School of the
Americas Watch, Nicaragua Solidarity Network, International Peace bureau,
International Fellowship of Reconciliation, Coalition for Human Rights of
Immig
------------------------------
Date: Tue, 13 Apr 2004 21:09:03 GMT
From: genevieve@votenader.org
Subject: Hey, Corporate America! Show Taxpayers Some Appreciation!
Message-Id: <b4b84de3.bd531176@host-69-48-73-244.roc.choiceone.net>
Hey, Corporate America! Show Taxpayers Some Appreciation!
By Ralph Nader
If you work for a corporation, ask your own employer to support
Taxpayer Appreciation Day. (We’ve included contact information at the
end of the article.)
Take Action Now! April 15 is just around the corner. Please let us know
what action you’ve taken and what type of response you receive at
taxday@votenader.org
I'm going to go out on a limb here and suggest that April 15th of each
year be designated Taxpayer Appreciation Day, a day when corporations
receiving taxpayer subsidies, bailouts, and other forms of corporate
welfare can express their thanks to the citizens who provide them.
Though it may not be evident, quite a few industries -- and the profits
they generate -- can be traced back to taxpayer-financed programs whose
fruits have been given away to (mostly) larger businesses.
Taxpayer dollars have often funded discoveries made by NASA, the
Department of Defense, and the National Institutes of Health and other
federal agencies. In many instances the rights to those discoveries were
later given away to companies that brag about them as though they were
the fruits of their own investments. Taxpayer dollars have played a
major role in the growth of the aviation and aerospace, biotechnology,
pharmaceutical, and telecommunications industries -- to name only a few.
Though corporate America insists it must file yearly income taxes just
like everyone else, it is responsible for a sharply decreasing portion
of federal tax dollars -- despite record profits. Despite record
profits, corporate tax contributions to the federal budget have been
steadily declining for fifty years and now stand at a mere 7.4% of the
federal government income because of the loopholes they driven into our
tax laws. The average citizen pays more than four to five times that in
federal income tax revenues (with the single exception of payroll
taxes).
Clearly corporations that believe they are self-reliant are often, in
fact, dependent on taxpayer funds to maintain their financial viability.
The least they could do is thank us. Which is why we need something like
Taxpayer Appreciation Day. Consider the following:
General Electric bought RCA (which owned NBC) in the mid-1980s with
funds it was able to save by using an outrageous tax loophole passed by
Congress in 1981. That loophole allowed GE to pay no federal taxes on
three years of profits, totaling more than $6 billion dollars. It also
gave them a $125 million refund! That gave GE the money to buy RCA. GE
should arrange a media extravaganzas on NBC to say "Thank you,
taxpayers.” Pharmaceutical companies constantly ballyhoo their
discoveries in advertisements. What they don't tell us is that many of
the important nonredundant therapeutic drugs -- including most
anticancer drugs -- were developed, in whole or in part, with taxpayer
money and then given to them by the NIH and the Defense Department.
Bristol-Meyers Squibb, for example, controls the rights to Taxol, an
anticancer drug developed all the way through human clinical trials at
the National Institutes of Health with $31 million of taxpayer moneys.
Pharmaceutical companies spend billions on advertisements each year.
Perhaps they should consider a big "Thank You, Taxpayers" ad campaign
every April 15, if only to remind them where their drug research and
development subsidies come from.
Mining companies often receive vast sweetheart deals from taxpayers.
Under the 1872 Mining Act hard rock mining companies are allowed to
purchase mining rights to public land for only $5 an acre, no matter how
valuable the minerals on (or in) that land might be. A Canadian company
recently mined $9 billion in gold on federal land in Nevada after using
the Mining Act to purchase the mining rights to it for about $30,000.
Mining companies owe the taxpayers their gratitude.
Television broadcasters were given free license to use public airwaves
(worth around $70 billion) by a supine Congress in 1997. They too should
thank us. What about all those professional sports corporations that
play and profit in taxpayer-funded stadiums and arenas? The owners and
players should thank the fans/taxpayers who -- in spite of their largess
-- still must pay through the nose for tickets. For years McDonalds
received taxpayer subsidies to promote its products overseas as part of
a foreign market access program. Now McDonalds is a ubiquitous brand
name worldwide, but has it ever thanked the taxpayers who underwrote its
efforts? Then there are the HMOs, hospitals, and defense contractors
that have had their legal fees reimbursed by the taxpayers when our
government prosecutes them for fraud or cost overruns. Those companies
have great public relations firms that can help them show us their
gratitude. Corporate America has taken too much from us for too long.
It's time it shows us a little bit of appreciation.
Corporate Contacts:
General Electric (NBC):
David Frail
Financial Communications
1--203-373-3387
david.frail@corporate.ge.com
Bristol-Meyers Squibb:
Peter R. Dolan, CEO
345 Park Avenue
New York, New York, USA 10154-0037
1-212-546-4000
peter.dolan@bms.com
Viacom (CBS, MTV, Nickelodeon, VH1, BET, Paramount Pictures, Viacom Outdoor, Infinity, UPN, Spike TV, TV Land, CMT: Country Music Television, Comedy Central, Showtime, Blockbuster, and Simon & Schuster):
Sumner M. Redstone , Chairman and CEO
1515 Broadway
New York, NY 10036
1-212-258-6000
(refused to provide email addresses)
Walt Disney Co. (ABC):
David Eisner, CEO
500 S. Buena Vista Street
Burbank, CA 91521 ABC, Inc.
1-818-460-7477
netaudr@abc.com
McDonalds USA:
Jim Cantalupo, Chairman and CEO
McDonald’s Plaza
Oak Brook, IL 60523
1-800-244-6227
Email on-line form.
Halliburton (Kellogg Brown & Root):
David J. Lesar, Chairman, President & CEO
5 Houston Center
1401 McKinney, Suite 2400
Houston, TX 77010
1-713-759-2600
communityrelations@halliburton.com
In addition to these, pursue your favorite and let us know what they say!
--
Marxism-Leninism-Maoism and its military strategy, people's war, the
Palestinian people's fight will surely become .more integral part of the
world revolution, hastening the day when imperialism, Zionism .meet their
doom."
These Maoist terrorist organizations are financing their activities by
trafficking in controlled substances. According to December 13, 2000,
testimony by Frank Cilluffo, to the U.S. House Committee on the Judiciary
Subcommittee on Crime, the Kurdistan Workers Party (PKK) " is heavily
involved in the European drug trade, especially in Germany and France.
French law enforcement estimates that the PKK smuggles 80 percent of the
heroin in Paris." Cilluffo is Deputy Director, Global Organized Crime
Program Counterterrorism Task Force at Washington, D.C.'s Center for
Strategic and International Studies.
This same testimony reveals the Nepal Communist Party, ".turned to drug
trafficking for funding. Nepal serves as a hub for hashish trafficking in
Asia." The CIA Fact Book lists Nepal as a major source for heroin from
Southeast Asia to the West.
The South Asia Terrorism Portal wrote of the Nepal Communist Party: "The
Maoists (Nepal) draw inspiration from the 'Revolutionary International
Movement', among whose affiliate is the American Revolutionary Communist
Party that provides them their ideological sustenance. Observers have
noticed striking similarities in the policies and guerilla tactics adopted
by the Maoists and those of the Shining Path of Peru.. Maoist violence has
already cost Nepal several hundred lives and destruction of property worth
millions of rupees. In 1996, the year the insurgency commenced, 82 people
were killed. This figure included insurgents, security f
------------------------------
Date: Tue, 13 Apr 2004 15:49:22 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: need to find word, and comment out next 5 lines
Message-Id: <slrnc7okii.94h.tadmc@magna.augustmail.com>
joe shaboo <jshaboo@hotmail.com> wrote:
> zone "mydomain.com" {
> type master;
> file "path/to/zone"
> notify yes;
> }
>
> what I'd like to do
>
> // Domain commented out by `finger `logname` | grep real | awk '{print
> $7" "$8}'` on date.
> // zone "mydomain.com"
> // type master;
> // file "path/to/zone"
> // notify yes;
> //}
> how can I do this using Perl?
-------------------------------------------------
#!/usr/bin/perl
use warnings;
use strict;
my $comment = 'Domain commented out by ...';
while ( <DATA> ) {
if ( /zone "mydomain\.com"/ ) {
print "// $comment\n";
print "// $_";
foreach my $i ( 1 .. 4 ) { # the next four lines
my $line = <DATA>;
print "// $line";
}
next;
}
print;
}
__DATA__
stuff
zone "mydomain.com" {
type master;
file "path/to/zone"
notify yes;
}
other stuff
-------------------------------------------------
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 13 Apr 2004 18:32:18 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude>
Subject: OT: Re: Writing to STDIN
Message-Id: <Xns94CA93E4A85F4asu1cornelledu@132.236.56.8>
hobbit_hk@hotmail.com (Hobbit HK) wrote in
news:22ee5d47.0404122255.196915b7@posting.google.com:
> Jim Cochrane <jtc@shell.dimensional.com> wrote in message
> news:<slrnc7m61v.78c.jtc@shell.dimensional.com>...
>> In article <22ee5d47.0404121318.6a28fdd1@posting.google.com>, Hobbit
>> HK wrote:
>> > Hmmm........ So if it's such a bad idea and such, how does bash and
>> > other shells write to STDIN when you press TAB to complete your
>> > writing?
>>
>> I believe the process is writing to stdout in such cases, not stdin -
>> i.e., it reads the tab from stdin and writes to stdout.
>>
>
> I don't think so.. Because you can erase that completion, and it's
> part of your input..
bash deals with user input using the readline library. You can download
that library and inspect it instead of thinking about it accomplishes
certain tasks.
You will find that STDIN is not written to anywhere. Instead, completions
etc get written/inserted into the edit buffer which is then displayed.
User input changes the contents of this internal buffer.
We are drifting off-topic here so I am not going to try to go into
details, but you should look at the contents of complete.c, input.c and
especially the update_line function in display.c in the readline library.
--
A. Sinan Unur
1usa@llenroc.ude (reverse each component for email address)
------------------------------
Date: Tue, 13 Apr 2004 19:00:06 GMT
From: Kirk Strauser <kirk@strauser.com>
Subject: Re: the code for bbs 3
Message-Id: <8765c3n1s3.fsf@strauser.com>
=2D----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
At 2004-04-13T17:54:39Z, "Robin" <robin @ infusedlight.net> writes:
> can someone point out a security hole? Or did I come to the wrong place?
Yes, to both.
=2D --=20
Kirk Strauser
The Strauser Group
Open. Solutions. Simple.
http://www.strausergroup.com/
=2D----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)
iD8DBQFAfDhF5sRg+Y0CpvERAgpXAJ4i5fvARDTAuCbNrGMMc5GeslzqvQCeObeg
eX0LAMa12j5dlafI2eP/KLI=3D
=3D/CS4
=2D----END PGP SIGNATURE-----
------------------------------
Date: Tue, 13 Apr 2004 18:25:12 GMT
From: Rob Perkins <rob_perkins@hotmail.com>
Subject: Re: Tough (for me) regex case
Message-Id: <fm9o7015jr0s739h201p23k33qm7cv4iq7@4ax.com>
[x-posted to m.p.d.f because it concerns the .NET Framework's regex-er
as well...]
"Matt Garrish" <matthew.garrish@sympatico.ca> wrote:
>Does it make a little more sense now why Microsoft's implementation is
>wrong?
I'm not ready to call it "wrong", but I'm getting close. OK, so we
start with:
/(?<!")"(?!")(.*?)(?<!")"(?!")/
Removing the lookahead and lookbehind stuff, (in other words, don't
worry about the paired doublequote case) I get a pattern which reads:
/"(.*?)"/
...which includes the quotes in the match, in the .NET implemenation.
In Perl, the quotes get consumed before the match is constructed. But
if I do this:
/".*?"/
Then the regex matches include the quote characters, in either
implementation. So apparantly in the .NET implementation there is no
semantic difference between the two smaller cases.
And... now it begins to make a bit more sense. One implementor decided
there was no distinction in that difference. Another did.
It makes me wonder if this .NET implementation approach is shared by
other implementations. IOW, is the desirable (for my problem) behavior
unique to Perl 5, or is the undesirable behavior unique to .NET?
TMTOWDI. But it represents a case which works desirably for me under
Perl, and generates a bit more work for me under the .NET Framework's
regex engine.
OK, so that leads me then to a case where this particular regex fails,
even in the Perl implementation. Consider the case of:
The "quick" brown "fox jumped ""over""" the lazy dog.
The desirable matches are:
quick
fox jumped ""over""
but this regex returns only
quick
If I stick whitespace between the second and third quote after "over"
then it returns:
quick
fox jumped ""over""<space>
Again, the plain-english description is "all text between a pair of
doublequote characters, except that paired doublequotes inside a
quoted string are part of the match."
What do you think the regex will be?
Rob
------------------------------
Date: Tue, 13 Apr 2004 19:54:14 GMT
From: Rob Perkins <rob_perkins@hotmail.com>
Subject: Re: Tough (for me) regex case
Message-Id: <gaho705d1uguhrgvjedh5hvfff7dl9lael@4ax.com>
Tad McClellan <tadmc@augustmail.com> wrote:
>We speak
>Perl here in the Perl newsgroup.
Then I guess I'll have to leave you alone, Tad.
Rob
------------------------------
Date: 13 Apr 2004 20:27:10 GMT
From: ctcgag@hotmail.com
Subject: Re: Why are arrays and hashes this way?
Message-Id: <20040413162710.065$wq@newsreader.com>
fxn@hashref.com (Xavier Noria) wrote:
> Uri Guttman <uri@stemsystems.com> wrote in message
> news:<x7n05jhuyo.fsf@mail.sysarch.com>...
>
> > and even without that, it makes very good sense. the problem with
> > storing a real hash where a scalar is, is how do you store it? the slot
> > in an SV can hold a single item (a scalar) so what would you put there
> > to represent a hash? and if any of those hash elements was a hash, all
> > memory hell breaks out. in c, you can only do multidim arrays of known
> > element size. with perl you can have each thing at any level be any
> > thing of any size. so the win is major flexibility at a cost of
> > understanding and dealing with refs. not a bad tradeoff IMO.
>
> In my opinion the reason cannot be only "because the slot is an SV".
You are right, they could have changed that if they wanted to. Or just
papered over it in the parser and left it the same behind the scenes.
> Why then arrays and hashes are data types that cannot be stored in
> SVs? I guess there was some choice made when those data types were
> defined that matters here. My question is why that initial choice was
> done like that.
How would you assign a hash or an array to a scalar?
$x=@a is already used to mean something different.
($x)=@a is already used to mean something different.
What notation would you use?
When it comes to dereferencing, what notation would you use?
And you have to use some notation, because sometimes I want
a shallow copy and sometimes I want a deep copy, so you have to give
me the power to declare which one I want. I guess they could have
made dereferencing the default behavior (and deny that that is what they
are doing, by decreeing that they weren't references in the firts place),
and you would instead need a special notation for a non-dereferencing
access. But regardless of which one is the default, the other one is still
necessary as an option. Or would you forbid the whole concept of multiple
handles into the same piece of data?
> Efficiency?
I doubt it. Behind the scenes it probably be pretty much the same.
(Unless you did forbid the concept of multiple handles into the same
piece of data.)
> No particular reason but historical
> accident? Different goals than today for which those types were better
> suited?
Well, until I see you give a grammar/syntax which allows us to accomplish
everything we can currently accomplish, I'll stick with the notion that
they didn't do it because it is a bad idea.
> I think this is important to know. Being arrays and hashes first-class
> citizens it kind of surprises to newcomers (like me when I learned
> Perl5) that they cannot be nested. The class about structures should
> have some comment like "You see we have all these high-level
> structures so easily handled at the tips of our fingers, but because
> of <<historical reasons>> they cannot be nested. We'll learn how to do
> that when we see references."
"Nested structures have a certain irreducible complexity, and you ignore
this complexity at your own peril. We need to thoroughly understand the
data structures themselves before we delve into nesting them. We will
learn how to appropriately deal with this complexity when we learn about
references."
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
------------------------------
Date: Tue, 13 Apr 2004 12:18:33 -0700
From: Lowell Kirsh <lkirsh@cs.ubc.ca>
Subject: why does this not work
Message-Id: <c5heea$p2i$1@mughi.cs.ubc.ca>
I'm trying to write a simple file-copy script on Windows and I can't
figure out why it's not working. Here's part of what I have:
my $fromDir = "C:\\Documents and Settings\\user\\Application
Data\\Mozilla\\Profiles\\default\\iw2wx3e0.slt\\";
my $fromFile = "\"${fromDir}bookmarks.html\"";
Now, at this point, '-r $fromFile' returns false, but I know the file is
there because in the same script I put in 'system "cat $fromFile"' and
this print the contents to screen, proving the file is really there.
What am I doing wrong?
Lowell
------------------------------
Date: Tue, 13 Apr 2004 19:36:46 +0000 (UTC)
From: "John J. Trammell" <trammell+usenet@hypersloth.invalid>
Subject: Re: why does this not work
Message-Id: <slrnc7ogae.sf.trammell+usenet@hypersloth.el-swifto.com.invalid>
On Tue, 13 Apr 2004 12:18:33 -0700, Lowell Kirsh <lkirsh@cs.ubc.ca> wrote:
> I'm trying to write a simple file-copy script on Windows and I can't
> figure out why it's not working. Here's part of what I have:
>
> my $fromDir = "C:\\Documents and Settings\\user\\Application
> Data\\Mozilla\\Profiles\\default\\iw2wx3e0.slt\\";
>
> my $fromFile = "\"${fromDir}bookmarks.html\"";
^^ ^^
Too many "s.
How about:
my $from_dir = "C:/Documents and Settings/user/whatever/.../";
my $from_file = $from_dir . "bookmarks.html";
------------------------------
Date: Tue, 13 Apr 2004 14:44:58 -0500
From: John Bokma <postmaster@castleamber.com>
Subject: Re: why does this not work
Message-Id: <407c434c$0$24356$58c7af7e@news.kabelfoon.nl>
Lowell Kirsh wrote:
> I'm trying to write a simple file-copy script on Windows and I can't
You use the File:: module(s) for this?
--
John personal page: http://johnbokma.com/
Experienced Perl / Java developer available - http://castleamber.com/
------------------------------
Date: Tue, 13 Apr 2004 13:31:27 -0700
From: Lowell Kirsh <lkirsh@cs.ubc.ca>
Subject: Re: why does this not work
Message-Id: <c5hin0$q3l$1@mughi.cs.ubc.ca>
yes
John Bokma wrote:
> Lowell Kirsh wrote:
>
>> I'm trying to write a simple file-copy script on Windows and I can't
>
>
> You use the File:: module(s) for this?
>
------------------------------
Date: 13 Apr 2004 20:58:33 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude>
Subject: Re: why does this not work
Message-Id: <Xns94CAACB0CDA3Easu1cornelledu@132.236.56.8>
Lowell Kirsh <lkirsh@cs.ubc.ca> wrote in news:c5heea$p2i$1
@mughi.cs.ubc.ca:
> I'm trying to write a simple file-copy script on Windows and I can't
> figure out why it's not working. Here's part of what I have:
>
> my $fromDir = "C:\\Documents and Settings\\user\\Application
> Data\\Mozilla\\Profiles\\default\\iw2wx3e0.slt\\";
use strict;
use warnings;
use File::Spec;
my $full_path = File::Spec->catfile(
$ENV{USERPROFILE}, 'Application Data', 'Mozilla',
'Profiles', 'default', 'iw2wx3e0.slt', 'bookmarks.html'
);
print qq{"$full_path"};
Reduces time spent escaping quotes, slashes etc.
--
A. Sinan Unur
1usa@llenroc.ude (reverse each component for email address)
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc. For subscription or unsubscription requests, send
#the single line:
#
# subscribe perl-users
#or:
# unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.
#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V10 Issue 6397
***************************************