[28855] in Perl-Users-Digest
Perl-Users Digest, Issue: 99 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Feb 2 18:10:53 2007
Date: Fri, 2 Feb 2007 15:10: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 Fri, 2 Feb 2007 Volume: 11 Number: 99
Today's topics:
Problems dealing with dates in Windows <Gregory.Geller@gmail.com>
Re: Problems dealing with dates in Windows <john@castleamber.com>
Re: Problems dealing with dates in Windows <mritty@gmail.com>
Re: Problems dealing with dates in Windows <glennj@ncf.ca>
Re: Problems dealing with dates in Windows <ayaz@dev.slash.null>
Re: Problems dealing with dates in Windows <john@castleamber.com>
Re: Problems dealing with dates in Windows <purlgurl@purlgurl.net>
Re: Problems dealing with dates in Windows <wahab-mail@gmx.de>
Re: Problems dealing with dates in Windows <purlgurl@purlgurl.net>
Re: Problems dealing with dates in Windows <glennj@ncf.ca>
Re: Randomly Choose from an Array <wahab-mail@gmx.de>
Re: Randomly Choose from an Array <abigail@abigail.be>
Re: Randomly Choose from an Array <tzz@lifelogs.com>
Split a very large log file Terry.Riegel@gmail.com
Re: Split a very large log file <glex_no-spam@qwest-spam-no.invalid>
Re: Stick Lines and Dividers Between Text <john@castleamber.com>
Re: Storing results in array rather than printing joseph85750@yahoo.com
Re: Storing results in array rather than printing <john@castleamber.com>
Re: Win32::Clipboard mutilates \n <fred4414@nethere.com>
Writing Math Equations in PERL for HTML cylurian@gmail.com
Re: Writing Math Equations in PERL for HTML <nobull67@gmail.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 2 Feb 2007 09:40:39 -0800
From: "GGelz" <Gregory.Geller@gmail.com>
Subject: Problems dealing with dates in Windows
Message-Id: <1170438039.822767.9010@s48g2000cws.googlegroups.com>
Hi all,
I'm having quite a bit of trouble simply getting a date using perl on
a winXP system.
First of all, if I do something like:
$date = `date /T`;
I'll get an error saying:
date: invalid date '/T'
on the console.
Now, I was able to work around this by just doing a:
$date = localtime(time);
printing $date gives
"Fri Feb 2 12:23:11 2007"
now, if I split it using
($day, $month, $monthday, $time, $year) = split(/\s/, $date);
and then print out all the values, this is what I get:
$day = Fri
$month = Feb
$monthday =
$time = 2
$year = 12:23:11
I have no idea what is happening between "Feb" and "2" but it is
driving me crazy.
There has to be an easier way to handle dates in Windows using perl.
Will someone clue me in, please?
Thank you!
------------------------------
Date: 2 Feb 2007 17:54:17 GMT
From: John Bokma <john@castleamber.com>
Subject: Re: Problems dealing with dates in Windows
Message-Id: <Xns98CB7919B496Bcastleamber@130.133.1.4>
"GGelz" <Gregory.Geller@gmail.com> wrote:
> Hi all,
>
> I'm having quite a bit of trouble simply getting a date using perl on
> a winXP system.
>
> First of all, if I do something like:
>
> $date = `date /T`;
>
> I'll get an error saying:
>
> date: invalid date '/T'
>
> on the console.
Weird:
perl -e "my $date = `date /T`; print $date"
Fri 02/02/2007
> Now, I was able to work around this by just doing a:
>
> $date = localtime(time);
>
> printing $date gives
>
> "Fri Feb 2 12:23:11 2007"
>
> now, if I split it using
>
> ($day, $month, $monthday, $time, $year) = split(/\s/, $date);
It really helps to read the documentation of new stuff you're about to
use.
> and then print out all the values, this is what I get:
>
> $day = Fri
> $month = Feb
> $monthday =
> $time = 2
> $year = 12:23:11
>
> I have no idea what is happening between "Feb" and "2" but it is
> driving me crazy.
>
> There has to be an easier way to handle dates in Windows using perl.
> Will someone clue me in, please?
perldoc -f split (also, count the number of spaces between Feb and 2)
Moreover, I strongly suggest to study perldoc -f localtime
--
John Experienced Perl programmer: http://castleamber.com/
Perl help, tutorials, and examples: http://johnbokma.com/perl/
------------------------------
Date: 2 Feb 2007 10:17:32 -0800
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: Problems dealing with dates in Windows
Message-Id: <1170440252.652952.101160@s48g2000cws.googlegroups.com>
On Feb 2, 12:40 pm, "GGelz" <Gregory.Gel...@gmail.com> wrote:
> I'm having quite a bit of trouble simply getting a date using perl on
> a winXP system.
>
> First of all, if I do something like:
>
> $date = `date /T`;
>
> I'll get an error saying:
>
> date: invalid date '/T'
>
> on the console.
On what OS version? On my WinXP, I get:
C:\>perl -le"print `date /T`"
02/02/2007
> Now, I was able to work around this by just doing a:
>
> $date = localtime(time);
Which is, of course, what you should have been doing in the first
place.
> printing $date gives
>
> "Fri Feb 2 12:23:11 2007"
>
> now, if I split it using
>
> ($day, $month, $monthday, $time, $year) = split(/\s/, $date);
>
> and then print out all the values, this is what I get:
>
> $day = Fri
> $month = Feb
> $monthday =
> $time = 2
> $year = 12:23:11
>
> I have no idea what is happening between "Feb" and "2"
There are two spaces between Feb and 2, but you're only telling Perl
to split on a single space. Therefore, there is one empty field
between the two delimiters. Just split on one-or-more spaces instead:
spilt /\s+/, $date;
> There has to be an easier way to handle dates in Windows using perl.
> Will someone clue me in, please?
"handle dates" is a nonsensical term. The easier and more correct way
to do whatever it is you want to do depends on whatever it is you want
to do. What values are you hoping to obtain? How do you want to use
them? The easiest way to capture numerical values for each component
of the date/time is to use localtime in a list context:
my ($sec, $min, $hour, $day, $month, $year) = localtime;
But make sure you read `perldoc -f localtime` so you know what $month
and $year actually are.
Paul Lalli
------------------------------
Date: 2 Feb 2007 18:21:43 GMT
From: Glenn Jackman <glennj@ncf.ca>
Subject: Re: Problems dealing with dates in Windows
Message-Id: <slrnes709o.o5h.glennj@smeagol.ncf.ca>
At 2007-02-02 12:40PM, "GGelz" wrote:
[...]
> There has to be an easier way to handle dates in Windows using perl.
> Will someone clue me in, please?
Read about 'strftime' in the POSIX module:
use POSIX 'strftime';
my $date = strftime "%Y-%m-%d", localtime;
--
Glenn Jackman
"You can only be young once. But you can always be immature." -- Dave Barry
------------------------------
Date: Fri, 02 Feb 2007 23:39:37 +0500
From: Ayaz Ahmed Khan <ayaz@dev.slash.null>
Subject: Re: Problems dealing with dates in Windows
Message-Id: <pan.2007.02.02.18.39.35.565427@dev.slash.null>
"GGelz" typed:
> $date = localtime(time);
> printing $date gives
> "Fri Feb 2 12:23:11 2007"
> now, if I split it using
> ($day, $month, $monthday, $time, $year) = split(/\s/, $date);
You need '\s+' in there to cause split() to split on any number of
consecuteive whitespaces.
> There has to be an easier way to handle dates in Windows using perl.
> Will someone clue me in, please?
Take a look at `perldoc -f localtime`.
--
Ayaz Ahmed Khan
A witty saying proves nothing, but saying something pointless gets
people's attention.
------------------------------
Date: 2 Feb 2007 18:42:50 GMT
From: John Bokma <john@castleamber.com>
Subject: Re: Problems dealing with dates in Windows
Message-Id: <Xns98CB81549A020castleamber@130.133.1.4>
"Paul Lalli" <mritty@gmail.com> wrote:
> On what OS version? On my WinXP, I get:
> C:\>perl -le"print `date /T`"
> 02/02/2007
No Fri?
--
John Experienced Perl programmer: http://castleamber.com/
Perl help, tutorials, and examples: http://johnbokma.com/perl/
------------------------------
Date: Fri, 02 Feb 2007 10:52:51 -0800
From: Purl Gurl <purlgurl@purlgurl.net>
Subject: Re: Problems dealing with dates in Windows
Message-Id: <45C38883.8060903@purlgurl.net>
GGelz wrote:
> I'm having quite a bit of trouble simply getting a date using perl on
> a winXP system.
> First of all, if I do something like:
> $date = `date /T`;
> I'll get an error saying:
> date: invalid date '/T'
> on the console.
Your comments present problems.
These results you report are consistent for older
DOS 6 / 7 typical for Windows 98 and Windows ME.
However, using your syntax under DOS 6 / 7 will
not produce your error message until Control C
is used to terminate the process. Your syntax
creates a request to change system date (or time),
then waits for Standard Input from a user. This
causes a Perl script to wait indefinitely until
input via STDIN, or terminates with CTRL C entry.
What you report is not true for newer Windows XP.
Additionally, this error message you report is not
consistent with a DOS error message returned.
Your article exhibits serious contradictions.
---
#!perl
$date = `echo.|time`;
print "BEGIN\n\n$date\nEND";
print "\n\n";
$date = `date /T`;
print $date;
---
PRINTED RESULTS:
Microsoft(R) Windows 98
(C)Copyright Microsoft Corp 1981-1999.
C:\APACHE\USERS\TEST>perl test.pl
BEGIN
Current time is 10:39:36.61a
Enter new time:
END
Invalid date
Enter new date (mm-dd-yy): ^C
C:\APACHE\USERS\TEST>
---
PRINTED RESULTS:
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.
c:\apache\users\test>perl test.pl
BEGIN
The current time is: 10:38:20.87
Enter the new time:
END
Fri 02/02/2007
c:\apache\users\test>
---
Purl Gurl
------------------------------
Date: Fri, 02 Feb 2007 20:57:59 +0100
From: Mirco Wahab <wahab-mail@gmx.de>
Subject: Re: Problems dealing with dates in Windows
Message-Id: <eq05d7$2b1$1@mlucom4.urz.uni-halle.de>
Purl Gurl wrote:
> GGelz wrote:
>> First of all, if I do something like:
>> $date = `date /T`;
>> I'll get an error saying:
>> date: invalid date '/T'
>> on the console.
>
> Your comments present problems.
>
> These results you report are consistent for older
> DOS 6 / 7 typical for Windows 98 and Windows ME.
You are on the wrong track. I can reproduce his
error message "under WinXP" without problems here:
Variant 1 win32/putty.exe remote)
[here]> perl -e '$date=`date /T`; print qq{$date $] on $^O\n}'
date: invalid date `/T'
5.008008 on linux
Variant 2 - cygwin/bash local, in a DOS-Box)
[there]> perl -e '$date=`date /T`; print qq{$date $] on $^O\n}'
date: invalid date `/T
5.008007 on cygwin
You see, I can reproduce the message "under XP"
in many cases ;-) XP sux! pearl sux!
Regards
Mirco
------------------------------
Date: Fri, 02 Feb 2007 14:10:19 -0800
From: Purl Gurl <purlgurl@purlgurl.net>
Subject: Re: Problems dealing with dates in Windows
Message-Id: <45C3B6CB.5070904@purlgurl.net>
Mirco Wahab wrote:
> Purl Gurl wrote:
>> GGelz wrote:
>> These results you report are consistent for older
>> DOS 6 / 7 typical for Windows 98 and Windows ME.
> You are on the wrong track. I can reproduce his
> error message "under WinXP" without problems here:
> 5.008008 on linux
> 5.008007 on cygwin
No, you are on the wrong track.
Linux is not Windows XP. Cygwin is not Windows XP.
Neither are a DOS 6 / 7 command line.
Others present precisely the same results as mine,
using Windows XP. Why have you singled me for
response but not others reporting precisely
the same results I report?
Purl Gurl
------------------------------
Date: 2 Feb 2007 22:13:22 GMT
From: Glenn Jackman <glennj@ncf.ca>
Subject: Re: Problems dealing with dates in Windows
Message-Id: <slrnes7ds3.o5h.glennj@smeagol.ncf.ca>
At 2007-02-02 01:42PM, "John Bokma" wrote:
> "Paul Lalli" <mritty@gmail.com> wrote:
>
> > On what OS version? On my WinXP, I get:
> > C:\>perl -le"print `date /T`"
> > 02/02/2007
>
> No Fri?
Depends on your regional settings. I use:
C:\>date /t
2007-02-02
C:\>perl -MWin32::TieRegistry -e "print $Registry->{'HKEY_CURRENT_USER\Control Panel\International\sShortDate'}"
yyyy-MM-dd
--
Glenn Jackman
"You can only be young once. But you can always be immature." -- Dave Barry
------------------------------
Date: Fri, 02 Feb 2007 17:17:46 +0100
From: Mirco Wahab <wahab-mail@gmx.de>
Subject: Re: Randomly Choose from an Array
Message-Id: <epvoh3$rs3$1@mlucom4.urz.uni-halle.de>
Abigail wrote:
> Mirco Wahab (wahab-mail@gmx.de) wrote on MMMMCMII September MCMXCIII in
> <URL:news:epts1r$apa$1@mlucom4.urz.uni-halle.de>:
> @@ But to be honest, I tried to give something like an 'alternative
> @@ formulation' for the 'shuffle', and the trivial solution like
> @@
> @@ my @r = (1, 2, 3, 4);
> @@
> @@ @r[$_->[0], $_->[1]] = @r[$_->[1], $_->[0]] for map [$_, int rand @r], 0..$#r;
>
> That's not a fair shuffle:
>
> 1 2 3 4: 977
> ...
> 4 3 2 1: 968
>
> Shorter, and fair:
>
> $r=@r;$i=rand$r--,@r[$i,$r]=@r[$r,$i]while$r;
Thats correct. My version from above over-generates
some pattern -- resulting in a wrong distribution.
I'm still struggling to see how your (wonderful)
example leads to equal distributed sets, but I
think (from intensive staring at your code) that
one has to 'move' both indexes with equal probability
in order to avoid overrepresentation of some sets.
(I'll look into this later ..)
Regards & thanks for this one ...
Mirco
------------------------------
Date: 02 Feb 2007 17:32:58 GMT
From: Abigail <abigail@abigail.be>
Subject: Re: Randomly Choose from an Array
Message-Id: <slrnes6tdt.ekq.abigail@alexandra.abigail.be>
Mirco Wahab (wahab-mail@gmx.de) wrote on MMMMCMIII September MCMXCIII in
<URL:news:epvoh3$rs3$1@mlucom4.urz.uni-halle.de>:
,, Abigail wrote:
,, > Mirco Wahab (wahab-mail@gmx.de) wrote on MMMMCMII September MCMXCIII in
,, > <URL:news:epts1r$apa$1@mlucom4.urz.uni-halle.de>:
,, > @@ But to be honest, I tried to give something like an 'alternative
,, > @@ formulation' for the 'shuffle', and the trivial solution like
,, > @@
,, > @@ my @r = (1, 2, 3, 4);
,, > @@
,, > @@ @r[$_->[0], $_->[1]] = @r[$_->[1], $_->[0]] for map [$_, int rand @r], 0..$#r;
,, >
,, > That's not a fair shuffle:
,, >
,, > 1 2 3 4: 977
,, > ...
,, > 4 3 2 1: 968
,, >
,, > Shorter, and fair:
,, >
,, > $r=@r;$i=rand$r--,@r[$i,$r]=@r[$r,$i]while$r;
,,
,, Thats correct. My version from above over-generates
,, some pattern -- resulting in a wrong distribution.
,,
,, I'm still struggling to see how your (wonderful)
,, example leads to equal distributed sets, but I
,, think (from intensive staring at your code) that
,, one has to 'move' both indexes with equal probability
,, in order to avoid overrepresentation of some sets.
,, (I'll look into this later ..)
Easy, using a pointer to loop over the array, it randomly picks (with
equal probability) an element that hasn't been picked yet, and swaps
it with the element the pointer is pointing at. (The element pointed at
can be picked). It then moves the pointer. Elements that have been picked
will never be picked again.
A precise proof can be found using induction.
Abigail
--
INIT {print "Perl " }
CHECK {print "another "}
BEGIN {print "Just " }
END {print "Hacker\n"}
------------------------------
Date: Fri, 02 Feb 2007 12:48:08 -0500
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: Randomly Choose from an Array
Message-Id: <g691wl85u3r.fsf@dhcp-65-162.kendall.corp.akamai.com>
On Fri, 02 Feb 2007 17:17:46 +0100 Mirco Wahab <wahab-mail@gmx.de> wrote:
MW> Abigail wrote:
>> Mirco Wahab (wahab-mail@gmx.de) wrote on MMMMCMII September MCMXCIII in
>> <URL:news:epts1r$apa$1@mlucom4.urz.uni-halle.de>:
>> @@ But to be honest, I tried to give something like an 'alternative
>> @@ formulation' for the 'shuffle', and the trivial solution like
>> @@ @@ my @r = (1, 2, 3, 4);
>> @@ @@ @r[$_->[0], $_->[1]] = @r[$_->[1], $_->[0]] for map [$_,
>> int rand @r], 0..$#r;
>>
>> That's not a fair shuffle:
>>
>> 1 2 3 4: 977
>> ...
>> 4 3 2 1: 968
>>
>> Shorter, and fair:
>>
>> $r=@r;$i=rand$r--,@r[$i,$r]=@r[$r,$i]while$r;
MW> Thats correct. My version from above over-generates
MW> some pattern -- resulting in a wrong distribution.
MW> I'm still struggling to see how your (wonderful) example leads to
MW> equal distributed sets, but I think (from intensive staring at
MW> your code) that one has to 'move' both indexes with equal
MW> probability in order to avoid overrepresentation of some sets.
MW> (I'll look into this later ..)
The easiest way to prove it is correct (I think) is by induction. The
1-element case is obvious.
Basically for 2 elements you have a 50% chance they will be swapped:
$i is between 0 and 2 on the first cycle, 0 and 1 on the second (last)
cycle, so the first cycle has a 50$ chance of swapping and the second
(last) cycle always swaps.
Add 1 element. Now the first cycle has a 1/3 chance of swapping
elements $r[0] and $r[2] and 1/3 chance of swapping $r[1] and $r[2],
so the new (third and last) element $r[2] has equal chances of ending
up in any position. The second and third (last) cycles shuffle the
2-element array we already did.
Thus for N elements, the last one will have a 1/N chance of ending in
any position on the first cycle, and we take the first N-1 elements of
the resulting array to be shuffled fairly and independently by the
remaining cycles.
Like qsort, it's pretty simple once you see the pattern, but hell on
the braincells until you do :)
Ted
------------------------------
Date: 2 Feb 2007 14:13:47 -0800
From: Terry.Riegel@gmail.com
Subject: Split a very large log file
Message-Id: <1170454427.379794.108070@m58g2000cwm.googlegroups.com>
I have a 9gig log file, I am trying to do something with it. I tried
to run it through awstats and after about 8 hours I got a segmentation
fault.
I think if I could break it up into 2 files I could process one , then
process the other. I am not very good at PERL, but have to believe
this would be a 5-10 line program.
Any ideas?
Thanks,
Terry Riegel
------------------------------
Date: Fri, 02 Feb 2007 16:43:17 -0600
From: "J. Gleixner" <glex_no-spam@qwest-spam-no.invalid>
Subject: Re: Split a very large log file
Message-Id: <45c3be2b$0$498$815e3792@news.qwest.net>
Terry.Riegel@gmail.com wrote:
> I have a 9gig log file, I am trying to do something with it. I tried
> to run it through awstats and after about 8 hours I got a segmentation
> fault.
>
> I think if I could break it up into 2 files I could process one , then
> process the other. I am not very good at PERL, but have to believe
> this would be a 5-10 line program.
Yep.. why not post what you've tried.
Also, if you're on *nix? There are a bunch of
commands that will do it:
man split
man head
man tail
------------------------------
Date: 2 Feb 2007 17:10:21 GMT
From: John Bokma <john@castleamber.com>
Subject: Re: Stick Lines and Dividers Between Text
Message-Id: <Xns98CB71A6F7B43castleamber@130.133.1.4>
vjp2@panix.com wrote:
> is that x or *???
>
> perl -pe 'if ($.%4==2){$_.="-" x 37} elseif {$.%4==0) {$_.="=" x 37}
> $_.="\n"' < %1 >%1
x
"-" x 37 is an expression that results in
----------------- ... ---
<-- 37 characters -->
--
John Experienced Perl programmer: http://castleamber.com/
Perl help, tutorials, and examples: http://johnbokma.com/perl/
------------------------------
Date: 2 Feb 2007 11:34:41 -0800
From: joseph85750@yahoo.com
Subject: Re: Storing results in array rather than printing
Message-Id: <1170444881.543276.172950@a34g2000cwb.googlegroups.com>
On Feb 1, 4:21 pm, xhos...@gmail.com wrote:
> joseph85...@yahoo.com wrote:
> > I have a unix program called zathras which will generate some useful
> > output results when a file is piped into it.
>
> > ie:
>
> > cat /path/to/asci-file.txt | zathras
> > (this will output some text I wish to capture)
>
> > I'm trying to write aperlscript to execute the above, but not from a
> > file piped in. Instead, a variable within theperlscript, since the
> > asci-file.txt above will have changing content. Here's what I have so
> > far:
>
> > $someData="12 15 77 19 42 2112 99 88"; #data from asci-file.txt
>
> > open (FOO,"|zathras");
>
> > print FOO $someData;
> > close;
>
> > This works, and behaves exactly as running the program directly from
> > unix. But what I really want is to store the results in an array,
> > rather than printing.
>
> > I suspected I could do something like:
>
> > @array=<FOO $someData>;
>
> my @array = `echo '$someData' | zathras`;
>
> This could be problematic if the shell interprets the characters in
> $someData (particular if $someData contains quotes, or on some systems,
> newlines)
>
> Also, IPC::Open2 would work, but getting the buffering right is not trivial
> if $someData is big and you are not used to that kind of thing.
>
> Xho
>
> --
> --------------------http://NewsReader.Com/--------------------
> Usenet Newsgroup Service $9.95/Month 30GB
Thanks for the replies, everyone. I couldn't get IPC::Open2 to work,
but I understand the need now. The system call solution:
@array = `echo '$someData' | zathras`
worked, and I'll stick with that. I was hoping to avoid a system
call, but I'm tired.
Thanks again!
------------------------------
Date: 2 Feb 2007 20:03:43 GMT
From: John Bokma <john@castleamber.com>
Subject: Re: Storing results in array rather than printing
Message-Id: <Xns98CB8F0B555D0castleamber@130.133.1.4>
joseph85750@yahoo.com wrote:
> @array = `echo '$someData' | zathras`
but at least there is symmetry :-D
--
John Experienced Perl programmer: http://castleamber.com/
Perl help, tutorials, and examples: http://johnbokma.com/perl/
------------------------------
Date: Fri, 02 Feb 2007 08:40:51 -0800
From: Fred Hare <fred4414@nethere.com>
Subject: Re: Win32::Clipboard mutilates \n
Message-Id: <RoqdndCaB5oH9F7YnZ2dnUVZ8s2mnZ2d@giganews.com>
Sisyphus wrote:
> "Fred Hare" <fred4414@nethere.com> wrote in message
> news:tPidneCOVrYU81_YnZ2dnUVZ8t2snZ2d@giganews.com...
> .
> .
>> OK, I tried 8 different text editors and also
>> my $clip = Win32::Clipboard::GetText();
>> print "Clipboard content is $clip\n" ;
>>
>> All but Windows Notepad and UltraEdit converted "0A" back to "0D 0A"
>
> Do they convert back to "0D 0A" or do they simply print the newline on the
> strength of the solitary "0A" ?
>
> It seems to me that Win32::Clipboard copies exactly what it is given:
>
> C:\_32\pscrpt>type try.pl
> use strict ;
> use warnings ;
> use Win32::Clipboard ;
>
> my $CLIP = Win32::Clipboard();
>
> my $block = "line1\nline2\nline3\n" ;
>
> for(0 .. length($block) - 1) {
> printf "%x ", ord(substr($block, $_, 1));
> }
>
> print "\n";
>
> $CLIP->Set($block);
>
> my $text = Win32::Clipboard::GetText();
>
> for(0 .. length($text) - 1) {
> printf "%x ", ord(substr($text, $_, 1));
> }
>
>
> C:\_32\pscrpt>perl try.pl
> 6c 69 6e 65 31 a 6c 69 6e 65 32 a 6c 69 6e 65 33 a
> 6c 69 6e 65 31 a 6c 69 6e 65 32 a 6c 69 6e 65 33 a
>
> Some text editors (such as Wordpad) seem to happily print a newline on the
> strength of a solitary "0A". Others, such as Notepad, will not.
>
> If you want to be sure that the editor does what you want, I think you need
> to replace each occurrence of "\n" with "\r\n" - which will hopefully work
> for *all* text editors.
>
> Cheers,
> Rob
>
Yes, that is correct. But I use UltraEdit *because* it is also a
hex-editor, and if it would change 0A to 0D 0A like all the other
editors its use as hex-editor would be limited.
I now started using a WinBatch script which copies newlines to the
clipboard as 0D 0A and shows correctly in all text editors...
Fred
--
When using my email address, add the word "Trustme" anywhere on the
subject-line. Otherwise the message will be deleted on the server.
------------------------------
Date: 2 Feb 2007 14:15:31 -0800
From: cylurian@gmail.com
Subject: Writing Math Equations in PERL for HTML
Message-Id: <1170454529.274828.120500@k78g2000cwa.googlegroups.com>
Hello everyone. I create a lot of math questions with PERL and
display them in html. One item that kills me is using negative signs,
especially for displaying on html. Question is what is the best
efficient way to account for positive and negative (addition and
subtraction) signs when displaying in html? I write many conditional
statements so I can account for the sign (operations). For example,
lets say I have a quadratic: ax^2 + bc + c = 0
And I want a, b and c to be random from -9 to -1 and 1 to 9. When I
print the problem, I have to all the cases for displaying in html.
If (($a >= 1)&&($b >= 1)&&($c >= 1) {
print "$a x<sup>2</sup> + $b x + $c = 0";
}elsif (($a >= 1)&&($b <= 1)&&($c >= 1)) {
print "$a x<sup>2</sup> $b x + $c = 0";
}..... keeps going until I cover all possible combinations with negative
and positive signs. Any suggestions on being more efficient?
------------------------------
Date: 2 Feb 2007 14:27:28 -0800
From: "Brian McCauley" <nobull67@gmail.com>
Subject: Re: Writing Math Equations in PERL for HTML
Message-Id: <1170455248.615766.245680@h3g2000cwc.googlegroups.com>
On Feb 2, 10:15 pm, cylur...@gmail.com wrote:
> Hello everyone. I create a lot of math questions with PERL and
> display them in html. One item that kills me is using negative signs,
> especially for displaying on html. Question is what is the best
> efficient way to account for positive and negative (addition and
> subtraction) signs when displaying in html? I write many conditional
> statements so I can account for the sign (operations). For example,
> lets say I have a quadratic: ax^2 + bc + c = 0
>
> And I want a, b and c to be random from -9 to -1 and 1 to 9. When I
> print the problem, I have to all the cases for displaying in html.
>
> If (($a >= 1)&&($b >= 1)&&($c >= 1) {
>
> print "$a x<sup>2</sup> + $b x + $c = 0";
>
> }elsif (($a >= 1)&&($b <= 1)&&($c >= 1)) {
>
> print "$a x<sup>2</sup> $b x + $c = 0";
>
> }..... keeps going until I cover all possible combinations with negative
>
> and positive signs. Any suggestions on being more efficient?
printf "%dx<sup>2</sup>%+dx%+d=0",$a,$b,$c;
------------------------------
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 V11 Issue 99
*************************************