[23705] in Perl-Users-Digest
Perl-Users Digest, Issue: 5911 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Dec 8 14:06:09 2003
Date: Mon, 8 Dec 2003 11:05:17 -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 Mon, 8 Dec 2003 Volume: 10 Number: 5911
Today's topics:
Re: A problem while testing MPEG-LibMPEG3-0.01 (xern)
Re: Am I right on Mod_Perl? (Anno Siegel)
Re: Am I right on Mod_Perl? <usenet@dwall.fastmail.fm>
Re: Another sort question. (Mal)
Re: Another sort question. <asu1@c-o-r-n-e-l-l.edu>
Re: appending to file appends twice!? <nobull@mail.com>
Re: Do we just use different file handles when we want (Sara)
Re: Do we just use different file handles when we want <matthew.garrish@sympatico.ca>
editing challenge: Perl vs. cfengine <tzz@lifelogs.com>
Re: Getting return code from a child process (Jon)
Help with formatting output with Text::Table <mothra@nowhereatall.com>
Re: How to write to drive A:\ from CGI Perl <asu1@c-o-r-n-e-l-l.edu>
HTTP::Date parse_date problem <rubberducky703@hotmail.com>
Re: HTTP::Date parse_date problem <trammell+usenet@hypersloth.invalid>
Re: HTTP::Date parse_date problem <mothra@nowhereatall.com>
Re: HTTP::Date parse_date problem <john.thetenant-s@moving-picture.com>
Re: HTTP::Date parse_date problem <xx087@freenet.carleton.ca>
Re: HTTP::Date parse_date problem <xx087@freenet.carleton.ca>
Re: HTTP::Date parse_date problem <mothra@nowhereatall.com>
Re: Module installation and permissions <matthew.garrish@sympatico.ca>
open/seek vs IO::Open/setpos news@roaima.freeserve.co.uk
Re: open/seek vs IO::Open/setpos <joost@rot13-ubeghf-zrpunavphf-rot13.net>
Re: Perl2EXE vs. PAR vs. perlcc <simon.andrews@bbsrc.ac.uk>
Re: Processing array elements without iterative loop (Anno Siegel)
Re: q on 'record', 'field' separators in text files <Juha.Laiho@iki.fi>
Ranging to 'z' (John M. Gamble)
Reading slective columns from *.csv file (Nithin)
Re: sorting file names (Ingo Menger)
Re: string matching question. <emschwar@pobox.com>
Re: string matching question. <noreply@gunnar.cc>
Re: Validate Excel Range with RegEx <pinyaj@rpi.edu>
Re: Validate Excel Range with RegEx <asu1@c-o-r-n-e-l-l.edu>
Re: Validate Excel Range with RegEx (James E Keenan)
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 8 Dec 2003 06:44:45 -0800
From: xern@cpan.org (xern)
Subject: Re: A problem while testing MPEG-LibMPEG3-0.01
Message-Id: <297c4cc7.0312080644.1b87f2e1@posting.google.com>
Ben Morrow <usenet@morrow.me.uk> wrote in message news:<bqo0ms$sn2$6@wisteria.csv.warwick.ac.uk>...
> xern@cpan.org (xern) wrote:
> > The error message is as follows.
> >
> > Can't load 'blib/arch/auto/MPEG/LibMPEG3/LibMPEG3.so' for module
> > MPEG::LibMPEG3:
> > blib/arch/auto/MPEG/LibMPEG3/LibMPEG3.so: undefined symbol:
> > mpeg3_seek_percentage at
> > /usr/local/lib/perl5/5.8.1/i686-linux/DynaLoader.pm line 229. at
> > test.pl line 18
> >
> > I've got libmpeg3.a successfully installed, and have written a C
> > program to test libmpeg3, which was good. I'm curious about why this
> > error would happen. The author's email seems broken, so I cannot reach
> > him for the answer. Hope someone can give me the solution.
>
> Are the versions compatible? What do you get from
>
> nm /path/to/libmpeg3.a | grep mpeg3_seek_percentage
>
Hmm, seems the perl module doesn't follow up to libmpeg3.
Anyway, thanks.
------------------------------
Date: 8 Dec 2003 13:15:02 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Am I right on Mod_Perl?
Message-Id: <br1tgm$svu$2@mamenchi.zrz.TU-Berlin.DE>
Randal L. Schwartz <merlyn@stonehenge.com> wrote in comp.lang.perl.misc:
> >>>>> "Picker" == Picker Leon <Temp@NoSuchDomain.Info> writes:
>
> Picker> If I have take care of the globle varible by either make no
> Picker> globle varibles, or by clean them each time before I use them
> Picker> and after I use them, I can pretty much use the same code of
> Picker> my perl in mod_perl enviroment.
>
> Perhaps you are confusing all of mod_perl with the one thing of the
> Apache::Registry module used with mod_perl.
>
> Picker> Please correct me if I am wrong.
>
> Asking for that is implied. :) You're in CLPM, remember? :)
s/CLPM/Usenet/
Anno
------------------------------
Date: Mon, 08 Dec 2003 17:05:40 -0000
From: "David K. Wall" <usenet@dwall.fastmail.fm>
Subject: Re: Am I right on Mod_Perl?
Message-Id: <Xns944B7B07D18CFdkwwashere@216.168.3.30>
Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> wrote:
> Randal L. Schwartz <merlyn@stonehenge.com> wrote in
> comp.lang.perl.misc:
>> >>>>> "Picker" == Picker Leon <Temp@NoSuchDomain.Info> writes:
>>
>> Picker> Please correct me if I am wrong.
>>
>> Asking for that is implied. :) You're in CLPM, remember? :)
>
> s/CLPM/Usenet/
"the best way to get accurate information on Usenet is to post
something wrong and wait for corrections"
--Matthew Austern, in rec.arts.sf-written
<dilvghnrzkk.fsf@isolde.research.att.com>
------------------------------
Date: 8 Dec 2003 08:05:29 -0800
From: mpatt644@yahoo.com (Mal)
Subject: Re: Another sort question.
Message-Id: <66f79aeb.0312080805.1b42ed84@posting.google.com>
> ^^^^^
> Well, it kind of works. Not under strict, though, and it produces
> a number of rather severe warnings ("substr outside of string..."),
> which shows that the program doesn't understand the data correctly.
>
> > and then by time. However I want to change it so that the time fields
>
> [snip]
>
> Please first fix the program so that it runs cleanly under strict and
> warnings, so we have a solid base to build on. I'm pretty sure what
> you want can be done by simple modifications of your code, so the effort
> won't be lost. At the moment, it is hard to tell what part of your
> program's behavior is intended and what is buggy.
>
> Anno
When I said "the data looks something like this" it was only a very
rough idea, and in actual fact the string lengths & positions were not
nearly correct. Anyway here's a "cleaned up" version complete with a
bit at the start which will create some test data of the correct
length. Note that in real life this data is coming at me from an
application over which I have no control, the output is supposed to be
human readable and the positions of some of the fields may vary:
TIA for any more feedback.
use strict;
#
# Create some test data
#
open(testout,">test.dat");
print testout "Enabled blah,blah,blah 18:30\n";
print testout "Enabled blah,blah,blah 23:30\n";
print testout "Disabled blah,blah,blah 18:00\n";
print testout "Enabled blah,blah,blah 3:50\n";
print testout "Enabled blah,blah,blah 20:50\n";
print testout "Disabled blah,blah,blah 19:30\n";
print testout "Enabled blah,blah,blah 23:40\n";
print testout "Enabled blah,blah,blah 1:30\n";
close(testout);
open(test,"test.dat");
chomp (my @results=<test>);
foreach (sort {
my $aEnabledField=substr($a,0,20);
my $bEnabledField=substr($b,0,20);
(my $aHourField,my $aMinField)=split
/:/,substr($a,38,20);
(my $bHourField,my $bMinField)=split
/:/,substr($b,38,20);
$aEnabledField cmp $bEnabledField
||
$aHourField <=> $bHourField
||
$aMinField <=> $bMinField
} @results) {
print "$_\n";
}
------------------------------
Date: 8 Dec 2003 18:26:29 GMT
From: "A. Sinan Unur" <asu1@c-o-r-n-e-l-l.edu>
Subject: Re: Another sort question.
Message-Id: <Xns944B88BCED45asu1cornelledu@132.236.56.8>
mpatt644@yahoo.com (Mal) wrote in news:66f79aeb.0312080805.1b42ed84
@posting.google.com:
>> won't be lost. At the moment, it is hard to tell what part of your
>> program's behavior is intended and what is buggy.
...
>
> When I said "the data looks something like this" it was only a very
> rough idea, and in actual fact the string lengths & positions were not
> nearly correct. Anyway here's a "cleaned up" version complete with a
> bit at the start which will create some test data of the correct
> length.
Find out about the DATA file handle and __DATA__ section.
> Note that in real life this data is coming at me from an
> application over which I have no control,
Does the application change its output format at certain intervals?
> the positions of some of the fields may vary:
In that case, techniques based on using the exact position of each field
are useless.
> use strict;
> #
> # Create some test data
> #
> open(testout,">test.dat");
Always check if open succeeded. Also, turn on warnings:
use warnings;
Unquoted string "testout" may clash with future reserved word at C:\Home
\bzzt.pl line 9.
Unquoted string "test" may clash with future reserved word at C:\Home
\bzzt.pl line 20.
Use all caps for file handles: TESTOUT.
I really have nothing else to say about the rest of the code you posted
because I have a mental block against huge indents, line wraps, annoyingly
long variable names.
I put together something below. It probably is not the neatest way to do
it.
use strict;
use warnings;
my @data = <DATA>;
my @sorted = sort my_compare @data;
print @sorted;
sub my_compare {
my @aa;
my @bb;
if($a =~ /^(\w+)\s+.+\s+(\d{1,2}):(\d\d)$/) {
push @aa, $1, $2, $3;
}
if($b =~ /^(\w+)\s+.+\s+(\d{1,2}):(\d\d)$/) {
push @bb, $1, $2, $3;
}
return 1 unless(@aa);
return -1 unless(@bb);
return -1 if $aa[0] eq "Enabled" and $bb[0] eq "Disabled";
return 1 if $aa[0] eq "Disabled" and $bb[0] eq "Enabled";
if($aa[0] eq $bb[0]) {
return 1 if $aa[1] < 17 and $bb[1] > 17;
return -1 if $aa[1] > 17 and $bb[1] < 17;
return $aa[2] <=> $bb[2] if $aa[1] == $bb[1];
return $aa[1] <=> $bb[1];
}
}
__DATA__
Enabled blah,blah,blah 18:30
Enabled blah,blah,blah 23:30
Disabled blah,blah,blah 18:00
Enabled blah,blah,blah 3:50
Enabled blah,blah,blah 20:50
Disabled blah,blah,blah 19:30
Enabled blah,blah,blah 23:40
Enabled blah,blah,blah 1:30
C:\Home> bzzt.pl
Enabled blah,blah,blah 18:30
Enabled blah,blah,blah 20:50
Enabled blah,blah,blah 23:30
Enabled blah,blah,blah 23:40
Enabled blah,blah,blah 1:30
Enabled blah,blah,blah 3:50
Disabled blah,blah,blah 18:00
Disabled blah,blah,blah 19:30
--
A. Sinan Unur
asu1@c-o-r-n-e-l-l.edu
Remove dashes for address
Spam bait: mailto:uce@ftc.gov
------------------------------
Date: 08 Dec 2003 17:48:17 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: appending to file appends twice!?
Message-Id: <u9iskrp5em.fsf@wcl-l.bham.ac.uk>
tadmc@augustmail.com (Tad McClellan) writes:
> Guy <someone@somewhere.nb.ca> wrote:
> > @qafield=();
> > push(@qafield,split(/\t/,$qaline));
> > $number=$qafield[0];
>
>
> You can replace those 3 lines with one line that uses a "list slice":
>
> my $number = (split(/\t/,$qaline))[0]; # untested
Or, better still, a list assignment:
my ($number) = split(/\t/,$qaline); # untested
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: 8 Dec 2003 05:46:30 -0800
From: genericax@hotmail.com (Sara)
Subject: Re: Do we just use different file handles when we want to have multiple files open at the same time...?
Message-Id: <776e0325.0312080546.33c1f754@posting.google.com>
"Matt Garrish" <matthew.garrish@sympatico.ca> wrote in message news:<6TTAb.6796$3y1.505664@news20.bellglobal.com>...
> "James Willmore" <jwillmore@remove.adelphia.net> wrote in message
> news:20031207121845.1c9a4183.jwillmore@remove.adelphia.net...
> > On Sun, 07 Dec 2003 17:15:32 GMT
> > "Guy" <someone@somewhere.nb.ca> wrote:
> >
> > > To have many files open at the same time, do I just use a different
> > > file handle like this:
> > >
> > > open(FILEA,"$stopfil");
> > > open(FILEB,"$startfil");
> > >
> > > # some extra code goes here
> > >
> > > close(FILEA);
> > > close(FILEB);
> > >
> > > Or are there other things that have to be done also.
> >
> > That will work. However, I'd check to see if you actually opened the
> > file.
> >
> > open(FILEA,"$stopfil") or die "Open failed for $stopfil: $!\n";
> > open(FILEB,"$startfil") or die "Open failed for $starfil: $!\n";
> >
>
> I'd also drop the useless quotes:
>
> open(FILEA, $stopfil) or die "Open failed for $stopfil: $!\n";
> open(FILEB, $startfil) or die "Open failed for $starfil: $!\n";
>
> Matt
might as well clean things up a little more while were at it..
die "Why me?\n\n" unless ( open FILEA, $stopfil ) && open FILEB, $startfil;
G
------------------------------
Date: Mon, 8 Dec 2003 09:01:34 -0500
From: "Matt Garrish" <matthew.garrish@sympatico.ca>
Subject: Re: Do we just use different file handles when we want to have multiple files open at the same time...?
Message-Id: <2v%Ab.7978$3y1.663063@news20.bellglobal.com>
"Sara" <genericax@hotmail.com> wrote in message
news:776e0325.0312080546.33c1f754@posting.google.com...
> "Matt Garrish" <matthew.garrish@sympatico.ca> wrote in message
news:<6TTAb.6796$3y1.505664@news20.bellglobal.com>...
> > "James Willmore" <jwillmore@remove.adelphia.net> wrote in message
> > news:20031207121845.1c9a4183.jwillmore@remove.adelphia.net...
> > >
> > > That will work. However, I'd check to see if you actually opened the
> > > file.
> > >
> > > open(FILEA,"$stopfil") or die "Open failed for $stopfil: $!\n";
> > > open(FILEB,"$startfil") or die "Open failed for $starfil: $!\n";
> > >
> >
> > I'd also drop the useless quotes:
> >
> > open(FILEA, $stopfil) or die "Open failed for $stopfil: $!\n";
> > open(FILEB, $startfil) or die "Open failed for $starfil: $!\n";
>
> might as well clean things up a little more while were at it..
>
> die "Why me?\n\n" unless ( open FILEA, $stopfil ) && open FILEB,
$startfil;
>
That's clean? You aren't getting the error message if it fails, and even if
you were how would you know which open it applied to? I personally prefer
James' method, where the file and error message are clearly identified. Why
add to your debugging time just to save a line?
Matt
------------------------------
Date: Mon, 08 Dec 2003 13:26:25 -0500
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: editing challenge: Perl vs. cfengine
Message-Id: <4n1xrf88tq.fsf@collins.bwh.harvard.edu>
This question was recently posted to the cfengine mailing list by a
cfengine user. Cfengine's 'editfiles' functionality in this
particular case is quite succinct. Can anyone do this in Perl to meet
the challenge? Of course it can be done in one line, but will it be
as elegant?
The actual sequence of commands is pretty obvious - the outer
BeginGroup/EndGroup is an if() statement, and
LocateLineMatching/IncrementPointer move the editing cursor; -3 means
to move 3 lines back in the file.
My own attempt used an array-file tie and was definitely not
as elegant.
Ted
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
How can I write a script that would perform something like the
following and would remain as elegant?
BeginGroupIfNoLineMatching "# Addition by EMC ended."
LocateLineMatching ".*. /etc/init.d/functions.*"
IncrementPointer "-3"
InsertLine "# Addition by EMC started."
InsertLine 'DHCP_HOSTNAME=${dollar}{HOSTNAME}'
InsertLine "# Addition by EMC ended."
InsertLine ""
EndGroup
Off course, this can be done, but I do not know of any scripting tool
that allows one to express the above changes so elegantly. Anybody
can translate this into sed/awk in about the same number of lines?
------------------------------
Date: 8 Dec 2003 04:19:11 -0800
From: jhayden@usa.com (Jon)
Subject: Re: Getting return code from a child process
Message-Id: <28769dad.0312080419.1fcbce29@posting.google.com>
Ben & Jim,
Thanks guys. You gave me some great information. I can do what I need to do now.
Jon
------------------------------
Date: Mon, 8 Dec 2003 07:36:18 -0800
From: "Mothra" <mothra@nowhereatall.com>
Subject: Help with formatting output with Text::Table
Message-Id: <3fd48d94@usenet.ugs.com>
Hi All,
I need some help formatting text output using Text table.
Is there a way to increase the space between the columns?
The output from what I have is:
Date Sunset Time
12/01/2003 16:42:32
12/01/2003 16:42:40
12/02/2003 16:42:32
What I would like is:
Date Sunset Time
12/01/2003 16:42:32
12/01/2003 16:42:40
12/02/2003 16:42:32
(I hope the newsreader does not screw this up)
I need to increase the space between the columns.
Also, Is there a way to add an overall title?
like:
Covenant Christian School location
Date Sunset Time
12/01/2003 16:42:32
12/01/2003 16:42:40
12/02/2003 16:42:32
Have the main title ( Coventant Christian school location) the
main center then Date (centered) Sunset Time (centered).
I hope this makes sense.
Thanks
Mothra
#!/app/perl5.8.0/bin/perl
use strict;
use warnings;
use Text::Table;
use DateTime;
use DateTime::Event::Sunrise;
my $dt = DateTime->new( year => 2003,
month => 12,
day => 01,
time_zone => 'America/Los_Angeles',
);
my $dt2 = DateTime->new( year => 2003,
month => 12,
day => 31,
time_zone => 'America/Los_Angeles',
);
my $sunset = DateTime::Event::Sunrise ->sunset(
longitude =>'-117.82399' ,
latitude => '33.80525',
);
my $dt_span = DateTime::Span->new( start =>$dt, end=>$dt2 );
my $set = $sunset->intersection($dt_span);
my $iter = $set->iterator;
my $tb = Text::Table->new(
{ title => 'Date', align_title => 'center' },
{ title => 'Sunset Time', align_title => 'center' }
);
for (1..32) {
my $tmp = $iter->next;
$tb->load(
[ $tmp->mdy('/'), $tmp->hms(':') ]
);
}
print $tb;
------------------------------
Date: 8 Dec 2003 13:39:28 GMT
From: "A. Sinan Unur" <asu1@c-o-r-n-e-l-l.edu>
Subject: Re: How to write to drive A:\ from CGI Perl
Message-Id: <Xns944B5813794BEasu1cornelledu@132.236.56.8>
canle@lecan.com (Cle) wrote in news:8a21e493.0312080237.47885c85
@posting.google.com:
> Sinan:
>
> Cle did not have 15 years of experinces in Perl, even he had bought 5
> books and online readings in Perl, with books in Linux, such
> experience can recommand a book for newbie, not yet for CGI Perl:
perldoc -q book
> Paul Haffman, author of Netscape 4 and Perl for Dummies, page 175:
> open(IN, "D:\ORDERS\DATA\JAN97.DAT");
Hmmm ... that won't do what you intended althought it does explain:
> This is what was appeared in my telnet home directory when I wrote to
> C:
> C:Documents and SettingsMyName.COMPNameDesktopOutputFile.txt
And you should always check if your call to open succeeded:
open IN, "<", "D:/ORDER/DATA/JAN97.DAT' or die "Error: $!\n";
> Sinan in first reply for this topic, article #4:
>
>>Easy:
>
>>#! C:/Perl/bin/perl.exe -T
>>
>>use strict;
>>use warnings;
Just to set the record straight: Apparently, I forgot that I typed those
characters into my first reply to you. I did not recognize this because I
was quoted with no context. Sorry.
--
A. Sinan Unur
asu1@c-o-r-n-e-l-l.edu
Remove dashes for address
Spam bait: mailto:uce@ftc.gov
------------------------------
Date: Mon, 8 Dec 2003 15:24:08 -0000
From: "Paul Tomlinson" <rubberducky703@hotmail.com>
Subject: HTTP::Date parse_date problem
Message-Id: <br252p$27h7op$1@ID-116287.news.uni-berlin.de>
use HTTP::Date
....
my ($year, $month, $day, $hour, $min, $sec, $tz) = parse_date(time2str());
why doesn't this work???
It's driving me mad, does this look like valid perl?
------------------------------
Date: Mon, 8 Dec 2003 15:46:36 +0000 (UTC)
From: "John J. Trammell" <trammell+usenet@hypersloth.invalid>
Subject: Re: HTTP::Date parse_date problem
Message-Id: <slrnbt976s.45m.trammell+usenet@hypersloth.el-swifto.com.invalid>
On Mon, 8 Dec 2003 15:24:08 -0000, Paul Tomlinson
<rubberducky703@hotmail.com> wrote:
> use HTTP::Date
----------------^
Missing semicolons are bad, mmkay?
> why doesn't this work???
http://www.catb.org/~esr/faqs/smart-questions.html
------------------------------
Date: Mon, 8 Dec 2003 07:53:17 -0800
From: "Mothra" <mothra@nowhereatall.com>
Subject: Re: HTTP::Date parse_date problem
Message-Id: <3fd4918e$1@usenet.ugs.com>
Hi Paul,
"Paul Tomlinson" <rubberducky703@hotmail.com> wrote in message
news:br252p$27h7op$1@ID-116287.news.uni-berlin.de...
> use HTTP::Date
> ....
> my ($year, $month, $day, $hour, $min, $sec, $tz) = parse_date(time2str());
>
> why doesn't this work???
>
> It's driving me mad, does this look like valid perl?
yep! it is valid perl :)
after checking the docs for this I found
This module provides functions that deal the date formats used by the
HTTP protocol (and then some more). Only the first two functions,
time2str() and str2time(), are exported by default.
So, you need to do something like
use HTTP::Date qw(parse_date time2str);
hope this helps
Mothra
------------------------------
Date: Mon, 8 Dec 2003 15:49:10 +0000
From: John Strauss <john.thetenant-s@moving-picture.com>
Subject: Re: HTTP::Date parse_date problem
Message-Id: <20031208154910.2380e0f6.john.thetenant-s@moving-picture.com>
On Mon, 8 Dec 2003 15:24:08 -0000
"Paul Tomlinson" <rubberducky703@hotmail.com> wrote:
>
> use HTTP::Date
> ....
> my ($year, $month, $day, $hour, $min, $sec, $tz) = parse_date(time2str());
>
> why doesn't this work???
>
> It's driving me mad, does this look like valid perl?
>
>
apart from the missing semicolon on the "use HTTP::Date" line,
it looks like valid perl.
otherwise the HTTP::Date docs state that parse_date() is not
exported by default. try HTTP::Date::parse_date instead.
--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drop the .thetenant to get me via mail
------------------------------
Date: 8 Dec 2003 15:43:42 GMT
From: Glenn Jackman <xx087@freenet.carleton.ca>
Subject: Re: HTTP::Date parse_date problem
Message-Id: <slrnbt9731.ar.xx087@smeagol.ncf.ca>
Paul Tomlinson <rubberducky703@hotmail.com> wrote:
> use HTTP::Date
> ....
> my ($year, $month, $day, $hour, $min, $sec, $tz) = parse_date(time2str());
>
> why doesn't this work???
Note how the HTTP::Date documentation says: "Only the first two
functions, time2str() and str2time(), are exported by default."
So:
my (...) = HTTP::Date::parse_date(time2str());
or
use HTTP::Date qw(parse_date time2str);
my (...) = parse_date(time2str());
--
Glenn Jackman
NCF Sysadmin
glennj@ncf.ca
------------------------------
Date: 8 Dec 2003 15:47:20 GMT
From: Glenn Jackman <xx087@freenet.carleton.ca>
Subject: Re: HTTP::Date parse_date problem
Message-Id: <slrnbt979r.ar.xx087@smeagol.ncf.ca>
Glenn Jackman <xx087@freenet.carleton.ca> wrote:
> Note how the HTTP::Date documentation says: "Only the first two
> functions, time2str() and str2time(), are exported by default."
>
> use HTTP::Date qw(parse_date time2str);
Upon reflection, this would be preferable:
use HTTP::Date qw(:DEFAULT parse_date);
--
Glenn Jackman
NCF Sysadmin
glennj@ncf.ca
------------------------------
Date: Mon, 8 Dec 2003 08:09:43 -0800
From: "Mothra" <mothra@nowhereatall.com>
Subject: Re: HTTP::Date parse_date problem
Message-Id: <3fd49568$1@usenet.ugs.com>
Hi Glenn,
[snipped]
> Upon reflection, this would be preferable:
>
> use HTTP::Date qw(:DEFAULT parse_date);
yep!! Thats better than my answer :)
Cool
Mothra
------------------------------
Date: Mon, 8 Dec 2003 09:13:33 -0500
From: "Matt Garrish" <matthew.garrish@sympatico.ca>
Subject: Re: Module installation and permissions
Message-Id: <hG%Ab.7994$3y1.668579@news20.bellglobal.com>
"Alexandre Jaquet" <alexj@freesurf.ch> wrote in message
news:3fd45d07$0$784$5402220f@news.sunrise.ch...
> Hi,
>
> I need to install new module on my shell but I didn't have
> a root account.
>
> I've upload and decompress the module archive in my
> home directory (/home/alexj/lib/Net-IRC)
>
Most Web hosts won't allow IRC because it hogs bandwidth. My guess is you've
been told by your admin that they won't install the module, so now you're
trying to do it on your own. Am I close, or have you bypassed the admin
entirely in the hopes of sneaking it onto the system? I would suggest that
you just learn to live without it.
Matt
------------------------------
Date: Mon, 8 Dec 2003 16:48:35 +0000
From: news@roaima.freeserve.co.uk
Subject: open/seek vs IO::Open/setpos
Message-Id: <3kmea1-7e7.ln1@news.roaima.co.uk>
I wouldn't be surprised if I'm doing something stupid here, but for the
life of me I can't see it.
Compare the following two snippets, which write and then rewrite a
sample file.
1. IO::Open and setpos
use IO;
use Fcntl;
use strict;
unlink "/tmp/x"; # Testing
my $h = new IO::File "+>/tmp/x" or die "IO::File: $!\n";
$h->print ("hello, world\n") or warn "hello: $!\n";
$h->setpos (0) or warn "setpos: $!\n";
$h->print ("goodbye\n") or warn "goodbye: $!\n";
$h->close or warn "close: $!\n";
2. open and seek
unlink "/tmp/x"; # Testing
open H, "+>/tmp/x" or die "open: $!\n";
print H "hello, world\n" or warn "hello: $!\n";
seek H, 0, 0 or warn "seek: $!\n";
print H "goodbye\n" or warn "goodbye: $!\n";
close H or warn "close: $!\n";
In case (1) I get "setpos: Invalid argument". Case (2) works.
Originally I had read the documentation for setpos to require the
following line, but that just generated a runtime usage error.
$h->setpos (0, SEEK_SET) # with Fcntl qw/:DEFAULT :seek/
Any suggestions, please? I'd prefer to use IO::File syntax, since it
gives me a little more flexibility and convenience. I've perl version
5.6.1 here.
Cheers,
Chris
--
@s=split(//,"Je,\nhn ersloak rcet thuarP");$k=$l=@s;for(;$k;$k--){$i=($i+1)%$l
until$s[$i];$c=$s[$i];print$c;undef$s[$i];$i=($i+(ord$c))%$l}
------------------------------
Date: Mon, 08 Dec 2003 17:59:52 +0100
From: "Joost Diepenmaat" <joost@rot13-ubeghf-zrpunavphf-rot13.net>
Subject: Re: open/seek vs IO::Open/setpos
Message-Id: <pan.2003.12.08.16.59.52.176540@rot13-ubeghf-zrpunavphf-rot13.net>
On Mon, 08 Dec 2003 16:48:35 +0000, new wrote:
> I wouldn't be surprised if I'm doing something stupid here, but for the
> life of me I can't see it.
...
> $h->setpos (0) or warn "setpos: $!\n";
setpos does not do wat you think it does; from the IO::Seekable
manpage:
$io->setpos
Uses the value of a previous getpos call to return to
a previously visited position. Returns "0 but true" on
success, "undef" on failure.
HTH,
Joost.
------------------------------
Date: Mon, 08 Dec 2003 15:03:25 +0000
From: Simon Andrews <simon.andrews@bbsrc.ac.uk>
Subject: Re: Perl2EXE vs. PAR vs. perlcc
Message-Id: <br23so$4ae$1@south.jnrs.ja.net>
Ralph K wrote:
> Before committing the time and effort to try one of these methods of
> producing compiled perl programs, I'd welcome the observations,
> experiences and warnings from those who have gone before.
I'd suggest PAR as the firt thing to try. Perlcc is only of academic
interest and needs a lot more work to be useful. Perl2exe (and perlapp)
cost money.
There really isn't much investment in time or effort required to get
going with PAR. You seem to be running on Windows, so assuming you're
using ActivePerl it might be as simple as:
ppm install PAR
[wait whilst PAR installs]
cd \my_perl_script_dir\
pp -o my_prog.exe my_perl_script.pl
[wait whilst your script is compiled]
Double click your new .exe to run your program.
Of course it may not end up being quite that simple as I've made a few
assumptions there, but I reckon that those instructions would be OK for
>75% of programs I've ever put through PAR.
Try it out and if you get stuck then come back with the specific error
you got and I'm sure someone will be happy to help. You may prefer to
direct your PAR / pp problems to the PAR mailing list though, as
suggested by Sisyphus.
HTH
Simon.
------------------------------
Date: 8 Dec 2003 13:08:15 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Processing array elements without iterative loop
Message-Id: <br1t3v$svu$1@mamenchi.zrz.TU-Berlin.DE>
John Markos O'Neill <john@nhoj.com> wrote in comp.lang.perl.misc:
> Yesterday someone suggested to me that it was possible to do something
> to each element in an array without an iterative (say, a foreach)
> loop. Well, actually, they said it could be done in one line but I
> assume they didn't just mean it would be done with an aesthetically
> displeasing removal of white space.
>
> In my experience, the least-lines-of-perl way to, say, print out all
> of the even elements in an array would be something like
>
> @array = (1, 2, 3, 4, 5, 6, 7, 8);
> foreach $array_ele (@array) {
> ($array_ele % 2 == 0) &&
> ($even_array_ele = $array_ele) &&
> print("\$even_array_ele: $even_array_ele\n");
> }
>
> For the sake of this discussion, let's call the three-line statement
> in the foreach loop a single line. Is it possible to do this with
> fewer statements? If so, how?
print "@array[ map 2*$_, 0 .. $#array/2]\n"
Anno
------------------------------
Date: Mon, 08 Dec 2003 17:37:01 GMT
From: Juha Laiho <Juha.Laiho@iki.fi>
Subject: Re: q on 'record', 'field' separators in text files
Message-Id: <br2ck2$rpi$2@ichaos.ichaos-int>
sparkane <nertz@numb.no> said:
>What characters if any are typically used to delimit 'fields' and
>'records' in a text file?
This doesn't matter - as you can nominate a third character to be
used as an "escape" character. This'd typically be '\', and is used
to strip special meanings off characters (at minimum, the two separators
_and_ the escape character itself).
--
Wolf a.k.a. Juha Laiho Espoo, Finland
(GC 3.0) GIT d- s+: a C++ ULSH++++$ P++@ L+++ E- W+$@ N++ !K w !O !M V
PS(+) PE Y+ PGP(+) t- 5 !X R !tv b+ !DI D G e+ h---- r+++ y++++
"...cancel my subscription to the resurrection!" (Jim Morrison)
------------------------------
Date: Mon, 8 Dec 2003 18:32:06 +0000 (UTC)
From: jgamble@ripco.com (John M. Gamble)
Subject: Ranging to 'z'
Message-Id: <br2g36$efe$1@e250.ripco.com>
I was reviewing my code, and came across a bit that made me say, "wait,
that can't work." Followed immediately by "why does that work?"
Here is the code reduced to it's essence:
my $inputs = 8;
my @alphabase = ('a'..chr($inputs));
The *intent* was to create a simple translation array (more complex
arrays are possible in this application, which is why i was going
through the bother of an array with this one). Now, according to my
naive reading of this code, this shouldn't produce anything useful at all.
But if you add the line
print @alphabase, "\n";
you get "abcdefghijklmnopqrstuvwxyz", which accidentally saved me.
Thing is, i don't think i deserved to be saved. Not because i am not
worthy (heh), but because this could be an error waiting to happen.
What if i wanted the length of the translation array later on, and i
used C<scalar @alphabase> instead of $inputs? Complications ensue.
The "Give 'em up to Z" feature can be seen in the even simpler one-
liner:
perl -le "print 'h'..'a'"
which prints out h through z. It's too consistent not be deliberate,
but what on Earth was it supposed to solve that someone thought it
was DWIM? Should this feature persist?
Thanks,
--
-john
February 28 1997: Last day libraries could order catalogue cards
from the Library of Congress.
------------------------------
Date: 8 Dec 2003 10:59:20 -0800
From: survesh2000@yahoo.com (Nithin)
Subject: Reading slective columns from *.csv file
Message-Id: <55b7ea65.0312081059.1f8b6a2@posting.google.com>
Hi,
I have a *.csv file that looks like this. I need to ignore Rows 1-5
and start reading from Row 6. From Row 6 I need only Column1, Column
3, Column4 and so on....(has about 35 values in each row).
RED - Letters in Red auto-populate columns from left to right.
Color Code - Yellow Field name boxes in yellow are fields required
Color Code - Gray Field name boxes in gray are fields are optional
Color Code - Green Field name boxes in green are optional fields
Color Code - Orange Field name boxes in orange indicate d - refer etc
44383 Ontario Dork Canal 288 1398 Malheur Ave TAC31NT
44384 Ontario Dork Canal 288 1398 Malheur Ave TAC31NT
44385 Ontario Dork Canal 288 1398 Malheur Ave TAC31NT
Previously, I used to copy manually the values I wanted to the
input.csv file. But, now I want to read directly from the source file
and avoid the extra step.
My code looks like this
open FILE, "input.csv";
while (<FILE>) {
chomp;
my ($col1, $col2, $col3, $col4, $col6) = split (/\,/);
}
------------------------------
Date: 8 Dec 2003 07:50:54 -0800
From: quetzalcotl@consultant.com (Ingo Menger)
Subject: Re: sorting file names
Message-Id: <d8184eb8.0312080750.647008b6@posting.google.com>
anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) wrote in message news:<bqq363$7o8$2@mamenchi.zrz.TU-Berlin.DE>...
>
> Untested, eh?
>
Sure. There has to be something left as execise for the OP. :-)
> map { s/^t-//; $_ } @allfiles;
or, better yet:
map { substr($_, 2) } @allfiles
or
map { m/^t-(\d+)/ and $1 } @allfiles
It's preferrable not to change lvalues if you don't have to.
------------------------------
Date: Mon, 08 Dec 2003 11:05:14 -0700
From: Eric Schwartz <emschwar@pobox.com>
Subject: Re: string matching question.
Message-Id: <etoiskrmbhh.fsf@fc.hp.com>
mishq00@yahoo.com (Mohammed Ishaq) writes:
> I have a been trying to do a string match, and the string has []
> characters. I do not want perl to treat this a regular expression, but
> I cannot get it match. I have the following perl snippet, and the
> output of these two searches is different, but I think that both
> searches should match successfully.
If you want to match a literal substring, then you don't want a regex,
you want index():
my $e="abcde[12]";
my $f="XYZ[12] abcde[12] XYZ[12]";
print "$e is in $f\n" if (index($f, $e));
Regexes are best (IMO) when you need to match a pattern; use index()
if you're matching the full string.
-=Eric
--
Come to think of it, there are already a million monkeys on a million
typewriters, and Usenet is NOTHING like Shakespeare.
-- Blair Houghton.
------------------------------
Date: Mon, 08 Dec 2003 19:31:43 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: string matching question.
Message-Id: <br2gh4$270rl6$1@ID-184292.news.uni-berlin.de>
Eric Schwartz wrote:
> If you want to match a literal substring, then you don't want a
> regex, you want index():
>
> my $e="abcde[12]";
> my $f="XYZ[12] abcde[12] XYZ[12]";
> print "$e is in $f\n" if (index($f, $e));
>
> Regexes are best (IMO) when you need to match a pattern; use
> index() if you're matching the full string.
If I understand OP's message correctly, he wants a regex that matches
this:
'XYZ[12] abcde[12] XYZ[12]'
but not this, for instance:
'XYZ[12]abcde[12]XYZ[12]'
You can't make that distinction with index(), can you?
I gave him an explanation why \b doesn't "work" together with '[' and
']' characters, but it just struck me that I didn't provide an
alternative solution. I suppose that something like this is what he
actually wants (if he is still around):
my $e = 'abcde[12]';
my $f = 'XYZ[12] abcde[12] XYZ[12]';
if ( $f =~ /[^\[\]\w]\Q$e\E[^\[\]\w]/ ) {
print "match\n";
} else {
print "no match\n"
}
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Mon, 8 Dec 2003 08:52:06 -0500
From: Jeff 'japhy' Pinyan <pinyaj@rpi.edu>
To: Fletch <fletch@hudsonroad.freeserve.co.uk>
Subject: Re: Validate Excel Range with RegEx
Message-Id: <Pine.SGI.3.96.1031208084937.16926D-100000@vcmr-64.server.rpi.edu>
[posted & mailed]
On 8 Dec 2003, Fletch wrote:
>Any thoughts on how to validate an Excel range with RegEx?
>Acceptable inputs would include $A1:$BD25, C:C, B4 etc.
What does that first range mean? Can you give an exhaustive list of
samples for Excel ranges?
>I'm close to coming up with an answer but I'm not sure how to stop
>invalid range references such as C3:A2 from being accepted.
Well, do you need to use a regex to enforce the logic as well? If you can
permit a regex to be used to capture the PARTS of the range, and then use
logic to compare them, then it shouldn't be too hard, you'll just need a
regex with the ability to *parse* Excel ranges.
--
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: 8 Dec 2003 15:02:49 GMT
From: "A. Sinan Unur" <asu1@c-o-r-n-e-l-l.edu>
Subject: Re: Validate Excel Range with RegEx
Message-Id: <Xns944B66351C74Casu1cornelledu@132.236.56.8>
> On 8 Dec 2003, Fletch wrote:
>
>>I'm close to coming up with an answer but I'm not sure how to stop
>>invalid range references such as C3:A2 from being accepted.
You know Excel itself does accept such ranges from the user. It just
quitely turns them into A2:C3.
--
A. Sinan Unur
asu1@c-o-r-n-e-l-l.edu
Remove dashes for address
Spam bait: mailto:uce@ftc.gov
------------------------------
Date: 8 Dec 2003 08:55:15 -0800
From: jkeen@concentric.net (James E Keenan)
Subject: Re: Validate Excel Range with RegEx
Message-Id: <b955da04.0312080855.74154549@posting.google.com>
fletch@hudsonroad.freeserve.co.uk (Fletch) wrote in message news:<b324dda0.0312080337.7c7ed8c8@posting.google.com>...
> Any thoughts on how to validate an Excel range with RegEx?
> Acceptable inputs would include $A1:$BD25, C:C, B4 etc.
> I'm close to coming up with an answer but I'm not sure how to stop
> invalid range references such as C3:A2 from being accepted.
>
> Thanks.
I don't know the full definition of a valid range in Excel, so take
the following only as a crude first pass:
my @ranges = qw( C3:A2 C3:C2 C3:C3 C3:C4 C3:CC3 );
for (@ranges) {
my @temp = split(/:/, $_, 2);
$temp[0] gt $temp[1] ? print "Invalid: $_\n" : print "Valid:
$_\n";
}
HTH!
Jim Keenan
------------------------------
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 5911
***************************************