[32155] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 3420 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jun 20 16:09:41 2011

Date: Mon, 20 Jun 2011 13:09:17 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Mon, 20 Jun 2011     Volume: 11 Number: 3420

Today's topics:
    Re: [RegEx] Optional parameter <rweikusat@mssgmbh.com>
    Re: [RegEx] Optional parameter <rweikusat@mssgmbh.com>
    Re: [RegEx] Optional parameter <hjp-usenet2@hjp.at>
    Re: [RegEx] Optional parameter <source@netcom.com>
    Re: [RegEx] Optional parameter <tadmc@seesig.invalid>
    Re: [RegEx] Optional parameter <rweikusat@mssgmbh.com>
    Re: [RegEx] Optional parameter <rweikusat@mssgmbh.com>
    Re: [RegEx] Optional parameter <ralph@happydays.com>
    Re: [RegEx] Optional parameter <tzz@lifelogs.com>
    Re: [RegEx] Optional parameter <rweikusat@mssgmbh.com>
        Automate Vxdiskadm using perl <rajashekar14@yahoo.com>
    Re: Automate Vxdiskadm using perl <tadmc@seesig.invalid>
    Re: FAQ 2.6 What modules and extensions are available f <kkeller-usenet@wombat.san-francisco.ca.us>
    Re: FAQ 2.6 What modules and extensions are available f <ralph@happydays.com>
    Re: FAQ 2.6 What modules and extensions are available f <ralph@happydays.com>
    Re: FAQ 2.6 What modules and extensions are available f (David Canzi)
    Re: Feeding STDIN <hjp-usenet2@hjp.at>
    Re: Feeding STDIN <kst-u@mib.org>
        Problems with Parse::Lex <gogala.mladen@gmail.com>
    Re: Problems with Parse::Lex <*@eli.users.panix.com>
    Re: Problems with Parse::Lex <jwkrahn@example.com>
    Re: Problems with Parse::Lex <rweikusat@mssgmbh.com>
    Re: send file as post to cgi that writes file on remote <tzz@lifelogs.com>
    Re: upload file rom solaris to debian using perl base i <jimsgibson@gmail.com>
    Re: upload file rom solaris to debian using perl base i <rweikusat@mssgmbh.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Sat, 18 Jun 2011 16:32:36 +0100
From: Rainer Weikusat <rweikusat@mssgmbh.com>
Subject: Re: [RegEx] Optional parameter
Message-Id: <87r56rtasr.fsf@sapphire.mobileactivedefense.com>

Tad McClellan <tadmc@seesig.invalid> writes:
> Randal L. Schwartz <merlyn@stonehenge.com> wrote:
>>>>>>> "David" == David Harmon <source@netcom.com> writes:
>>
>>David> On Sun, 12 Jun 2011 17:11:10 -0700 in comp.lang.perl.misc,
>>David> merlyn@stonehenge.com (Randal L. Schwartz) wrote,
>>>> I'm actually of the camp that "use warnings" does
>>>> more harm than good for the expert programmer. 
>>
>>David> Would you care to say why that is?  It seems to me that if I put
>>David> "use warnings" and no warnings appear, then it isn't doing any harm.
>>
>> Because the workarounds an expert has to do to get warnings not to
>> appear in perfectly good code make it uglier.
>>
>> For example, suppose *you* know that it's perfectly fine to treat an
>> undef as a 0 in a particular situation.  
>
>
> I would want the *next guy* to know that I knew that it was OK.

This is not going to happen unless the next guy can somehow read
your mind. And even if he could, that still doesn't mean that you were
necessarily correct. In order to determine if the code does what it
should be doing/ what needs to be done, the code needs to be examined,
not some set of convictions some other person had about this code.

> I want to say "It is OK if undefs are treated as zeros here, I
> checked".
>
> So I would write:
>
>     $a = 0 unless defined;
>     $b = 0 unless defined;

This implies that defined($a) and defined($b) will henceforth return
true. It is not entirely inconceivable that 'other code' has been
written based on the assumption that what was !defined will remain
!defined even despite the value was used for a calculation (or to
print a string) in between ...

>> So you write:
>>
>>   my $c = $a + $b; 
>>
>> even if $a or $b might be undef.
>
>
> _I_ would pause here to wonder about the values of $a and $b, and
> would go find out where their values came from, and what $c was
> supposed to be if they happened to be undef.

Since $c is going to be 0 if both $a and $b were undef, the assumption
that it was supposed to have any other value in this case is somewhat
far fetched ..

[...]

>> Far far far too much wasted
>> effort.
>
>
> Far too much misdirected effort.
>
> It is not wasted if it avoids leading me "off into the woods"
> when I could have "stayed on the trail".

