[23017] in Perl-Users-Digest
Perl-Users Digest, Issue: 5237 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Jul 18 11:05:46 2003
Date: Fri, 18 Jul 2003 08:05:10 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Fri, 18 Jul 2003 Volume: 10 Number: 5237
Today's topics:
Re: Behind the scene <jpagnew@vcu.edu>
Re: Calculate next available IP (Jim)
Re: Calculate next available IP (Jim)
Daily Perl puzzle (Lawrence Tierney)
Re: Forcing Alphanumeric Text Entry (sekdab)
Re: HTML REGEX <bruce@ghbraille.com>
Re: HTML REGEX <bruce@ghbraille.com>
HTTP::Request failed on HTTP/1.1 and Connection: Keep-A (Simon Tneoh)
Re: HTTP::Request failed on HTTP/1.1 and Connection: Ke <abigail@abigail.nl>
Import - Read file <member33560@dbforums.com>
need 2 digit dd/mm output <rpl-erroroneous@goldengate.net>
Re: need 2 digit dd/mm output <tony_curtis32@yahoo.com>
Re: need 2 digit dd/mm output <vladimir@NoSpamPLZ.net>
prime ?? <thens@nospam.com>
Re: prime ?? <abigail@abigail.nl>
regl expression <bruno_storz@gmx.de>
Re: regl expression <abigail@abigail.nl>
Re: regl expression <bruno_storz@gmx.de>
Re: regl expression <pinyaj@rpi.edu>
Re: regl expression <abigail@abigail.nl>
Removing characters once a series stops (Jim)
Re: Removing characters once a series stops <jkeen@concentric.net>
Re: tab delimited file processing problem <domenico_discepola@quadrachemicals.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 18 Jul 2003 09:08:40 -0400
From: Jim Agnew - VCU/MCV Neurosurgery <jpagnew@vcu.edu>
Subject: Re: Behind the scene
Message-Id: <3F17F158.25A9EFD1@vcu.edu>
Uri Guttman wrote:
>
> >>>>> "MP" == Matija Papec <mpapec@yahoo.com> writes:
>
> MP> http://www.perl.com/lpt/a/2003/07/16/soto2003.html
>
> >> I'm not looking for sympathy, but I want you to know that I almost
> >> certainly could have landed a full-time job 20 months ago if I'd
> >> been willing to forget about Perl 6.
>
> MP> huh?
>
> larry has been working on the perl6 apocalypses and design for much of
> this period. he has been funded partly by the perl foundation but has
> not had major income from them. and he has 2 kids in college, a
> mortgage, etc. so he has sacrificed a lot. his comment above means he
> could have had a decent paying job but he turned it down instead to work
> on perl6.
>
> so the way you can help is to donate money to the perl foundation and
> help larry pay for his mortgage. :)
>
> uri
>
> --
> Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
> --Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
> Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
does buying books from O'Reilly help out at all? I was under the
impression it does...
jim
(Oh, and No, Randall, I didn't hand out my backup copy of the Perl
online bookshelf.. ;-D )
--
"4,000 years ago I made a mistake." Elrond Half-Elven, in "Fellowship
of the Ring"
"I try not to be right any more than necessary". -- Larry Wall, author
of the Perl Language
------------------------------
Date: 18 Jul 2003 05:30:47 -0700
From: jimnl69@hotmail.com (Jim)
Subject: Re: Calculate next available IP
Message-Id: <3966ee66.0307180430.3b394dee@posting.google.com>
tiltonj@erols.com (Jay Tilton) wrote in message news:<3f03581a.943182260@news.erols.com>...
> jimnl69@hotmail.com (Jim) wrote:
>
> : Is there a module, or a readily available algorithm, for calculating
> : the next available IP Address?
> :
> : Let's say I have an array
> : ('10.1.1.1','10.1.1.2','10.1.1.3','10.1.1.10'). I want to find that
> : the next available address is 10.1.1.4. Thanks.
>
> #!perl
> use warnings;
> use strict;
> use Socket qw(inet_aton inet_ntoa);
> use List::Util qw(min);
>
> my @used = ('10.1.1.1', '10.1.1.2', '10.1.1.3', '10.1.1.10');
> my %seen = map { unpack('N', inet_aton($_)), 1 } @used;
> my $check = min( keys %seen );
> $check++ while defined $seen{$check};
> print inet_ntoa( pack 'N', $check ), " is available\n";
Thanks.. Where can I get the List-Util package? I found List-Utils
but it doesn't have "min" so don't believe it to be the same package.
Thanks!
Jim
------------------------------
Date: 18 Jul 2003 05:41:33 -0700
From: jimnl69@hotmail.com (Jim)
Subject: Re: Calculate next available IP
Message-Id: <3966ee66.0307180441.44c29a34@posting.google.com>
Benjamin Goldberg <ben.goldberg@hotpop.com> wrote in message news:<3F03A233.DA82A00B@hotpop.com>...
> Jim wrote:
> >
> > Is there a module, or a readily available algorithm, for calculating
> > the next available IP Address?
> >
> > Let's say I have an array
> > ('10.1.1.1','10.1.1.2','10.1.1.3','10.1.1.10'). I want to find that
> > the next available address is 10.1.1.4. Thanks.
>
> use Socket qw(inet_aton inet_ntoa);
>
> my @readable = qw(10.1.1.1 10.1.1.2 10.1.1.3 10.1.1.10);
>
> my @addrs = sort map inet_aton($_), @readable;
> my ($mask) = @addrs or die;
> chop $mask;
> for my $i ( 1 .. 255 ) {
> if( !@addrs or $addrs[0] ne $mask . chr($i) ) {
> print inet_ntoa( $mask . chr($i) ), "\n";
> exit;
> }
> shift @addrs;
> }
Thanks Ben.. Your example worked great. Is there a limit to the size
of the test case? The following example gives me an error of: Bad arg
length for Socket::inet_ntoa, length is 1, should be 4 at C:\ip.pl
line 16
I would expect a print of 10.1.1.254. What I want to do is expand this
to start at 10.1.1.1 and give me the next available address, even if
in the middle, from a list that could span into 10.1.2.0, 10.1.3.0,
etc. Thanks again!
use Socket qw(inet_aton inet_ntoa);
foreach ( 1 .. 253) { $ips .= "10.1.1.$_ "; }
# my @readable = qw(10.1.1.1 10.1.1.2 10.1.1.3 10.1.1.10 10.1.1.4);
my @readable = qw($ips);
my @addrs = sort map inet_aton($_), @readable;
my ($mask) = @addrs or die;
chop $mask;
for my $i ( 1 .. 255 ) {
if( !@addrs or $addrs[0] ne $mask . chr($i) ) {
print inet_ntoa( $mask . chr($i) ), "\n";
exit;
} shift @addrs;
}
------------------------------
Date: 18 Jul 2003 06:45:53 -0700
From: lawrence.tierney@bipcontracts.com (Lawrence Tierney)
Subject: Daily Perl puzzle
Message-Id: <17e88dbe.0307180545.4623780b@posting.google.com>
Hello,
Anybody know of a website or similar which will, on a daily basis,
email you a perl problem or puzzle etc with the answer being provided
at a later date?
I ask because our dept. of programmers is looking for some way to sort
out the wheat from the chaff - a perl top-gun if you will.
Thanks
Lord0
------------------------------
Date: 18 Jul 2003 04:07:24 -0700
From: seldan@lore.cc (sekdab)
Subject: Re: Forcing Alphanumeric Text Entry
Message-Id: <4b21880f.0307180307.20f1266e@posting.google.com>
Wow!
Thanks for the responses, this is exactly what I need and corresponds
to what I've been reading up on regex. I am loving this language :-).
I'll start using the taint option as well; have been using -w and use
strict.
Thanks again,
Tom
"James E Keenan" <jkeen@concentric.net> wrote in message news:<bf7ncb$gc4@dispatch.concentric.net>...
> "Steve" <me@home.com> wrote in message
> news:uh1fhvkfuh82tu1tpa1gie6rv54h166k0g@4ax.com...
> > Hi Tom,
> >
> > I'm still kind of new to this, but have been reading up on the topic.
> > For security, you want to first investigate using the -T taint switch:
> >
> > #!/usr/bin/perl -Tw
> >
> > This now makes the script die if unsafe data (input from outside of
> > the script) is used in a dangerous way.
> >
> > Then, to untaint the data, you need to use backreferences (I think
> > this is what it is called):
> >
> > if ($key =~ /^([-_\w\s]+)$/) {
> > $key = $1
> > } else {
> bad_data ($bad_string)
> > }
> >
> Right code; wrong terminology. $1 is a 'match variable': it captures what
> was matched in the 1st pair of parentheses and stores it in a variable. A
> backreference (written \1 \2 \3 and so on) is a way of re-using a match
> within the same regular expression pattern.
>
> my $string = 'aaabacabad';
> # my $string = 'aaabacad';
> if ($string =~ /(ab).*\1/) {
> print "Pattern matched in $string\n";
> my $cap = $1;
> print "$cap was captured\n";
> } else {
> print "Out of luck, buddy\n";
> }
------------------------------
Date: Fri, 18 Jul 2003 08:11:12 -0500
From: "Boudga" <bruce@ghbraille.com>
Subject: Re: HTML REGEX
Message-Id: <vhfs53l8uohgba@corp.supernews.com>
I tried this "s/<+\s*STYLE(.*?)>+.+<+\s*\/STYLE(.*?)>+//gis" verbose and it
didn't work at all for me!?!?!?
Here's the whole script that I am currently working with...
----------------------------------------------------
#!/usr/bin/perl
$ARGV[0] =~ /(.*)\.([^\.]*)/;
$outfile = "$1_cleaned.$2";
open (INFILE, "<$ARGV[0]");
open (OUTFILE, ">$outfile");
$outline="";
while($outline=<INFILE>){
$outline =~ s/\n/ /gis;
$outline =~ s/<body.*?>/<bodymatter>\n/gi;
$outline =~ s/<p class=footnote>/<footnote>/gi;
$outline =~ s/<p.*?>/<p>/gi;
$outline =~ s/<b>/<strong>/gi;
$outline =~ s/<\/b>/<\/strong>/gi;
$outline =~ s/<td.*>/<td>/gi;
$outline =~ s/ //gi;
$outline =~ s/<meta.*>//gi;
$outline =~ s/<div.*?>//gi;
$outline =~ s/<span.*?>/[0]/ig;
$outline =~ s/<\/span>//gi;
$outline =~ s/<\/body>/<\/bodymatter>/gi;
$outline =~ s/<\/p>/<\/p>\n/gi;
$outline =~ s/<br.*?>//gi;
$outline =~ s/<+\s*STYLE(.*?)>+.+<+\s*\/STYLE(.*?)>+//gis;
$outline =~ s/<\/div>//gi;
$outline =~ s/<html>/<\?xml version\=\"1\.0\"
encoding\=\"UTF\-8\"\?>\n<dtbook version\=\"1\.1\.0\">\n/gi;
$outline =~ s/<head>/<head>\n/gi;
$outline =~ s/<\/head>/\n<\/head>\n<book>\n/gi;
$outline =~ s/<\/title>/<\/title>\n/gi;
$outline =~ s/<tab.*>/<table>\n/gi;
$outline =~ s/<\/table>/<\/table>\n/gi;
$outline =~ s/<\/tr>/<\/tr>\n/gi;
$outline =~ s/<tr>/<tr>\n/gi;
$outline =~ s/<\/td>/<\/td>\n/gi;
#$outline =~ s///gi;
print OUTFILE "$outline";
}
print OUTFILE "$outline";
close INFILE;
close OUTFILE;
------------------------------------------
"Janek Schleicher" <bigj@kamelfreund.de> wrote in message
news:<pan.2003.07.18.04.19.00.434799@kamelfreund.de>...
> Brendan Byrd/SineSwiper wrote at Fri, 18 Jul 2003 00:22:34 +0000:
>
> > Boudga wrote:
> >
> >> I want to remove the Style tags from my HTML files so I wrote this
> >> Perl script to remove the line breaks and attempt to remove the
> >> Style tags but it fails....any help would be much appreciated!
> >
> > I've got one that does that:
> >
> > $j =~ s/<+\s*STYLE(.*?)>+.+<+\s*\/STYLE(.*?)>+//gis
> ^^
> .+?
>
> >
> > Should remove the style tags and any contents thereof.
>
> In the hope that there are not more than only one style elements (what
> is to be fair really rare).
>
>
> Greetings,
> Janek
"Janek Schleicher" <bigj@kamelfreund.de> wrote in message
news:pan.2003.07.18.04.19.00.434799@kamelfreund.de...
Brendan Byrd/SineSwiper wrote at Fri, 18 Jul 2003 00:22:34 +0000:
> Boudga wrote:
>
>> I want to remove the Style tags from my HTML files so I wrote this Perl
>> script to remove the line breaks and attempt to remove the Style tags but
it
>> fails....any help would be much appreciated!
>
> I've got one that does that:
>
> $j =~ s/<+\s*STYLE(.*?)>+.+<+\s*\/STYLE(.*?)>+//gis
^^
.+?
>
> Should remove the style tags and any contents thereof.
In the hope that there are not more than only one style elements
(what is to be fair really rare).
Greetings,
Janek
------------------------------
Date: Fri, 18 Jul 2003 08:13:02 -0500
From: "Boudga" <bruce@ghbraille.com>
Subject: Re: HTML REGEX
Message-Id: <vhfs8f1s7vfodf@corp.supernews.com>
I tried this "s/<+\s*STYLE(.*?)>+.+<+\s*\/STYLE(.*?)>+//gis" verbose and it
didn't work at all for me!?!?!?
Here's the whole script that I am currently working with...
----------------------------------------------------
#!/usr/bin/perl
$ARGV[0] =~ /(.*)\.([^\.]*)/;
$outfile = "$1_cleaned.$2";
open (INFILE, "<$ARGV[0]");
open (OUTFILE, ">$outfile");
$outline="";
while($outline=<INFILE>){
$outline =~ s/\n/ /gis;
$outline =~ s/<body.*?>/<bodymatter>\n/gi;
$outline =~ s/<p class=footnote>/<footnote>/gi;
$outline =~ s/<p.*?>/<p>/gi;
$outline =~ s/<b>/<strong>/gi;
$outline =~ s/<\/b>/<\/strong>/gi;
$outline =~ s/<td.*>/<td>/gi;
$outline =~ s/ //gi;
$outline =~ s/<meta.*>//gi;
$outline =~ s/<div.*?>//gi;
$outline =~ s/<span.*?>/[0]/ig;
$outline =~ s/<\/span>//gi;
$outline =~ s/<\/body>/<\/bodymatter>/gi;
$outline =~ s/<\/p>/<\/p>\n/gi;
$outline =~ s/<br.*?>//gi;
$outline =~ s/<+\s*STYLE(.*?)>+.+<+\s*\/STYLE(.*?)>+//gis;
$outline =~ s/<\/div>//gi;
$outline =~ s/<html>/<\?xml version\=\"1\.0\"
encoding\=\"UTF\-8\"\?>\n<dtbook version\=\"1\.1\.0\">\n/gi;
$outline =~ s/<head>/<head>\n/gi;
$outline =~ s/<\/head>/\n<\/head>\n<book>\n/gi;
$outline =~ s/<\/title>/<\/title>\n/gi;
$outline =~ s/<tab.*>/<table>\n/gi;
$outline =~ s/<\/table>/<\/table>\n/gi;
$outline =~ s/<\/tr>/<\/tr>\n/gi;
$outline =~ s/<tr>/<tr>\n/gi;
$outline =~ s/<\/td>/<\/td>\n/gi;
#$outline =~ s///gi;
print OUTFILE "$outline";
}
print OUTFILE "$outline";
close INFILE;
close OUTFILE;
------------------------------------------
"Janek Schleicher" <bigj@kamelfreund.de> wrote in message
news:<pan.2003.07.18.04.19.00.434799@kamelfreund.de>...
> Brendan Byrd/SineSwiper wrote at Fri, 18 Jul 2003 00:22:34 +0000:
>
> > Boudga wrote:
> >
> >> I want to remove the Style tags from my HTML files so I wrote this
> >> Perl script to remove the line breaks and attempt to remove the
> >> Style tags but it fails....any help would be much appreciated!
> >
> > I've got one that does that:
> >
> > $j =~ s/<+\s*STYLE(.*?)>+.+<+\s*\/STYLE(.*?)>+//gis
> ^^
> .+?
>
> >
> > Should remove the style tags and any contents thereof.
>
> In the hope that there are not more than only one style elements (what
> is to be fair really rare).
>
>
> Greetings,
> Janek
"Janek Schleicher" <bigj@kamelfreund.de> wrote in message
news:pan.2003.07.18.04.19.00.434799@kamelfreund.de...
Brendan Byrd/SineSwiper wrote at Fri, 18 Jul 2003 00:22:34 +0000:
> Boudga wrote:
>
>> I want to remove the Style tags from my HTML files so I wrote this Perl
>> script to remove the line breaks and attempt to remove the Style tags but
it
>> fails....any help would be much appreciated!
>
> I've got one that does that:
>
> $j =~ s/<+\s*STYLE(.*?)>+.+<+\s*\/STYLE(.*?)>+//gis
^^
.+?
>
> Should remove the style tags and any contents thereof.
In the hope that there are not more than only one style elements
(what is to be fair really rare).
Greetings,
Janek
------------------------------
Date: 18 Jul 2003 06:16:10 -0700
From: simon.tneoh@mybiz.net (Simon Tneoh)
Subject: HTTP::Request failed on HTTP/1.1 and Connection: Keep-Alive
Message-Id: <a07bdd22.0307180516.3c1d95e2@posting.google.com>
Hello all,
Thanks in advance for any helps provided.
I try to download a page through GET method with protocol HTTP/1.1
by
using HTTP::Request module and it fails.
The page is downloaded properly through IE and the headers are:
--------------------------------------------------------------------------------
GET /filepath HTTP/1.1
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg,
application/vnd.ms-excel, application/msword,
application/vnd.ms-powerpoint, */*
Accept-Language: ms
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 5.0; Windows NT; DigExt)
Host: servername
Connection: Keep-Alive
--------------------------------------------------------------------------------
I did a telnet server 80 test and found out that HTTP/1.1,
Connection and
Host are the required headers. The others can be ignored.
So I added these settings into HTTP::Request, but still failed.
The $request->as_string() shows:
--------------------------------------------------------------------------------
GET http://server/filepath HTTP/1.1
Connection: Keep-Alive
Host: server
--------------------------------------------------------------------------------
The error is:
--------------------------------------------------------------------------------
Apache Tomcat/4.0.4 - HTTP Status 500 - Internal Server Error
type Exception report
message Internal Server Error
description The server encountered an internal error (Internal Server
Error) that prevented it from fulfilling this request.
exception
java.lang.NullPointerException
at java.util.Calendar.setTime(Calendar.java:882)
at java.text.SimpleDateFormat.format(SimpleDateFormat.java:400)
at java.text.DateFormat.format(DateFormat.java:305)
at PolicyDetail.doGet(PolicyDetail.java:114)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:243)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:190)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2347)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:170)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:468)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.connector.http.HttpProcessor.process(HttpProcessor.java:1027)
at org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.java:1125)
at java.lang.Thread.run(Thread.java:484)
--------------------------------------------------------------------------------
Just wonder what have I missed out here that caused the download
failed?
Thanks.
Regards,
Simon.
------------------------------
Date: 18 Jul 2003 13:34:57 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: HTTP::Request failed on HTTP/1.1 and Connection: Keep-Alive
Message-Id: <slrnbhfts1.1e7.abigail@alexandra.abigail.nl>
Simon Tneoh (simon.tneoh@mybiz.net) wrote on MMMDCVIII September MCMXCIII
in <URL:news:a07bdd22.0307180516.3c1d95e2@posting.google.com>:
-: Hello all,
-: Thanks in advance for any helps provided.
-: I try to download a page through GET method with protocol HTTP/1.1
-: by
-: using HTTP::Request module and it fails.
And the error you show us is a Java trace. The Java program makes
one of the most common errors in Java programs: nullpointer
exception.
But Java has *nothing* to do with the charter of this group.
Abigail
--
#!/opt/perl/bin/perl -- # Remove trailing newline!
BEGIN{$SIG{__WARN__}=sub{$_=pop;y-_- -;print/".*(.)"/;
truncate$0,-1+-s$0;exec$0;}}//rekcaH_lreP_rehtona_tsuJ
------------------------------
Date: Fri, 18 Jul 2003 13:22:28 +0000
From: ttnguyen <member33560@dbforums.com>
Subject: Import - Read file
Message-Id: <3126185.1058534548@dbforums.com>
Hello,
I have been working with ColdFusion and DB2 for about 1 month. I have a
question and hope someone could me me with.
"How can I import an excel file to DB2 table"?
Your help would be appreciated.
-Thien
--
Posted via http://dbforums.com
------------------------------
Date: Fri, 18 Jul 2003 08:16:37 -0500
From: "Bob" <rpl-erroroneous@goldengate.net>
Subject: need 2 digit dd/mm output
Message-Id: <3f17f31a$0$100$8f4e7992@newsreader.goldengate.net>
x-no-archive:yes
need to have host get date and use in outputfile name. mon and day has to
be two digits.
ex: spc20030702.kdg
ex:
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday)=localtime(time);
print "spc$year$mon$mday.kdg\n";
results in: spc2003718.kdg and I need spc20030718.kdg
thanks
------------------------------
Date: Fri, 18 Jul 2003 08:20:24 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: need 2 digit dd/mm output
Message-Id: <87el0oug2v.fsf@limey.hpcc.uh.edu>
>> On Fri, 18 Jul 2003 08:16:37 -0500,
>> "Bob" <rpl-erroroneous@goldengate.net> said:
> need to have host get date and use in outputfile name.
> mon and day has to be two digits. ex: spc20030702.kdg
perldoc POSIX
strftime
%Y%m%d
hth
t
------------------------------
Date: Fri, 18 Jul 2003 14:05:25 GMT
From: "Vladimir P." <vladimir@NoSpamPLZ.net>
Subject: Re: need 2 digit dd/mm output
Message-Id: <F8TRa.4700$d34.173390@weber.videotron.net>
On Fri, 18 Jul 2003 08:16:37 -0500, Bob wrote:
>
> need to have host get date and use in outputfile name. mon and day has to
> be two digits.
> ex: spc20030702.kdg
>
Here is one way of doing it:
($yr,$mon,$day) = (localtime)[5,4,3];
$yr+=1900,$mon++;
printf "spc%4d%02d%02d.kdg",$yr,$mon,$day;
--
.signature: No such file or directory
------------------------------
Date: Fri, 18 Jul 2003 18:26:59 +0530
From: Thens <thens@nospam.com>
Subject: prime ??
Message-Id: <20030718182659.09a76915.thens@nospam.com>
On 18 Jul 2003 12:51:04 GMT
Abigail <abigail@abigail.nl> wrote:
>
>
>Abigail
>perl -wle '(1 x $_) !~ /^(11+)\1+$/ && print while ++ $_'
This prints 1 which is not a prime !!
Regards,
Thens.
------------------------------
Date: 18 Jul 2003 13:16:17 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: prime ??
Message-Id: <slrnbhfsp1.1e7.abigail@alexandra.abigail.nl>
Thens (thens@nospam.com) wrote on MMMDCVIII September MCMXCIII in
<URL:news:20030718182659.09a76915.thens@nospam.com>:
~~ On 18 Jul 2003 12:51:04 GMT
~~ Abigail <abigail@abigail.nl> wrote:
~~
~~ >
~~ >
~~ >Abigail
~~
~~ >perl -wle '(1 x $_) !~ /^(11+)\1+$/ && print while ++ $_'
~~
~~ This prints 1 which is not a prime !!
Yes, and? The program prints all positive non-composite numbers.
Can you decomposite 1 into 2 different positive integers?
Abigail
--
BEGIN {my $x = "Knuth heals rare project\n";
$^H {integer} = sub {my $y = shift; $_ = substr $x => $y & 0x1F, 1;
$y > 32 ? uc : lc}; $^H = hex join "" => 2, 1, 1, 0, 0}
print 52,2,10,23,16,8,1,19,3,6,15,12,5,49,21,14,9,11,36,13,22,32,7,18,24;
------------------------------
Date: Sat, 19 Jul 2003 14:36:37 +0200
From: "bruno_storz" <bruno_storz@gmx.de>
Subject: regl expression
Message-Id: <bf8pmn$nj9$07$1@news.t-online.com>
Hi there,
I wonder, why this reg. expression does not replace this:
$line = "<title><!-- HTML_titel --></title>";
$html{'titel'} = "my Titel";
$line =~ s/<!-- HTML_([a-z]+) -->/$htmlref->{$1}/gix;
Any ideas?
Regards
Bruno
------------------------------
Date: 18 Jul 2003 12:51:04 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: regl expression
Message-Id: <slrnbhfr9o.17k.abigail@alexandra.abigail.nl>
bruno_storz (bruno_storz@gmx.de) wrote on MMMDCIX September MCMXCIII in
<URL:news:bf8pmn$nj9$07$1@news.t-online.com>:
[] Hi there,
[]
[] I wonder, why this reg. expression does not replace this:
[]
[] $line = "<title><!-- HTML_titel --></title>";
[] $html{'titel'} = "my Titel";
[] $line =~ s/<!-- HTML_([a-z]+) -->/$htmlref->{$1}/gix;
What's in $htmlref?
Abigail
--
perl -wle '(1 x $_) !~ /^(11+)\1+$/ && print while ++ $_'
------------------------------
Date: Fri, 18 Jul 2003 15:34:30 +0200
From: "bruno_storz" <bruno_storz@gmx.de>
Subject: Re: regl expression
Message-Id: <bf8t33$4vg$02$1@news.t-online.com>
> [] Hi there,
> []
> [] I wonder, why this reg. expression does not replace this:
> []
> [] $line = "<title><!-- HTML_titel --></title>";
> [] $html{'titel'} = "my Titel";
> [] $line =~ s/<!-- HTML_([a-z]+) -->/$htmlref->{$1}/gix;
>
>
> What's in $htmlref?
a more complete code snipplet:
$html{'titel'} = "my Titel";
$template = "aFile.html";
....
print &html_export( $template, \%html);
sub html_export {
$line = "<title><!-- HTML_titel --></title>";
my ($htmlref) = @_;
$line =~ s/<!-- HTML_([a-z]+) -->/$htmlref->{$1}/gix;
....
}
I want to replace the comment ><!-- HTML_titel --> by somthing, which is in
the hash $html.
regards Bruno
------------------------------
Date: Fri, 18 Jul 2003 10:18:05 -0400
From: Jeff 'japhy' Pinyan <pinyaj@rpi.edu>
Subject: Re: regl expression
Message-Id: <Pine.SGI.3.96.1030718101716.82447A-100000@vcmr-64.server.rpi.edu>
On Fri, 18 Jul 2003, bruno_storz wrote:
>print &html_export( $template, \%html);
You send TWO arguments here...
> sub html_export {
> $line = "<title><!-- HTML_titel --></title>";
> my ($htmlref) = @_;
But you store the FIRST one as $htmlref. The second argument is the hash
ref.
my ($tpl, $htmlref) = @_;
> $line =~ s/<!-- HTML_([a-z]+) -->/$htmlref->{$1}/gix;
>....
>}
--
Jeff Pinyan RPI Acacia Brother #734 2003 Rush Chairman
"And I vos head of Gestapo for ten | Michael Palin (as Heinrich Bimmler)
years. Ah! Five years! Nein! No! | in: The North Minehead Bye-Election
Oh. Was NOT head of Gestapo AT ALL!" | (Monty Python's Flying Circus)
------------------------------
Date: 18 Jul 2003 14:28:06 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: regl expression
Message-Id: <slrnbhg0vm.1i6.abigail@alexandra.abigail.nl>
bruno_storz (bruno_storz@gmx.de) wrote on MMMDCVIII September MCMXCIII in
<URL:news:bf8t33$4vg$02$1@news.t-online.com>:
'' > [] Hi there,
'' > []
'' > [] I wonder, why this reg. expression does not replace this:
'' > []
'' > [] $line = "<title><!-- HTML_titel --></title>";
'' > [] $html{'titel'} = "my Titel";
'' > [] $line =~ s/<!-- HTML_([a-z]+) -->/$htmlref->{$1}/gix;
'' >
'' >
'' > What's in $htmlref?
''
'' a more complete code snipplet:
''
'' $html{'titel'} = "my Titel";
'' $template = "aFile.html";
'' ....
'' print &html_export( $template, \%html);
''
'' sub html_export {
'' $line = "<title><!-- HTML_titel --></title>";
'' my ($htmlref) = @_;
'' $line =~ s/<!-- HTML_([a-z]+) -->/$htmlref->{$1}/gix;
'' ....
'' }
Try running it with warnings turned on. Or even better, with
strict turned on. I expect that Perl will tell you what
went wrong....
And please don't send me stealth Cc's anymore.
Abigail
--
BEGIN {$^H {q} = sub {$_ [1] =~ y/S-ZA-IK-O/q-tc-fe-m/d; $_ [1]}; $^H = 0x28100}
print "Just another PYTHON hacker\n";
------------------------------
Date: 18 Jul 2003 07:45:42 -0700
From: jimnl69@hotmail.com (Jim)
Subject: Removing characters once a series stops
Message-Id: <3966ee66.0307180645.1bf4f959@posting.google.com>
I have strings that I need to get the first set of numbers from. IE:
ABC123DEF
ABC11JH8KLZ
I need to get 123 and 11 from the from the above strings. I can strip
the first characters off with =~ s/\D*//; but how do I strip off
everything else, even any additional numbers, after the first set of
numbers ends? Thanks!
J
------------------------------
Date: 18 Jul 2003 14:59:16 GMT
From: "James E Keenan" <jkeen@concentric.net>
Subject: Re: Removing characters once a series stops
Message-Id: <bf9204$be1@dispatch.concentric.net>
"Jim" <jimnl69@hotmail.com> wrote in message
news:3966ee66.0307180645.1bf4f959@posting.google.com...
> I have strings that I need to get the first set of numbers from. IE:
>
> ABC123DEF
> ABC11JH8KLZ
>
> I need to get 123 and 11 from the from the above strings. I can strip
> the first characters off with =~ s/\D*//; but how do I strip off
> everything else, even any additional numbers, after the first set of
> numbers ends? Thanks!
>
If you simply need to "get" the first set of numbers from the string, then a
simple pattern match should do:
my ($string, $capture);
if ($string =~ /^\D*(\d+)/) {
$capture = $1;
}
I don't think you would need to do a substitution unless you wanted to
entirely replace $string with $capture.
------------------------------
Date: Fri, 18 Jul 2003 09:50:16 -0400
From: "Domenico Discepola" <domenico_discepola@quadrachemicals.com>
Subject: Re: tab delimited file processing problem
Message-Id: <VYSRa.43068$PD3.4432101@nnrp1.uunet.ca>
"Greg Bacon" <gbacon@hiwaay.net> wrote in message
news:vhe5ainqmno028@corp.supernews.com...
> In article <698c67f.0307171302.5b601332@posting.google.com>,
> Domenico Discepola <joeminga@yahoo.com> wrote:
>
> : [...]
> : Example Excel file row:
> : col A's value=<empty>
> : col B's value = "1"
> : col C's value = "2"
> : <end of row>
> :
> : When you use Win32::OLE to "tell" Excel to save this as a TSV file
(using
> : the SaveAs method), a hex-dump of the resultant TSV file reveals row1
as:
> : /^\t12$/ (using regex notation). In other words, I lose the existence
of
> : col A (which I need).
>
> How have you lost column A? Consider the example below:
>
> C:\Temp>type try
> #! perl
>
> use warnings;
> use strict;
>
> use Data::Dumper;
>
> my $data = "\t12";
> my @fields = split /\t/, $data;
>
> print Dumper \@fields;
>
> C:\Temp>perl try
> $VAR1 = [
> '',
> '12'
> ];
>
> Are you sure there wasn't a TAB between the 1 and the 2? Even so,
> you're still happy; note that the first element of @fields is empty:
>
> #! perl
>
> use warnings;
> use strict;
>
> use Data::Dumper;
>
> my $data = "\t1\t2";
> my @fields = split /\t/, $data;
>
> print Dumper \@fields;
>
> C:\Temp>perl try
> $VAR1 = [
> '',
> '1',
> '2'
> ];
>
> How were you trying to extract the fields in your TSV file?
>
> Technical side note: what you're calling tab-delimited is really
> tab-separated. Using [TAB] to make things stand out, a tab-delimited
> record would look like
>
> [TAB]field_1[TAB]field_2[TAB]...[TAB]field_n[TAB]
>
> Tab-*separated*, however, would look like
>
> field_1[TAB]field_2[TAB]...[TAB]field_n
>
> Hope this helps,
> Greg
> --
> It remains true today as it did in fascist Italy, socialist Germany, New
> Deal America, and socialist Russia: freedom has no greater opponents than
> those who despise and demonize commercial society.
> -- Lew Rockwell
1st off, you're right - my regex describing my output from Excel was
incorrect - it should have read (as you suggested) /^\t1\t2$/
2nd, I did mean tab separated (instead of tab delimited). 3rd, thanks for
mentioning the Data::Dumper module, I hadn't heard of that - I'll check it
out. Right off the bat it seems to help diagnosing my problem.
------------------------------
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 5237
***************************************