[23681] in Perl-Users-Digest
Perl-Users Digest, Issue: 5888 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Dec 3 18:05:49 2003
Date: Wed, 3 Dec 2003 15:05:12 -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 Wed, 3 Dec 2003 Volume: 10 Number: 5888
Today's topics:
Re: Add File Names with Time Stamp (Malcolm Dew-Jones)
Re: Add File Names with Time Stamp <mahesha-at-mahesha-dot-net>
Another sort question. (Mal)
Re: Another sort question. (Anno Siegel)
Can an .OCX be used in Perl? <martinvalley@comcast.net>
Re: Can an .OCX be used in Perl? <mgjv@tradingpost.com.au>
Re: Capture external command output line by line on Win <bik.mido@tiscalinet.it>
Re: Descending sort <tore@aursand.no>
Re: Descending sort <tore@aursand.no>
Re: Descending sort (Anno Siegel)
Re: Don't Read - Testing (Anno Siegel)
email attachments - doc file (Nara Bala)
Re: email attachments - doc file <me@privacy.net>
Re: Generating Day of Week in Pure Perl <abigail@abigail.nl>
How to disable print() function buffering in perl? (KJ)
Re: How to disable print() function buffering in perl? <lmai@mytum.de>
In search of elegant code: is variable is within a rang (David Filmer)
Re: In search of elegant code: is variable is within a <invalid-email@rochester.rr.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 3 Dec 2003 13:27:28 -0800
From: yf110@vtn1.victoria.tc.ca (Malcolm Dew-Jones)
Subject: Re: Add File Names with Time Stamp
Message-Id: <3fce5540@news.victoria.tc.ca>
Picker Leon (Temp@NoSuchDomain.Info) wrote:
: Here is what I wrote. Works 100%. But the only problem is if I have two
: files with the same timestamp, it will overwrite it. Can you fix it? If the
: rename to exit, then add a A to the end of the file
: #############start
: #!/usr/local/bin/perl
: $some_dir='.';
: opendir(DIR, $some_dir) || die "can't opendir $some_dir: $!";
: @dots = grep { /.jpg/ } readdir(DIR);
: closedir DIR;
: for (@dots) {
: ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
: $atime,$mtime,$ctime,$blksize,$blocks)
: = stat($_);
: ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =
: localtime($mtime);
: $year = sprintf("%02d", $year % 100);
: $mon = sprintf("%02d", $mon % 100);
: $mday = sprintf("%02d", $mday % 100);
: $hour = sprintf("%02d", $hour % 100);
: $min = sprintf("%02d", $min % 100);
: $sec = sprintf("%02d", $sec % 100);
: $new= "$year$mon$mday$hour$min$sec.jpg";
: print "$new\n";
: rename $_, $new;
A very simple change that would work most of the time, and all the time if
you choose the syntax carefully.
rename $_, "$_-$new" or warn(qq{rename $_, "$_-$new" : $!});
The old name was unique, so the new name will _eventually_ be unique.
This can still overwrite a file, but choose a syntax for the new names
that you know will work. (e.g. if no files have two dashes in their names
then use two dashes in the new name).
------------------------------
Date: Wed, 03 Dec 2003 13:55:10 -0800
From: Mahesha <mahesha-at-mahesha-dot-net>
Subject: Re: Add File Names with Time Stamp
Message-Id: <vssmtultm5eq25@corp.supernews.com>
Picker Leon wrote:
> I have 1000 pictures files from digital camera. I want to rename the files
> so that the file will have the time stamp so that I can know where I took
> those pictures. If I FTP those files, the time stampe will always change etc
> so I must include the time stamp into the filename. Here is what I want PERL
> to do:
>
> Dir the directory
> Add each file's timestamp to the end of the file name.
>
> Anyone knows a little script to do that work?
>
>
I use Image::Info to get similar information from my digital pictures.
If your camera stores timestamp in the jpeg file, you could use this
method too. That way, even if you ftp your pictures, you can still get
the original timestamp.
http://search.cpan.org/~gaas/Image-Info-1.15/lib/Image/Info.pm
HTH,
Mahesh.
------------------------------
Date: 3 Dec 2003 12:01:51 -0800
From: mpatt644@yahoo.com (Mal)
Subject: Another sort question.
Message-Id: <66f79aeb.0312031201.34e0e070@posting.google.com>
Hi,
I've got some data that looks someting like this:
Disabled blah,blah,blah 18:00
Disabled blah,blah,blah 19:30
Enabled blah,blah,blah 1:30
Enabled blah,blah,blah 3:50
Enabled blah,blah,blah 23:30
Enabled blah,blah,blah 18:30
Enabled blah,blah,blah 20:50
Enabled blah,blah,blah 23:40
and I'm sorting it using:
sort {
$aEnabledField=substr($a,0,20);
$bEnabledField=substr($b,0,20);
($aHourField,$aMinField)=split /:/,substr($a,38,20);
($bHourField,$bMinField)=split /:/,substr($b,38,20);
$aEnabledField cmp $bEnabledField
||
$aHourField <=> $bHourField
||
$aMinField <=> $bMinField
}
which works in as much it sorts first by the Enabled/Disabled field,
and then by time. However I want to change it so that the time fields
after 17:00 are sorted first, and times before 17:00 sort last. So the
above data would come out like:
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
TIA for any help.
M:
------------------------------
Date: 3 Dec 2003 22:38:13 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Another sort question.
Message-Id: <bqlokl$dai$1@mamenchi.zrz.TU-Berlin.DE>
Mal <mpatt644@yahoo.com> wrote in comp.lang.perl.misc:
> Hi,
> I've got some data that looks someting like this:
>
>
> Disabled blah,blah,blah 18:00
> Disabled blah,blah,blah 19:30
> Enabled blah,blah,blah 1:30
> Enabled blah,blah,blah 3:50
> Enabled blah,blah,blah 23:30
> Enabled blah,blah,blah 18:30
> Enabled blah,blah,blah 20:50
> Enabled blah,blah,blah 23:40
>
>
> and I'm sorting it using:
>
> sort {
> $aEnabledField=substr($a,0,20);
> $bEnabledField=substr($b,0,20);
> ($aHourField,$aMinField)=split /:/,substr($a,38,20);
> ($bHourField,$bMinField)=split /:/,substr($b,38,20);
>
> $aEnabledField cmp $bEnabledField
> ||
> $aHourField <=> $bHourField
> ||
> $aMinField <=> $bMinField
> }
>
> which works in as much it sorts first by the Enabled/Disabled field,
^^^^^
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
------------------------------
Date: Wed, 03 Dec 2003 13:02:37 -0700
From: Martin <martinvalley@comcast.net>
Subject: Can an .OCX be used in Perl?
Message-Id: <24gssv8jn23sasi8m5i9a48i8or2prgdtq@4ax.com>
Can an .OCX (ActiveX) that is normally used in a Windows Visual Basic
program be used in a Perl/Unix environment?
------------------------------
Date: 03 Dec 2003 21:52:20 GMT
From: Martien Verbruggen <mgjv@tradingpost.com.au>
Subject: Re: Can an .OCX be used in Perl?
Message-Id: <slrnbssmom.2sd.mgjv@verbruggen.comdyn.com.au>
On Wed, 03 Dec 2003 13:02:37 -0700,
Martin <martinvalley@comcast.net> wrote:
> Can an .OCX (ActiveX) that is normally used in a Windows Visual Basic
> program be used in a Perl/Unix environment?
No.
Martien
--
|
Martien Verbruggen | We are born naked, wet and hungry. Then
Trading Post Australia | things get worse.
|
------------------------------
Date: Wed, 03 Dec 2003 20:57:50 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: Capture external command output line by line on Windows 98, shell problem.
Message-Id: <p38ssv4ijhh6r5etgenc6u932jaonf1ps3@4ax.com>
On Wed, 3 Dec 2003 07:46:04 -0600, tadmc@augustmail.com (Tad
McClellan) wrote:
>><OT>
> ^^^^
> ^^^^
>
>> print ($_);
>> print $_;
>> print;
>
>That sure looks like Perl to me...
OT wrt the subject line!
Michele
--
# This prints: Just another Perl hacker,
seek DATA,15,0 and print q... <DATA>;
__END__
------------------------------
Date: Wed, 03 Dec 2003 20:24:07 +0100
From: Tore Aursand <tore@aursand.no>
Subject: Re: Descending sort
Message-Id: <pan.2003.12.03.13.24.23.60474@aursand.no>
On Wed, 03 Dec 2003 11:37:34 +0000, Anno Siegel wrote:
>> I have a flat database file this way:
>>
>> A00469.PE1 SSGGH.PE1 HBG011318 1.26943 39
>> A00469.PE1 SGGH2.PE1 HBG011318 1.26943 110
>> A14829.PE1 SSAPOLAI.PE1 HBG004257 1.88791 39
>> A14829.PE1 DRAPLIPAI.PE1 HBG004257 1.96625 386
>> A14829.PE1 AF042219.PE1 HBG004257 2.03983 110
>>
>> The fields are tab separated. I want it this way:
>> A00469.PE1 SGGH2.PE1 HBG011318 1.26943 110
>> A00469.PE1 SSGGH.PE1 HBG011318 1.26943 39
>> A14829.PE1 DRAPLIPAI.PE1 HBG004257 1.96625 386
>> A14829.PE1 AF042219.PE1 HBG004257 2.03983 110
>> A14829.PE1 SSAPOLAI.PE1 HBG004257 1.88791 39
> No column in your proposed output data is sorted, [...]
Really? It seems to me that the data is sorted based on the values of
columns 3 and 5.
But! It's quite a guess from me, though; The OP _should_ have given us a
better understanding of what (s)he really want to do.
--
Tore Aursand <tore@aursand.no>
"Every man usually has something he can do better than anyone else.
Usually it is reading his own handwriting." -- Unknown
------------------------------
Date: Wed, 03 Dec 2003 20:24:07 +0100
From: Tore Aursand <tore@aursand.no>
Subject: Re: Descending sort
Message-Id: <pan.2003.12.03.13.37.01.395855@aursand.no>
On Wed, 03 Dec 2003 11:48:23 +0100, Colossus wrote:
> I have a flat database file this way:
>
> A00469.PE1 SSGGH.PE1 HBG011318 1.26943 39
> A00469.PE1 SGGH2.PE1 HBG011318 1.26943 110
> A14829.PE1 SSAPOLAI.PE1 HBG004257 1.88791 39
> A14829.PE1 DRAPLIPAI.PE1 HBG004257 1.96625 386
> A14829.PE1 AF042219.PE1 HBG004257 2.03983 110
>
> The fields are tab separated. I want it this way:
> A00469.PE1 SGGH2.PE1 HBG011318 1.26943 110
> A00469.PE1 SSGGH.PE1 HBG011318 1.26943 39
> A14829.PE1 DRAPLIPAI.PE1 HBG004257 1.96625 386
> A14829.PE1 AF042219.PE1 HBG004257 2.03983 110
> A14829.PE1 SSAPOLAI.PE1 HBG004257 1.88791 39
Well. You don't actually tell us the criteria for your sorting, but it
seems to me that you'd like to sort the numeric value of column 5, then by
column 3, in a descending order.
For that, use Sort::Fields from CPAN.
--
Tore Aursand <tore@aursand.no>
"Nothing is certain but death and taxes. Of the two, taxes happen
annually." -- Joel Fox
------------------------------
Date: 3 Dec 2003 21:13:42 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Descending sort
Message-Id: <bqljm6$a4t$1@mamenchi.zrz.TU-Berlin.DE>
Tore Aursand <tore@aursand.no> wrote in comp.lang.perl.misc:
> On Wed, 03 Dec 2003 11:37:34 +0000, Anno Siegel wrote:
> >> I have a flat database file this way:
> >>
> >> A00469.PE1 SSGGH.PE1 HBG011318 1.26943 39
> >> A00469.PE1 SGGH2.PE1 HBG011318 1.26943 110
> >> A14829.PE1 SSAPOLAI.PE1 HBG004257 1.88791 39
> >> A14829.PE1 DRAPLIPAI.PE1 HBG004257 1.96625 386
> >> A14829.PE1 AF042219.PE1 HBG004257 2.03983 110
> >>
> >> The fields are tab separated. I want it this way:
> >> A00469.PE1 SGGH2.PE1 HBG011318 1.26943 110
> >> A00469.PE1 SSGGH.PE1 HBG011318 1.26943 39
> >> A14829.PE1 DRAPLIPAI.PE1 HBG004257 1.96625 386
> >> A14829.PE1 AF042219.PE1 HBG004257 2.03983 110
> >> A14829.PE1 SSAPOLAI.PE1 HBG004257 1.88791 39
>
> > No column in your proposed output data is sorted, [...]
>
> Really? It seems to me that the data is sorted based on the values of
> columns 3 and 5.
So no column is sorted, qed :)
Since columns 1 and 3 agree in all visible cases, the result is also
sorted wrt columns 1 and 5, which is what I happened to notice first.
Such are the possible (and actual) misunderstandings caused by a
lacking description.
> But! It's quite a guess from me, though; The OP _should_ have given us a
> better understanding of what (s)he really want to do.
Indeed.
Anno
------------------------------
Date: 3 Dec 2003 22:12:14 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Don't Read - Testing
Message-Id: <bqln3u$cen$1@mamenchi.zrz.TU-Berlin.DE>
Alquemius <Alquemius@hotmail.com> wrote in comp.lang.perl.misc:
> I am sorry for that HUGE mistake i have commited. It was just a test of my
> account, and i needed to do it in the channel i was intending to use.
This is Usenet, there are no channels. What you are talking to is called
a newsgroup. If the software you use to access Usenet doesn't allow you
to post tests to a test group it is unfit for use. Get something else.
You are on new territory and don't know the local habits. Sneering
irony is not going to endear you to the natives.
> Up from this moment, that i hope everything is properly fixed, the main
> subject of every mail i post will be Perl Programming and all the terms
> related with biological aplications of Perl, ok?
Let's hope so. Note that by top-posting you have violated another Usenet
rule. I guess it's best you take a look at the posting guidelines, posted
regularly to this group.
[...]
> PS: Its incredible that a 1KB test post can generate a conversation... lol
...nor do the natives appreciate outright laughter at their strange habits.
[TOFU snipped]
Anno
------------------------------
Date: 3 Dec 2003 08:19:52 -0800
From: bnaray@rediffmail.com (Nara Bala)
Subject: email attachments - doc file
Message-Id: <9f47aead.0312030819.6bd23e3a@posting.google.com>
Hi,
I am doing a cgi script through which the client attaches a file on
the local machine and submits a form, upon which the file is uploaded
to an unix-based server and emailed using sendmail as an attachment.
I am able to send ordinary text files successfully. But when I try
doing it for word documents. The file is attached and sent. But when I
recieve it, the file is slighlty largerthan the original file and it
doesnt open in Word. The word throws an error saying "The document
name or path is not valid....". I tried saving the file to local
machine and then opening still i have the same problem.
Pls. let me know what mistake I am making.
Look at this code -
#!/usr/bin/perl
use CGI;
use CGI qw(:standard);
require 'CGI_LIB.pl';
my $sendmail = "/usr/lib/sendmail -t";
my $filename = "/srcm/smsf/temp/uploadedFile.txt";
&Parse_Multi;
binmode($CGI);
open(SENDMAIL, "|$sendmail") or die "Cannot open $sendmail: $!";
print SENDMAIL <<"EOF";
Content-Transfer-Encoding: 7bit
Content-Type: multipart/mixed; boundary="=_3D647253.85E4AEC4"
MIME-Version: 1.0
Date: Thu, 21 Mar 2002 19:32:35 UT
From: nara\@hotmail.com
To: narayananb\@ami.com
Subject: Testing File Attachments - quoted printable
This is a MIME message. If you are reading this text, you may want to
consider changing to a mail
reader or gateway that understands how to properly handle MIME
multipart messages.
--=_3D647253.85E4AEC4
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline
Test from Shane
Hello World
--=_3D647253.85E4AEC4
Content-Description: "$filename"
Content-Type: $CGI{'UploadedFile'}->{'Content-Type'};
charset=iso-8859-1
Content-Disposition: attachment; filename="file_name.doc"
$CGI{'UploadedFile'}->{'Contents'}
--=_3D647253.85E4AEC4--
EOF
close(SENDMAIL) or warn "sendmail did not close nicely";
$url = "/others/feedback-thanks.html";
print "Location: $url\n\n";
# end of code
exit;
thanks,
Nara
------------------------------
Date: Thu, 4 Dec 2003 08:21:27 +1300
From: "Tintin" <me@privacy.net>
Subject: Re: email attachments - doc file
Message-Id: <bqld5b$24369u$1@ID-172104.news.uni-berlin.de>
"Nara Bala" <bnaray@rediffmail.com> wrote in message
news:9f47aead.0312030819.6bd23e3a@posting.google.com...
> Hi,
> I am doing a cgi script through which the client attaches a file on
> the local machine and submits a form, upon which the file is uploaded
> to an unix-based server and emailed using sendmail as an attachment.
> I am able to send ordinary text files successfully. But when I try
> doing it for word documents. The file is attached and sent. But when I
> recieve it, the file is slighlty largerthan the original file and it
> doesnt open in Word. The word throws an error saying "The document
> name or path is not valid....". I tried saving the file to local
> machine and then opening still i have the same problem.
> Pls. let me know what mistake I am making.
> Look at this code -
>
>
> #!/usr/bin/perl
Where's the:
use strict;
> use CGI;
> use CGI qw(:standard);
No need/use/point in trying to use the CGI module twice.
> require 'CGI_LIB.pl';
Why use another CGI module, surely one is enough?
>
> my $sendmail = "/usr/lib/sendmail -t";
> my $filename = "/srcm/smsf/temp/uploadedFile.txt";
> &Parse_Multi;
Why are you using the & for the function call?
[snipped a whole bunch of hardcoded MIME encoding that would be much better
done using the MIME::Lite module]
------------------------------
Date: 03 Dec 2003 18:41:20 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: Generating Day of Week in Pure Perl
Message-Id: <slrnbssbig.eu.abigail@alexandra.abigail.nl>
rev (rev@TheWaterCooler.com) wrote on MMMDCCXLIV September MCMXCIII in
<URL:news:7qOyb.28801$2y3.5045@newssvr29.news.prodigy.com>:
$$ I have a date formatted like so MM/DD/YYYY (e.g. 12/01/2003) and I need
$$ to get the day of the week from this (Monday). But, this is occurring
$$ on my hosting vendor so whatever does it needs to be pure Perl.
$$
$$ I cannot use the POSIX package.
$$ I cannot install any package that requires compilation.
$$ Anything I use needs to work through the year 2100.
$$
$$ Any suggestions on this?
Sure, use this handy module (works only for days since 1 Jan 1970):
package Week; # Finds the day of the week!
# No dependency on any modules.
sub import {
my $pkg = shift;
my $caller = caller ();
*{$caller . "::day_of_week"} = \&{$pkg . "::day_of_week"};
}
my @days = qw /Thursday Friday Saturday Sunday Monday Tuesday Wednesday/;
sub day_of_week {
local $_ = shift;
die "Illegal date format '$_' given to day_of_week\n" unless
my ($mm, $dd, $yyyy) = m!^(\d{2})/(\d{2})/(\d{4})$!;
my ($d, $m, $y) = (1, 1, 1970);
my $counter = 0;
{
return if $yyyy < $y;
return $days [$counter % @days] if $y == $yyyy &&
$m == $mm &&
$d == $dd;
$counter ++;
$d ++;
if ($d > 31 || $d == 31 && ($m == 4 || $m == 6 || $m == 9 || $m == 11)
|| $d == 29 && $m == 2 && ($y % 4 || $y % 100 == 0 &&
$y % 400)
|| $d == 30 && $m == 2) {
$d = 1;
if (++ $m > 12) {
$m = 1;
$y ++
}
}
redo
}
}
1;
__END__
Abigail
--
BEGIN {$^H {q} = sub {$_ [1] =~ y/S-ZA-IK-O/q-tc-fe-m/d; $_ [1]}; $^H = 0x28100}
print "Just another PYTHON hacker\n";
------------------------------
Date: 3 Dec 2003 10:24:19 -0800
From: ziggycpu@hotmail.com (KJ)
Subject: How to disable print() function buffering in perl?
Message-Id: <fd40be35.0312031024.25db342@posting.google.com>
Hello,
I'm having a touch of trouble with a fairly simple program that I am
writing. It is a program that executes some interesting sorting
routines (I prefer using my own sort since it allows greater control
and debugging output, especially when the data set I'm using is very
large and "dirty" - ie. many erroneous values that I filter out during
the sort.)
Anyway, on to my question... The program has a statement such as
this:
$sortcount=0;
$debug=1;
while($condition)
{
if($debug)
{
$sortcount++;
if($sortcount%100000==0)
{
print(".");
}
}
<<SORTING CODE GOES HERE>>
}
My problem is this - with the program setup as above, the text gets
buffered for some reason (and doesn't appear on the screen at
run-time). I want the program to output a period (.) to the terminal
for every 100000 executions of the sort subroutine. When I execute
the code above, it outputs all of the periods after the sort
subroutine is finished. HOWEVER, when I run this code:
$sortcount=0;
$debug=1;
while($condition)
{
if($debug)
{
$sortcount++;
if($sortcount%100000==0)
{
print("$sortcount\n");
}
}
<<SORTING CODE GOES HERE>>
}
The program outputs the $sortcount number as the program is executing
and the sort is being performed.
My logic for why this is happening is this: PERL optimizes the code
(as all good compilers do) and erroneously thinks that since the "."
output is static, it is "unimportant" and can be buffered. In the
latter case, though, it sees that $sortcount is a dynamic variable
that is modified within the sort function's loop and deems it as
"important" - therefore outputting it to the screen without buffering
as the loop is executing.
Any ideas on how I can force PERL to deem that little period (.) as
important enough to output at runtime (and thus, disable print
buffering)? Any help or ideas that anyone can provide would be
greatly appreciated.
<<On a side note, I know there is a command "cerr <<" in C++ that
outputs a line of text as an "error" to the screen. Basically it is a
high-priority call to the print queue and followed by an immediate
buffer flush. Is there such an error output in PERL that I could use?
Keep in mind, this is for debugging purposes and will NOT be used in
the program on a regular basis... >>
Thanks,
KJ
------------------------------
Date: Wed, 3 Dec 2003 18:56:26 +0000 (UTC)
From: Lukas Mai <lmai@mytum.de>
Subject: Re: How to disable print() function buffering in perl?
Message-Id: <bqlbkq$4frqa$1@sunsystem5.informatik.tu-muenchen.de>
KJ <ziggycpu@hotmail.com> wrote:
> Hello,
[print "." vs print "$sortcount\n"]
> My logic for why this is happening is this: PERL optimizes the code
> (as all good compilers do) and erroneously thinks that since the "."
> output is static, it is "unimportant" and can be buffered. In the
> latter case, though, it sees that $sortcount is a dynamic variable
> that is modified within the sort function's loop and deems it as
> "important" - therefore outputting it to the screen without buffering
> as the loop is executing.
No, it's because STDOUT is line buffered by default, so "\n" forces
a flush.
> Any ideas on how I can force PERL to deem that little period (.) as
> important enough to output at runtime (and thus, disable print
> buffering)? Any help or ideas that anyone can provide would be
> greatly appreciated.
$| = 1;
$| is documented in perldoc perlvar. See also
http://perl.plover.com/FAQs/Buffering.html
> <<On a side note, I know there is a command "cerr <<" in C++ that
> outputs a line of text as an "error" to the screen. Basically it is a
> high-priority call to the print queue and followed by an immediate
> buffer flush. Is there such an error output in PERL that I could use?
> Keep in mind, this is for debugging purposes and will NOT be used in
> the program on a regular basis... >>
It's Perl, not PERL. There is STDERR, and it's unbuffered by default.
HTH, Lukas
------------------------------
Date: 3 Dec 2003 14:39:13 -0800
From: IneverReadAnythingSentToMe@hotmail.com (David Filmer)
Subject: In search of elegant code: is variable is within a range???
Message-Id: <e4c916dd.0312031439.69419e1e@posting.google.com>
Suppose I want to check if $foo is between 1 and 10. What I would like
to do is something elegant like:
if (1 < $foo < 10) {blah blah...
But Perl doesn't like that. Am I forced to resort to
if (1 < $foo && $foo < 10) {blah blah...
or is there a more elegant way to write it?
------------------------------
Date: Wed, 03 Dec 2003 23:01:32 GMT
From: Bob Walton <invalid-email@rochester.rr.com>
Subject: Re: In search of elegant code: is variable is within a range???
Message-Id: <3FCE68A4.8020806@rochester.rr.com>
David Filmer wrote:
> Suppose I want to check if $foo is between 1 and 10. What I would like
> to do is something elegant like:
>
> if (1 < $foo < 10) {blah blah...
>
> But Perl doesn't like that. Am I forced to resort to
>
> if (1 < $foo && $foo < 10) {blah blah...
>
> or is there a more elegant way to write it?
>
if(abs($foo-5.5)<4.5){blah blah...
--
Bob Walton
Email: http://bwalton.com/cgi-bin/emailbob.pl
------------------------------
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 5888
***************************************