Assuming that code is correct because an arbitrary, informal and
meaningless 'code annotation' has been added to it is way off
in the woods. Programming languages provide in line documentation
facilities in the form of comments. Consequently, this should have
been

	my $c = $a + $b;	# undef + undef is ok

This is still problematic, because sooner or later someone will copy &
paste this line of code to an entirely different file and modify it as
follows:

	my $c = 1/($a + $b);	# undef + undef is ok

Since the comment isn't executed, that someone will - of course -
refrain from changing it --- if the line has already a comment
attached, why 'reinvent the wheel' and write a new one?

NB: This is not a joke. Places where I encountered this practice in
the past have (among others) been in something as 'reputable' as
Linux.


------------------------------

Date: Sat, 18 Jun 2011 16:40:28 +0100
From: Rainer Weikusat <rweikusat@mssgmbh.com>
Subject: Re: [RegEx] Optional parameter
Message-Id: <87mxhftafn.fsf@sapphire.mobileactivedefense.com>

"Peter J. Holzer" <hjp-usenet2@hjp.at> writes:
> On 2011-06-17 21:10, Randal L. Schwartz <merlyn@stonehenge.com> wrote:

[...]

>> And anyone who religiously says "warnings are mandatory" needs to be
>> distrusted slightly, I think.
>
> Anyone who says anything religiously needs to be distrusted slightly, I
> think.
>
> But I was involved when we revamped a systems programming course for 3rd
> semester students back in the 90s. Among other things we required that
> the programs need to compile without warnings at a specified warning
> level. Some of the students showed a lot of creativity in shutting up
> the compiler without actually fixing the problem, but overall the code
> quality of the solutions increased markedly in that year. Yes, those
> were beginners. But I've seen enough code by experienced programmers to
> be sure that almost every programmer can use a little help from the
> compiler. Maybe you are one of the rare exceptions. I certainly ain't.

I have actually never questioned this. My original statement was about
using perl -cw -Mstrict and suitable Makefiles to enable 'static'
checks of files which changed instead of adding

	use warnings;
        use strict;

to each of this files. It's just the the Messieurs Guttman, Pendley
and probably others whose postings I haven't read have chosen to
assume that I must have been lying about the way I usually work with
perl and to make a lot of loud and rude noises regarding what they
believed I must be doing instead of what I wrote.


------------------------------

Date: Sat, 18 Jun 2011 22:00:19 +0200
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: [RegEx] Optional parameter
Message-Id: <slrnivq0uj.koj.hjp-usenet2@hrunkner.hjp.at>

On 2011-06-18 15:40, Rainer Weikusat <rweikusat@mssgmbh.com> wrote:
> "Peter J. Holzer" <hjp-usenet2@hjp.at> writes:
>> On 2011-06-17 21:10, Randal L. Schwartz <merlyn@stonehenge.com> wrote:
> [...]
>>> And anyone who religiously says "warnings are mandatory" needs to be
>>> distrusted slightly, I think.
>>
>> Anyone who says anything religiously needs to be distrusted slightly, I
>> think.
>>
>> But I was involved when we revamped a systems programming course for 3rd
>> semester students back in the 90s. Among other things we required that
>> the programs need to compile without warnings at a specified warning
>> level. Some of the students showed a lot of creativity in shutting up
>> the compiler without actually fixing the problem, but overall the code
>> quality of the solutions increased markedly in that year. Yes, those
>> were beginners. But I've seen enough code by experienced programmers to
>> be sure that almost every programmer can use a little help from the
>> compiler. Maybe you are one of the rare exceptions. I certainly ain't.
>
> I have actually never questioned this. My original statement was about
> using perl -cw -Mstrict and suitable Makefiles to enable 'static'
> checks of files which changed instead of adding

Static checks are much less useful in Perl than they are in statically
typed languages like C. The compiler simply doesn't have enough
information to perform useful checks (at least not fast enough to be
performed every time a program runs[1]). OTOH, unlike the code emitted
by typical C compilers, perl is able to do significant run-time
checking. If you do only static checks and no run-time checks, you
concentrate on an area where perl is relatively weak and ignore the
strengths of perl. Not the best use of the tools available, IMNSHO.

I agree fully with you and Randal that warnings and strictures cannot
replace good design and proper testing, but I don't think anybody meant
to imply that. They are simply another tool.

There is some merit in the notion that they should be necessary only
during testing, but I see little reason to remove them from released
code - if your code got through testing without warnings, it should also
run in production without warnings - if it doesn't, you obviously didn't
test some code paths which are used in reality.

> to each of this files. It's just the the Messieurs Guttman, Pendley
> and probably others whose postings I haven't read have chosen to
> assume that I must have been lying about the way I usually work with
> perl and to make a lot of loud and rude noises regarding what they
> believed I must be doing instead of what I wrote.

