[16583] in Perl-Users-Digest
Perl-Users Digest, Issue: 3995 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Aug 12 09:05:34 2000
Date: Sat, 12 Aug 2000 06:05:17 -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: <966085516-v9-i3995@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Sat, 12 Aug 2000 Volume: 9 Number: 3995
Today's topics:
Re: Access html file from perl (Colin Keith)
ANNOUNCE Carp::Notify 1.00 thomasoniii@yahoo.com
ANNOUNCE Mail::Bulkmail 2.00 thomasoniii@yahoo.com
ANNOUNCE: AI::NeuralNet::BackProp version 0.77 <jdb@wcoil.com>
ANNOUNCE: XML::BMEcat 0.52 <fpreich@yahoo.com>
Re: CGI, How to get back to cached dokument (Colin Keith)
dbi odbc placeholder problem dr_dubosc@my-deja.com
dbi odbc placeholder problem dr_dubosc@my-deja.com
Re: ecologically printed perldocs <bcaligari@shipreg.com>
Re: GREP - type of script... <elephant@squirrelgroup.com>
Re: GREP - type of script... <bart.lateur@skynet.be>
Re: HELP - string permutations in perl (Neil Kandalgaonkar)
Re: HELP - string permutations in perl <abe@ztreet.demon.nl>
Re: HELP - string permutations in perl <wyzelli@yahoo.com>
Re: How to know if a scalar contain string or numeric d <elephant@squirrelgroup.com>
Re: How to replace the newline in perl? <flavell@mail.cern.ch>
Re: Large-File Reformatting Problem (Regexp gurus, et a (Abigail)
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sat, 12 Aug 2000 11:34:26 GMT
From: newsgroups@ckeith.clara.net (Colin Keith)
Subject: Re: Access html file from perl
Message-Id: <6Dal5.99$DT4.3347081@nnrp2.clara.net>
Cross posts to .module dropped, its not about modules.
In article <8n14ae$1i9$1@reader1.fr.uu.net>, "Gloff"
<mgangloff@framacom.com> wrote:
>Is it possible, on one or another way (copy with ftp?), to access, from a
>cgi application, an html file in another server than the one were the cgi
>script is working?
Yes, but it depends entirely on what you want to do and like most people
you know what you want to do and think that your problem lies here so you
only need to tell us this bit. You don't, you need to give the whole
picture, thus I can't give you a definite answer on (imho) the best way
to do this because I don't know what you're trying to do.
So, probably.
>I mean , for exemple, using the file access functions, (open / close etc...)
>to access an html file from its URL, like:
>open(MYFILE,"http://www.mydomain.com/myfile.htm");
Given this I would assume that you're having to do this remotely using the
HTTP protocol. For instance you want to send data to a CGI script on a
search engine and get the HTML back for your script (Though if you are using
other people's resources, it is at least polite to make sure they don't have
a problem with it first.)
If this is what you're trying to do, then you should look into the modules
on CPAN (<http://www.cpan.org/modules> and pick a mirror near you) for LWP,
for instance. Download it, install it, look at the example in the
synopsis section of the man page for LWP::Simple.
Of course there are alternatives, Net::FTP could FTP the file, but if its a
static file you'd be better off doing it once and leaving it. If you really
want to use open() etc, and it is your machine, you might be able to
mount it as a network drive and access the file from there. Its might also
be possible to get the same effect from other services or programs that are
running but without details ....
Col.
---
Colin Keith
Systems Administrator
Network Operations Team
ClaraNET (UK) Ltd. NOC
------------------------------
Date: Fri, 11 Aug 2000 14:47:37 GMT
From: thomasoniii@yahoo.com
Subject: ANNOUNCE Carp::Notify 1.00
Message-Id: <space13fn4t12@corp.supernews.com>
Carp::Notify is a perl error reporting module designed for applications
that are running unsupervised (a CGI script, for example, or a cron job)
and need to keep running with as little downtime as possible.
Carp::Notify lets you know quickly if your program has experience a
problem that needs immediate attention. If a program has an explosion, it
terminates (same as die or croak or exit, depending on preference) and
then emails someone with useful information about what caused the
problem. Said information can also be logged to a file. If you want the
program to tell you something about an error that's non fatal (disk size
approaching full, but not quite there, for example), then you can have it
notify you of the error but not terminate the program.
I've seen a lot of places that have very similar routines to this, but
they're all home-grown custom made jobs that are tricky to maintain, not
overly flexible, and generally annoying to work with. Carp::Notify lets
everyone use a nice, standard interface for these notifications. Plus,
you don't have to worry about writing your own custom routines so it
saves you time.
Defaults are set up within the module, but they can be overridden once
the module is used, or as individual explosions take place.
AUTHOR
Jim Thomason thomasoniii@yahoo.com
#store $data, do email the errors, and alias croak => explode
use Carp::Notify ('$data', 'email_it' => 1, "croak");
#email it to a different address, and don't log it.
use Carp::Notify ("email" => 'thomasoniii@yahoo.com', 'log_it' => 0);
#die with an explosion.
explode("Ye gods! An error!");
#explode, but do it quietly.
explode ("die_quietly" => 1, "Ye gods! An error!");
#notify someone of a problem, but keep the program running
notify ("Ye gods! A little error!");
Carp::Notify is on CPAN and should be working its way to a CPAN mirror
near you sometime soon.
It can also be retrieved from my web page at http://members.home.net/
jimandkoka/perl/
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Fri, 11 Aug 2000 15:30:17 GMT
From: thomasoniii@yahoo.com
Subject: ANNOUNCE Mail::Bulkmail 2.00
Message-Id: <spacerhvn4t149@corp.supernews.com>
Mail::Bulkmail gives a fairly complete set of tools for managing mass-
mailing lists. I wrote it because our existing tools were just too damn
slow for mailing out to thousands of recipients.
2.00 is a major major major upgrade to the previous version (1.11). I
literally threw out all of the code from 1.00 and started over. Well,
almost all of it, I'm really content with the email validation, so I kept
that. :)
Everything else is brand spanking new. All of the bugs from the 1.x
releases should be gone (ever try allowing duplicates? Good.). And, of
course, a bunch of new toys have been added in.
The two major additions to v2 are the ability to send via envelope and
support for dynamic messaging. Sending via the envelope allows you to
potentially transfer your email *much* faster (I've been estimating a
900% speed increase vs. non- envelope sending in 1.11). Dynamic messaging
allows you to actually construct the message that you're sending out on
the fly. Specify which components of a message you want to include, and
Bulkmail will generate the message on the fly.
Dynamic messaging is a few steps above a simple mail merge. While you
could accomplish the same effect using a simple mail merge it wouldn't be
pretty. You'd have to duplicate each component of the message for each
person on the list.
Further changes are listed in the version history and FAQ sections below,
I just wanted to mention the big guns up front.
AUTHOR
Jim Thomason thomasoniii@yahoo.com
It's on CPAN and should be making its way to a mirror near you and is
also available on my homepage
at http://members.home.net/jimandkoka/perl/
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 12 Aug 2000 08:14:27 GMT
From: "Josiah Bryan" <jdb@wcoil.com>
Subject: ANNOUNCE: AI::NeuralNet::BackProp version 0.77
Message-Id: <spacgncpn4t131@corp.supernews.com>
Greetings Perlfolk,
Announcing the release of the new AI::NeuralNet::BackProp, version 0.77.
Announcing the upgrade release (from v0.42) of
AI::NeuralNet::BackProp v0.77, beta.
Download URL **recomended:
http://www.josiah.countystart.com/modules/AI/cgi-bin/rec.pl
Or, you can download it from your favorite CPAN mirror under:
$CPAN/authors/id/J/JB/JBRYAN/AI-NeuralNet-BackProp-0.77.zip
File size totals 95764 bytes.
Synopsis:
use AI::NeuralNet::BackProp;
my $net = new
AI::NeuralNet::BackProp($layers,$neurons_per_layer,$number_outputs);
$net->learn(\@input_pattern, \@desired_output_pattern);
my $array_ref_to_net_output = $net->run(\@test_input_pattern);
Description:
AI::NeuralNet::BackProp implements a neural network in perl similar to a
feed-foward, back-propagtion network; learning via a mix of a generalization
of the Delta rule and a disection of Hebbs rule. The actual neruons of the
network are implemented via the AI::NeuralNet::BackProp::neuron package.
>From the POD:
This is version 0.77, a complete internal upgrade from version 0.42. A new
feature is the introduction of a randomness factor in the network, optional
to disable. The restriction on 0s are removed, so you can run any network
you like. See NOTES on using 0s with randomness disabled, below. Included is
an improved learn() function, and a much more accurate internal fixed-point
system for learning. Also included is automated learning of input sets. See
learn_set() and learn_rand_set() methods.
>From me now:
Thanks to suggestions from Pat Trainor, I have reworked parts of the
crunch() and uncrunch() methods. uncrunch() now returns a string, and
crunch() now takes a string, instead of a qw()ed word set. Also available is
the ability to handle 0s (Thanx again, Pat). You can also specify an
optional "maximum error" to allow in the learning. If the difference between
the desired result map and actual result map fall below a max error level,
then the learn loop will consider itself done, instead of waiting for an
absolute match. See the included POD docs for usage, look at the options for
learn().
Please give feedbacks on any idea you have for this module. Also, if you can
patch any bugs you think you find, or just tell me about any bugs you find
that I didn't mention in README, I would be grateful!
Always open for new suggestions.
Cheers!
--
Josiah Bryan
VP of Product Development
TDCJ, Inc.
"Anything is possible."
vp@tdcj.com
http://www.josiah.countystart.com/
Tel: 937.316.6256
------------------------------
Date: Fri, 11 Aug 2000 23:36:01 +0200
From: "Frank-Peter Reich" <fpreich@yahoo.com>
Subject: ANNOUNCE: XML::BMEcat 0.52
Message-Id: <spacfkcjn4t184@corp.supernews.com>
============================================================================
==
Release of version 0.52 of XML::BMEcat
============================================================================
==
NAME
XML::BMEcat - Perl extension for generating BMEcat-XML
SYNOPSIS
use XML::BMEcat;
my $BMEcat = XML::BMEcat->new();
$BMEcat->setOutfile("catalog.xml");
DESCRIPTION
XML::BMEcat is a simple module to help in the generation of BMEcat-XML.
Basically, you create an XML::BMEcat object and then call the related
methods with the necessary parameters.
METHODS
The following methods are provided:
HEADER
Writes the BMEcat-Header:
* createHeader
my $Header = $BMEcat->creatHeader();
* setTransaction
$Header->setTransaction($TRANSACTION, [ 'PREV_VERSION' =>
$prev_version ]);
* setGeneralInfo
$Header->setGeneralInfo(
'GENERATOR_INFO' => $GENERATOR_INFO,
'LANGUAGE' => $LANGUAGE,
'CATALOG_ID' => $CATALOG_ID,
'CATALOG_VERSION' => $CATALOG_VERSION,
'CATALOG_NAME' => $CATALOG_NAME,
'DATE' => $DATE,
'TIME' => $TIME,
'CURRENCY' => $CURRENCY,
'MIME_ROOT' => $MIME_ROOT
);
setBuyerInfo
$Header->setBuyerInfo(
'BUYER_ID' => $BUYER_ID,
'BUYER_NAME' => $BUYER_NAME,
'NAME' => $NAME,
'STREET' => $STREET,
'ZIP' => $ZIP,
'CITY' => $CITY,
'COUNTRY' => $COUNTRY,
'EMAIL' => $EMAIL,
'URL' => $URL
);
setAgreementInfo
$Header->setAgreementInfo(
'AGREEMENT_ID' => $AGREEMENT_ID,
'AGREEMENT_start_date' => $AGREEMENT_start_date,
'AGREEMENT_end_date' => $AGREEMENT_end_date
);
setSupplierInfo
$Header->setSupplierInfo(
'SUPPLIER_ID' => $SUPPLIER_ID,
'SUPPLIER_NAME' => $SUPPLIER_NAME,
'NAME' => $NAME,
'NAME2' => $NAME2,
'CONTACT' => $CONTACT,
'STREET' => $STREET,
'ZIP' => $ZIP,
'CITY' => $CITY,
'COUNTRY' => $COUNTRY,
'PHONE' => $PHONE,
'FAX' => $FAX,
'EMAIL' => $EMAIL,
'URL' => $URL
);
* setConfigInfo
$Header->setConfigInfo(
'CHAR_SET' => $CHAR_SET,
'DTD' => $DTD,
'VERBOSE' => 1
);
* writeHeader
$BMEcat->writeHeader();
FEATURE_SYSTEM
Writes the BMEcat - Feature-System:
* setConfigInfo
$Header->setConfigInfo('FEATURE_SYSTEM_NAME' => $FEATURE_SYSTEM_NAME);
* creatFeatureSystem
my $FeatureSystem = $BMEcat->creatFeatureSystem();
* addFeatureGroup
$FeatureSystem->addFeatureGroup( 'ftg1',
'ft1' => $unit_a,
'ft2' => $unit_b,
'ft3' => $unit_c,
);
$FeatureSystem->addFeatureGroup( 'ftg2',
'ft4' => $unit_d,
'ft5' => $unit_e,
'ft6' => $unit_f,
);
* writeFeatureSystem
$BMEcat->writeFeatureSystem();
GROUP_SYSTEM
Writes the BMEcat - Catalog-Structure:
* setConfigInfo
$Header->setConfigInfo('GROUP_SYSTEM_ID' => $GROUP_SYSTEM_ID);
* creatGroupSystem
my $GroupSystem = $BMEcat->creatGroupSystem();
* creatCatalogGroup
my $CatalogGroup = $GroupSystem->creatCatalogGroup($group_id);
* getCatalogGroup
my $CatalogGroup = $GroupSystem->getCatalogGroup($group_id);
* setData
$CatalogGroup->setData( 'PARENT' => 0,
'NAME' => $name02,
'SORT' => 5 );
$CatalogGroup = $GroupSystem->creatCatalogGroup('04');
$CatalogGroup->setData( 'PARENT' => 2,
'NAME' => $name04,
'SORT' => 5 );
$CatalogGroup = $GroupSystem->creatCatalogGroup('06');
$CatalogGroup->setData( 'PARENT' => 2,
'NAME' => $name06,
'SORT' => 10 );
$CatalogGroup = $GroupSystem->creatCatalogGroup('08');
$CatalogGroup->setData( 'PARENT' => 4,
'NAME' => $name08,
'SORT' => 5,
'LEAF' => 1 );
* addDescription
$CatalogGroup->addDescription($Description08);
* addMime
$CatalogGroup->addMime($type, $source, $purpose);
$CatalogGroup = $GroupSystem->creatCatalogGroup('10');
$CatalogGroup->setData( 'PARENT' => 4,
'NAME' => $name10,
'SORT' => 10,
'LEAF' => 1 );
* writeGroupSystem
$BMEcat->writeGroupSystem() and print "not ";
ARTICLES
Writes the BMEcat - Article-Entrys:
General
* creatArticleSystem
my $ArticleSystem = $BMEcat->creatArticleSystem();
* writeArticleSystem
$BMEcat->writeArticleSystem();
* creatArticle
my $Article = $ArticleSystem->creatArticle($index);
* getArticel
my $Article = $ArticleSystem->getArticle($index);
* setMainInfo
$Article->setMainInfo('mode' => $mode,
'SUPPLIER_AID' => $SUPPLIER_AID );
Features
* setFeatureGroup
$Article->setFeatureGroup($group_id);
* setFeatureValues
$Article->setFeatureValues(
$ft_val1,
$ft_val2,
$ft_val3,
$ft_val4
);
Details
* addMime
Several mimes are possible. See the BMEcat-spezification for more details.
$Article->addMime(
$mime_type,
$mime_source,
$mime_purpose
);
* setDetails
All in the BMEcat-spezification described elements are allowed to set in
free order
and at several times.
$Article->setDetails(
'DESCRIPTION_SHORT' => $DESCRIPTION_SHORT,
'DESCRIPTION_LONG' => $DESCRIPTION_LONG,
'EAN' => $EAN,
. . . ,
'SPECIAL_TREATMENT_CLASS' => [ $type => $val ],
. . .
);
Orderdetails
All in the BMEcat-spezification described elements are allowed to set in
free order
and at several times.
$Article->setOrderDetails(
'ORDER_UNIT' => $ORDER_UNIT,
'CONTENT_UNIT' => $CONTENT_UNIT,
'NO_CU_PER_OU' => $NO_CU_PER_OU
. . .
);
Pricedetails
Several prices and types are possible. See the BMEcat-Spezification for
more details.
* setPriceDetails
$Article->setPriceDetails(
'valid_start_date' => $start_date,
'valid_end_date' => $end_date
);
* addPrice
$Article->addPrice(
'price_type' => $price_type,
'PRICE_AMOUNT' => $price_amount,
'PRICE_CURRENCY' => $currency,
'TAX' => $tax
);
ART_GROUP_MAP
Maps Articles to the BMEcat - Catalog-Structure:
* map2Group
$Article->map2Group($group_id);
* writeArticleGroupMap
$BMEcat->writeArticleGroupMap();
TAIL
* writeTail
Writes the Tail and closes the BMEcat - Document
$BMEcat->writeTail();
BUGS
At this time not usable:
- FEATURE_GROUP_NAME
- DAILY_PRICE
LIMITATIONS
Not all BMEcat-features have been implemented yet.
See method-descriptions for detailed informations.
SEE ALSO
The BMEcat-Authors
http://www.BMEcat.org
Perl-XML FAQ
http://www.perlxml.com/faq/perl-xml-faq.html
ACKNOWLEDGMENTS
I'd like to thank Larry Wall, Randolph Schwarz, Tom Christiansen,
Gurusamy Sarathy and many others for making Perl what it is today.
I had the privilege of working with a really excellent teacher,
Robert Krüger. He have guided me through the entire process and his
criticisms where always right on.
COPYRIGHT
Copyright 2000 by Frank-Peter Reich (fp$), fpreich@cpan.org
This library is free software; you can redistribute it and/or modify it
under
the same terms as Perl itself.
BMEcat is a trademark of BME - Bundesverband Materialwirtschaft, Einkauf
und Logistik e.V.
------------------------------
Date: Sat, 12 Aug 2000 12:09:21 GMT
From: newsgroups@ckeith.clara.net (Colin Keith)
Subject: Re: CGI, How to get back to cached dokument
Message-Id: <R7bl5.100$DT4.3350894@nnrp2.clara.net>
In article <39942837.B6CAEC7A@khio.no>, Bulent Sarinc <Bulent@khio.no> wrote:
>CGI, How to get back to cached already-filled-form from a CGIscript
>without erasing the text in the fields.?
I don't quite understand this. If you me the user filled in the data and
submitted it and you want to go back ... well, why not just redraw the page
with the information they submitted to your script? I wouldn't suggest
relying on the browser to cache the information though. Mine seems to do
it with a degree of randomness. Mind you, most things around me seem to be
random :)
Try this as a very short + sweet (actually nasty) script to demo what I
mean:
#!/usr/bin/perl
use strict;
use CGI qw/:standard/;
my($cgi) = CGI->new();
# First calling, draw the form
draw_form() if(!$cgi->param('number'));
# Something submitted, check it
draw_form($cgi->param('number')) if($cgi->param('number') !~ /^\d+$/);
# It was okay, say thank you
print header(), start_html('A Simple Example'), h1('Thank you'), end_html();
sub draw_form {
print header(), start_html('A Simple Example'), h1('A Simple Example'),
start_form(), "Number: ",
textfield(-name=>'number',
-size=>30,
-default=>$_[0] ? $_[0] : 'Your Number'),
($_[0] ? 'You must enter a number!': ''),
br(), submit(), end_form(), hr(), end_html(), "\n";
exit(0);
}
(Originally I wrote a snippet, but I wanted to test that it worked, so I
ended up doing a program but that was too long, so I cut it down to the
above)
Hope it helps,
Col.
---
Colin Keith
Systems Administrator
Network Operations Team
ClaraNET (UK) Ltd. NOC
------------------------------
Date: Sat, 12 Aug 2000 12:02:17 GMT
From: dr_dubosc@my-deja.com
Subject: dbi odbc placeholder problem
Message-Id: <8n3ec9$a4t$1@nnrp1.deja.com>
I can't get placeholders to work in the following
context:
use DBI;
my $dbpath = {some valid dbpath}
my $driver = "driver = Microsoft Access Driver
(*.mdb)";
my $dbh = DBI->connect("dbi:ODBC:$driver;
$dbpath") or die "can't connect to db";
#here, this executes .....
my $rc = $dbh->do(q|delete from jobs where id =
30|,undef) || die $dbh->errstr;
#but this doesn't
my $rc = $dbh->do(q|delete from jobs where id = ?
|,undef,30) || die $dbh->errstr;
does anybody know why?
placeholders have saved me all the trouble of
variable quoting according to type in SQL insert
statements, but not here.
id is an MS Access autonumber field.
thanks in advance, Robin
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Sat, 12 Aug 2000 12:28:14 GMT
From: dr_dubosc@my-deja.com
Subject: dbi odbc placeholder problem
Message-Id: <8n3fst$ats$1@nnrp1.deja.com>
I'm having a problem with placeholders in the ODBC Access driver under
DBI: viz ....(minimally)
#=======begin snip
use DBI;
my $dbpath = "xxx\\xxx\\etc"; #a valid path to an access db
my $driver = "driver=Microsoft Access Driver (*.mdb)";
my $dbh = DBI->connect("dbi:ODBC:$driver;$dbpath")
|| die "can't connect to db";
###THIS EXECUTES .....
my $rc = $dbh->do(q |delete from mytable where id = 30 |,undef)
|| die $dbh->errstr;
###BUT THIS DOESN'T.....
#my $rc = $dbh->do(q |delete from mytable where id = ? |,undef, 30 )
#|| die $dbh->errstr;
#=====end snip
It doesn't work if I explicitly prepare and execute the query, either.
The (access driver) complaint is of a type mismatch in the parameter.
Is this a hole in the perl driver implementation or am I missing
something? 'id' is an Access auto-increment field.
I would like to use placeholders to avoid tangles of code to quote
field values variably according to type, but I can't. Placeholders work
elsewhere, in INSERT statements and the like.
Anybody got any clues here, or had the same problem?
TIA, Robin
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Sat, 12 Aug 2000 10:54:29 +0200
From: "Brendon Caligari" <bcaligari@shipreg.com>
Subject: Re: ecologically printed perldocs
Message-Id: <8n32ne$8oh$1@news.news-service.com>
>
> I'm not intrerested in that--too much effort to set up--but I would
> buy perlfaq-embroidered toilet tissue. I wouldn't need to take a
> book with me--I could just rtfm!
>
> The scary thing is that I'm serious--I really would buy this.
>
> I need to get out more.
>
> Steve
With a crucifix in one hand and my perlfaqs in another
B
------------------------------
Date: Sat, 12 Aug 2000 12:17:28 GMT
From: jason <elephant@squirrelgroup.com>
Subject: Re: GREP - type of script...
Message-Id: <MPG.13ffddc4582b726c9896a8@localhost>
Bart Lateur wrote ..
>Larry Rosler wrote:
>
>>> Can't do inplace edit without backup.
>>>
>>> this error is explained in perldiag
>>
>>The behavior (which is the same in 5.6.0) should be documented in
>>perlrun, where I quoted from. This is a documentation bug.
>
>Is it? I would think it is an implementation bug. I can imagine what
>happens under Unix...
>
> * The old file is renamed to a temporary backup name.
> * A new file is created with the same path as the old file had. It
>remains open for writing.
> * The backup file is opened for reading.
> * Then, the name is deleted from the directory listing (AKA
>"unlinked"); but the file still exists since it's open.
the comment in perldiag would seem to suggest that the method of doing
the in-place edit is not as simple as this .. it would seem that the
actual method does some sort of read from an opened but deleted file
I think that if it was as simple as you suggest then the P5Ps would
certainly have implemented it on Win32
--
jason -- elephant@squirrelgroup.com --
------------------------------
Date: Sat, 12 Aug 2000 12:49:56 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: GREP - type of script...
Message-Id: <mlhapssrkdoi4fg7t18l4mkmtoa9ahj42i@4ax.com>
jason wrote:
>the comment in perldiag would seem to suggest that the method of doing
>the in-place edit is not as simple as this .. it would seem that the
>actual method does some sort of read from an opened but deleted file
In what is that different from what I described? Except that, uh, you
don't actually need the temporary renaming of the file. Just open and
unlink. On Unix, it works. So what you're paraphrasing from the docs is
actually even simpler, than my original scheme:
: * The old file is renamed to a temporary backup name.
: * A new file is created with the same path as the old file had. It
: remains open for writing.
: * The backup file is opened for reading.
: * Then, the name is deleted from the directory listing (AKA
: "unlinked"); but the file still exists since it's open.
Make that:
* The old file is opened for reading
* Then, the name is deleted from the directory listing (AKA
"unlinked"); but the file still exists since it's open.
* A new file is created with the same path as the old file had. It
remains open for writing.
3 steps instead of 4.
--
Bart.
------------------------------
Date: Sat, 12 Aug 2000 05:10:04 GMT
From: neil@brevity.org (Neil Kandalgaonkar)
Subject: Re: HELP - string permutations in perl
Message-Id: <8n2lq1$477$1@localhost.localdomain>
In article <8n1soa$9fr$1@nnrp1.deja.com>, <kassaal@my-deja.com> wrote:
>I need to
>generate every permutation of
>(A,C,G,U) for each length of each string.
I'm using this pattern a lot in my clpmisc answers, but what the heck.
#!/usr/bin/perl -w
use strict;
my @base = qw/A C G U/;
for (0, 1, 2) {
print "--- $_ ---\n";
print join " ", permute_base($_), "\n";
}
sub permute_base {
my ($count, $seq) = @_;
defined $seq or $seq = '';
if ($count) {
return map { permute_base($count-1, $seq . $_) } @base;
} else {
return map { $seq . $_ } @base;
}
}
--
Neil Kandalgaonkar <neil@brevity.org>
------------------------------
Date: Sat, 12 Aug 2000 12:15:21 +0200
From: Abe Timmerman <abe@ztreet.demon.nl>
Subject: Re: HELP - string permutations in perl
Message-Id: <6f7apscmk9au3ki40ibsjfdv9hbcrvel6c@4ax.com>
On Fri, 11 Aug 2000 21:55:23 GMT, kassaal@my-deja.com wrote:
> I am working on a project that requires me to
> create fixed length strings
> (8 -16 characters). Each character can be
> (A,C,G,U). That probably perked
> up the ear of a biologist or two. I need to
> generate every permutation of
> (A,C,G,U) for each length of each string.
> Basically, I want to create all
> permutations of strings which are between 8 and
> 16 characters in length and
> only consisting of the 4 characters I specified.
And what do want to do with them? The requested set won't fit into
memory.
The obvious answer is: You already have them as it is a special case of
base 4 numbers.
for size $size, any number $n in the range of (0 .. (1<<(2*$size) - 1))
represents an element of the required data_set:
my $p = join ' ', map {
('A', 'C', 'G', 'U')[($n >> (2*$_)) & 3] } (0..$size-1);
--
Good luck,
Abe
------------------------------
Date: Sat, 12 Aug 2000 22:07:30 +0930
From: "Wyzelli" <wyzelli@yahoo.com>
Subject: Re: HELP - string permutations in perl
Message-Id: <gybl5.8$aV1.723@vic.nntp.telstra.net>
<kassaal@my-deja.com> wrote in message news:8n1soa$9fr$1@nnrp1.deja.com...
> I am working on a project that requires me to
> create fixed length strings
> (8 -16 characters). Each character can be
> (A,C,G,U). That probably perked
> up the ear of a biologist or two. I need to
> generate every permutation of
> (A,C,G,U) for each length of each string.
> Basically, I want to create all
> permutations of strings which are between 8 and
> 16 characters in length and
> only consisting of the 4 characters I specified.
> I can't seem to come up
> with an elegant solution. I also can't fine a
> module that can do what I
> want. I think the solution involves a bunch on
> nested for loops, but I am
> pretty stumped on this one. Any help would
> greatly be appreciated.
>
Here's one way using nested foreach loops. Takes about a minute to run on
my PIII 500.
You should be able to easily extend it to the longer strings yourself, but
processing time goes up by a large factor each extra loop.
#!/usr/bin/perl -w
use strict;
my @string = qw(A G C U);
open (OUT, '>/data/perm8.txt') or die "wont $!";
foreach my $one (@string){
foreach my $two (@string){
foreach my $three (@string){
foreach my $four (@string){
foreach my $five (@string){
foreach my $six (@string){
foreach my $seven (@string){
foreach my $eight (@string){
print OUT "$one $two $three $four $five $six $seven $eight\n";
}
}
}
}
}
}
}
}
Wyzelli
------------------------------
Date: Sat, 12 Aug 2000 12:21:58 GMT
From: jason <elephant@squirrelgroup.com>
Subject: Re: How to know if a scalar contain string or numeric data?
Message-Id: <MPG.13ffdecaa160a9959896a9@localhost>
Anno Siegel wrote ..
>jason <elephant@squirrelgroup.com> wrote in comp.lang.perl.misc:
>>sth@ms1.hinet.net wrote ..
>>> We all know that a scalar variable is capable of storing either an
>>>string or an numeric number. My question is how I can know if a scalar
>>>variable is now containing a string or a number?
>>
>> perldoc perlfaq4
>>
>> "How do I determine whether a scalar is a number/whole/integer/float?"
>
>I'm not entirely sure if that is what the OP meant. Even in Perl it
>occasionally makes a difference whether you say $x = 123; or $x = '123';
>None of the regular expressions in the faq can tell these cases apart,
>but
> ~$x ne ~"$x" ? 'numeric' : 'string'
>can.
yes sorry .. I misread the question .. you and nobull would seem to be
correct
--
jason -- elephant@squirrelgroup.com --
------------------------------
Date: Sat, 12 Aug 2000 12:12:12 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: How to replace the newline in perl?
Message-Id: <Pine.GHP.4.21.0008121209150.4459-100000@hpplus03.cern.ch>
On 12 Aug 2000, Joe Smith wrote:
> The CSV files I've looked at have two types of \n in them:
Oh dear. In Perl the notation \n denotes the platform-dependent
newline representation. On a given platform the meaning of \n is
well-defined, there can't be two kinds of them.
What I'm trying to say is that if you don't use clear terminology
you're only going to make a confusing topic even more confusing.
------------------------------
Date: 12 Aug 2000 07:24:32 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Large-File Reformatting Problem (Regexp gurus, et al.)
Message-Id: <slrn8p9us8.cro.abigail@alexandra.foad.org>
Greg Bacon (gbacon@HiWAAY.net) wrote on MMDXXXVI September MCMXCIII in
<URL:news:sp5qhdcn4t174@corp.supernews.com>:
-- In article <v1j5psge2g0flr12nilv65u5o0ikdjpc3e@4ax.com>,
-- Bart Lateur <bart.lateur@skynet.be> wrote:
--
-- : I sure hope that [regular expressions in $/] will be added in Perl6.
-- : If nobody else cares enough to impleent it, I'll end up trying to
-- : implement it myself (shudder).
-- :
-- : Using a less powerful but speedingly fast DFA regex engine, it should be
-- : possible to add this feature, with a barely noticable slowdown.
--
-- Yeah, but then everyone would bitch about not having backreferences
-- in $/. :-)
Oooooh, $/ a regex with parens, and then using perl -p and @+ and
friends..... That must give a cool program. ;-)
Abigail
--
perl -MLWP::UserAgent -MHTML::TreeBuilder -MHTML::FormatText -wle'print +(
HTML::FormatText -> new -> format (HTML::TreeBuilder -> new -> parse (
LWP::UserAgent -> new -> request (HTTP::Request -> new ("GET",
"http://work.ucsd.edu:5141/cgi-bin/http_webster?isindex=perl")) -> content))
=~ /(.*\))[-\s]+Addition/s) [0]'
------------------------------
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 3995
**************************************