[25847] in Perl-Users-Digest
Perl-Users Digest, Issue: 8082 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun May 15 18:05:38 2005
Date: Sun, 15 May 2005 15:05:08 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Sun, 15 May 2005 Volume: 10 Number: 8082
Today's topics:
Re: arrays <tadmc@augustmail.com>
GMT time to local time, according to timezone and summe <djb@global.net.mt>
Re: GMT time to local time, according to timezone and s <noreply@gunnar.cc>
Google Groups and netiquette <noreply@gunnar.cc>
Handling NTFS permissions, 3 way. <mtjjarvin@yahoo.com>
Re: query = new CGI; <1usa@llenroc.ude.invalid>
Re: Regex not matching <Andrew@DeFaria.com>
where to define this array? <jblno@spamhotmail.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sun, 15 May 2005 09:14:18 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: arrays
Message-Id: <slrnd8em9q.9ch.tadmc@magna.augustmail.com>
Bob Then <bob_then@yahoo.com.au> wrote:
> I tried using /^\d/ but it didn't work
Show us your attempt (and its data), and we can help you fix it.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sun, 15 May 2005 21:45:06 +0200
From: "David Joseph Bonnici" <djb@global.net.mt>
Subject: GMT time to local time, according to timezone and summer/winter time.
Message-Id: <d688sc$ter$1@domitilla.aioe.org>
Hi, is there an already made function , or some easy method, where I can
convert a gmt time to local time or vice versa. It should also account for
Summer and winter time 1 hour differences, apart from that it should support
also timezones.
Any suggestions before I dive in the coding.
David
------------------------------
Date: Sun, 15 May 2005 23:15:37 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: GMT time to local time, according to timezone and summer/winter time.
Message-Id: <3epsf3F4bbhoU1@individual.net>
David Joseph Bonnici wrote:
> Hi, is there an already made function , or some easy method, where I can
> convert a gmt time to local time or vice versa. It should also account for
> Summer and winter time 1 hour differences, apart from that it should support
> also timezones.
There are most certainly a few CPAN modules.
http://search.cpan.org/
Even if I'm not sure, two modules I'd check out are DateTime and
Date::Manip.
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Sun, 15 May 2005 23:47:00 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Google Groups and netiquette
Message-Id: <3epuanF48dutU1@individual.net>
It seems like groups-beta.google.com has undergone a change which leads
people to not quote anything when replying to a message. Maybe those who
dislike when people reply without providing context should better call
Google's attention to the problem rather than blaming GG posters...
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Sun, 15 May 2005 17:31:52 GMT
From: mtjjarvin <mtjjarvin@yahoo.com>
Subject: Handling NTFS permissions, 3 way.
Message-Id: <cILhe.319$In4.37@read3.inet.fi>
Hi there!
Hopefully someone know what the hell is going wrong.
I'm stuck in setting NTFS permissions. So far I have seen 2 different
methods, how to handle it. (of course I can system('cacls'), but will
try these first.
I'm runing on ActivePerl v.5.8.4 build 810 on Windows XP sp2.
1) Win32::FileSecurity
Either it does not find an user account, or (seen on documentation) it
may not work for remote files (not tested yet).
use Win32::FileSecurity qw( MakeMask Get Set EnumerateRights );
use Data::Dumper;
use warnings;
use strict;
my $edir = "C:\\temp\\test";
my $user = "mtjj";
my $dir = MakeMask( qw( FULL GENERIC_ALL ));
my %ace = ();
Get($edir, \%ace) ) {
print ("\n\t Before: \n".Dumper(\%ace));
$ace{'mtjj'} = $dir; # user really exist.
#$ace{'bigboss\mtjj'} = $dir; # not work.
#$ace('mtjj@domain.com'} = $dir; # neither this.
Set( $edir, {%ace} )) {
print ("\n\t After: \n".Dumper(\%ace));
result:
Program displays Data Dumper Before as it should be, but then:
Error handling error: 1722, LookupAccountName at
D:\Perl\tests\Win32Perms5.pl...
and net helpmsgs 1722 says "remote procedure call server is not in use"
(or similiar, I do not have english version windows in this pc).
2) Win32::Perms
use strict;
use warnings;
# install http://perlscript.tlk.fr/perl/packages/Win32-Perms.ppd
use Win32::Perms;
my $dir = "testi";
my $do = new Win32::Perms ( $dir );
$do->Allow('mtjj', FULL, FILE);
$do->Allow('mtjj', FULL, DIR);
$do->Set;
Result: Can't call method "Allow" on an undefined value at
D:\Perl\omat\ad\Win32perms4.pl...
I copied perms.dll to @inc, and windows system32 dir, but not work.
Suggestions are welcome
~mtjj~
------------------------------
Date: Sun, 15 May 2005 15:16:17 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: query = new CGI;
Message-Id: <Xns96577282FE30Casu1cornelledu@127.0.0.1>
Fabian Pilkowski <pilkowsk@informatik.uni-marburg.de> wrote in
news:3eovifF48rgmU1@individual.net:
> * A. Sinan Unur schrieb:
>> "CS" <cprevra@satx.rr.com> wrote
>>>
>>> print "<html><head><title>A test</title></head\n";
>>> print "<body>The test was successful</body></html>";
>>
>> AFAIK, that is not valid HTML.
>>
>> print <<HTML;
>> <html>
>> <head>
>> <title>A Test</title>
>> </head>
>> <body>
>> <p>The test was successful</p>
>> </body>
>> </html>
>> HTML
>
> But this isn't valid HTML too. You want to point out the difference
> between "transitional" and "strict" HTML. The first is almost valid
> for the "transitional" DTD, yours is almost valid for the "strict"
> one. But in both cases there is no DOCTYPE header as urgent required
> for "valid HTML", AFAIK.
>
> I suggest to use CGI.pm's method start_html() if valid HTML is
> required. If you really want to do the HTML part *by hand* learn more
> about HTML's validness first ;-)
You are, of course, correct in pointing out that my example is not valid
either because of the missing doctype. My only excuse is that I normally
use HTML::Template, and the editor I use automatically inserts the
HTML4.01 strict doctype.
Upon reading your response, I decided to add a start_html call to my
snippet to show how it ought to be done, but I have not been able to
convince CGI.pm to emit a HTML4.01 strict doctype. What would be the
proper arguments to
$cgi->start_html(
-dtd => 'what should I put there for HTML4.01 strict'
);
I am beginning to realize why I do not use the HTML generating functions
of CGI.pm -- too deep for me.
The following does not generate valid HTML either (at least according to
the HTML validator at http://validator.w3.org/):
use CGI();
use CGI::Pretty;
my $cgi = CGI->new;
print $cgi->start_html(
-dtd => [
'-//W3C//DTD HTML 4.01//EN',
'http://www.w3.org/TR/html4/strict.dtd',
],
Title => 'Test Document',
), $cgi->p('The test was successful'), $cgi->end_html;
__END__
So, I would really appreciate an example of how to produce the HTML 4.01
strict doctype with CGI.pm, because I am very confused right now.
Thanks.
Sinan
--
A. Sinan Unur <1usa@llenroc.ude.invalid>
(reverse each component and remove .invalid for email address)
comp.lang.perl.misc guidelines on the WWW:
http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html
------------------------------
Date: Sun, 15 May 2005 15:49:50 GMT
From: Andrew DeFaria <Andrew@DeFaria.com>
Subject: Re: Regex not matching
Message-Id: <ycKhe.561$W51.4813@typhoon.sonic.net>
Joe Smith wrote:
> Andrew DeFaria wrote:
>
>> Ignoramus4744 wrote:
>>
>>> it did not fail, it successfuly mapped \d* to an empty string.
>>
>> OK why didn't it match it to 80 like the first pattern did? Why is it
>> required to have the "=" and the space in the pattern? Why wouldn't
>> ".*" suck that up?
>
> /^#.*(\d*)/ = Match '#' at the beginning of the line, followed by any
> number of characters (as much as possible) followed by
> zero or more digits. The greediness of the '.*' ate up everything,
> including '80', which allowed (forced) \d* to match zero digits.
>
> /^#.*(\d+)/ = Match '#' at the beginning of the line, followed by any
> number of characters (as much as possible) followed by
> one or more digits. The greediness of the '.*' grab everything
> possible, as long as it leaves one digit left over for \d+. This
> means that '8' is included in .* and only '0' is picked up by \d+.
>
> /^#.*?(\d+)/ = Match '#' at the beginning of the line, followed by as
> few as characters as possible to allow the rest of the regex to
> match. This means that \d+ will match '80'. (Using \d* would also
> match '80' in this case.)
>
> Two things to remember:
> 1) Use \d+ instead of \d* to avoid matching zero digits.
> 2) .* is greedy; it will swallow up everything possible. Only if
> there is more to match will it accept less than everything.
Thanks. Good explanation. The matching zero digits got me here. And
thanks for the 2nd paragraph too. Got caught by that too.
--
If a cow laughed, would milk come out her nose?
------------------------------
Date: Sun, 15 May 2005 21:52:43 GMT
From: jbl <jblno@spamhotmail.com>
Subject: where to define this array?
Message-Id: <7cff8194d98odp91h8feocnqce3sh9rkct@4ax.com>
I am using Win32 so the shebang is just for looks.
Where is the correct place to define @line_data in the example below?
#!/user/bin/perl
use warnings;
use strict;
#remove duplicate (elements) lines from file
open(IN,'C:\mydir\myfile.txt')
|| die "Cannot open C:\\mydir\\myfile\.txt: $!";
open(OUT,">C:\\newsbin_dot_com\\mylog\.txt")
|| die "Cannot open to write C:\\newsbin_dot_com\\mylog\.txt: $!";
while (<IN>) {
push (@line_data,$_); # <=HERE
}
close(IN);
my (%saw,undef); # from perlfaq4.htm
my @duplicates_removed = grep(!$saw{$_}++, @line_data); #<=HERE
print OUT @duplicates_removed;
close(OUT);
__END__
It runs fine without use warnings; use strict;
This just creates an array from a flat file and removes the duplicate
elements.
When I try to append this to the end of the script that creates
myfile.txt, it runs without errors if I define @line_data globaly ( at
the top) but it doesn't remove the duplicates.
I can save the above as junk.pl and systen call junk.pl instead of
trying to use the above code and it runs and does remove the duplicate
elements.
myfile.txt
_DATA_
Sunday May 15, 2005
aaaaaaaaaaaaaaaaaaa
bbbbbbbbbbbbbbbbbbb
Sunday May 15, 2005
ccccccccccccccccccc
aaaaaaaaaaaaaaaaaaa
Sunday May 15, 2005
ddddddddddddddddddd
bbbbbbbbbbbbbbbbbbb
Saturday May 14, 2005
eeeeeeeeeeeeeeeeeee
fffffffffffffffffff
Saturday May 14, 2005
ggggggggggggggggggg
ggggggggggggggggggg
Saturday May 14, 2005
hhhhhhhhhhhhhhhhhhh
iiiiiiiiiiiiiiiiiii
Saturday May 14, 2005
jjjjjjjjjjjjjjjjjjj
ccccccccccccccccccc
Friday May 13, 2005
kkkkkkkkkkkkkkkkkkk
lllllllllllllllllll
Friday May 13, 2005
mmmmmmmmmmmmmmmmmmm
aaaaaaaaaaaaaaaaaaa
bbbbbbbbbbbbbbbbbbb
Thanks
jbl
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc. For subscription or unsubscription requests, send
#the single line:
#
# subscribe perl-users
#or:
# unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.
#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V10 Issue 8082
***************************************