Strange. I just browsed through the two threads and found no such
assumption. I did, however, find a posting where you were publically
airing a lot of assumptions about what a certain contractor may or may
not have been told.

	hp

[1] So maybe we need a perl lint.



------------------------------

Date: Sat, 18 Jun 2011 17:50:06 -0700
From: David Harmon <source@netcom.com>
Subject: Re: [RegEx] Optional parameter
Message-Id: <EcadnX1eJLZt2mDQnZ2dnUVZ_hOdnZ2d@earthlink.com>

On Fri, 17 Jun 2011 22:52:11 -0500 in comp.lang.perl.misc, Tad
McClellan <tadmc@seesig.invalid> wrote,
>I want to say "It is OK if undefs are treated as zeros here, I checked".
>
>So I would write:
>
>    $a = 0 unless defined;
>    $b = 0 unless defined;

I will have to study up on that, but I would have guessed it means
the same as

    $a = 0 unless defined $_;
    $b = 0 unless defined $_;


------------------------------

Date: Sun, 19 Jun 2011 00:52:04 -0500
From: Tad McClellan <tadmc@seesig.invalid>
Subject: Re: [RegEx] Optional parameter
Message-Id: <slrnivr37i.fmr.tadmc@tadbox.sbcglobal.net>

David Harmon <source@netcom.com> wrote:
> On Fri, 17 Jun 2011 22:52:11 -0500 in comp.lang.perl.misc, Tad
> McClellan <tadmc@seesig.invalid> wrote,
>>I want to say "It is OK if undefs are treated as zeros here, I checked".
>>
>>So I would write:
>>
>>    $a = 0 unless defined;
>>    $b = 0 unless defined;
>
> I will have to study up on that, but I would have guessed it means
> the same as
>
>     $a = 0 unless defined $_;
>     $b = 0 unless defined $_;


I wrote it wrong.

    $a = 0 unless defined $a;

Sorry.


-- 
Tad McClellan
email: perl -le "print scalar reverse qq/moc.liamg\100cm.j.dat/"
The above message is a Usenet post.
I don't recall having given anyone permission to use it on a Web site.


------------------------------

Date: Sun, 19 Jun 2011 15:05:32 +0100
From: Rainer Weikusat <rweikusat@mssgmbh.com>
Subject: Re: [RegEx] Optional parameter
Message-Id: <87r56pc3wz.fsf@sapphire.mobileactivedefense.com>

Tad McClellan <tadmc@seesig.invalid> writes:
> David Harmon <source@netcom.com> wrote:
>> On Fri, 17 Jun 2011 22:52:11 -0500 in comp.lang.perl.misc, Tad
>> McClellan <tadmc@seesig.invalid> wrote,
>>>I want to say "It is OK if undefs are treated as zeros here, I checked".
>>>
>>>So I would write:
>>>
>>>    $a = 0 unless defined;
>>>    $b = 0 unless defined;
>>
>> I will have to study up on that, but I would have guessed it means
>> the same as
>>
>>     $a = 0 unless defined $_;
>>     $b = 0 unless defined $_;
>
>
> I wrote it wrong.
>
>     $a = 0 unless defined $a;

Given a sufficiently recent version of perl, this can also be written
as

	$a //= 0;

but this is still change that, when applied to existing code, will
break stuff with a very high probability.


------------------------------

Date: Sun, 19 Jun 2011 15:34:27 +0100
From: Rainer Weikusat <rweikusat@mssgmbh.com>
Subject: Re: [RegEx] Optional parameter
Message-Id: <87k4chc2ks.fsf@sapphire.mobileactivedefense.com>

"Peter J. Holzer" <hjp-usenet2@hjp.at> writes:
> On 2011-06-18 15:40, Rainer Weikusat <rweikusat@mssgmbh.com> wrote:
>> "Peter J. Holzer" <hjp-usenet2@hjp.at> writes:
>>> On 2011-06-17 21:10, Randal L. Schwartz <merlyn@stonehenge.com> wrote:
>> [...]
>>>> And anyone who religiously says "warnings are mandatory" needs to be
>>>> distrusted slightly, I think.
>>>
>>> Anyone who says anything religiously needs to be distrusted slightly, I
>>> think.
>>>
>>> But I was involved when we revamped a systems programming course for 3rd
>>> semester students back in the 90s. Among other things we required that
>>> the programs need to compile without warnings at a specified warning
>>> level. Some of the students showed a lot of creativity in shutting up
>>> the compiler without actually fixing the problem, but overall the code
>>> quality of the solutions increased markedly in that year. Yes, those
>>> were beginners. But I've seen enough code by experienced programmers to
>>> be sure that almost every programmer can use a little help from the
>>> compiler. Maybe you are one of the rare exceptions. I certainly ain't.
>>
>> I have actually never questioned this. My original statement was about
>> using perl -cw -Mstrict and suitable Makefiles to enable 'static'
>> checks of files which changed instead of adding
>
> Static checks are much less useful in Perl than they are in statically
> typed languages like C. The compiler simply doesn't have enough
> information to perform useful checks (at least not fast enough to be
> performed every time a program runs[1]).

