[21862] in Perl-Users-Digest
Perl-Users Digest, Issue: 4066 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Nov 5 03:06:18 2002
Date: Tue, 5 Nov 2002 00:05:10 -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 Tue, 5 Nov 2002 Volume: 10 Number: 4066
Today's topics:
Re: "Premature end of script headers" error message <Dave.BarnettNOSPAM@westerngeco.com>
Re: A vision for Parrot (Cameron Laird)
Re: A vision for Parrot <robin@jessikat.fsnet.co.uk>
Re: A vision for Parrot <simon@simon-cozens.org>
Re: A vision for Parrot <cbbrowne@acm.org>
Re: A vision for Parrot <goldbb2@earthlink.net>
Re: CGI Upload Problems (ebchang)
How to copy some sections of a file that varies every m (Karen)
Re: How to copy some sections of a file that varies eve <mgjv@tradingpost.com.au>
Re: How to copy some sections of a file that varies eve <bobesch@letras.net>
Re: Perl -e "print qq! Tips and Tricks !" <dha@panix2.panix.com>
Re: Perl and large text files <spam@thecouch.homeip.net>
Tie'd filehandle and the system() function (Tim)
Re: Tie'd filehandle and the system() function <goldbb2@earthlink.net>
unwanted white space when I write to files (Matt Oefinger)
Re: unwanted white space when I write to files <steven.smolinski@sympatico.ca>
Re: unwanted white space when I write to files <jurgenex@hotmail.com>
Re: Written under a socket descriptor problem .... <nospam@nospam.com>
Re: ||= |= <goldbb2@earthlink.net>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 04 Nov 2002 18:26:44 -0600
From: Dave Barnett <Dave.BarnettNOSPAM@westerngeco.com>
Subject: Re: "Premature end of script headers" error message
Message-Id: <aq739d$6n2$1@news.sinet.slb.com>
Albert wrote:
> Hi,
>
> I try to start a perl script by executing it via the address bar of
> Internet Explorer. It is located on Apache Server with Linux.
>
> After this I get an Internal Server Error. In the Apache error log
> file I get the error message "Premature end of script headers".
>
> A friend of mine said it could be that I used the wrong Perl editor. I
> used the Windows editor to change the script. I doubt that's the
> reason. Could it be that I have to transfer the perl script to the
> host in binary and not in ASCII mode? I transfered it with WS-FTP in
> ASCII mode. By the way, what is the "script header"?
>
> It would be nice if you could help me.
>
> Thanks in advance.
>
> Albert
Albert:
This message usually means that your script did not print out the proper
heading for a valid html response.
You should:
1. Examine the logs for details regarding what has gone wrong.
2. Make sure that you do:
print "Content-type: text/html\n\n";
as the very first line that prints from your script. The double newlines
(\n\n) are important.
If that doeasn't help, see the information in "perldoc CGI", especially
about the "fatalstobrowser" bit.
One of those should give you some ideas....
Cheers,
Dave
--
Dave Barnett
Support bacteria -- they're the only culture some people have.
------------------------------
Date: Mon, 04 Nov 2002 23:09:18 -0000
From: claird@lairds.com (Cameron Laird)
Subject: Re: A vision for Parrot
Message-Id: <usdvgusfjjbcd2@corp.supernews.com>
In article <87vg3dt21t.fsf@simoncozens-2.dsl.easynet.co.uk>,
Simon Cozens <simon@simon-cozens.org> wrote:
.
.
.
>Particularly myself; in fact, it was named Parrot precisely to represent its
>language-agnosticism.
>
>The thought is also behind why I wrote the Python::Bytecode module, why I
>learnt Ruby, and why I've been asking interesting questions about access to
>the Ruby AST.
>
>I don't think the reality is as far away as you imply.
.
.
.
Super! Being wrong about this would thrill me--that
is, I'd love to see Parrot go as far as we all think
it can.
Simon certainly has worked with this far more than I.
--
Cameron Laird <Cameron@Lairds.com>
Business: http://www.Phaseit.net
Personal: http://phaseit.net/claird/home.html
------------------------------
Date: Tue, 5 Nov 2002 00:12:15 +0000
From: Robin Becker <robin@jessikat.fsnet.co.uk>
Subject: Re: A vision for Parrot
Message-Id: <h0rpqKAfzwx9EwiH@jessikat.fsnet.co.uk>
.
....
>> This thought inspired enthusiasm in others long ago--from
>> before it was named "Parrot", at least.
>
>Particularly myself; in fact, it was named Parrot precisely to represent its
>language-agnosticism.
.... here in Wandsworth the name Lucky Parrot has long belonged to a
Grey that has been incarcerated in a small cage for twenty years.
Calling such a bird dead would be a mercy.
--
Robin Becker
------------------------------
Date: 05 Nov 2002 00:35:07 +0000
From: Simon Cozens <simon@simon-cozens.org>
Subject: Re: A vision for Parrot
Message-Id: <87heewua4k.fsf@simoncozens-2.dsl.easynet.co.uk>
Robin Becker <robin@jessikat.fsnet.co.uk> writes:
> .... here in Wandsworth the name Lucky Parrot has long belonged to a
> Grey that has been incarcerated in a small cage for twenty years.
> Calling such a bird dead would be a mercy.
Maybe it's not dead; it may have just ceased to be.
I had similar problems, since my next stop after the "Parrot tour",
where all this boring VM stuff was decided, happened to be New York
City, home of the extremely famous tic-tac-toe chicken.
(http://members.tripod.com/the-wire/wire0102/ny0102.html)
Since then, of course, the bird has been rescued, given a new home,
and is now much happier.
Whether we need to give a new home to our brand new Virtual Machine
performing bird is not clear, but I'm happily convinced that its soul
will not die off, and that people will make the most of its talents in
the most humane way possible.
--
"(Because if life's not shit, then you're not doing it right.)"
- Rebecca Luckraft
------------------------------
Date: 5 Nov 2002 05:16:11 GMT
From: Christopher Browne <cbbrowne@acm.org>
Subject: Re: A vision for Parrot
Message-Id: <aq7k6q$6ufmv$1@ID-125932.news.dfncis.de>
In an attempt to throw the authorities off his trail, Daniel Pfeiffer <occitan@esperanto.org> transmitted:
> this morning it struck me that it would be nice to have Parrot not
> only run Perl 6 and similar byte code, but that any of the common
> interpreted languages be compiled to this same byte code.
I'd think it quite plausible that if someone took the project on,
there could readily be a pretty functional Python compiler for Parrot
/before/ a Perl 6 one would be likely to emerge...
--
(reverse (concatenate 'string "ac.notelrac.teneerf@" "454aa"))
http://www3.sympatico.ca/cbbrowne/sap.html
Signs of a Klingon Programmer - 7. "Klingon function calls do not have
'parameters' - they have 'arguments' -- and they ALWAYS WIN THEM."
------------------------------
Date: Tue, 05 Nov 2002 02:20:53 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: A vision for Parrot
Message-Id: <3DC77155.83075923@earthlink.net>
Daniel Pfeiffer wrote:
>
> Hi,
>
> this morning it struck me that it would be nice to have Parrot not
> only run Perl 6 and similar byte code, but that any of the common
> interpreted languages be compiled to this same byte code.
Only just this morning? I take it that parrot itself only came to your
attention recently, since that concept has been with the VM since it's
inception.
> Then no matter whether running a Perl 6, Python, Ruby, Tcl maybe even
> bash script the same interpreter library would be used. Then likely
> it would already be in memory speeding up start time.
The difficult task is compiling those languages into parrot bytecode.
This may not be horrible if those languages have their own bytecode,
which can then be translated into parrot bytecode. As an example, there
already exists a perl script which translates java .class files into
parrot bytecode.
For other languages, a compiler would actually be needed -- eg, for
bash.
> And this would also ease cross language module/library inclusion.
> Imagine instantiating some Python class from Perl!
Ya mean the same way that you can, using Jython, instantiate Python
classes from Java and vice-versa? :)
> Apache would essentially have a mod_parrot.
Well, obviously it would.
> Maybe, if this can be tested very hard, we'd even have a Parrot kernel
> module for all Unices supporting that. Then exec() could perform
> compiled scripts right away, like machine code :-)
Or, your whatever_2_parrot compiler insert an appropriate #! line at the
beginning, pointing to the parrot VM -- this is much simpler, as it
takes advantage of an existing mechanism.
--
my $n = 2; print +(split //, 'e,4c3H r ktulrnsJ2tPaeh'
."\n1oa! er")[map $n = ($n * 24 + 30) % 31, (42) x 26]
------------------------------
Date: Tue, 05 Nov 2002 04:44:16 GMT
From: echang@netstorm.net (ebchang)
Subject: Re: CGI Upload Problems
Message-Id: <Xns92BCF1B602626echangnetstormnet@207.106.93.86>
"Josh Stedman" <stedman@siam.org> wrote in
<sPCx9.20391$T_.500864@iad-read.news.verio.net>:
>I've been really stumped on this for a while now, and have scoured
the
>Google Groups archives, with no help.
>
>I've got a CGI script that I want to use to (among other things,
which
>already work) upload a few files. As of now, I'm trying to settle
with
>one file. But I can't get the file to save on the server or even
print
>out to the screen.
You didn't mention what you have on the client end - does the form
use enctype="multipart/form-data"? If you leave the default, the
form will submit, but the file will not be attached.
EBC
------------------------------
Date: 4 Nov 2002 15:31:02 -0800
From: kjbarahona@hotmail.com (Karen)
Subject: How to copy some sections of a file that varies every month?
Message-Id: <ade6ec5e.0211041531.3b917784@posting.google.com>
Hi everybody,
I'm trying to modify a file with a perl script. I get a report once a
month (the report has 11 sections), I need to be able to run a script
that will make the report have only 5 sections. (It must be done
automatically, that's why I don't do it manually)
This is part of the file I get originally (the one that needs to be
modified by the script):
################################################################
### Section 1
<h3>The last Months Daily Availability</h3>
<p>Daily Average of svcs monitored and availability of svcs divided by
the total svc minutes (last month)</p>
<table border="1">
<tr><th>Date</th><th>Percentage Availability</th></tr>
<tr><td>01</td><td align="right">99.99973</td></tr>
<tr><td>02</td><td align="right">99.99806</td></tr>
<tr><td>03</td><td align="right">99.97838</td></tr>
### Keeps going until the 30th
<tr><td>30</td><td align="right">99.73012</td></tr>
</table>
### Section 2
<h3>Month To Date Daily Availability</h3>
<p>Daily Average of svc monitored and availability of svcs div by
total svc minutes of month frm 1st till date</p>
<table border="1">
<tr><th>Date</th><th>Percentage Availability</th></tr>
<tr><td>02</td><td align="right">99.99230</td></tr>
<tr><td>03</td><td align="right">99.99947</td></tr>
<tr><td>04</td><td align="right">99.96867</td></tr>
### Keeps going until the 30th
### there are 9 more sections in the file
#################################################################
With my current script I read the whole file to an array so it's
easier to access parts of the file (Ex, $file[202], etc). One of the
problems that I've run into is that some sections vary each month so I
can't hard code the changes that I need.
Here is part of the code I have:
###########################################################################
#!/usr/bin/perl -w
use Tie::File;
$OPENNMS_HOME="/opt/OpenNMS";
$file="$OPENNMS_HOME/share/reports/AVAIL-HTML-Overall-Service-Availability20021031.html";
tie @file, "Tie::File", $file;
###
###here was a lot of code that has nothing to do with this current
problem
###
$file[62]=("<tr>" . "\n" . "<td>12 months Average<\/td><td
align=\"right\">$totalAvg<\/td>" . "\n" . "<\/tr>" . "\n<\/table>\n" .
"<h3>The last Months Daily Availability </h3>" . "\n");
### The following code I used it to delete one of the 11 sections
###(this section is constant)
($mon)=(localtime)[4];
if ($mon==0 || $mon==2 || $mon==4 || $mon==7 || $mon==9 || $mon==11){
for ($b=159; $b<250; $b++){
delete $file[$b];
}
} elsif ($mon==3 || $mon==5 || $mon==8 || $mon==10){
for ($b=176; $b<274; $b++){
delete $file[$b];
}
} else {
for ($b=176; $b<267; $b++){
delete $file[$b];
}
}
######################################################################
In conclusion this is what I need to do, copy the 6 sections I do want
to a new file or my other option was delete the 5 sections I don't
need in the original file. I would appreciate if somebody can lead me
in the right direction to write the code.
#This is how I was trying to do it, but when I don't know where to go
with this.
foreach (@file) {
do{
###when $_ eq <h3>The last Months Daily Availability</h3>
### copy $_ to a new file
until ($_eq </table>)
}
}
Thanks is advance,
-Karen-
------------------------------
Date: Tue, 05 Nov 2002 01:15:59 GMT
From: Martien Verbruggen <mgjv@tradingpost.com.au>
Subject: Re: How to copy some sections of a file that varies every month?
Message-Id: <slrnase71m.2c3.mgjv@verbruggen.comdyn.com.au>
On 4 Nov 2002 15:31:02 -0800,
Karen <kjbarahona@hotmail.com> wrote:
> Hi everybody,
>
> I'm trying to modify a file with a perl script. I get a report once a
> month (the report has 11 sections), I need to be able to run a script
> that will make the report have only 5 sections. (It must be done
> automatically, that's why I don't do it manually)
>
> This is part of the file I get originally (the one that needs to be
> modified by the script):
>
> ################################################################
> ### Section 1
><h3>The last Months Daily Availability</h3>
><p>Daily Average of svcs monitored and availability of svcs divided by
[SNIP]
Your file looks like HTML. You should probably have a look at the
various HTML:: modules on CPAN. Maybe HTML::Tree would be useful.
If your HTML is very clean, and is valid XML, maybe one of the
XML::DOM modules could be of use.
> With my current script I read the whole file to an array so it's
> easier to access parts of the file (Ex, $file[202], etc). One of the
> problems that I've run into is that some sections vary each month so I
> can't hard code the changes that I need.
Using something that builds an organised tree would probably get rid
of that problem.
http://search.cpan.org/
Martien
--
|
Martien Verbruggen |
Trading Post Australia | 42.6% of statistics is made up on the spot.
|
------------------------------
Date: 05 Nov 2002 02:22:27 +0100
From: Bodo Schulze <bobesch@letras.net>
Subject: Re: How to copy some sections of a file that varies every month?
Message-Id: <87lm48yfn0.fsf@letras.net>
kjbarahona@hotmail.com (Karen) writes:
> Hi everybody,
>
> I'm trying to modify a file with a perl script. I get a report once a
> month (the report has 11 sections), I need to be able to run a script
> that will make the report have only 5 sections. (It must be done
> automatically, that's why I don't do it manually)
>
> This is part of the file I get originally (the one that needs to be
> modified by the script):
>
> ################################################################
> ### Section 1
> <h3>The last Months Daily Availability</h3>
> <p>Daily Average of svcs monitored and availability of svcs divided by
> the total svc minutes (last month)</p>
> <table border="1">
> <tr><th>Date</th><th>Percentage Availability</th></tr>
> <tr><td>01</td><td align="right">99.99973</td></tr>
> <tr><td>02</td><td align="right">99.99806</td></tr>
> <tr><td>03</td><td align="right">99.97838</td></tr>
>
> ### Keeps going until the 30th
> <tr><td>30</td><td align="right">99.73012</td></tr>
> </table>
> ### Section 2
> <h3>Month To Date Daily Availability</h3>
> <p>Daily Average of svc monitored and availability of svcs div by
> total svc minutes of month frm 1st till date</p>
> <table border="1">
> <tr><th>Date</th><th>Percentage Availability</th></tr>
> <tr><td>02</td><td align="right">99.99230</td></tr>
> <tr><td>03</td><td align="right">99.99947</td></tr>
> <tr><td>04</td><td align="right">99.96867</td></tr>
> ### Keeps going until the 30th
> ### there are 9 more sections in the file
> #################################################################
>
> With my current script I read the whole file to an array so it's
> easier to access parts of the file (Ex, $file[202], etc). One of the
> problems that I've run into is that some sections vary each month so I
> can't hard code the changes that I need.
> Here is part of the code I have:
>
> ###########################################################################
> #!/usr/bin/perl -w
> use Tie::File;
[snip]
Hi Karen,
I did not yet try Tie::File, so I can't help you this way. Perhaps
something simple will fit your needs, like this:
#!/usr/bin/perl
use warnings;
use strict;
my $in = "input.html";
my $out = "output.html";
### These are the sections they go into $out
my @wanted = qw(1 3 5 7 9 11);
open (IN, $in) or die "Can't open $in for reading: $!";
my $count = 0;
my %sections = ();
while (<IN>) {
### Supposing each section begins with <h3>
$count++ if /^<h3>/;
push @{$sections{$count}}, $_;
}
close IN;
open (OUT, ">$out") or die "Can't open $out for writing: $!";
print OUT @$_ for @sections{@wanted};
close OUT;
Best regards,
Bodo
------------------------------
Date: Tue, 5 Nov 2002 06:34:00 +0000 (UTC)
From: "David H. Adler" <dha@panix2.panix.com>
Subject: Re: Perl -e "print qq! Tips and Tricks !"
Message-Id: <slrnasepio.2n8.dha@panix2.panix.com>
In article <3DC2F1CC.3988B114@earthlink.net>, Benjamin Goldberg wrote:
>
> Personally, though, I think that any code which has "Just another Perl
> hacker" written in anything resembling clear text is insufficiently
> obscure.
I don't know... one of my favorite JAPH moments was during a talk on
them where Abigail said "The question here is not what this does.
That's obvious - it prints 'Just Another Perl Hacker'. the question is
'Why does it COMPILE??'."
(all quotes approximate)
dha
--
David H. Adler - <dha@panix.com> - http://www.panix.com/~dha/
philosophy department
- you don't have to be to work here, but it helps
------------------------------
Date: Mon, 04 Nov 2002 20:50:02 -0500
From: Mina Naguib <spam@thecouch.homeip.net>
Subject: Re: Perl and large text files
Message-Id: <3DC723CA.40305@thecouch.homeip.net>
-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1
JorkkiS wrote:
| Hi!
|
| I'm supposed to write a sript that searches through a text file for a
given
| string. The script it self will be very simple, but I was wondering will I
| run into problems, because the size of the text file is around 5
megabytes.
| I was thinking of reading it into an array and then greping throug it...
| will there be problems, other than it might take a while.
|
| Is there a better way to approach this?
|
| Thanks for advice or comments
| BR,
| Jarkko
|
|
Others replied with very concrete examples.
Assuming what you're looking for will be found in 1 line (not split over
2 or more lines), here's a bit of fun perl shorthand:
- - - - cut here - - -
#!/usr/bin/perl -ln
print if (/whatyourelookingfor/);
- - - - cut here - - -
Assuming you save the above as "searcher.pl" you can search a file like so:
./searcher.pl file_to_search.txt
Have fun !
-----BEGIN xxx SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQE9xyPKeS99pGMif6wRAi3WAJwOPDOaSxACfWMIwDrUCUKuX1Pg0wCaAj3h
w+nYXU5fzySxxJiFu7LAGYM=
=onRJ
-----END PGP SIGNATURE-----
------------------------------
Date: 4 Nov 2002 16:14:31 -0800
From: google@hoodfamily.org (Tim)
Subject: Tie'd filehandle and the system() function
Message-Id: <1d2abc5d.0211041614.49350dc3@posting.google.com>
Hi:
I've tied STDOUT and STDERR to be able to manipulate the input data
before it's put into a file. This works well with functions like
print. However, due (I'm sure) to my limited understanding of tie and
object-oriented perl (I've learned just enough to be dangerous), I
can't get output from the system() function to behave. Here's what
I've got so far:
#!/usr/local/bin/perl
use English;
use strict;
use warnings;
open LOG_FILE, ">> script.log" or die "Can't open log file:
$OS_ERROR\n";
open ERR_FILE, ">> script.log" or die "Can't open log file:
$OS_ERROR\n";
my $tie_log = tie *STDOUT, 'Log::Output', *LOG_FILE;
my $err_log = tie *STDERR, 'Log::Output', *ERR_FILE;
# test print stuff
print "Beginning script\n";
print "This script was executed with", "no command-line arguments\n";
system('external_process'); # for testing, just a simple sh script
# with echo statements
print "Ending script\n";
undef $tie_log;
untie *STDOUT;
package Log::Output;
use English;
sub TIEHANDLE
{
my ($class) = shift;
my $handle = shift || select;
return bless { array => [], handle => $handle }, $class;
} # End TIEHANDLE()
sub PRINT
{
my ($self) = shift;
my $log_stamp = "DATE|TIME|HOST|APP|SCRIPT|PID|";
my $handle = select $self->{handle};
print "$log_stamp@_";
select $handle;
} # End PRINT()
# <begin laughter>
sub SYSTEM
{
print "An external command would be called here.";
system('external_process');
print "I just finished calling the external command.";
}
# <end laughter>
sub DESTROY
{
# maybe I'll put something here later
} # End DESTROY()
__END__
------------------------------
Date: Tue, 05 Nov 2002 02:28:27 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Tie'd filehandle and the system() function
Message-Id: <3DC7731B.C1CCB69D@earthlink.net>
Tim wrote:
>
> Hi:
>
> I've tied STDOUT and STDERR to be able to manipulate the input data
> before it's put into a file. This works well with functions like
> print. However, due (I'm sure) to my limited understanding of tie and
> object-oriented perl (I've learned just enough to be dangerous), I
> can't get output from the system() function to behave.
This is because system() starts a seperate process, which inherits your
own process's STD{IN,OUT,ERR} filedescriptors -- it does *not* inherit
any high-level objects created inside your process (such as the the
parts of the filehandles other than the filedescriptors, nor any objects
which are tied to the filehandles)
Supposing that your external script merely sends data to it's STDOUT,
you can send that data to your tied handle with something like:
open( my($fh), "-|", 'external_process' ) or die horribly;
print while <$fh>;
close $fh;
It gets a bit more complicated if you want to get both it's STDOUT and
it's STDERR.
--
my $n = 2; print +(split //, 'e,4c3H r ktulrnsJ2tPaeh'
."\n1oa! er")[map $n = ($n * 24 + 30) % 31, (42) x 26]
------------------------------
Date: 4 Nov 2002 19:04:38 -0800
From: oefinger@mit.edu (Matt Oefinger)
Subject: unwanted white space when I write to files
Message-Id: <e9b08c9f.0211041904.53a46944@posting.google.com>
I'm getting unwanted white space when I try to write to a file as follows:
if(!open(FILE, "temp.txt")) {die("can't open for read.");}
@temp = <FILE>;
$templength = @temp;
close FILE;
if(!open(FILE, ">temp.txt")) {die("can't open for write.");}
print FILE "@temp[0..2]";
print FILE "\nNEWLINE";
print FILE "@temp[3..$templength-1]";
close FILE;
----------------------------------------------
The output I get has spaces leading the @temp lines as follows:
oldtext line 0
oldtext line 1
oldtext line 2
NEWLINE
oldtext line 3
oldtext line 4
If I run it again I get..
oldtext line 0
oldtext line 1
oldtext line 2
NEWLINE
NEWLINE
oldtext line 3
oldtext line 4
-----------------------
Any ideas?
Thanks,
Matt
------------------------------
Date: Tue, 05 Nov 2002 03:22:10 GMT
From: Steven Smolinski <steven.smolinski@sympatico.ca>
Subject: Re: unwanted white space when I write to files
Message-Id: <CPGx9.3403$EY2.545526@news20.bellglobal.com>
Matt Oefinger <oefinger@mit.edu> wrote:
> I'm getting unwanted white space when I try to write to a file as
> follows:
>
> if(!open(FILE, "temp.txt")) {die("can't open for read.");}
> @temp = <FILE>;
> $templength = @temp;
> close FILE;
>
> if(!open(FILE, ">temp.txt")) {die("can't open for write.");}
> print FILE "@temp[0..2]";
^ ^
^ ^
Not just useless quotes, but harmful to your intent. They bring $" into
play. Read all about it in the perlvar manpage.
> print FILE "\nNEWLINE";
> print FILE "@temp[3..$templength-1]";
^ ^
^ ^
Same thing. Sticking in quotes where unnecessary is dangerous.
> close FILE;
Steve
------------------------------
Date: Tue, 05 Nov 2002 04:07:09 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: unwanted white space when I write to files
Message-Id: <NtHx9.21287$7W2.13779@nwrddc01.gnilink.net>
Matt Oefinger wrote:
> I'm getting unwanted white space when I try to write to a file as
> follows:
>
> if(!open(FILE, "temp.txt")) {die("can't open for read.");}
> @temp = <FILE>;
> $templength = @temp;
[...]
> print FILE "@temp[0..2]";
[...]
> The output I get has spaces leading the @temp lines as follows:
[...]
> Any ideas?
Yep. What about reading the FAQ? E.g. "perldoc -q space"
Found in ....\perl\lib\pod\perlfaq5.pod
Why do I get weird spaces when I print an array of lines?
jue
------------------------------
Date: Mon, 4 Nov 2002 18:23:23 -0800
From: "Tan D Nguyen" <nospam@nospam.com>
Subject: Re: Written under a socket descriptor problem ....
Message-Id: <aq7a1k$77e2r$1@ID-161864.news.dfncis.de>
"Olive" <ochampag@nortelnetworks.com> wrote in message
news:aq67ls$pcg$1@bcarh8ab.ca.nortel.com...
> #EXEC CMD open TMP,"$exec|";
You might want to check if you've successfully run this command.
open TMP, "$exec |" or die "failed to kick off $exec: $!\n";
> #EXEC CMD while($WR = <TMP>) {
> #EXEC CMD print NS "$con : $WR"; ===>>>>
> That is not read by the client
> #EXEC CMD }
If you failed to start the process, there's nothing to print for the client
to read.
------------------------------
Date: Tue, 05 Nov 2002 02:01:47 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: ||= |=
Message-Id: <3DC76CDB.836BF8A6@earthlink.net>
Bart Lateur wrote:
>
> Jeff Thies wrote:
[snip]
> >What's the right why to assign defaults?
>
> ||=
Or, if you're using bleedperl, then the answer is
//=
, the defined-or operator.
--
my $n = 2; print +(split //, 'e,4c3H r ktulrnsJ2tPaeh'
."\n1oa! er")[map $n = ($n * 24 + 30) % 31, (42) x 26]
------------------------------
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 4066
***************************************