[25121] in Perl-Users-Digest
Perl-Users Digest, Issue: 7371 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Nov 7 00:05:44 2004
Date: Sat, 6 Nov 2004 21:05:08 -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 Sat, 6 Nov 2004 Volume: 10 Number: 7371
Today's topics:
[OT] Re: casting question <spamtrap@dot-app.org>
Re: an original perldoc viewer <usenet@morrow.me.uk>
Re: an original perldoc viewer <ioneabu@yahoo.com>
Re: an original perldoc viewer <spamtrap@dot-app.org>
Re: an original perldoc viewer <1usa@llenroc.ude.invalid>
Re: an original perldoc viewer <spamtrap@dot-app.org>
Re: casting question <spamtrap@dot-app.org>
Re: casting question <spamtrap@dot-app.org>
Re: casting question <uri@stemsystems.com>
Re: Check POP3 E-mail <1usa@llenroc.ude.invalid>
Re: Check POP3 E-mail <usenet@morrow.me.uk>
Re: Common file operations <uri@stemsystems.com>
FAQ 4.6: Why doesn't & work the way I want it to? <comdog@panix.com>
Re: Gethostbyaddr INET <nospam.hciss@yahoo.com>
Re: map()'s BLOCK <uri@stemsystems.com>
Re: Newbie Question <usenet@morrow.me.uk>
Re: perl win32 & output of printf <kalinaubears@iinet.net.au>
perldoc problem on linux (Zhiliang Hu)
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sat, 06 Nov 2004 20:00:15 -0500
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: [OT] Re: casting question
Message-Id: <__WdnePtH9sC7hDcRVn-2g@adelphia.com>
daniel kaplan wrote:
> shouldn't casting and derefencing be the same thing? aren't
> they both NO-OP?
I guess you're talking about C now, since there's no such thing as type
casting in Perl. But no, they're not the same, not even in C. Consider:
int foo = 0;
int *foo_ptr = &foo;
// Dereference foo_ptr
int bar = *foo_ptr;
Now bar == the value of foo_ptr's target - i.e. the value of foo.
// Type cast foo_ptr
int baz = (int)foo_ptr;
Now baz == the value of foo_ptr itself, converted to an int - *not* the
value of foo_ptr's target.
Neither one is guaranteed to be a no-op, although casting one pointer
type to another often is, as is casting a pointer to an integer like in
the code above. But casting an int to a float, for example, will cause
the compiler to emit the appropriate conversion code.
I can see where your confusion might come from though, as in C it's not
at all rare to get a void* that actually points to some structure. In
order to dereference the pointer and get at the elements inside the
structure, you also need to cast the pointer to the appropriate type:
int foo = (struct bar*)bar_ptr->an_int;
sherm--
--
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org
------------------------------
Date: Sat, 6 Nov 2004 16:15:13 +0000
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: an original perldoc viewer
Message-Id: <ht9v52-g45.ln1@osiris.mauzo.dyndns.org>
Quoth ioneabu@yahoo.com:
> I have been reprimanded for my lack of knowledge of perldoc material so I
> have decided to do more reading. I realized that I am often (%50 of the
> time) working on a machine that does not have Perl but is connected to the
> internet. My first thought was to go to perldoc.com, but it seemed to be
> down tonight, so I wrote a simple home-made solution to get by for now. I
> was hoping pod2html would format my perldocs but it did not work when I
> tried: pod2html perltoc (maybe perldoc pod2html says how to do it). Here
> it is. Improvements, especially in output formatting, would be welcome.
>
> #!/usr/bin/perl
USE TAINT MODE.
#!/usr/bin/perl -T
This would have caught the error you noticed for yourself.
Ben
--
Joy and Woe are woven fine,
A Clothing for the Soul divine William Blake
Under every grief and pine 'Auguries of Innocence'
Runs a joy with silken twine. ben@morrow.me.uk
------------------------------
Date: Sat, 06 Nov 2004 19:56:24 -0500
From: wana <ioneabu@yahoo.com>
Subject: Re: an original perldoc viewer
Message-Id: <10oqpbbogom6sf5@news.supernews.com>
Ben Morrow wrote:
>
> Quoth ioneabu@yahoo.com:
>> I have been reprimanded for my lack of knowledge of perldoc material so I
>> have decided to do more reading. I realized that I am often (%50 of the
>> time) working on a machine that does not have Perl but is connected to
>> the
>> internet. My first thought was to go to perldoc.com, but it seemed to
>> be
>> down tonight, so I wrote a simple home-made solution to get by for now.
>> I was hoping pod2html would format my perldocs but it did not work when I
>> tried: pod2html perltoc (maybe perldoc pod2html says how to do it). Here
>> it is. Improvements, especially in output formatting, would be welcome.
>>
>> #!/usr/bin/perl
>
> USE TAINT MODE.
>
> #!/usr/bin/perl -T
>
> This would have caught the error you noticed for yourself.
>
> Ben
>
which perldoc explains taint mode? I searched perltoc and did perldoc -q
taint and didn't find much.
wana
------------------------------
Date: Sat, 06 Nov 2004 19:02:55 -0500
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: an original perldoc viewer
Message-Id: <KbKdncyuZK2y-xDcRVn-qA@adelphia.com>
wana wrote:
> which perldoc explains taint mode?
perlsec is a good start.
sherm--
--
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org
------------------------------
Date: 7 Nov 2004 03:28:33 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: an original perldoc viewer
Message-Id: <Xns9599E4A4F1189asu1cornelledu@132.236.56.8>
wana <ioneabu@yahoo.com> wrote in
news:10or4qgndr82ef8@news.supernews.com:
> ok, I read perlsec and did a little testing...
> ------------------
> #!/usr/bin/perl -T
>
> my $a = 'perl';
> `perldoc $a`;
> ------------------
> me> perl -c test.pl
> Perl> Too late for "-T" option at test.pl line 1.
> (what does that mean?)
Exactly what it says. Since you have invoked your script via the perl
binary, you should specify the T switch on the command line:
perl -T test.pl
This does not really matter when you are only checking syntax. So, keep
the -T option on the shebang line but also specify it on the command line
if you are going to run the script via perl.
--
A. Sinan Unur
1usa@llenroc.ude.invalid
(remove '.invalid' and reverse each component for email address)
------------------------------
Date: Sat, 06 Nov 2004 23:07:46 -0500
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: an original perldoc viewer
Message-Id: <yLqdnXmvfZEOAhDcRVn-qg@adelphia.com>
wana wrote:
> $a = `perldoc $doc`; #this is the dangerous line
> $a = 'not found' if not $a;
IMNSHO, you're looking at this from the wrong direction.
Instead of trying to filter out any "bad" characters that might be
subject to special interpretation by the shell, bypass the shell
entirely by using the multi-argument version of open() instead of backticks.
Instead of trying to anticipate in advance what doc names might be
valid, just check the name you're given before running perldoc on it.
Something like this:
my @podpaths;
foreach my $path (@INC) {
push @podpaths, $path;
push @podpaths, "$path/pods";
}
push @podpaths, split(/:/, $ENV{'PATH'});
my $podfile = $doc;
$podfile =~ s%::%/%g;
my $pod;
PODSEARCH: foreach my $path (@podpaths) {
foreach my $ext ('', '.pm', '.pl', '.pod') {
if (-f "$path/$podfile$ext") {
$pod = "$path/$podfile$ext";
last PODSEARCH;
}
}
}
if ($pod) {
# You've already translated the doc name to a file path,
# so just pass the path to perldoc using its -F switch
open(PODFILE, '<', '/usr/bin/perldoc|', '-F', $pod)
or die("Could not open $pod: $!");
$a = join('', <PODFILE>);
close PODFILE;
} else {
$a = 'not found';
}
The above is typed into Mozilla, and is meant to be illustrative, not
complete. It's untested, and it's missing some important "boilerplate"
bits and output code.
sherm--
--
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org
------------------------------
Date: Sat, 06 Nov 2004 20:25:09 -0500
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: casting question
Message-Id: <ce6dnftUOP3o5BDcRVn-qA@adelphia.com>
daniel kaplan wrote:
> would still very much like to figure out the syntax tho for my first
> headache...
Well - keep in mind first, that dereferencing the array reference is
*not* what you really wanted to do in this case. For the sake of
argument however:
Suppose you have an array reference:
my @array = (1,2,3);
my $array_ref = \@array;
You can dereference it like this:
# Push 4 onto @array by way of $array_ref
push @{$array_ref}, 4;
The most commonly used method of dereferencing a reference in Perl is
the "double dollar sign" syntax:
my $foo = $$array_ref[2];
You can also use the dereference operator ->, which isn't as popular but
might be a easier for C/C++ programmers to get their heads around:
my $foo = $array_ref->[2];
The same options exist for hash references:
my $foo = $$hash_ref{'baz'};
my $foo = $hash_ref->{'baz'};
Most (but *not* all) objects are blessed hash references, and the last
form above is most commonly used to access their properties. (Keeping in
mind that, regardless of the syntax used, directly accessing an object's
properties from outside the object itself is not a very good idea.)
This post is really an absurdly brief overview though. It doesn't do the
subject justice. For a more thorough tutorial, see:
References:
perldoc perlreftut
perldoc perldsc
perldoc perllol
OOP (Read about references first!):
perldoc perlboot
perldoc perltoot
perldoc perltooc
perldoc perlbot
sherm--
--
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org
------------------------------
Date: Sat, 06 Nov 2004 21:28:39 -0500
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: casting question
Message-Id: <E8KdnaZYfuvKFRDcRVn-hA@adelphia.com>
Jürgen Exner wrote:
> The only place in Perl where you might find something like "casting" is to
> add a 0 to get the numerical value of a scalar or append an empty string to
> get the text value. But even to call that casting would be a stretch.
I'd say that blessing an ordinary reference, or re-blessing an object
into a different class, would be the closest thing that Perl has to type
casting. That's still a stretch though.
sherm--
--
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org
------------------------------
Date: Sun, 07 Nov 2004 04:38:18 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: casting question
Message-Id: <x7is8itgsm.fsf@mail.sysarch.com>
>>>>> "L" == Laura <lwt0301@bellsouth.net> writes:
L> A future version of Perl will surely implement restricted access in
L> classes like C++. Those guys really thought out the OO thing
L> carefully.
L> All languages, as they mature, become more C++-like.
you are so nutso. stay in the c++ groups please. your blathering here is
not wanted nor needed.
and perl can do restricted access in tighter ways than c++ can. but i
will not tell you how. read the book object oriented perl to find out.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
------------------------------
Date: 6 Nov 2004 23:08:10 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Check POP3 E-mail
Message-Id: <Xns9599B87E93D55asu1cornelledu@132.236.56.8>
Gunnar Hjalmarsson <noreply@gunnar.cc> wrote in
news:2v532rF2hr9bnU1@uni-berlin.de:
> A. Sinan Unur wrote:
>> Gunnar Hjalmarsson wrote:
>>> The point I was trying to make is that package variables and
>>> lexically scoped variables behave differently in this respect.
>>> However, see Brian's message in this thread. Even if I haven't seen
>>> file scoped lexicals retain their values, I trust that Brian knows
>>> what he is talking about.
>>
>> Gunnar,
>>
>> You were correct. What krakle is krakling about is summarized here:
>>
>> http://perl.apache.org/docs/1.0/guide/porting.html#Exposing_Apache__Re
>> gistry_secrets
>
> To me, that rather confirms that brian was correct. The handler
> subroutine, seemingly top level subroutines behaving as nested ditto,
> etc...
>
> I for one learned from this exchange of messages that *really* file
> scoped lexicals, i.e. top level lexicals in programs that are run
> under variants of mod_perl that do not make use of any "handler
> subroutine", retain their values. I did not know that before.
OK. I misunderstood your earlier statement then. Of course, Brian is
correct. I am re-reading the thread, and it seems like I lost track of
who was saying what at one point.
My main argument was with the statement that krakle made regarding the
necessity of resetting package lexicals. That necessity only arises from
when good programming discipline is not followed, IMHO.
Sinan.
--
A. Sinan Unur
1usa@llenroc.ude.invalid
(remove '.invalid' and reverse each component for email address)
------------------------------
Date: Sat, 6 Nov 2004 15:42:18 +0000
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: Check POP3 E-mail
Message-Id: <qv7v52-g45.ln1@osiris.mauzo.dyndns.org>
Quoth "David Gale" <dsgSPAMFILTER@alum.dartmouth.org>:
> Quoth Ben Morrow <usenet@morrow.me.uk>:
> > Quoth Gunnar Hjalmarsson <noreply@gunnar.cc>:
> >> David Gale wrote:
> >>> Quoth A. Sinan Unur:
> >>>> wana wrote:
> >>>>>
> >>>>> my @message = ();
> >>>>
> >>>> There is no need to explictly initialize my variables.
> >>>
> >>> Nor does it hurt to do so,
> >
> > It is a trivial waste of runtime, and a non-trivial waste of a
> > reader's time when they try to figure out *why* you're explicitly
> > initializing something which doesn't need it.
>
> Wait, you're saying that the perl interpretter doesn't just skip the
> unnecessary assignment?
~% perl -MO=Concise -e'my $x = undef'
6 <@> leave[1 ref] vKP/REFC ->(end)
1 <0> enter ->2
2 <;> nextstate(main 1 -e:1) v ->3
5 <2> sassign vKS/2 ->6
3 <0> undef s ->4
4 <0> padsv[$x:1,2] sRM*/LVINTRO ->5
-e syntax OK
Note the sassign and the undef; so no, it doesn't.
> That's a surprise to me; I've always had the impression that perl
> optimizes fairly well (I've never had a problem with its running
> speed),
I did say a trivial waste. I would bet that it almost never makes any
difference, so it's not worth the optimizer finding it.
> and since most early perl programmers were coming from languages which
> did require explicit initialization,
What, like shell and awk? :)
> As for wasting a reader's time: a) Anyone as familiar with perl as you
> would immediately realize that this is an extraneous hold-over, and
> thus not waste any time wondering about the initialization;
Not true. I am familiar with Perl; however, although I had a little
knowledge of C when I learned Perl most of my background was in BASIC
and FoxPro, which do not require explicit initialization. When someone
puts an explicit initial value in, it makes me think immediately that
there is some reason why that value a. is not there anyway and b. is
necessary (I tend to start with the assumption that the writer of the
code wasn't a fool). If I can't see any obvious reason for it it makes
me worry for a minute that there is something going on that I don't
understand, which is not a kind thing to do to a reader of your code.
> b) anyone not as wise and experienced, or whose primary experience is
> in a different language, wouldn't even notice the initialization as
> being out-of-place.
Languages which require explicit initialization are by no means as
common as those which do not.
> In neither case would it slow the reader down, and, in
> fact, can often aid in interpretation--if I initialize a scalar to 0,
> then it's clear that I intend that variable to be numeric; if I
> initialize it to '', then it's clear that I intend to use it as a
> string. Granted, wise perl programmers like yourself would know that
> 0 and '' are both false values, and thus equivalent
NO! They are both false, yes; but they are *NOT* equivalent, and are
*NOT* equivalent to undef. I will occasionally write something like
my $x = '';
where I wish to avoid uninit value warnings, or am going to use undef as
a flag later, or something; and that initialization tells the reader
that there is some reason why the default initial value of undef won't
do.
> --but the lesser
> mortals would benefit from the extra tip. Think of it as a small form
> of self-commenting code.
>
> >>> and is a good habit to get into,
> >
> > Thus I would strongly disagree here. Write less code, unless that
> > makes things less clear.
>
> And, as argued above, I think that it does help keep things clear.
>
> my $var; my $var = 0; my $var = '';
>
> are all equivalent statements,
NO THEY ARE NOT.
$\ = '';
print '[';
{
local ($\, $,) = ("]\n[", '], [');
{
my $var;
print $var, defined $var;
}
{
my $var = 0;
print $var, defined $var;
}
{
my $var = '';
print $var, defined $var;
}
}
print "]\n";
> but, as pointed out above, the first
> tells you *nothing* about how the variable is intended to be used;
> that has to be determined through code examination. The second and
> third, however, show their purpose immediately.
>
> >>> in case you're ever in an environment when you can't choose which
> >>> language to program in, and have to use something (say, C) which
> >>> does not implicitly initialize variables.
> >
> > Know The Language You're Writing In. It *never* pays to carry habits
> > across from one language to another.
>
> Ah, the great philosophy of, "If you can't become an instant expert in
> whatever language your boss determines to be appropriate for the job,
> you might as well flip burgers at the local burger joint."
I said noting about 'expert', and nothing about 'instant'. You should
read enough about the language to understand how it works before writing
(real) code in it. I would have thought this was obvious.
> Code is code. Often, habits that are helpful in one language are
> helpful in others--or do you not use subroutines, because they are too
> similar to C's functions?
Yes, I use subs, because they are a feature of *Perl*. I do not
explicitly initialize variables where I don't need to, because such
initializations not being required is a feature of *Perl*.
> >>> Of course, I always initialize my variables (in any language)
> >>> simply because I'm a control freak, and want to be darn certain I
> >>> know what's in there. ;-)
> >
> > You do. Perl guarantees variables to be correctly initialized to
> > what you expect. If you don't trust Perl to leave $x undef after 'my
> > $x;', why do you trust it after 'my $x = undef;'?
>
> I do, in perl. But not in most other languages. And, again, 'my $x;'
> tells me nothing of the expected use of the variable, whereas 'my $x =
> 0;' does. (Incidentally, 'my $x = undef;' suffers from the same
> problem, and so I never use it. So, *in my opinion*, 'my $x;' and 'my
> $x = undef;' are both equivalent unclear constructs, and ought to be
> avoided.)
They are not unclear; they leave $x with a value of undef, which has a
function in Perl similar to SQL's NULL. If you came to Perl from C you
may not yet have realised it's usefulness, as C has no equivalent.
Ben
--
Musica Dei donum optimi, trahit homines, trahit deos. |
Musica truces molit animos, tristesque mentes erigit. | ben@morrow.me.uk
Musica vel ipsas arbores et horridas movet feras. |
------------------------------
Date: Sun, 07 Nov 2004 04:29:26 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Common file operations
Message-Id: <x7oeiath7g.fsf@mail.sysarch.com>
>>>>> "SM" == Shmuel (Seymour J ) Metz <spamtrap@library.lspace.org.invalid> writes:
SM> In <x7d5ywst5f.fsf@mail.sysarch.com>, on 11/02/2004
SM> at 05:43 AM, Uri Guttman <uri@stemsystems.com> said:
>> what is $dirs?
SM> Typo. That should have been
SM> if (@dirs==0) {
if you get anything from this, it is to use strict so you don't get
spelling bugs like this.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
------------------------------
Date: Sun, 7 Nov 2004 05:03:01 +0000 (UTC)
From: PerlFAQ Server <comdog@panix.com>
Subject: FAQ 4.6: Why doesn't & work the way I want it to?
Message-Id: <cmkaa5$kjr$1@reader1.panix.com>
This message is one of several periodic postings to comp.lang.perl.misc
intended to make it easier for perl programmers to find answers to
common questions. The core of this message represents an excerpt
from the documentation provided with Perl.
--------------------------------------------------------------------
4.6: Why doesn't & work the way I want it to?
The behavior of binary arithmetic operators depends on whether they're
used on numbers or strings. The operators treat a string as a series of
bits and work with that (the string "3" is the bit pattern 00110011).
The operators work with the binary form of a number (the number 3 is
treated as the bit pattern 00000011).
So, saying "11 & 3" performs the "and" operation on numbers (yielding
3). Saying "11" & "3" performs the "and" operation on strings (yielding
"1").
Most problems with "&" and "|" arise because the programmer thinks they
have a number but really it's a string. The rest arise because the
programmer says:
if ("\020\020" & "\101\101") {
# ...
}
but a string consisting of two null bytes (the result of ""\020\020" &
"\101\101"") is not a false value in Perl. You need:
if ( ("\020\020" & "\101\101") !~ /[^\000]/) {
# ...
}
--------------------------------------------------------------------
Documents such as this have been called "Answers to Frequently
Asked Questions" or FAQ for short. They represent an important
part of the Usenet tradition. They serve to reduce the volume of
redundant traffic on a news group by providing quality answers to
questions that keep coming up.
If you are some how irritated by seeing these postings you are free
to ignore them or add the sender to your killfile. If you find
errors or other problems with these postings please send corrections
or comments to the posting email address or to the maintainers as
directed in the perlfaq manual page.
Note that the FAQ text posted by this server may have been modified
from that distributed in the stable Perl release. It may have been
edited to reflect the additions, changes and corrections provided
by respondents, reviewers, and critics to previous postings of
these FAQ. Complete text of these FAQ are available on request.
The perlfaq manual page contains the following copyright notice.
AUTHOR AND COPYRIGHT
Copyright (c) 1997-2002 Tom Christiansen and Nathan
Torkington, and other contributors as noted. All rights
reserved.
This posting is provided in the hope that it will be useful but
does not represent a commitment or contract of any kind on the part
of the contributers, authors or their agents.
------------------------------
Date: Sat, 6 Nov 2004 18:35:32 -0600
From: "Matt" <nospam.hciss@yahoo.com>
Subject: Re: Gethostbyaddr INET
Message-Id: <10oqrhil146qt59@corp.supernews.com>
> Rule number one: Don't steal.
>
> > http://iis1.cps.unizar.es/Oreilly/perl/cookbook/ch17_06.htm
Not my website. I was searching with google and found it. Now I feel like
idiot. Sorry.
Matt
------------------------------
Date: Sun, 07 Nov 2004 04:35:09 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: map()'s BLOCK
Message-Id: <x7lldetgxu.fsf@mail.sysarch.com>
>>>>> "MD" == Michele Dondi <bik.mido@tiscalinet.it> writes:
MD> On Wed, 03 Nov 2004 00:23:13 +0100, Michele Dondi
MD> <bik.mido@tiscalinet.it> wrote:
>> { map {
>> no strict 'refs';
>> $_ => \&{$_};
>> } qw/sol1 sol2 .../ };
MD> Except that this won't work! When I try it in actual code I get
MD> "no" not allowed in expression at foo.pl line 12, at end of line
MD> BEGIN not safe after errors--compilation aborted at foo.pl line 12.
MD> Of course I can do
MD> {
MD> no strict 'refs';
MD> cmpthese 500, { map { $_ => \&{$_} }
MD> qw/sol1 sol2 etc/ };
MD> }
or use a do{} block inside the map block. that should handle any stuff
you want to put in there.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
------------------------------
Date: Sat, 6 Nov 2004 16:18:02 +0000
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: Newbie Question
Message-Id: <q2av52-g45.ln1@osiris.mauzo.dyndns.org>
Quoth serhant@doruk.net.tr (Ali Ataman):
> Hello
>
> I have a perl script and I would like to write the output of this perl
> script to a file. How can I do this.
>
> I know it is simple but I just started perl..
Use your shell (if any)
perl script > file
Use Perl
open STDOUT, '>', 'file' or die "can't redirect STDOUT: $!";
See perlfunc, and the documentation for your shell (which should have come with
your OS).
Ben
--
Every twenty-four hours about 34k children die from the effects of poverty.
Meanwhile, the latest estimate is that 2800 people died on 9/11, so it's like
that image, that ghastly, grey-billowing, double-barrelled fall, repeated
twelve times every day. Full of children. [Iain Banks] ben@morrow.me.uk
------------------------------
Date: Sun, 07 Nov 2004 02:12:15 +0000
From: Sisyphus <kalinaubears@iinet.net.au>
Subject: Re: perl win32 & output of printf
Message-Id: <418d85d0$0$6553$5a62ac22@per-qv1-newsreader-01.iinet.net.au>
vp wrote:
> Hi all,
> In Perl win32 (ActivePerl v5.8.3), when I use
>
> printf "%8d %15.6E\n", $x, $y;
>
> I got always:
>
> 100207 -8.000000E+002
>
> With the same script, under Linux & HP-UX, I got:
>
> 100207 -8.000000E+02
>
> How I could tell Perl win32 that I need only two numbers for exposant
> (E+02 instead of E+002) ?
>
You can't. According to 'perldoc -f sprintf' this behaviour is system
dependent.
Cheers,
Rob
--
To reply by email u have to take out the u in kalinaubears.
------------------------------
Date: 6 Nov 2004 18:26:42 -0800
From: zhilianghu@yahoo.com (Zhiliang Hu)
Subject: perldoc problem on linux
Message-Id: <1daf0582.0411061826.2a70aabb@posting.google.com>
I have a strange problem - recently I newly setup a linux server and
installed perl 5.8, and when I tried to use "perldoc" (such as
"perldoc DBI"), nothing happens except as if I issued "source .cshrc"
(some personalized login message passes), then it's ready to take next
command. However "perldoc" works normal for ~root (both accounts are
on "tcsh" shell). Where should I check to solve it?
PS:
My linux: version 2.4.21-20.ELsmp (gcc version 3.2.3 20030502)
(Red Hat Linux 3.2.3-42))
My perl: version: v5.8.5 built for i686-linux
Thanks in advance!
Zhiliang
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc. For subscription or unsubscription requests, send
#the single line:
#
# subscribe perl-users
#or:
# unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.
#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V10 Issue 7371
***************************************