But it is actually doing this every time before a program starts to
run. The command I gave stops after the code was compiled and
before it actually ran and compilation happens with warnings and
strict enabled. This will detect all syntactical and grammatical
errors, including miscalled subroutines insofar prototype information
is available, everything which violates the 'strict' rules (the strict
module enables additional compile time checks) and any questionable
construct the compiler warns about.

> OTOH, unlike the code emitted by typical C compilers, perl is able
> to do significant run-time checking. If you do only static checks
> and no run-time checks, you concentrate on an area where perl is
> relatively weak and ignore the strengths of perl. Not the best use
> of the tools available, IMNSHO.

Could you give a couple of examples of these runtime checks? The only
one I am aware of is the 'use of unintialized value' warning and the
person who implemented that needs, in my also not so humble
opinion[*], rather a lesson on the difference between C and Perl than
I need this 'voodoo check' for a problem that doesn't exist in the
programming language.

	[*] I've been using Perl professionally for all kinds of
	things, both large and small, since 1996 or so. And for
	not 'killing the time' aka 'implementing generally useful
	modules' but for real application code.

[...]

> There is some merit in the notion that they should be necessary only
> during testing, but I see little reason to remove them from released
> code -

My reason for that is very simple: Code is already complicated enough
to understand, especially if it is used to solve complex problems, and
it should always be as simple as possible. And this implies that it
shouldn't contain anything that performs no useful function.

[...]

>> to each of this files. It's just the the Messieurs Guttman, Pendley
>> and probably others whose postings I haven't read have chosen to
>> assume that I must have been lying about the way I usually work with
>> perl and to make a lot of loud and rude noises regarding what they
>> believed I must be doing instead of what I wrote.
>
> Strange. I just browsed through the two threads and found no such
> assumption.

This was a reasonable posting until this last paragraph.

http://gutenberg.spiegel.de/buch/4994/40




------------------------------

Date: Mon, 20 Jun 2011 01:47:33 -0400
From: Ralph Malph <ralph@happydays.com>
Subject: Re: [RegEx] Optional parameter
Message-Id: <727f2$4dfedef7$ce534406$29705@news.eurofeeds.com>

Man, everybody does.

> ... I Love Ralph




------------------------------

Date: Mon, 20 Jun 2011 08:09:35 -0500
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: [RegEx] Optional parameter
Message-Id: <87boxs3b00.fsf@lifelogs.com>

On Fri, 17 Jun 2011 14:10:56 -0700 merlyn@stonehenge.com (Randal L. Schwartz) wrote: 

RLS> Warnings should be *off* in production (to keep a Perl upgrade from
RLS> yelling at perfectly good production code).

RLS> Warnings might be *off* all the time when experts program.

RLS> Warnings are for beginners.  Only.  And anyone who religiously says
RLS> "warnings are mandatory" needs to be distrusted slightly, I think.

I'd rather use warnings religiously than suffer in maintenance hell.
You may feel differently, but debugging code without warnings
(especially when all you have are the log files) is a nightmare.  Simple
typos can turn into multi-hour hunts, which is a waste ot time, money,
energy, and resources.

Ted


------------------------------

Date: Mon, 20 Jun 2011 14:31:45 +0100
From: Rainer Weikusat <rweikusat@mssgmbh.com>
Subject: Re: [RegEx] Optional parameter
Message-Id: <87liwwvdby.fsf@sapphire.mobileactivedefense.com>

Ted Zlatanov <tzz@lifelogs.com> writes:
> On Fri, 17 Jun 2011 14:10:56 -0700 merlyn@stonehenge.com (Randal L. Schwartz) wrote: 
>
> RLS> Warnings should be *off* in production (to keep a Perl upgrade from
> RLS> yelling at perfectly good production code).
>
> RLS> Warnings might be *off* all the time when experts program.
>
> RLS> Warnings are for beginners.  Only.  And anyone who religiously says
> RLS> "warnings are mandatory" needs to be distrusted slightly, I think.
>
> I'd rather use warnings religiously than suffer in maintenance hell.
> You may feel differently, but debugging code without warnings
> (especially when all you have are the log files) is a nightmare.  Simple
> typos can turn into multi-hour hunts,

