[22087] in Perl-Users-Digest
Perl-Users Digest, Issue: 4309 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Dec 24 06:05:40 2002
Date: Tue, 24 Dec 2002 03:05:08 -0800 (PST)
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, 24 Dec 2002 Volume: 10 Number: 4309
Today's topics:
DC to DC Converter 13044 (Thermal King)
Re: File::Find module ; want to resume search from poin (Anno Siegel)
Generalising a function was: Re: how to read(string) in <marc@nospam.com>
Re: I can't remove the \n please help me! <rduc@apogee-com.fr>
Re: Is it safe to return a reference to local or lexica <andrew_lee@earthlink.net>
Re: Line delimiters in Win32 Perl <jurgenex@hotmail.com>
Re: Lotus Notes OLE: Help on avoiding undefined value a <Pens@hotmail.com>
Merry Christmas <bernard.el-hagin@DODGE_THISlido-tech.net>
missing Net/SMTP and PPM search shows nothing. (R Solberg)
Re: Need help with octal numbers in substitution (Anno Siegel)
Re: Perl Vs PHP <reggie@_reggieband.com>
Re: re splitting up a file <j.perez.montes@terra.es>
Re: re splitting up a file <geoff.cox@blueyonder.co.uk>
Re: re splitting up a file <geoff.cox@blueyonder.co.uk>
Re: regular expression help <geoff.cox@blueyonder.co.uk>
Re: regular expression help <geoff.cox@blueyonder.co.uk>
SOS: evaluate a string/function jg10@duke.edu
Re: SOS: evaluate a string/function (Jay Tilton)
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 24 Dec 2002 09:26:00 GMT
From: info@tibbo.com(Thermal King)
Subject: DC to DC Converter 13044
Message-Id: <au9978$4qq@netnews.hinet.net>
Aluminum Extrusions 6063-T5 ,6061-T6 and customer
design Heatsink OEM.
Hardcoat anodized of MIL-A-8625-C-Type 3
for Aluminum parts.
Please link http://www.coolkeep.com for more information
wBD I
------------------------------
Date: 24 Dec 2002 09:14:23 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: File::Find module ; want to resume search from point of failure.
Message-Id: <au98hf$mes$1@mamenchi.zrz.TU-Berlin.DE>
According to Mitchell Laks <mlaks2000@yahoo.com>:
> (Anno Siegel) wrote in message news:<au6s8j$55d$1@mamenchi.zrz.TU-Berlin.DE>...
> > According to Mitchell Laks <mlaks2000@yahoo.com>:
> > > Hi -
> > > Thanks millions - i guess i want to be able to say is
> > >
> > > do the file::find algorithm on a directory tree - but begin at
> > > specified file xyz in the tree... instead of the beginning...
> >
>
> > I don't think you'll find such a feature in File::Find. In general,
> > re-starting a process over a file system in this way doesn't make
> > much sense, because a live file system changes permanently.
>
> You are right! however I have frozen the directory from new additions,
> and am trying to export/convert all the individual files at the
> branches of the tree via my "wanted" function to a second machine. I
> want to resume the File::find algorithm mechanism from the crash point
> in the directory hierarchy, whereever it is - which i can determine by
> looking at the target - find out what file came over last.
>
> >
> > For a practical approach, I'd consider just printing to a log file
> > all directory names File::Find comes across:
> >
> > print LOG "$File::Find::name\n" if -d;
> >
> > Then start the thing and hope for the best. If it indeed crashes,
> > evaluate the log to see which directories have been finished and
> > set up another run that doesn't repeat too much.
>
> what algorithm does file::find use to order the directories and
> subdirectories
It does a breadth-first search, that is, it works on all the files
in a directory before diving deeper into the subdirectories, if any.
There is also finddepth(), which does it the other way around.
Otherwise, files and directories are handled in the sequence they
come from readdir(), that is, in no predictable order.
> i guess i can make a array of the remaining directories and feed that
> to file::find. i guess file find must use lexicographic order. i am
> looking at the code in file/find.pm. :( its a little over my (learning
> perl level) head...
Before reading the source, consult the documentation. The depth-first
behavior of find() is described. I don't think it explicitly mentions
that files are processed as delivered from readdir(), but that's the
only reasonable thing to do.
> >
> > The latter step could certainly be automated, but if this is a one-time
> > (or rare) thing, I wouldn't bother.
>
> i have 10 machines with about 300gb of data in 500,000 files each.
> sort of in between (rare and not rare). :).
Oh well... It is certainly a good idea to think about ways to recover.
However, I wouldn't spend too much time planning for an event that, with
some luck, will never happen. If you log carefully what each process
does, you will have the necessary info to restart it after a crash,
even if the procedure isn't entirely clear. If you really have to,
doing it manually once will also show ways how it can be automated.
Anno
------------------------------
Date: Tue, 24 Dec 2002 19:34:43 +1300
From: "Marcus" <marc@nospam.com>
Subject: Generalising a function was: Re: how to read(string) instead of read(STDIN)?
Message-Id: <au8v5g$56s$1@lust.ihug.co.nz>
Bart Lateur <bart.lateur@pandora.be> wrote in message
news:fsud0vkoh80q86r9luctmpkms4bie9qr44@4ax.com...
> Marcus wrote:
>
> >I'm trying to make a while loop like this:
"while(read(STDIN,$q,$w=3)){...}"
> >except I'd like to use a string instead of STDIN. I would use Tie, but
> >don't know what to put in the read() method. Could anyone please help?
>
> Look into IO::Scalar.
>
> --
> Bart.
I had looked at it and it's not easily available on the system I'm using.
I've written read2 which seems to do the trick. Can anyone tell me how to
generalise read2, so I don't have to always use $_ and $w as inputs?
$d= "";
$w= 0;
$_ = 1;
$text = "abcdefghijklmnopqrstuvwxyz";
while(read(STDIN,$_,$w=3)) #$w characters of STDIN
{
$d++;
print $_ . $w;
$d .= "x ";
}
print "\n";
$position = 0; $exit = 0;
while(read2($text,$_,$w=3)) #$w characters of STDIN
{
$d++;
print $_ . $w;
$d .= "x ";
}
print "\n";
sub read2 {
($text,$_, $w) = @_;
if ($exit) {return undef};
if ($w+$position > length($text)) {
$_ = substr($text,$position,length($text)-$position);
$exit = 1;
}
elsif ($w+$position eq length($text)) {
$_ = substr($text,$position,$w);
$exit = 1;
}
else {
$_ = substr($text, $position, $w);
$position += $w;
}
}
------------------------------
Date: 24 Dec 2002 09:58:03 GMT
From: DUCLOS <rduc@apogee-com.fr>
Subject: Re: I can't remove the \n please help me!
Message-Id: <20021224-10583-156362@foorum.com>
Yes, many thanks, It's Ok.
--
Ce message a ete poste via la plateforme Web club-Internet.fr
This message has been posted by the Web platform club-Internet.fr
http://forums.club-internet.fr/
------------------------------
Date: Tue, 24 Dec 2002 05:56:07 -0500
From: Andrew Lee <andrew_lee@earthlink.net>
Subject: Re: Is it safe to return a reference to local or lexical data?
Message-Id: <5qeg0v45pg4bt3r99eclv7udk689vven4i@4ax.com>
On Tue, 17 Dec 2002 22:08:16 GMT, Martien Verbruggen
<mgjv@tradingpost.com.au> wrote:
>On Tue, 17 Dec 2002 09:36:28 -0500,
> Christian Caron <nospam@nospam.org> wrote:
>>
>> "Tad McClellan" <tadmc@augustmail.com> wrote in message
>> news:slrnavub72.2nm.tadmc@magna.augustmail.com...
>>> Christian Caron <nospam@nospam.org> wrote:
>>> >
>>> >>
>>> >> 3.18: Is it safe to return a reference to local or lexical data?
>>>
>>>
>>> > Is it me or is there a problem with that?
>>>
>>>
>>> Can't tell unless you let us know what you think the problem is.
>>>
>>>
>>
>> I thought print "@many\n"; would return numbers:
>>
>> 1 2 3 4 5 6 7 8 9 10
>> 1 2 3 4 5...
>
>let's revisit the code that creates @many:
>
> for $i ( 1 .. 10 ) {
> push @many, makeone();
> }
>
>where each invocation of makeone() returns a (unique) reference to an
>array. push() simply pushes the argument list onto the array. That
>means that given that @many is empty to start off with, after this
>loop it will have 10 elements, each element being a value returned by
>makeone(). Since makeone() returns a reference to an array, there
>should be 10 references to arrays, which is exactly what happens.
>
>> Maybe it's my misunderstanding of (Perl | English | FAQ)... I think I now
>> know it is indeed returning the right thing (10 references to arrays that
>> contain 10 numbers each).
>
>I am not sure why you think there should be numbers. The 1..10 in
>there simply serves as a counter for the loop, the values themselves
>are never used (the $i loop variable shouldn't really be there, it just
>distracts).
>
>Oh, I suddenly see what you mean. The sub makeone() looks like this:
>
>sub makeone {
> local @a = ( 1 .. 10 );
> return \@a;
>}
>
>meaning that each reference points to an array with 10 elements,
>valued 1 to 10. Is that what you expect to see?
>
>Well, print, or rather, stringification simply doesn't work that way
>in Perl. When a reference gets stringified, it becomes a textual
>representation of itself, not of what it refers to. If you want to do
>a "deep" stringification, i.e. each reference is followed and what it
>refers to is stringified in some way, you could use the Data::Dumper
>module, or write something yourself. Data::Dumper would give you
>something like (reformatted to fit 80 characters per line):
>
>$VAR1 = [
> [1,2,3,4,5,6,7,8,9,10],[1,2,3,4,5,6,7,8,9,10],[1,2,3,4,5,6,7,8,9,10],
> [1,2,3,4,5,6,7,8,9,10],[1,2,3,4,5,6,7,8,9,10],[1,2,3,4,5,6,7,8,9,10],
> [1,2,3,4,5,6,7,8,9,10],[1,2,3,4,5,6,7,8,9,10],[1,2,3,4,5,6,7,8,9,10],
> [1,2,3,4,5,6,7,8,9,10]];
>
>Is that what you expected?
>
>Martien
Isn't this way to much discussion for a faulted FAQ posting? Or am I
(like the original poster) seeing the Emperor with no clothes?
If I posted that code I would be shouted down for not testing it
before posting -- in that sense it is in error.
------------------------------
Date: Tue, 24 Dec 2002 06:29:55 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Line delimiters in Win32 Perl
Message-Id: <D9TN9.40911$3t6.18485@nwrddc03.gnilink.net>
T Conti wrote:
> I have run into an anomaly that I am seeking some explanation of in
> Win32 perl. I am writing a service that reads in a file. This could
> be a Unix or windows file. The lines in the Unix file will be
> terminated by \n (OA) and the lines in the windows file are delimited
> by \r\n (0D 0A).
No.
\n is a logical end-of-line marker which _on Windows(!)_ is translated into
the physical 0D 0A.
> I use chomp to rip the delimiter from the line and I
> noticed that it is removes the \n from the first file as expected, but
> it also hack off \r\n from the second file.
Of course. chomp removes the logical end-of-line marker which happens to be
0D 0A because you are running on Windows. Apparently chomp is smart enough
to remove a single 0A, too.
> This is confusing. I
> append a \n to the end of the line and when I view the file in hex the
> lines are delimited by \r\n.
No. It is delimited by whatever the end-of-line marker is for the current
OS. In case of Windows that is 0D 0A.
> Does anyone have any input on this
> behavior? Do I need to set a property in Perl to modify this behavior?
No, that is the expected behaviour of perl on a Windows OS.
jue
------------------------------
Date: Tue, 24 Dec 2002 09:53:07 +0100
From: "Pens" <Pens@hotmail.com>
Subject: Re: Lotus Notes OLE: Help on avoiding undefined value as HASH reference.
Message-Id: <au97a2$53m$1@reader1.tiscali.nl>
smasr <isresi1@xs4all.nl> schreef in berichtnieuws
3e076ad1$0$134$e4fe514c@dreader5.news.xs4all.nl...
> Hi,
>
> I am busy for several days now with a Perl script to extract views and
> attachements from a Lotus Notes database.
>
> Finally the scripts runs but i have still a few problems. One problem i
> still have is:
>
> explaination:
> "Product" is a Notes view name and contains a product name.
>
> I read it in a Perl scalar as shown in this code:
> my $Product = $document->GetFirstItem('Product')->{Text};
>
>
> All goes well but after looping trough 150 documents or so i suddenly get
an
> error:
> "Can't use an undefined value as a HASH reference at line xx."
>
>
> At some point there isn't a value in the 'Product' view and thats why i
get
> the error. I think.. I have commented the line out and ran the script
> again. Then it stops after 170 documents with the same error but on the
> next line where i am reading another a View variable into a scalar.
>
> Is there a way to avoid this error? I don't mind if there is no value but
i
> don't want the script to stop.
>
>
> Regards,
> Smasr.
>
>
>
>
I found the problem but i still have no solution. It seems that at a certain
point the value in Product is:
'A&C Chemicals A`FilePlan'.
There is a backtick in the product name! I read it into this:
> my $Product = $document->GetFirstItem('Product')->{Text};
A solution would be to skip this record and place it on a badlist. I would
prefer a real solution.
Does someone has an idea how to do this ?
Smasr
------------------------------
Date: Tue, 24 Dec 2002 10:51:11 +0000 (UTC)
From: Bernard El-Hagin <bernard.el-hagin@DODGE_THISlido-tech.net>
Subject: Merry Christmas
Message-Id: <slrnb0ger3.13t.bernard.el-hagin@gdndev25.lido-tech>
I'd like to wish all the regulars and all the lurkers of CLPM a very:
perl -e 'print "M$0-r-r-y C-h-r-i-s-t-m-a-s\n"'
Cheers,
Bernard
--
echo 42|perl -pe '$#="Just another Perl hacker,"'
------------------------------
Date: 23 Dec 2002 22:19:32 -0800
From: flateyjarbok@yahoo.com (R Solberg)
Subject: missing Net/SMTP and PPM search shows nothing.
Message-Id: <386cc483.0212232219.45745be1@posting.google.com>
Hi,
I have activeperl, and my pgm for email sending says that
Can't locate Net/SMTP.pm in @INC (@INC contains: C:/perl/lib
C:/perl/site/lib .)
at c:\perl\myapps\mail0104.pl line 4.
The program is like this:
#!/usr/bin/perl -w
#from FAQ 9 in my active perl files. R. solberg
use Net::SMTP;
$smtp = Net::SMTP->new('attbi.com'); # connect to an SMTP
server
$smtp->mail( 'fromuser@attbi.com' ); # use the sender's
address here
$smtp->to('touser@attbi.com'); # recipient's address
$smtp->data(); # Start the mail
# Send the header.
$smtp->datasend("To: touser@attbi.com\n");
$smtp->datasend("From: fromuser@attbi.com\n");
$smtp->datasend("\n");
# Send the body.
$smtp->datasend("Hello, World!\n");
$smtp->dataend(); # Finish sending the mail
$smtp->quit; # Close the SMTP
connection
# Create a subject and a body.
#
$msg->{Subject} = "Test Message";
$msg->{Text} = <<EOF;
This is a sample test message.
Cheers,
Mr. Email
EOF
THen I checked PPM and it shows that I have the following. Then I ran
ppm search and nothing comes back. How do I get NET::SMTP from PPM?
THanks much.
PPM interactive shell (2.0) - type 'help' for available commands.
PPM> query
Archive-Tar [0.072] module for manipulation of tar archives.
Compress-Zlib [1.03 ] Interface to zlib compression library
HTML-Parser [2.23 ] SGML parser class
MIME-Base64 [2.11 ] Encoding and decoding of base64 strings
PPM [2 ] Perl Package Manager: locate, install, upgrade
software
packages.
URI [1.04 ] Uniform Resource Identifiers (absolute and
relative)
XML-Element [1.07 ] Base element class for XML elements
XML-Parser [2.27 ] A Perl module for parsing XML documents
libwin32 [0.16 ] A collection of extensions that aims to provide
comprehensive access to the Windows API.
libwww-perl [5.45 ] Library for WWW access in Perl
PPM>
------------------------------
Date: 24 Dec 2002 09:27:40 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Need help with octal numbers in substitution
Message-Id: <au99ac$mes$2@mamenchi.zrz.TU-Berlin.DE>
According to Fred <No_Mail_Address@cox.net>:
> Anno Siegel wrote:
> >
> > According to Fred <No_Mail_Address@cox.net>:
> > > Hello there,
> > >
> > > I want to remove all 8-bit characters from a file, but keep ü ä ö
> > > (decimal 129, 132, 148)
> >
> > tr/üäö/ /cs;
> >
> > Anno
>
> Thank you Anno, it works fine. I use it in:
> while (<IN>) {
> if (m/[\200-\377]+?/g) {
m/[\200-\377]/ would match the same strings. "+" (match more than one
instance), "?" (non-greedy match) and the /g modifier (match all instances)
do nothing useful in this regex and shouldn't be there.
> tr/üäö/ /cs ;
> }
> print OUT $_ ;
> }
Anno
------------------------------
Date: Tue, 24 Dec 2002 07:31:35 GMT
From: reggie <reggie@_reggieband.com>
Subject: Re: Perl Vs PHP
Message-Id: <r3UN9.9088$na.204834@news2.calgary.shaw.ca>
Uri Guttman wrote:
>>>>>> "K" == Kasp <kasp@NO_SPAMepatra.com> writes:
>
> K> I would like to know your opinion on whether Perl or PHP is better?
> K> Lately, more people are looking into PHP. Why?
>
> because they think the web is the entire net out there. which isn't
> true if you didn't know that. most perl is not used for web stuff.
> php is never used outside the web.
Maybe rarely, instead of never.
> php is a specialize web templating system with some
> ideas poorly borrowed from perl.
Hmm - not a web templating system, no.
There are templating systems for php
(Smarty comes to mind).
There are also application frameworks for php.
I might add that php is significantly easier to
learn than Perl. php _is_ primarily for internet
application development. php is hosted on many unix
based shared servers (no stats off the top of my
head).
I've never been able to compare programming
languages as 'better or worse'. If you are
developing for the web (considering to use CGI for
Perl) you may find php to be a better solution.
--
regards,
reggie.
------------------------------
Date: Tue, 24 Dec 2002 09:21:03 GMT
From: Javier =?iso-8859-1?Q?P=E9rez?= Montes <j.perez.montes@terra.es>
Subject: Re: re splitting up a file
Message-Id: <3E082720.4A324837@terra.es>
You need only to count blank lines, each time you count three blank
lines (line feeds) then you got another Poem.
So you need a variable to count the blank lines and a condition that
detects the blank line and increments the variable.
What do you want to do with each poem?
Geoff Cox ha escrito:
>
> Hello,
>
> I am using following to extract individual poems from a large
> collection of poems. Each poem was separated from the next by 3 line
> feeds and the title of each poem separated from the body of the poem
> by 2 line feeds. Using MS Word I separated each poem by @@@ and each
> title was enclosed by ~~~. Then used the the code below to extract
> each poem and name each file with the title of the poem.
>
> There must be many more elegant solutions ! Not clear how I could
> detect 3 line feeds and use the titles of the poems as the file names
> without using Word to put in the @@@ and the ~~~.
>
> Any sugestions re improvements?
>
> Geoff
>
> Just to be clear the original collection was as follows
>
> __________
>
> title1
>
> ahjshJS Jk
> hjkhS Jks
> hshJSJKsa
>
> title2
>
> hjhhjk
> djahdhajkda
> ahjdkadha
>
> title3
>
> jakdkajdkl
> dkjakdjkla
> djkadkla
> djkadl
>
> etc
> ------------------------------------------
>
> open (IN,"poems");
>
> $file = join " ", <IN>;
>
> @split = split "@@@", $file;
>
> for ($n=0;$n<90;$n++) {
>
> $poem[$n] = $split[$n];
> &title;
> open (OUT, ">>$title[1].txt");
> &removezzz;
>
> print OUT $split[$n];
>
> }
>
> sub title {
>
> my $name = $poem[$n];
> @title = split "~~~", $name;
> }
>
> sub removezzz {
>
> $split[$n] =~ s/[~{2}]/\n /g;
>
> }
--
_ _
(_)__ ___ _(_)_____ _ _ __ _____ ________ _ __ __ _
| | _` | \ / / | _ \ '/ | '_ \ _ \ '/ _ \_ | | '_ ' _' |
| |(_| |\ V /| | __/ | | |_) |__/ | __// / | | | | | | _
| |__,_| \_/ |_|___|_| | .__/___|_|\___|___| |_| |_| |_|(_)
|__/ non nova sed nove |_| e-mail: j.perez.montes@terra.es
http://www.elmaquinas.com
-------------------------------------------------------------
PGP KEY/CLAVE PGP: http://www.pca.dfn.de/eng/dfnpca/pgpkserv/
-------------------------------------------------------------
------------------------------
Date: Tue, 24 Dec 2002 09:49:48 GMT
From: Geoff Cox <geoff.cox@blueyonder.co.uk>
Subject: Re: re splitting up a file
Message-Id: <hcbg0vk4cp2e281lg6apug0p6e99e7m6de@4ax.com>
On Tue, 24 Dec 2002 09:21:03 GMT, Javier Pérez Montes
<j.perez.montes@terra.es> wrote:
Javier,
the idea is to extract each file into a file of its own and ues the
title of the poem as the name for the file...
Cheers
Geoff
>You need only to count blank lines, each time you count three blank
>lines (line feeds) then you got another Poem.
>
>So you need a variable to count the blank lines and a condition that
>detects the blank line and increments the variable.
>
>What do you want to do with each poem?
>
>Geoff Cox ha escrito:
>>
>> Hello,
>>
>> I am using following to extract individual poems from a large
>> collection of poems. Each poem was separated from the next by 3 line
>> feeds and the title of each poem separated from the body of the poem
>> by 2 line feeds. Using MS Word I separated each poem by @@@ and each
>> title was enclosed by ~~~. Then used the the code below to extract
>> each poem and name each file with the title of the poem.
>>
>> There must be many more elegant solutions ! Not clear how I could
>> detect 3 line feeds and use the titles of the poems as the file names
>> without using Word to put in the @@@ and the ~~~.
>>
>> Any sugestions re improvements?
>>
>> Geoff
>>
>> Just to be clear the original collection was as follows
>>
>> __________
>>
>> title1
>>
>> ahjshJS Jk
>> hjkhS Jks
>> hshJSJKsa
>>
>> title2
>>
>> hjhhjk
>> djahdhajkda
>> ahjdkadha
>>
>> title3
>>
>> jakdkajdkl
>> dkjakdjkla
>> djkadkla
>> djkadl
>>
>> etc
>> ------------------------------------------
>>
>> open (IN,"poems");
>>
>> $file = join " ", <IN>;
>>
>> @split = split "@@@", $file;
>>
>> for ($n=0;$n<90;$n++) {
>>
>> $poem[$n] = $split[$n];
>> &title;
>> open (OUT, ">>$title[1].txt");
>> &removezzz;
>>
>> print OUT $split[$n];
>>
>> }
>>
>> sub title {
>>
>> my $name = $poem[$n];
>> @title = split "~~~", $name;
>> }
>>
>> sub removezzz {
>>
>> $split[$n] =~ s/[~{2}]/\n /g;
>>
>> }
------------------------------
Date: Tue, 24 Dec 2002 10:04:55 GMT
From: Geoff Cox <geoff.cox@blueyonder.co.uk>
Subject: Re: re splitting up a file
Message-Id: <c5cg0vkluvi54siq0ui2phfih0vnfe1f7n@4ax.com>
On Mon, 23 Dec 2002 19:27:26 -0000, "David K. Wall"
<usenet@dwall.fastmail.fm> wrote:
David,
your code does the job fine but could you please put into English what
is happening at following points?! Have only done v simple pattern
matching so far....
$/ = "\n\n\n";
my $title = $1 if /^(.*?)\n\n/s;
if ($title =~ /^\s*$/) {
Thanks
Geoff
> use strict;
> use warnings;
>
> $/ = "\n\n\n";
> open IN, 'poems' or die "Cannot open poems: $!";
> while (<IN>) {
> my $title = $1 if /^(.*?)\n\n/s;
> if ($title =~ /^\s*$/) {
> warn "Missing title at record $.:";
> next;
> }
> open POEM, ">$title.txt" or die "Cannot open $title.txt: $!";
> print POEM $_;
> close POEM;
> }
>
>Spaces in filenames can be a pain, so you might want to put the line
>
> $title =~ tr/ /-/;
>
>just before you open() the POEM filehandle to change all the spaces
>to dashes. Your call.
------------------------------
Date: Tue, 24 Dec 2002 09:48:36 GMT
From: Geoff Cox <geoff.cox@blueyonder.co.uk>
Subject: Re: regular expression help
Message-Id: <u9bg0vo4afgncnn9tmsv8aja0s1a8rjs1a@4ax.com>
On Mon, 23 Dec 2002 16:38:54 -0500, Benjamin Goldberg
<goldbb2@earthlink.net>
Benjamin,
the idea is simply to extract each poem into a file of its own, taking
the title of the poem as the name of the file.
Geoff
>Matt Knecht wrote:
>>
>> Mark <mfaine@knology.net> wrote:
>> >passwords must meet the following guidelines:
>> >
>> >eight characters exactly
>> >
>> >The eight characters will contain at least one character each from at
>> >least three of the following sets of characters:
>> >
>> >At least one uppercase letter
>> >At least one lowercase letters
>> >At least one numbers
>> >At least one special characters
>>
>> Easier to write and maintain with seperate regexen IMHO:
>>
>> die unless $passwd =~ /^.{8}$/; # length $passwd == 8
>> $num_sets++ if $passwd =~ /\p{IsUpper}/ # At least one uppercase
>> $num_sets++ if $passwd =~ /\p{IsLower}/ # At least one lowercase
>> $num_sets++ if $passwd =~ /\d/ # At least one digit
>> $num_sets++ if $passwd =~ /\p{IsPunct}/ # At least one punctuation
>
>Or perhaps:
>
>my $num_sets = grep $passwd =~ /$_/,
> qw/^.{8}\z \p{IsUpper} \p{IsLower} \d \p{IsPunct}/;
>
>> die unless $num_sets >= 3;
>>
>> You can cram it into one regex. It'll look cool. The person you pass
>> the code onto will curse you and your lineage, however.
------------------------------
Date: Tue, 24 Dec 2002 09:51:06 GMT
From: Geoff Cox <geoff.cox@blueyonder.co.uk>
Subject: Re: regular expression help
Message-Id: <nebg0vs7uqtiojh52qbvplcv6iftpic68k@4ax.com>
On Mon, 23 Dec 2002 16:38:54 -0500, Benjamin Goldberg
<goldbb2@earthlink.net> wrote:
Benjamin ,
apologies for the inappropriate response - got the my message into the
wrong thread !
Geoff
>Matt Knecht wrote:
>>
>> Mark <mfaine@knology.net> wrote:
>> >passwords must meet the following guidelines:
>> >
>> >eight characters exactly
>> >
>> >The eight characters will contain at least one character each from at
>> >least three of the following sets of characters:
>> >
>> >At least one uppercase letter
>> >At least one lowercase letters
>> >At least one numbers
>> >At least one special characters
>>
>> Easier to write and maintain with seperate regexen IMHO:
>>
>> die unless $passwd =~ /^.{8}$/; # length $passwd == 8
>> $num_sets++ if $passwd =~ /\p{IsUpper}/ # At least one uppercase
>> $num_sets++ if $passwd =~ /\p{IsLower}/ # At least one lowercase
>> $num_sets++ if $passwd =~ /\d/ # At least one digit
>> $num_sets++ if $passwd =~ /\p{IsPunct}/ # At least one punctuation
>
>Or perhaps:
>
>my $num_sets = grep $passwd =~ /$_/,
> qw/^.{8}\z \p{IsUpper} \p{IsLower} \d \p{IsPunct}/;
>
>> die unless $num_sets >= 3;
>>
>> You can cram it into one regex. It'll look cool. The person you pass
>> the code onto will curse you and your lineage, however.
------------------------------
Date: Tue, 24 Dec 2002 02:22:54 -0500
From: jg10@duke.edu
Subject: SOS: evaluate a string/function
Message-Id: <Pine.GSO.4.50.0212240211450.8678-100000@teer4.acpub.duke.edu>
Hi,
SOS!!!
I have a seemingly very simple problem, but I'm stuck!
Basically, I have a string: $str="sin(2)", and I wanted
to evaluate this string to get a numerical answer.
Please see simple code below.
Thanks a million if you could help!
Merry Xmas!
#################################
#!/usr/bin/perl -w
use strict;
# This is ok: sin(2) gets executed
print "sin(2)=", sin(2),"\n";
# Trying to execute sin(2) through $str, does not work.
my $str="sin(2)";
print "sin(2) again = ",eval{$str},"\n";
####################################
Output:
sin(2)=0.909297426825682
sin(2) again = sin(2)
First output is ok,
But I want the second to be 0.909 too.
------------------------------
Date: Tue, 24 Dec 2002 08:21:23 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: SOS: evaluate a string/function
Message-Id: <3e081876.175749157@news.erols.com>
jg10@duke.edu wrote:
: SOS!!!
:
: I have a seemingly very simple problem, but I'm stuck!
Getting excited about it won't help.
: my $str="sin(2)";
: print "sin(2) again = ",eval{$str},"\n";
That's a block eval. You want a string eval.
print "sin(2) again = ", eval($str), "\n";
------------------------------
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.
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 4309
***************************************