[11437] in Perl-Users-Digest
Perl-Users Digest, Issue: 5037 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Mar 2 18:07:29 1999
Date: Tue, 2 Mar 99 15:01:38 -0800
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, 2 Mar 1999 Volume: 8 Number: 5037
Today's topics:
Re: Question about converting newlines to <br> tags <Webmaster@qax.org>
Re: Question about converting newlines to <br> tags (Larry Rosler)
shell escaping and command line options mrai@my-dejanews.com
Re: system() question patowic_is_my_name@bouncespam.jurai.net
Re: The millennium cometh -- eventually (I R A Aggie)
Re: Tom, where are the FAQ'lets ??? <gellyfish@btinternet.com>
Re: translating a hex/int value to a string of bits. (Daniel S. Lewart)
Re: translating a hex/int value to a string of bits. jfv@capgroup.com
Re: translating a hex/int value to a string of bits. scraig@my-dejanews.com
URGENT! Where Do You Hide The CGI Cards From The Spider tatabu@my-dejanews.com
Re: URGENT! Where Do You Hide The CGI Cards From The Sp <Webmaster@qax.org>
Re: URGENT! Where Do You Hide The CGI Cards From The Sp (Martien Verbruggen)
Re: Variables in regular expressions <Allan@due.net>
Re: Variables in regular expressions (Larry Rosler)
Re: Variables in regular expressions <Allan@Due.net>
Re: Why can't my .pl find my SCRIPT ?? <gellyfish@btinternet.com>
Re: y2k and 4-digit dates (was Re: foreach and while) (Abigail)
Yes, I'm a newbie. Any suggestions despite that? <wyma69@nidlink.com>
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 02 Mar 1999 22:11:09 +0000
From: Colin Drew <Webmaster@qax.org>
To: George <fred222@mauimail.com>
Subject: Re: Question about converting newlines to <br> tags
Message-Id: <36DC61FC.36241492@qax.org>
Try adding a + symbol, you might be receiving 2 or more \n where your expecting
only one.
$mod_joke_text =~ s/\n+/<br>/g;
I would also suggest adding |\r+ just incase some \n are turned into \r
instead
$mod_joke_text =~ s/\n+|\r+/<br>/g;
Colin
George wrote:
> Greetings! Just learned perl over the Christmas break for fun, and I've
> been working on a pretty massive (2,700+ lines) set of scripts to make a
> completely dynamic webpage (GUI, font size, display, the works..) It's a
> joke site, and I have about 2,000 jokes so far (slightly messed up, but
> functional :). My problem is the following: I have an admin module which
> can delete and modify jokes (each is its own seperate database file, in
> folders which are the names of the categories).. to modify a joke, I read
> it in and convert <br> tags into \n newlines by using the following normal
> expression:
>
> $joke[3] =~ s/<br>/\n/g;
>
> (the joke file, as a database, is split by |'s. $joke[3] is, therefore,
> the fourth bit of the array.. and in this case, is the actual 'joke').
>
> So far, so good. I display the newly-formatted joke in a <textarea> so the
> newlines look like, well, newlines. When we press submit, we want to
> convert the "\n" newlines back into <br> tags, right? So I do this ($INPUT
> is the all-around variable grabber from the ENV CONTENT_LENGTH):
>
> $mod_joke_text = $INPUT{'mod_joke_text'};
> $mod_joke_text =~ s/\n/<br>/g;
>
> But this does something odd! It puts <br> tags where I want 'em, but it
> seems to leave the newlines in too. Does anyone know what sort of error
> I've made? If needs be, I can post bigger parts of the script.
>
> If any responses could also be emailed to me at yurtle@bellatlantic.net, I
> would be MOST appreciative! :-)
>
> Best regards,
> George Henry
>
> --
> Just another hacking head >l-d
--
From Colin Drew,
You can Email
mailto:Colin@qax.org or mailto:c.drew@qax.org
Why not visit my WebSite :- http://www.qax.org/
---------------------------------------------------------------------
Any Syntax or Spelling Errors are nothing to do with me,
They must be Transmission Errors !
---------------------------------------------------------------------
------------------------------
Date: Tue, 2 Mar 1999 14:48:54 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Question about converting newlines to <br> tags
Message-Id: <MPG.11460ab2f66efb939896c5@nntp.hpl.hp.com>
In article <36DC61FC.36241492@qax.org> on Tue, 02 Mar 1999 22:11:09
+0000, Colin Drew <Webmaster@qax.org> says...
> Try adding a + symbol, you might be receiving 2 or more \n where your expecting
> only one.
>
> $mod_joke_text =~ s/\n+/<br>/g;
>
> I would also suggest adding |\r+ just incase some \n are turned into \r
> instead
>
> $mod_joke_text =~ s/\n+|\r+/<br>/g;
Good idea; bad implementation (alternation is one of the slowest regex
operations).
$mod_joke_text =~ s/[\n\r]+/<br>/g;
But I don't know why anyone really wants to remove newlines when adding
'<br>'s. Some poor human may choose to view or download the HTML
source, and having manageable line lengths is a great virtue. The
browser couldn't care less, and the increase in file size is trivial.
$mod_joke_text =~ s/[\n\r]+/<br>\n/g;
--
Larry Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Tue, 02 Mar 1999 22:24:55 GMT
From: mrai@my-dejanews.com
Subject: shell escaping and command line options
Message-Id: <7bhofd$jq8$1@nnrp1.dejanews.com>
Im trying to do a substitution
$foo =~ s/$var1/$var2/g;
where $var1 = "\n";
and $var2 = "\t"
that is replace the newline with the tab character.
if I try to read $var1 and $var2 from the commandline,
i.e. $var1 = $ARGV[0]; etc.
then the result I get is that the newline gets replaced with a "backslash t"
instead of a tab.
Im passing the stuff like so:
myscript.pl "\n" "\t"
i've tried single quotes
help.
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Tue, 02 Mar 1999 21:10:49 GMT
From: patowic_is_my_name@bouncespam.jurai.net
Subject: Re: system() question
Message-Id: <ttYC2.406$66.19404@ptah.visi.com>
Just before high-siding, patowic_is_my_name@bouncespam.jurai.net shrieked:
: I'm trying to run a remsh command through a perl script, and while the
: command string I'm trying runs fine from shell or shell script, my perl
: program always stops after issuing the command. By this, I mean: I am running
: the program in the background, and after issuing the pager command, it
: halts, and I have to issue 'bg' to get it to keep going.
I found the answer to this, and it was that I needed to pump some input into
the remsh, for some odd reason. So this line:
: @arg = ("/usr/ucb/remsh telalert -l pager \"/usr/telalert/telalert -i
: janderson -m \'try this one on for size\'\"");
Became this:
: @arg = ("/usr/ucb/remsh telalert -l pager \"/usr/telalert/telalert -i
: janderson -m \'try this one on for size\'\" < /dev/null");
And it worked beautifully.
--
Some people have told me they don't think a fat penguin
really embodies the grace of Linux, which just tells me
they have never seen a angry penguin charging at them in
excess of 100mph. They'd be a lot more careful about what
they say if they had.
-- Linus Torvalds
patowic jurai net DoD# WildCard cabal# e
------------------------------
Date: 2 Mar 1999 21:55:05 GMT
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: The millennium cometh -- eventually
Message-Id: <slrn7donmh.jnf.fl_aggie@enso.coaps.fsu.edu>
On Tue, 2 Mar 1999 10:55:10 -0500, Russell Schulz
<Russell_Schulz@locutus.ofB.ORG> wrote:
+ stop writing functions that return year-1900.
Why? the number for a given year is an arbritrary definition. If I choose
to come up with a different numbering scheme, but one I can map into the
currently accepted (the legal calendar), or any other calendar I choose,
and as long as I document such behaviour, why should it matter to you?
+ stop saying `20th Century'.
Tell that to the historians...
+ stop whining about 2000 not being a change into a new millennium
+ (because it is,
No. It isn't. You know it isn't. Do you _really_ want to get into the
history of mathematics, Rome, the Roman army, and the early Christian
church?
In brief:
1. The concept of "zero" hadn't been discovered, and wouldn't be until
the 1100 or 1200's by _Islamic_ scholars. Ergo, when the calendar was
laid out, it started with 1 AD. There was no 0th year.
2. The chuch comes into this with the AD part, but you knew that...
3. The Roman legions where subdivided into smaller units. One of those
units was called a 'century', was made up of 100 men, and was commanded
by a centurion.
4. Ergo, a 'century' of years consists of 100 years, and that the 'first
century AD' consists of the years 1-100, inclusive.
5. Since a millenium is 1000 years (10 centuries), it stands to reason
that the first millenium was the years 1-1000, the second will be
the years 1001-2000, yadda, yadda, yadda.
But you knew all this, yes?
+ there. is _my_ point clear?
Yeah. You disagree with the definition of what a century/millenium is.
And there's nothing wrong with that.
However, that definition is an arbritrary one, one that is commonly
accepted not only in day-to-day operations, but also by the legal
establishment. You're welcome to try and change their minds, if you
can. Good luck.
+ have you _ever_ seen anyone think 2000 is part of the 1900s?
Yes. People who have a clue. Alternatively, you can always use the
Hewbrew calendar, where this year is 5759.
James
------------------------------
Date: 2 Mar 1999 21:42:56 -0000
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: Tom, where are the FAQ'lets ???
Message-Id: <7bhm10$1l2$1@gellyfish.btinternet.com>
On Mon, 01 Mar 1999 20:54:43 -0600 Michael D. Schleif wrote:
> Why stop now? Simply, because some repeated?
>
Nah, I think it was causing some peoples modems to overheat.
/J\
--
Jonathan Stowe <jns@btinternet.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>
------------------------------
Date: 2 Mar 1999 21:07:01 GMT
From: d-lewart@uiuc.edu (Daniel S. Lewart)
Subject: Re: translating a hex/int value to a string of bits.
Message-Id: <7bhjtl$plc$1@vixen.cso.uiuc.edu>
jfv@capgroup.com writes:
> I'm working on a Sybase system where some data is returned as a hex value
> which needs to be translated to a bitmap. I found an example at the
> language.perl.com site where the following technique is used:
> bitstring = join('',unpack('B*',"\x29")); ( 00101001)
> Yet as much as I try, I cannot get "assigned" values to work. For example
> $x="\\x29";
> join('',unpack('B*',"$x")); will result in 01011100011110000011001000111001
> what am I not getting ?
You are not getting that you have an extra backslash and should do this instead:
$x = "\x29";
$bitstring = unpack('B*', $x);
Daniel Lewart
d-lewart@uiuc.edu
------------------------------
Date: Tue, 02 Mar 1999 21:50:24 GMT
From: jfv@capgroup.com
Subject: Re: translating a hex/int value to a string of bits.
Message-Id: <7bhmes$i4e$1@nnrp1.dejanews.com>
Never mind , I found it in dejanews. Thanks Tom P. My apologies for the
premature post.
In article <7bhi3e$e79$1@nnrp1.dejanews.com>,
jfv@capgroup.com wrote:
> I'm working on a Sybase system where some data is returned as a hex value
> which needs to be translated to a bitmap. I found an example at the
> language.perl.com site where the following technique is used:
>
> bitstring = join('',unpack('B*',"\x29")); ( 00101001)
>
> Yet as much as I try, I cannot get "assigned" values to work. For example
>
> $x="\\x29";
>
> join('',unpack('B*',"$x")); will result in 01011100011110000011001000111001
>
> what am I not getting ?
>
> Thanks --jim
>
> -----------== Posted via Deja News, The Discussion Network ==----------
> http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
>
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Tue, 02 Mar 1999 22:21:35 GMT
From: scraig@my-dejanews.com
Subject: Re: translating a hex/int value to a string of bits.
Message-Id: <7bho94$jo1$1@nnrp1.dejanews.com>
In article <7bhi3e$e79$1@nnrp1.dejanews.com>,
jfv@capgroup.com wrote:
>... some data is returned as a hex value
> which needs to be translated to a bitmap.
>
> bitstring = join('',unpack('B*',"\x29")); ( 00101001)
>
> $x="\\x29";
>
> join('',unpack('B*',"$x")); will result in 01011100011110000011001000111001
>
The string "\x29" is the same as ")", a string with one character whose
ascii value is 29 in hex. This is why the trick works.
The variable $x above contains a string with four characters: '\', 'x',
'2', '9'. That makes four bytes, or thirtytwo bits.
Instead use $x="\x29"; as in the first case. Then it works fine.
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Tue, 02 Mar 1999 21:25:37 GMT
From: tatabu@my-dejanews.com
Subject: URGENT! Where Do You Hide The CGI Cards From The Spiders?
Message-Id: <7bhl07$god$1@nnrp1.dejanews.com>
When we use a CGI script to create greeting cards for people,
we usually create the cards in a directory, say "cards", which can
be accessed by anybody. If this is the case, then the search engines
that spider our pages can actually suck in all the confidential
greeting cards that have been created. What do we do to
remedy this?
Thanks!
tatabu@ix.netcom.com
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Tue, 02 Mar 1999 21:47:53 +0000
From: Colin Drew <Webmaster@qax.org>
To: tatabu@my-dejanews.com
Subject: Re: URGENT! Where Do You Hide The CGI Cards From The Spiders?
Message-Id: <36DC5C89.16136AC0@qax.org>
Have you tried adding a
robot.txt file in the root dir of your site containing :
User-agent: * # all robots
Disallow: /cards
Disallow: /anotherfolder
Disallow: /anotherfolder/yetanother
tatabu@my-dejanews.com wrote:
> When we use a CGI script to create greeting cards for people,
> we usually create the cards in a directory, say "cards", which can
> be accessed by anybody. If this is the case, then the search engines
> that spider our pages can actually suck in all the confidential
> greeting cards that have been created. What do we do to
> remedy this?
> Thanks!
>
> tatabu@ix.netcom.com
>
> -----------== Posted via Deja News, The Discussion Network ==----------
> http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
--
From Colin Drew,
You can Email
mailto:Colin@qax.org or mailto:c.drew@qax.org
Why not visit my WebSite :- http://www.qax.org/
---------------------------------------------------------------------
Any Syntax or Spelling Errors are nothing to do with me,
They must be Transmission Errors !
---------------------------------------------------------------------
------------------------------
Date: Tue, 02 Mar 1999 22:38:49 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: URGENT! Where Do You Hide The CGI Cards From The Spiders?
Message-Id: <ZLZC2.79$hc3.684@nswpull.telstra.net>
In article <7bhl07$god$1@nnrp1.dejanews.com>,
tatabu@my-dejanews.com writes:
> When we use a CGI script to create greeting cards for people,
> we usually create the cards in a directory, say "cards", which can
> be accessed by anybody. If this is the case, then the search engines
> that spider our pages can actually suck in all the confidential
> greeting cards that have been created. What do we do to
> remedy this?
This has absolutely nothing at all to do with perl. You would be
better off asking this question in a group like
comp.infosystems.www.authoring or something like that. You can find
it.
One way of stopping spiders is to not provide any links to any of the
things you don't want to be found. Get your server to not allow
listing display of the directory that contains those things. make the
filenames of those things contain some random something.
All of the above make it harder to find them. Not impossible. Spiders
will simply not find it if there is no link to them. Well behaved
spiders can be stopped with a robots.txt file. Etc.
Ask on one of the comp.infosystems.www.* groups for more information.
And don't hesitate to come back here when you have a question about
Perl.
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | "In a world without fences,
Commercial Dynamics Pty. Ltd. | who needs Gates?"
NSW, Australia |
------------------------------
Date: Tue, 2 Mar 1999 16:11:40 -0500
From: "Allan M. Due" <Allan@due.net>
Subject: Re: Variables in regular expressions
Message-Id: <7bhk6l$roc$1@camel18.mindspring.com>
Larry Rosler wrote in message ...
:In article <7bh7bv$qqd$1@camel19.mindspring.com> on Tue, 2 Mar 1999
:12:39:24 -0500, Allan M. Due <Allan@due.net> says...
:...
:> Anyway, in the script below if I use
:> my $match = "$foo";
:> then $match = 'oo' and there is a successful match.
:>
:> if I use
:> my $match = "\\\$foo";
:> Then $foo becomes the literal '$foo' and I match. All well and good.
:
:Not so. $foo becomes the literal '\$foo' and it doesn't match.
I must be really missing something because it looks to me like the output
does show that it matches. Check my pedantic version below
:
:> But what would $match = "\$foo" actually match? I have tried modifying
:> $string in all kinds of ways
:> my $string = '\$foo';
:> my $string = "\$foo";
:> and I never get a match to \$foo. Can someone shed some light on what is
:> going on here? What would $match = "\$foo"; match?
:
:'$foo'
But it doesn't. Ack. Below $match = "\$foo"; is number 3 and it does not
match. Number 2, $match = "\\\$foo"; does match while you note above that
it should not. I must be seriously dense, seriously confused, or (more
likely) both.
#!/usr/local/bin/perl -w
use strict;
my $string = '$foo';
my $foo = 'oo';
my $i;
for my $match (
"$foo", # 1) $match = $foo = 'oo' so we match
"\\\$foo", # 2) $match = '$foo' so we match
"\$foo", # 3) What would this match in $string?
) {
$i++;
$string =~ /($match)/ ? print "$i) Matched $match in $string with: $1\n" :
print "$i) Couldn't match $match in $string\n";
}
__END__
gives:
1) Matched oo in $foo with: oo
2) Matched \$foo in $foo with: $foo
3) Couldn't match $foo in $foo
--
$email{'Allan M. Due'} = ' All@n.Due.net ';
--random quote --
[End of diatribe. We now return you to your regularly scheduled
programming...]
- Larry Wall in Configure from the perl distribution
:--
:Larry Rosler
:Hewlett-Packard Company
:http://www.hpl.hp.com/personal/Larry_Rosler/
:lr@hpl.hp.com
------------------------------
Date: Tue, 2 Mar 1999 14:25:31 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Variables in regular expressions
Message-Id: <MPG.114605374e8738b49896c3@nntp.hpl.hp.com>
In article <7bhk6l$roc$1@camel18.mindspring.com> on Tue, 2 Mar 1999
16:11:40 -0500, Allan M. Due <Allan@due.net> says...
> I must be really missing something because it looks to me like the output
> does show that it matches.
You are right. I misread the output.
'$foo' matches the pattern "\\\$foo" which when interpolated in the
regex becomes '\$foo', hence literally '$foo'.
'$foo' doesn't match the pattern "\$foo" which when interpolated into
the regex becomes '$foo', hence 'end-of-string' followed by 'foo'.
Sorry for the confusion.
--
Larry Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Tue, 2 Mar 1999 17:36:41 -0500
From: "Allan M. Due" <Allan@Due.net>
Subject: Re: Variables in regular expressions
Message-Id: <EKZC2.206$EU1.4436@nntp1.nac.net>
Larry Rosler wrote in message ...
:In article <7bhk6l$roc$1@camel18.mindspring.com> on Tue, 2 Mar 1999
:16:11:40 -0500, Allan M. Due <Allan@due.net> says...
:
:> I must be really missing something because it looks to me like the output
:> does show that it matches.
:
:You are right. I misread the output.
:
:'$foo' matches the pattern "\\\$foo" which when interpolated in the
:regex becomes '\$foo', hence literally '$foo'.
:
:'$foo' doesn't match the pattern "\$foo" which when interpolated into
:the regex becomes '$foo', hence 'end-of-string' followed by 'foo'.
:
Of course, $ in a regex (smaking head with hand). Thank you, that was what I
was missing. So obvious now that I see it.
:Sorry for the confusion.
Thanks too for making the odd mistake. Gives hope to still learning <g>.
AmD
--
$email{'Allan M. Due'} =' All@n.Due.net '
--random quote--
Numbers are symbols for things; the number and the thing are not the
same.
Ashley-Perry Statistical Axioms[1]
------------------------------
Date: 2 Mar 1999 22:32:14 -0000
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: Why can't my .pl find my SCRIPT ??
Message-Id: <7bhote$1nv$1@gellyfish.btinternet.com>
On Mon, 01 Mar 1999 20:29:33 -0600 Michael Fuerst wrote:
>
> I wish to pull out javascript code from an HTML file.
> I am running PERL on Win NT.
Whilst I dont want to spoil your fun but deep down in your soul you know
that one day some badass is going to come along with some HTML file that
is going to completely mess up your regex and then you're going to have
to come back here cap and broken script in hand ...
The *approved* method for doing this sort of thing is to use the module
HTML::Parser or one of its offspring:
#!/usr/bin/perl
package RipScript;
@ISA = qw(HTML::Parser);
require HTML::Parser;
use vars qw($inscript);
$parser = new RipScript;
$parser->parse_file($ARGV[0]);
sub start()
{
my($self,$tag,$attr,$attrseq,$orig) = @_;
$inscript++ if($tag eq "script");
}
sub text()
{
my ($self,$text) = @_;
if ($inscript )
{
print ($text) if $text;
}
}
sub comment()
{
my ($self,$comment) = @_;
if ($inscript)
{
print $comment;
}
}
sub end()
{
my ($self,$tag) = @_;
$inscript-- if($tag eq "script");
}
1;
Now that was fairly painless wasnt it. You'll notice that I have printed
either the text or the contents of a comment just in case ...
/J\
--
Jonathan Stowe <jns@btinternet.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>
------------------------------
Date: 2 Mar 1999 22:25:11 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: y2k and 4-digit dates (was Re: foreach and while)
Message-Id: <7bhog7$2o$1@client2.news.psi.net>
Russell Schulz (Russell_Schulz@locutus.ofB.ORG) wrote on MMIX September
MCMXCIII in <URL:news:19990302.102654.8J5.rnr.w164w@locutus.ofB.ORG>:
^^ [ where should this followup go? comp.software.y2k.fluff ? ]
^^
^^ merlyn@stonehenge.com (Randal L. Schwartz) writes:
^^
^^ > Ronald> don't use 6 digit dates !
^^ >
^^ > Why not?
^^
^^ because they're ambiguous, and ambiguous in a small time frame. a real,
^^ practicaly one that affects us (as opposed to the y10k problem, which
^^ is `real' but also `real silly').
^^
^^ > I'm not going to start writing 1/2/2000 when 1/2/00 will work just
^^ > fine to indicate the second day of the first month of the closest year
^^ > ending in 00.
^^
^^ is that Feb 1 or Jan 2?
That's a silly argument. 8 digit dates don't magically solve the US
vs rest-of-the-world ambiguity.
^^ > It's all about context. 4 digits doesn't magically fix everything.
^^
^^ actually, for the overwhelming majority of cases (AD1-AD9999), they do.
^^ if used consistently, if there hadn't been `year-1900' silliness, if
^^ data storage would have allowed them, if output fields were wide enough,
^^ there wouldn't have been a y2k concern.
Many of the y2k problems have to do with how people often write dates.
Using 2 digit years is very common.
Think about it. If you make an appointment to meet someone for dinner,
would you make that appointment for '20h00 March 2, 1999 A.D.', or
use something less cumbersome?
Abigail
--
sub _'_{$_'_=~s/$a/$_/}map{$$_=$Z++}Y,a..z,A..X;*{($_::_=sprintf+q=%X==>"$A$Y".
"$b$r$T$u")=~s~0~O~g;map+_::_,U=>T=>L=>$Z;$_::_}=*_;sub _{print+/.*::(.*)/s}
*_'_=*{chr($b*$e)};*__=*{chr(1<<$e)};
_::_(r(e(k(c(a(H(__(l(r(e(P(__(r(e(h(t(o(n(a(__(t(us(J())))))))))))))))))))))))
------------------------------
Date: Tue, 2 Mar 1999 13:52:27 -0800
From: "jim" <wyma69@nidlink.com>
Subject: Yes, I'm a newbie. Any suggestions despite that?
Message-Id: <7bhmhv$ha@faile.nidlink.com>
Hi All,
I'm attempting to monitor a very large, constantly growing, log file
(RADIUS logs). My Idea is to read the new info each night from the log
file, and write a file with the file size as of last reading, for reference
at the next reading. Sounds simple enough, but I'm having trouble. What
happens is that it gives me a file of the right length, but without the
proper offset. the size calculates properly, but the reading starts at the
beginning of the file rather than starting with the new stuff. the output
file is padded at the start with null characters equal to what the offset
should be. I'ts obviously ugly, but I can't for the life of me figure out
where the problems are.
any suggestions would be greatly appreciated,
please respond to
wyma69@nidlink.com
thanx a lot
#!/usr/bin/perl
$SIZE = -s('detail'); #get initial log file size
open(LAST, "last")||die "can't open last-size file: $!\n"; #get size from
last time
while (<LAST>){
if ($_ <= $SIZE) {
$LASTSIZE = $_;
}
elsif ($_ > $SIZE){ #if new log, reset size to zero
$LASTSIZE = 0;
}
}
close LAST;
$LENGTH = $SIZE - $LASTSIZE; #get length of new info in log
open(LOG, "detail")||die "can't open log file: $!\n";
open(OUT, ">output")||die "can't open output file: $!\n";
$len = sysread(LOG, $buf, $LENGTH, $LASTSIZE); #read new info
if (!defined $len){
next if $! =~ /^Interrupted/;
die "System read error: $!\n";
}
$offset = 0;
while ($len){
$written = syswrite(OUT, $buf, $len, $offset); #write out new file
if (!defined $written){
die "System write error: $!\n";
}
$len -= $written;
$offset += $written;
}
open (LAST, ">last")||die "can't open last-size file for writing: $!\n";
print (LAST $SIZE);
close LAST;
close LOG;
close OUT;
------------------------------
Date: 12 Dec 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Special: Digest Administrivia (Last modified: 12 Dec 98)
Message-Id: <null>
Administrivia:
Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing.
]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body. Majordomo will then send you instructions on how to confirm your
]subscription. This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.
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.misc (and this Digest), send your
article to perl-users@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.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.
The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.
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 V8 Issue 5037
**************************************