Can you provide an example of a 'simple typo' perl cannot detect at
compile time but does detect at runtime?


------------------------------

Date: Mon, 20 Jun 2011 06:59:04 -0700 (PDT)
From: tony <rajashekar14@yahoo.com>
Subject: Automate Vxdiskadm using perl
Message-Id: <8a1e95f6-1fe5-4941-b035-6ad0c98f9488@r33g2000prh.googlegroups.com>

Hi All,
I am trying to run Vxdiskadm veritas command using perl (system)
since vxdiskadm is interactive mode command . it's not working

Example:
When I enter "vxdiskadm" command.It will provide list of options. I
need to choose from that option.
Based on which it give another set of options and so on.
So I need to automate this..
can someone please provide commands for the same


------------------------------

Date: Mon, 20 Jun 2011 11:21:28 -0500
From: Tad McClellan <tadmc@seesig.invalid>
Subject: Re: Automate Vxdiskadm using perl
Message-Id: <slrnivusfl.q28.tadmc@tadbox.sbcglobal.net>

tony <rajashekar14@yahoo.com> wrote:
> Hi All,
> I am trying to run Vxdiskadm veritas command using perl (system)
> since vxdiskadm is interactive mode command . it's not working
>
> Example:
> When I enter "vxdiskadm" command.It will provide list of options. I
> need to choose from that option.
> Based on which it give another set of options and so on.
> So I need to automate this..
> can someone please provide commands for the same


    perldoc -q expect


-- 
Tad McClellan
email: perl -le "print scalar reverse qq/moc.liamg\100cm.j.dat/"
The above message is a Usenet post.
I don't recall having given anyone permission to use it on a Web site.


------------------------------

Date: Mon, 20 Jun 2011 11:16:16 -0700
From: Keith Keller <kkeller-usenet@wombat.san-francisco.ca.us>
Subject: Re: FAQ 2.6 What modules and extensions are available for Perl? What  is CPAN? What does CPAN/src/... mean?
Message-Id: <gcf4d8x4k5.ln2@goaway.wombat.san-francisco.ca.us>

On 2011-06-20, Ralph Malph <ralph@happydays.com> wrote:
> On 6/17/2011 6:31 PM, brian d foy wrote:
>>
>> However, I'm no longer the perlfaq maintainer, so somebody else will
                                                     ^^^^^^^^^^^^^^^^^^
>> have to submit a patch to perl5-porters if they want to change it.
   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

> Ah! Ok. When did this change? You were the maintainer up until just a 
> few weeks ago, right?
> Who is the new maintainer? Does this person know that the faq gets 
> posted here? Will this
> person look here for faq comments and updates?

http://dev.perl.org/perl5/docs/p5p-faq.html

--keith


-- 
kkeller-usenet@wombat.san-francisco.ca.us
(try just my userid to email me)
AOLSFAQ=http://www.therockgarden.ca/aolsfaq.txt
see X- headers for PGP signature information



------------------------------

Date: Mon, 20 Jun 2011 13:20:14 -0400
From: Ralph Malph <ralph@happydays.com>
Subject: Re: FAQ 2.6 What modules and extensions are available for Perl? What is CPAN? What does CPAN/src/... mean?
Message-Id: <c39f9$4dff814f$ce534406$10767@news.eurofeeds.com>

On 6/17/2011 6:31 PM, brian d foy wrote:
> In article<6e6d4$4dfb6edf$ce534406$12125@news.eurofeeds.com>, Ralph
> Malph<ralph@happydays.com>  wrote:
>
>>> It's always dated. There's no way for it to have information that isn't
>>> from the past. :)
>>
>> *sigh*. I'll try one more time.
>
> I wasn't disagreeing with you.  I agree with everything you said.
>
> However, I'm no longer the perlfaq maintainer, so somebody else will
> have to submit a patch to perl5-porters if they want to change it.

Ah! Ok. When did this change? You were the maintainer up until just a 
few weeks ago, right?
Who is the new maintainer? Does this person know that the faq gets 
posted here? Will this
person look here for faq comments and updates?


------------------------------

Date: Mon, 20 Jun 2011 14:51:18 -0400
From: Ralph Malph <ralph@happydays.com>
Subject: Re: FAQ 2.6 What modules and extensions are available for Perl? What is CPAN? What does CPAN/src/... mean?
Message-Id: <184bd$4dff96a9$ce534406$18874@news.eurofeeds.com>

What does the perl 5 porters faq have to do with the perlfaq 
(http://faq.perl.org/) ?
The link you posted is useless and provides no answer to any question 
raised in this thread.

On 6/20/2011 2:16 PM, Keith Keller wrote:
> On 2011-06-20, Ralph Malph<ralph@happydays.com>  wrote:
>> On 6/17/2011 6:31 PM, brian d foy wrote:
>>>
>>> However, I'm no longer the perlfaq maintainer, so somebody else will
>                                                       ^^^^^^^^^^^^^^^^^^
>>> have to submit a patch to perl5-porters if they want to change it.
>     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>
>> Ah! Ok. When did this change? You were the maintainer up until just a
>> few weeks ago, right?
>> Who is the new maintainer? Does this person know that the faq gets
>> posted here? Will this
>> person look here for faq comments and updates?
>
> http://dev.perl.org/perl5/docs/p5p-faq.html
>
> --keith
>
>



------------------------------

Date: Mon, 20 Jun 2011 19:24:53 +0000 (UTC)
From: dmcanzi@remulak.uwaterloo.ca.uwaterloo.ca (David Canzi)
Subject: Re: FAQ 2.6 What modules and extensions are available for Perl? What is CPAN? What does CPAN/src/... mean?
Message-Id: <ito6q5$i96$1@rumours.uwaterloo.ca>

Ralph Malph  <ralph@happydays.com> wrote:
>On 6/17/2011 4:00 AM, brian d foy wrote:
>> In article<4dfafef5$0$23625$ed362ca5@nr5-q3a.newsreader.com>, Xho
>> Jingleheimerschmidt<xhoster@gmail.com>  wrote:
>>
>>> And the faq actually *is* dated unless it is kept updated.  It's a fact,
>>> why hide it?
>>
>> It's always dated. There's no way for it to have information that isn't
>> from the past. :)
>
>*sigh*. I'll try one more time.
>     -5 years is a long time.
>     -CPAN stats from 2006 look bad.
>     -if you can't be bothered to update this entry than remove the date.

Outdated information, with a date, is historically accurate.
Outdated information, without a date, is wrong.  Removing the
date is not an improvement.

-- 
David Canzi		| Life is too short to point out every mistake. |


------------------------------

Date: Sat, 18 Jun 2011 21:46:59 +0200
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: Feeding STDIN
Message-Id: <slrnivq05j.koj.hjp-usenet2@hrunkner.hjp.at>

On 2011-06-19 07:00, ela <ela@yantai.org> wrote:
> "Tad McClellan" <tadmc@seesig.invalid> wrote in message 
> news:slrnivpe3c.d94.tadmc@tadbox.sbcglobal.net...
>> Your Perl program takes *input*, not *arguments*.
>>
>> It wants 2 lines of input, so you must figure out how to get your
>> shell to pass it 2 lines of input:
>>
>>    echo -e "13\n22" | perl test.pl
>
> This is the most important part that I understand now. STDIN is expecting *a 
> line* (I know it's naive...)

No, STDIN doesn't expect anything (it's just a file handle).

It's the <> operator which reads one line.

	hp



------------------------------

Date: Sun, 19 Jun 2011 12:53:08 -0700
From: Keith Thompson <kst-u@mib.org>
Subject: Re: Feeding STDIN
Message-Id: <lny60xwqcb.fsf@nuthaus.mib.org>

"ela" <ela@yantai.org> writes:
> "Tad McClellan" <tadmc@seesig.invalid> wrote in message 
> news:slrnivpe3c.d94.tadmc@tadbox.sbcglobal.net...
>> There *are no* arguments to your Perl program.
>>
>> Your Perl program takes *input*, not *arguments*.
>>
>> It wants 2 lines of input, so you must figure out how to get your
>> shell to pass it 2 lines of input:
>>
>>    echo -e "13\n22" | perl test.pl
>
> This is the most important part that I understand now. STDIN is expecting *a 
> line* (I know it's naive...) so I have to pass in a newline character to it.
> since I'm using tcsh so the solution is
>
> echo "13\n22\n" | perl test.pl

This does not reliably do what you want it to do.

Re-post in comp.unix.shell, and I'll be glad to explain further
(it has nothing to do with Perl).

-- 
Keith Thompson (The_Other_Keith) kst-u@mib.org  <http://www.ghoti.net/~kst>
Nokia
"We must do something.  This is something.  Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"


------------------------------

Date: Sun, 19 Jun 2011 19:14:42 +0000 (UTC)
From: Mladen Gogala <gogala.mladen@gmail.com>
Subject: Problems with Parse::Lex
Message-Id: <pan.2011.06.19.19.14.42@gmail.com>

I can't get Parse::Lex to work. I am getting the following error:

Scalar found where operator expected at (eval 11) line 58, near "}#CASE
  
  $self"
	(Missing operator before #CASE

The script itself is extremely simple and it looks like this:

#!/usr/bin/env perl
use Parse::Lex;
my @token-qw(
    BegParen [\(]
    EndParen [\)]
    Operator [+-*/^]
    Number   [-?\d+|-?\d+\.\d*]
);
my $lexer=Parse::Lex->new(@token);
$lexer->from(\*STDIN);
TOKEN:
while(1) {
    my $token=$lexer->next;
    if(!$lexer->eoi) {
        print $token->name." ".$token->text." \n";
    } else { last TOKEN; }
}

Syntax of the script itself is OK:
 perl -c /tmp/lexerex
/tmp/lexerex syntax OK

This is the first example from the book "Pro Perl Parsing" by Christopher 
M. Frenz. Does anyone have more information about the Perl::Lex module 
and is anybody aware that it doesn't work? I will contact the author, but 
I am interested in whether anybody here has ever used this module and has 
any experience with it? I'm on F14, Perl is 5.12.3. Thanks in advance.
-- 
http://mgogala.byethost5.com


------------------------------

Date: Mon, 20 Jun 2011 03:29:32 +0000 (UTC)
From: Eli the Bearded <*@eli.users.panix.com>
Subject: Re: Problems with Parse::Lex
Message-Id: <eli$1106192324@qz.little-neck.ny.us>

In comp.lang.perl.misc, Mladen Gogala  <gogala.mladen@gmail.com> wrote:
> I can't get Parse::Lex to work. I am getting the following error:

I've gotten small scripts with Parse::Lex to work, but found larger
scripts difficult. I switched to Parse::RecDescent and I have had
no problems.


> #!/usr/bin/env perl
> use Parse::Lex;
> my @token-qw(
           ^
Syntax error right there.

>     BegParen [\(]
>     EndParen [\)]
>     Operator [+-*/^]
                ^^^
Character class syntax error right there.

>     Number   [-?\d+|-?\d+\.\d*]
               ^^^^^^^^^^^^^^^^^^
That's a completely wrong regexp bit.

> );
> my $lexer=Parse::Lex->new(@token);

I don't have that module installed on the computer I'm at right now,
but doesn't it take a string, not an array?

Elijah
------
can't recall the trouble he was having now


------------------------------

Date: Sun, 19 Jun 2011 21:52:31 -0700
From: "John W. Krahn" <jwkrahn@example.com>
Subject: Re: Problems with Parse::Lex
Message-Id: <lmALp.2403$Md1.445@newsfe19.iad>

Mladen Gogala wrote:
> I can't get Parse::Lex to work. I am getting the following error:
>
> Scalar found where operator expected at (eval 11) line 58, near "}#CASE
>
>    $self"
> 	(Missing operator before #CASE
>
> The script itself is extremely simple and it looks like this:
>
> #!/usr/bin/env perl
> use Parse::Lex;
> my @token-qw(
>      BegParen [\(]
>      EndParen [\)]
>      Operator [+-*/^]
>      Number   [-?\d+|-?\d+\.\d*]
> );

$ perl -le'
use warnings;
my @token-qw(
     BegParen [\(]
     EndParen [\)]
     Operator [+-*/^]
     Number   [-?\d+|-?\d+\.\d*]
);
'
Useless use of a constant in void context at -e line 7.
Useless use of a constant in void context at -e line 7.
Useless use of a constant in void context at -e line 7.
Useless use of a constant in void context at -e line 7.
Useless use of a constant in void context at -e line 7.
Useless use of a constant in void context at -e line 7.
Useless use of a constant in void context at -e line 7.
Useless use of subtraction (-) in void context at -e line 2.
Argument "[-?\\d+|-?\\d+\\.\\d*]" isn't numeric in subtraction (-) at -e 
line 2.




John
-- 
Any intelligent fool can make things bigger and
more complex... It takes a touch of genius -
and a lot of courage to move in the opposite
direction.                   -- Albert Einstein


------------------------------

Date: Mon, 20 Jun 2011 13:27:54 +0100
From: Rainer Weikusat <rweikusat@mssgmbh.com>
Subject: Re: Problems with Parse::Lex
Message-Id: <87sjr48z79.fsf@sapphire.mobileactivedefense.com>

Mladen Gogala <gogala.mladen@gmail.com> writes:
> I can't get Parse::Lex to work. I am getting the following error:
>
> Scalar found where operator expected at (eval 11) line 58, near "}#CASE
>   
>   $self"
> 	(Missing operator before #CASE
>
> The script itself is extremely simple and it looks like this:
>
> #!/usr/bin/env perl
> use Parse::Lex;
> my @token-qw(

The - here should probably have been a =.

>     BegParen [\(]
>     EndParen [\)]
>     Operator [+-*/^]

The minus needs to come last, otherwise, it is intepreted as 'middle
part' of a character range.

>     Number   [-?\d+|-?\d+\.\d*]

You are using character set syntax for an ordinary regular
expressions.

> );
> my $lexer=Parse::Lex->new(@token);
> $lexer->from(\*STDIN);
> TOKEN:
> while(1) {
>     my $token=$lexer->next;
>     if(!$lexer->eoi) {
>         print $token->name." ".$token->text." \n";
>     } else { last TOKEN; }
> }
>
> Syntax of the script itself is OK:
>  perl -c /tmp/lexerex

Consider enabling warning (-w) and possibly, the strict module
(-Mstrict) when doing something like this. Both will usually help to
catch errors.

Variant of your script which seems to work as was probably intended:

-----------------
#!/usr/bin/env perl
use Parse::Lex;

my @token = qw(
		BegParen [\(]
		EndParen [\)]
		Operator [+*/^-]
		Number   \d+(?:\.\d+)?
		EOL	 \n
	   );

my $lexer=Parse::Lex->new(@token);
$lexer->from(\*STDIN);
TOKEN:
while(1) {
    my $token=$lexer->next;
    if(!$lexer->eoi) {
        print $token->name." ".$token->text." \n";
    } else { last TOKEN; }
}


------------------------------

Date: Mon, 20 Jun 2011 08:11:54 -0500
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: send file as post to cgi that writes file on remote webserver command line
Message-Id: <877h8g3aw5.fsf@lifelogs.com>

On Sat, 18 Jun 2011 00:49:02 -0700 (PDT) gavino <gavcomedy@gmail.com> wrote: 

g> how?

First, you write the CGI script that writes file on remote webserver.

Then, you invoke it from the command line with a filename POST
parameter.

Ted


------------------------------

Date: Mon, 20 Jun 2011 09:42:32 -0700
From: Jim Gibson <jimsgibson@gmail.com>
Subject: Re: upload file rom solaris to debian using perl base install
Message-Id: <200620110942325430%jimsgibson@gmail.com>

In article
<e5a775ea-22e7-4b2f-9792-0218fc2961b4@r35g2000prj.googlegroups.com>,
gavino <gavcomedy@gmail.com> wrote:

> how?
> 
> I tried fo rhours to piece this one together.
> 
> Whew
> 
> it seems u need a cgi on box 2 to accept some kinda wget uplaod from
> box1
> 
> by the way I am not allowed anything but base perl 5.10 with cgi.pm
> and wget
> 
> no curl
> 
> on soalris 10 box1
> 
> have to upload files to webserver on debian box2
> 
> how?
> 
> read about 30 pages mostly with upload forms

What 30 pages did you read? Where did the pages come from? Have you
read the documentation for the CGI module? (perldoc CGI). That module
includes an upload function.

From the CGI documentation:

           $fh = upload('uploaded_file');
            while (<$fh>) {
                  print;
            }

  
> 
> I want to command line script this and put in cron on box1

Do you have ssh on the debian box? Can you use scp?

> 
> lighttps on debian is also annoying as docs are light for cgi

Do you mean 'lighttpd'? I have not used it, so can't help there.

-- 
Jim Gibson


------------------------------

Date: Mon, 20 Jun 2011 18:24:15 +0100
From: Rainer Weikusat <rweikusat@mssgmbh.com>
Subject: Re: upload file rom solaris to debian using perl base install
Message-Id: <874o3kl8lc.fsf@sapphire.mobileactivedefense.com>

gavino <gavcomedy@gmail.com> writes:

[...]


> it seems u need a cgi on box 2 to accept some kinda wget uplaod from
> box1
>
> by the way I am not allowed anything but base perl 5.10 with cgi.pm
> and wget
>
> no curl
>
> on soalris 10 box1
>
> have to upload files to webserver on debian box2

Have you considered the ultra-simple solution, namely,

--------------
#!/usr/bin/perl
#

use Socket;

{
    my ($conn_sk, $sk, $rc, $buf);

    $rc = socket($sk, AF_INET, SOCK_STREAM, 0);
    $rc || die('socket');
    
    $rc = bind($sk, pack_sockaddr_in(1234, inet_aton('0.0.0.0')));
    $rc || die('bind');

    $rc = listen($sk, 1);
    $rc || die('listen');

    $rc = accept($conn_sk, $sk);
    $rc || die('accept');

    print($buf) while (($rc = sysread($conn_sk, $buf, 8192)) > 0);
    $rc // die('sysread');
}
--------------

This will bind a listening TCP socket to port 1234, accept a
connection on that and print whatever data is sent accross the
connected socket to stdout.


------------------------------

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:

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

Back issues are available via anonymous ftp from
ftp://cil-www.oce.orst.edu/pub/perl/old-digests. 

#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 3420
***************************************


home help back first fref pref prev next nref lref last post