[31259] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2504 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jul 6 16:09:45 2009

Date: Mon, 6 Jul 2009 13:09:12 -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, 6 Jul 2009     Volume: 11 Number: 2504

Today's topics:
    Re: Best way to do server side tasks with new ISP <cwilbur@chromatico.net>
    Re: Best way to do server side tasks with new ISP <cwilbur@chromatico.net>
    Re: Best way to do server side tasks with new ISP <paul@peschoen.com>
    Re: Best way to do server side tasks with new ISP <tadmc@seesig.invalid>
    Re: Best way to do server side tasks with new ISP sln@netherlands.com
    Re: Best way to do server side tasks with new ISP <cwilbur@chromatico.net>
    Re: Best way to do server side tasks with new ISP sln@netherlands.com
    Re: Best way to do server side tasks with new ISP sln@netherlands.com
    Re: Excel Formatting <rajpreetsidhu@gmail.com>
    Re: FAQ 4.28 How do I change the Nth occurrence of some <anno4000@zrz.tu-berlin.de>
    Re: formatting a number of elsif statements sln@netherlands.com
        how to format output <moonhkt@gmail.com>
    Re: how to format output <rabbits77@my-deja.com>
    Re: how to format output <uri@stemsystems.com>
    Re: how to format output <rabbits77@my-deja.com>
    Re: how to format output <uri@stemsystems.com>
    Re: how to format output <rabbits77@my-deja.com>
    Re: how to format output <uri@stemsystems.com>
    Re: how to write a script to only process one depth dir <m@rtij.nl.invlalid>
    Re: how to write a script to only process one depth dir (Tim McDaniel)
        Perl scalars as numbers or character strings <paul@peschoen.com>
        Snake bite deaths highest in Sri Lanka <asim.ssat@gmail.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Mon, 06 Jul 2009 02:37:33 -0400
From: Charlton Wilbur <cwilbur@chromatico.net>
Subject: Re: Best way to do server side tasks with new ISP
Message-Id: <86d48ee2qa.fsf@mithril.chromatico.net>

>>>>> "PES" == Paul E Schoen <paul@peschoen.com> writes:

    PES> Yes, I was very confused about what the point was. I have no
    PES> idea why the following line would ever need to be parsed in C,
    PES> or in any other language:

    PES>     foo=1;bar=yes;baz=c;baz=b;baz=c;quux=seven;quux=;submit=true

Consider a list of CGI form parameters in a GET query string.

Charlton




-- 
Charlton Wilbur
cwilbur@chromatico.net


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

Date: Mon, 06 Jul 2009 02:49:47 -0400
From: Charlton Wilbur <cwilbur@chromatico.net>
Subject: Re: Best way to do server side tasks with new ISP
Message-Id: <868wj2e25w.fsf@mithril.chromatico.net>

>>>>> "sln" == sln  <sln@netherlands.com> writes:

    >> 	Given the following line:
    >>
    >>    foo=1;bar=yes;baz=c;baz=b;baz=c;quux=seven;quux=;submit=true
    >> 
    >>  Produce the following output:
    >>
    >> 	* An alphabetically sorted list of the values assigned
    >>    to each variable 
    >>  * The count of values assigned to each variable 
    >>  * The result of foo * 27 + 3

    sln> In no way, shape or form, is this a problem specification, nor
    sln> anything of any use to anything or anybody, et all.

On the contrary, if you were half the programmer you claim to be, you
would recognize the rudimentary elements of CGI query string parsing.

    sln> You can't parse c/c++ with this simplistic approach.  You can't
    sln> get from HERE -->"foo=1;" to HERE --> "bar=yes;".  You can't
    sln> even get to HERE -->"foo=1;"

Er, I'm not *trying* to parse C or C++, and I can, actually, parse the
string as specified in the problem.

    sln> Alpha sorted list of "values" assigned to each variable? Whats
    sln> that tell ya?  Count of values, here I assume you are adressing
    sln> re-assignment, as if scope is not an issue.  Finally, the
    sln> result of foo's multiplicity.

The point of the example, as noted above, was to produce an example
problem that included the more basic elements of CGI processing, and in
particular those that would demonstrate the annoyances with using C to
write CGI-handling scripts.  The original querent asked why Perl was
used in preference to C for early web programming, and I thought a
concrete example would be more useful than a history lesson.

    sln> Are you desperately trying to be funny?

No.  Are you desperately trying to be an idiot?  Or are you just soused
again?

Charlton



-- 
Charlton Wilbur
cwilbur@chromatico.net


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

Date: Mon, 06 Jul 2009 17:19:17 GMT
From: "Paul E. Schoen" <paul@peschoen.com>
Subject: Re: Best way to do server side tasks with new ISP
Message-Id: <pmq4m.1133$P5.733@nwrddc02.gnilink.net>


"Charlton Wilbur" <cwilbur@chromatico.net> wrote in message 
news:86d48ee2qa.fsf@mithril.chromatico.net...
>>>>>> "PES" == Paul E Schoen <paul@peschoen.com> writes:
>
>    PES> Yes, I was very confused about what the point was. I have no
>    PES> idea why the following line would ever need to be parsed in C,
>    PES> or in any other language:
>
>    PES>     foo=1;bar=yes;baz=c;baz=b;baz=c;quux=seven;quux=;submit=true
>
> Consider a list of CGI form parameters in a GET query string.

Well, I had to look up what a GET query string was. I found a reasonable 
explanation at:
http://www.antipope.org/charlie/attic/webbook/ch5perl/perl7.html

Then I searched for what CGI form parameters were. I found:
http://www.perlmeme.org/tutorials/cgi_form.html

Now I am somewhat at a loss as to what created the GET query string in the 
first place, and I also see that it seems to use semicolons instead of the 
ampersands that are specified in the explanation. But my understanding is 
that a query string is usually generated as a result of items a user may 
have entered or selected in a blank form, and these items are then 
interpreted and converted to HTML so that a new document will be created 
according to the request of the user.

So, AIUI, the CGI script only needs to parse the query string and then 
create a new HTML according to the parameters which were generated by the 
original form, and the script is written specifically for that form, so it 
already knows what the variables are, and what the values mean. So the 
string could be formatted in any way that the script could understand, and 
convert back to appropriate HTML.

I'm also not quite sure why the query string needs to be part of the URL, 
although I can see that it identifies how the CGI script should format the 
special version of the form as desired by the user. Thus the original URL 
is just the blank form and the URL with the query is the modified version 
as created by the CGI script. I take it that this exists as a temporary 
file on the server which is then read by the browser?

There is probably a very basic level of understanding that I just do not 
quite grasp.

Paul 




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

Date: Mon, 06 Jul 2009 14:20:00 -0500
From: Tad J McClellan <tadmc@seesig.invalid>
Subject: Re: Best way to do server side tasks with new ISP
Message-Id: <slrnh54jbe.asd.tadmc@tadmc30.sbcglobal.net>

Paul E. Schoen <paul@peschoen.com> wrote:
>
> "Charlton Wilbur" <cwilbur@chromatico.net> wrote in message 
> news:86d48ee2qa.fsf@mithril.chromatico.net...
>>>>>>> "PES" == Paul E Schoen <paul@peschoen.com> writes:
>>
>>    PES> Yes, I was very confused about what the point was. I have no
>>    PES> idea why the following line would ever need to be parsed in C,
>>    PES> or in any other language:
>>
>>    PES>     foo=1;bar=yes;baz=c;baz=b;baz=c;quux=seven;quux=;submit=true
>>
>> Consider a list of CGI form parameters in a GET query string.
>
> Well, I had to look up what a GET query string was. I found a reasonable 
> explanation at:
> http://www.antipope.org/charlie/attic/webbook/ch5perl/perl7.html
>
> Then I searched for what CGI form parameters were. I found:
> http://www.perlmeme.org/tutorials/cgi_form.html
>
> Now I am somewhat at a loss as to what created the GET query string in the 
> first place, 



Err, that would be a piece of technology often called a "web browser".


> and I also see that it seems to use semicolons instead of the 
> ampersands that are specified in the explanation. 


An "explanation" is not "the standard".

The Standard allows either character.


> But my understanding is 
> that a query string is usually generated 


by a browser 


> as a result of items a user may 
> have entered or selected in a blank form, and these items are then 
> interpreted and converted to HTML 


by a "CGI program"

This CGI program (in Perl in this case) must then decode the
query string so that it can then generate the response.


> I'm also not quite sure why the query string needs to be part of the URL, 


That is what The Standard says is supposed to happen for an
HTTP GET request.

For an HTTP POST request, the parameters are not in the URL, they
are on STDIN.


> There is probably a very basic level of understanding that I just do not 
> quite grasp.


Indeed.

You seem to not have a grasp of the rudiments of how the WWW
(ie. HTTP requests and responses) operates.

How it operates is independent of the language you choose to
implement the parts necessary, and hence is not on-topic in
a programming language newsgroup.

Have you tried searching the Perl FAQ for info about CGI and HTML stuff:

    perldoc -q CGI

        How can I make my CGI script more efficient?

        Where can I learn about CGI or Web programming in Perl?

        What is the correct form of response from a CGI script?

        My CGI script runs from the command line but not the browser.  (500 Server Error)

        How can I get better error messages from a CGI program?

        How do I make sure users can't enter values into a form that cause my CGI script to do bad things?

        How do I decode a CGI form?


    perldoc -q HTML

        How do I remove HTML from a string?

        How do I make a pop-up menu in HTML?

        How do I fetch an HTML file?

        How do I automate an HTML form submission?


-- 
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"


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

Date: Mon, 06 Jul 2009 12:21:43 -0700
From: sln@netherlands.com
Subject: Re: Best way to do server side tasks with new ISP
Message-Id: <42j455567qihfvmacq1kderib7qgfq1uaj@4ax.com>

On Sun, 05 Jul 2009 19:25:09 GMT, "Paul E. Schoen" <paul@peschoen.com> wrote:

>
><sln@netherlands.com> wrote in message 
>news:trvv455m441keqht10c2nb68fn161e9e1o@4ax.com...
>>
>> In no way, shape or form, is this a  problem specification, nor anything 
>> of
>> any use to anything or anybody, et all.
>>
[snip]

>Yes, I was very confused about what the point was. I have no idea why the 
>following line would ever need to be parsed in C, or in any other language:
>
>    foo=1;bar=yes;baz=c;baz=b;baz=c;quux=seven;quux=;submit=true
>
[snip]

>And the point of using fewer lines to accomplish the same thing is not very 
>beneficial if the code is difficult to understand. Delphi (Pascal) does 
>tend to be rather verbose, and I wish there were constructs like {} rather 
>than "Begin" and "End", but well-written code with liberal use of 
>indentation and whitespace make it easy to understand and maintain. "C" has 
>some operators that make for more compact code, but IMHO at the cost of 
>readability. Then Perl seems to be at another level of brevity that reminds 
>me of command line switches as used in MSDOS and even CP/M utilities like 
>the line editor "ed".
>
>Paul 
>

Ah CP/M, z80(a), Zilog. My first real computer TimexSinclair Z80.
Assembly, my first language. Z80a decompiler, my first program.

In all fairness, I only read the last few posts starting with Dr. Ruud's
apparent solution to what appeared (to him I think) to be a problem statement
by Wilbur guy.

Well, in all fairness to me, as threads fracture, so they become fractured.

-sln


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

Date: Mon, 06 Jul 2009 15:20:52 -0400
From: Charlton Wilbur <cwilbur@chromatico.net>
Subject: Re: Best way to do server side tasks with new ISP
Message-Id: <864otpehyj.fsf@mithril.chromatico.net>

>>>>> "PES" == Paul E Schoen <paul@peschoen.com> writes:

    PES> There is probably a very basic level of understanding that I
    PES> just do not quite grasp.

Yes, I'd say that's a very accurate statement.

Charlton




-- 
Charlton Wilbur
cwilbur@chromatico.net


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

Date: Mon, 06 Jul 2009 12:34:30 -0700
From: sln@netherlands.com
Subject: Re: Best way to do server side tasks with new ISP
Message-Id: <h1k455ljjoshmad9839hageh3ud9erfds3@4ax.com>

On Mon, 06 Jul 2009 14:20:00 -0500, Tad J McClellan <tadmc@seesig.invalid> wrote:

>Paul E. Schoen <paul@peschoen.com> wrote:
>>
>> "Charlton Wilbur" <cwilbur@chromatico.net> wrote in message 
>> news:86d48ee2qa.fsf@mithril.chromatico.net...
>>>>>>>> "PES" == Paul E Schoen <paul@peschoen.com> writes:
[snip]
>> There is probably a very basic level of understanding that I just do not 
>> quite grasp.
>
>
>Indeed.
>
>You seem to not have a grasp of the rudiments of how the WWW
>(ie. HTTP requests and responses) operates.
>
>How it operates is independent of the language you choose to
>implement the parts necessary, and hence is not on-topic in
>a programming language newsgroup.
>

Now about ON-TOPIC, I wouldn't go that far Tad. If you take away
applications, programming language newsgroups wouldn't exist.
Larry would be the only poster here, questions and answers.

-sln


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

Date: Mon, 06 Jul 2009 12:36:19 -0700
From: sln@netherlands.com
Subject: Re: Best way to do server side tasks with new ISP
Message-Id: <hfk4555rb183je1olpup8aafmsk95flfic@4ax.com>

On Mon, 06 Jul 2009 15:20:52 -0400, Charlton Wilbur <cwilbur@chromatico.net> wrote:

>>>>>> "PES" == Paul E Schoen <paul@peschoen.com> writes:
>Yes, I'd say that's a very accurate statement.
>
>Charlton

I'm not sure you are qualified to determine accuracy are you fella?

-sln


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

Date: Mon, 6 Jul 2009 00:38:20 -0700 (PDT)
From: Rajpreet <rajpreetsidhu@gmail.com>
Subject: Re: Excel Formatting
Message-Id: <3b966944-081f-496b-9756-8071f9cf8bb9@f20g2000prn.googlegroups.com>

@ccc31807

Thanks for your answer.
Actually this is an existing file, where in I was supposed to fix few
things.
I did not want to touch other cells using merge_range, but I guess I
do not have any option.

I worked out the merge_range way, and my issue is resolved now.

Thanks once again!


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

Date: Mon, 06 Jul 2009 15:44:25 +0200
From: Anno <anno4000@zrz.tu-berlin.de>
Subject: Re: FAQ 4.28 How do I change the Nth occurrence of something?
Message-Id: <anno4000-F9773C.15442506072009@news.cis.dfn.de>

In article <5e8eh6-4an.ln1@blue.stonehenge.com>,
 PerlFAQ Server <brian@stonehenge.com> wrote:
 
> 4.28: How do I change the Nth occurrence of something?

[snip solutions]

Recently I noticed another solution for that:

    my $str = '1 whomever 2 whoever 3 whomever' . 
              '4 whoever 5 whomever 6 whoever';
    my $n = 5;
    my $re = qr/(whom?)ever/;

    $str =~ /$re/g for 1 .. 5;    # put pos($str) right past fifth match
    $str =~ s/$re\G/${1}soever/;  # replace that one


Anno


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

Date: Mon, 06 Jul 2009 12:55:43 -0700
From: sln@netherlands.com
Subject: Re: formatting a number of elsif statements
Message-Id: <v2l4559lkj8pf8lhiu8126bbm11fnfsjud@4ax.com>

On Sun, 5 Jul 2009 12:07:41 -0700 (PDT), ccc31807 <cartercc@gmail.com> wrote:

>Using 5.8 in a web app, I have about 18 elsif statements which look
>similar to this:
>
>elsif ($action eq 'AddAttorney')
>{
>	print qq(<h4>Add Attorney</h4>);
>	HTML::add_professional($oprid, $role, 'Attorney');
>	HTML::print_button('setup.cgi','Return To Setup',$oprid, $role);
>}
>elsif($action eq 'AddInsurer')
>...
>
>I now fact the prospect of adding some more, hopefully not many, but
>I'm getting tired of looking at all of this.
>
>Is there any way to mimic the case/switch statement? Ideally, I'd like
>to have just the matching term for each block, like this:
>
>'AddAttorney'
>        print qq(<h4>Add Attorney</h4>);
>	HTML::add_professional($oprid, $role, 'Attorney');
>	HTML::print_button('setup.cgi','Return To Setup',$oprid, $role);
>'AddInsurer'
>       ...
>
>It's not critical, but I'm just getting tired of looking at all the
>repetition.
>
>CC.

I haven't read any other reply's but I would bet there is that
switch/case mimic in Perl 5.10

Since you bring up the C switch/case construct, lets talk about
what that really is and how much you should really worry about it.

Forgetting languages except assembly for the moment. How many branch
instructions do you think there are, and how many language intrinsics
do you think you can make with them?

Lets get at least a little bit real. Case/Switch was added to C for only one
reason, as a pass through when conditions overlapp. It still uses the basic
assembly branches but it is still a compound.

Looks are in the eye of the beholder. You obviously never programmed in assembly.

-sln


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

Date: Mon, 6 Jul 2009 08:14:55 -0700 (PDT)
From: moonhkt <moonhkt@gmail.com>
Subject: how to format output
Message-Id: <13b626ea-da2a-4980-a764-561aaf2f2db9@f20g2000prn.googlegroups.com>

Hi All

How to format output ? I want output format in io2.txt file.


$fn="io.txt";        # Input file
$fout = ">io2.txt";  # Write to file
$abc="String";
open ( OUTFILE, $fout);
open( IN, $fn) or die (" cannot open in.txt for reading: $!");

format HEADER=
@<<<<<<<<<@<<@<<
$abc$so_type$code

 .

while (my $line = <IN>)  {
	print "$line";
}

print (OUTFILE "Output to file\n");


close ( IN ) or die("Cannot close file: $!");
close (OUTFILE) or die ("Can not close io2.txt");



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

Date: Mon, 06 Jul 2009 12:21:44 -0400
From: rabbits77 <rabbits77@my-deja.com>
Subject: Re: how to format output
Message-Id: <c0d87$4a52249a$c650990a$30197@news.eurofeeds.com>

moonhkt wrote:
> Hi All
> 
> How to format output ? I want output format in io2.txt file.
> 
> 
> $fn="io.txt";        # Input file
> $fout = ">io2.txt";  # Write to file
> $abc="String";
> open ( OUTFILE, $fout);
> open( IN, $fn) or die (" cannot open in.txt for reading: $!");
> 
> format HEADER=
> @<<<<<<<<<@<<@<<
> $abc$so_type$code
> 
> .
> 
> while (my $line = <IN>)  {
> 	print "$line";
> }
> 
> print (OUTFILE "Output to file\n");
> 
> 
> close ( IN ) or die("Cannot close file: $!");
> close (OUTFILE) or die ("Can not close io2.txt");
I think your question is better phrased as "How do I 
choose to send
my format output to something other than STDOUT?"
The answer is to use the select() operator.
Be aware that virtually every other reply you will
get in this thread will be from Asperberger victims
whinging that you shouldn't use format. You may
safely ignore those posts.




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

Date: Mon, 06 Jul 2009 12:43:28 -0400
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: how to format output
Message-Id: <87ws6l69u7.fsf@quad.sysarch.com>

>>>>> "r" == rabbits77  <rabbits77@my-deja.com> writes:

  r> I think your question is better phrased as "How do I choose to send
  r> my format output to something other than STDOUT?"
  r> The answer is to use the select() operator.
  r> Be aware that virtually every other reply you will
  r> get in this thread will be from Asperberger victims
  r> whinging that you shouldn't use format. You may
  r> safely ignore those posts.

and why would you want to use format? you can use cpan modules (damian's
Text::Format is popular) which are better and easier and allow you to
simply print to any file. perl's builtin format is clunky, inflexible
and even larry wall doesn't use it. so do you have any valid reasons why
the OP should still use format? also larry has aspergerger's. do you
want to insult him some more?

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  --------  http://www.sysarch.com --
-----  Perl Code Review , Architecture, Development, Training, Support ------
--------- Free Perl Training --- http://perlhunter.com/college.html ---------
---------  Gourmet Hot Cocoa Mix  ----  http://bestfriendscocoa.com ---------


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

Date: Mon, 06 Jul 2009 13:16:17 -0400
From: rabbits77 <rabbits77@my-deja.com>
Subject: Re: how to format output
Message-Id: <887f8$4a523162$c650990a$4406@news.eurofeeds.com>

Uri Guttman wrote:
>>>>>> "r" == rabbits77  <rabbits77@my-deja.com> writes:
> 
>   r> I think your question is better phrased as "How do I choose to send
>   r> my format output to something other than STDOUT?"
>   r> The answer is to use the select() operator.
>   r> Be aware that virtually every other reply you will
>   r> get in this thread will be from Asperberger victims
>   r> whinging that you shouldn't use format. You may
>   r> safely ignore those posts.
> 
> and why would you want to use format? you can use cpan modules (damian's
> Text::Format is popular) which are better and easier and allow you to
> simply print to any file. perl's builtin format is clunky, inflexible
> and even larry wall doesn't use it. so do you have any valid reasons why
> the OP should still use format? 
[purposely obtuse statement snipped]
I believe that instead of blindly following what you or
anyone else has to say the OP should let his own
curiosity lead his exploration of the language.
Sure, he would be well served to be aware of
Text::Format but he would be better off to
know the many different ways perl offers to
accomplish things and then make his own decisions
within the rules defined by his employer, his own 
style, and so forth. Clearly the OP is a beginner so
why shouldn't he have some fun exploring all the
neat corners in Perl? By strongly advocating
*don't do this...do that* you are spoiling the very
sense of fun that most people enjoy about Perl to
begin with. Corporations should have coding
standards. Individuals learning a language should
not. Why enforce this stifling corporate mindset?
What is clunky and inflexible are the coding rules
you are trying to force onto other people. Perl is
a language that allows for a great deal more
creativity in expression than you want to allow
others to have. What an odd mentality. This is like
bringing a hungry child to an ice cream shop and 
only allowing them to have one flavor of ice cream.
Perl Best Practices should be read after one knows 
the language very well and not one second before
that!



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

Date: Mon, 06 Jul 2009 13:30:31 -0400
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: how to format output
Message-Id: <87prcd4t3c.fsf@quad.sysarch.com>

>>>>> "r" == rabbits77  <rabbits77@my-deja.com> writes:

  r> Uri Guttman wrote:
  >>>>>>> "r" == rabbits77  <rabbits77@my-deja.com> writes:
  >> 
  >> and why would you want to use format? you can use cpan modules (damian's
  >> Text::Format is popular) which are better and easier and allow you to
  >> simply print to any file. perl's builtin format is clunky, inflexible
  >> and even larry wall doesn't use it. so do you have any valid reasons why
  >> the OP should still use format? 

  r> I believe that instead of blindly following what you or anyone else
  r> has to say the OP should let his own curiosity lead his exploration
  r> of the language.  Sure, he would be well served to be aware of
  r> Text::Format but he would be better off to know the many different
  r> ways perl offers to accomplish things and then make his own
  r> decisions within the rules defined by his employer, his own style,
  r> and so forth. Clearly the OP is a beginner so why shouldn't he have
  r> some fun exploring all the neat corners in Perl? By strongly

consider that the 'neat' corner he asked about is poorly done and very
few perl hackers use it. forewarning newbies about a bad corner is perl
is a good thing. learning to use modules is a very good thing. so the OP
can use this as a double learning opportunity, learning to use cpan and
also learning how to use a decent module for formatting text.

  r> advocating *don't do this...do that* you are spoiling the very
  r> sense of fun that most people enjoy about Perl to begin
  r> with. Corporations should have coding standards. Individuals

who said anything about coding standards? you are babbling here.

  r> learning a language should not. Why enforce this stifling corporate
  r> mindset?  What is clunky and inflexible are the coding rules you

who said anything about corporate mindsets? i don't work for any
corporation but i have taught plenty of perl to many different levels of
perl hackers. 

  r> are trying to force onto other people. Perl is a language that
  r> allows for a great deal more creativity in expression than you want
  r> to allow others to have. What an odd mentality. This is like
  r> bringing a hungry child to an ice cream shop and only allowing them
  r> to have one flavor of ice cream.  Perl Best Practices should be
  r> read after one knows the language very well and not one second
  r> before that!

who mentioned perl best practices? i mentioned one module that damian
wrote. the fact that he wrote it wasn't even important other than
knowing it will be solid and well documented which are big plusses.

so you imply i mentioned coding standards, corporate mindsets and perl
best practices when i said none of them. i should say you are the one
with delusions of how perl should be used and taught, not me.

now please reply with another inane post which assumes more things
unsaid by me. i order you to do this, now!

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  --------  http://www.sysarch.com --
-----  Perl Code Review , Architecture, Development, Training, Support ------
--------- Free Perl Training --- http://perlhunter.com/college.html ---------
---------  Gourmet Hot Cocoa Mix  ----  http://bestfriendscocoa.com ---------


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

Date: Mon, 06 Jul 2009 13:43:04 -0400
From: rabbits77 <rabbits77@my-deja.com>
Subject: Re: how to format output
Message-Id: <e07d1$4a5237a9$c650990a$13390@news.eurofeeds.com>

Uri Guttman wrote:
>>>>>> "r" == rabbits77  <rabbits77@my-deja.com> writes:
> 
>   r> Uri Guttman wrote:
>   >>>>>>> "r" == rabbits77  <rabbits77@my-deja.com> writes:
>   >> 
>   >> and why would you want to use format? you can use cpan modules (damian's
>   >> Text::Format is popular) which are better and easier and allow you to
>   >> simply print to any file. perl's builtin format is clunky, inflexible
>   >> and even larry wall doesn't use it. so do you have any valid reasons why
>   >> the OP should still use format? 
> 
>   r> I believe that instead of blindly following what you or anyone else
>   r> has to say the OP should let his own curiosity lead his exploration
>   r> of the language.  Sure, he would be well served to be aware of
>   r> Text::Format but he would be better off to know the many different
>   r> ways perl offers to accomplish things and then make his own
>   r> decisions within the rules defined by his employer, his own style,
>   r> and so forth. Clearly the OP is a beginner so why shouldn't he have
>   r> some fun exploring all the neat corners in Perl? By strongly
> 
> consider that the 'neat' corner he asked about is poorly done and very
> few perl hackers use it. forewarning newbies about a bad corner is perl
> is a good thing. learning to use modules is a very good thing. so the OP
> can use this as a double learning opportunity, learning to use cpan and
> also learning how to use a decent module for formatting text.
> 
>   r> advocating *don't do this...do that* you are spoiling the very
>   r> sense of fun that most people enjoy about Perl to begin
>   r> with. Corporations should have coding standards. Individuals
> 
> who said anything about coding standards? 
Call your admonitions what you will. Labeling them 
as "rules" or "standards", no matter the source, 
still apply. You are clearly trying to back out of 
your statements. Good!
To the OP: use format. Try things
out and explore! Have fun!
Give back to the community by not developing this
annoying preachy attitude about how to do things
either.



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

Date: Mon, 06 Jul 2009 14:01:04 -0400
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: how to format output
Message-Id: <87ljn14rof.fsf@quad.sysarch.com>

>>>>> "r" == rabbits77  <rabbits77@my-deja.com> writes:

  >> consider that the 'neat' corner he asked about is poorly done and very
  >> few perl hackers use it. forewarning newbies about a bad corner is perl
  >> is a good thing. learning to use modules is a very good thing. so the OP
  >> can use this as a double learning opportunity, learning to use cpan and
  >> also learning how to use a decent module for formatting text.
  >> 

  r> advocating *don't do this...do that* you are spoiling the very
  r> sense of fun that most people enjoy about Perl to begin
  r> with. Corporations should have coding standards. Individuals

how nice that you obeyed my order to reply but deleted it from the
quote!

  >> who said anything about coding standards? 

  r> Call your admonitions what you will. Labeling them as "rules" or
  r> "standards", no matter the source, still apply. You are clearly trying
  r> to back out of your statements. Good!
  r> To the OP: use format. Try things
  r> out and explore! Have fun!
  r> Give back to the community by not developing this
  r> annoying preachy attitude about how to do things
  r> either.

me thinks thou dost protest too much. i smell preachy all over you. i
don't preach, i teach. i offer suggestions, better ideas, solutions,
etc. readers or students are free to do as they please after i
pontficate from above. you are obviously wiser than me so please train
all the newbies you can. are you on the perl beginner's list?

and i repeat my order to inanely reply to this. you will keep replying
until i tell you to stop. this is fun!

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  --------  http://www.sysarch.com --
-----  Perl Code Review , Architecture, Development, Training, Support ------
--------- Free Perl Training --- http://perlhunter.com/college.html ---------
---------  Gourmet Hot Cocoa Mix  ----  http://bestfriendscocoa.com ---------


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

Date: Mon, 6 Jul 2009 08:39:55 +0200
From: Martijn Lievaart <m@rtij.nl.invlalid>
Subject: Re: how to write a script to only process one depth directories
Message-Id: <rqi8i6-fgt.ln1@news.rtij.nl>

On Sun, 05 Jul 2009 20:10:46 -0700, Randal L. Schwartz wrote:

>>>>>> "Martijn" == Martijn Lievaart <m@rtij.nl.invlalid> writes:
> 
> Martijn> echo /server/server*/Defaults | while read f; do perl -pi
> $SCRIPT; done
> 
> I don't think that'll do it.
> 
> echo will generate something like:
> 
>   /server/server1/Defaults /server/server2/Defaults
>   /server/server3/Defaults
> 
> which "read f" will read all at once making $f to be
> 
>   "/server/server1/Defaults /server/server2/Defaults
>   /server/server3/Defaults"

You're right. I'll think about it some more. Shows again this simple 
problem is not simple solvable in shell without gnu utilities. So there 
is a lot to be said for the Perl solution after all.

OK, how about this:

ls /server | grep ^server | while read f; do if [ -e "/server/$f/
Default" ]; then perl -pi $SCRIPT "$f" ; fi; done

Oh, this is a Perl newsgroup, I'll let it go at this.

M4


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

Date: Mon, 6 Jul 2009 18:39:49 +0000 (UTC)
From: tmcd@panix.com (Tim McDaniel)
Subject: Re: how to write a script to only process one depth directories
Message-Id: <h2tgdl$ib$1@reader1.panix.com>

In article <86prcea4ll.fsf@blue.stonehenge.com>,
Randal L. Schwartz <merlyn@stonehenge.com> wrote:
>>>>>> "Martijn" == Martijn Lievaart <m@rtij.nl.invlalid> writes:
>
>Martijn> echo /server/server*/Defaults | while read f; do perl -pi $SCRIPT; done
>
>I don't think that'll do it.
>
>echo will generate something like:
>
>  /server/server1/Defaults /server/server2/Defaults /server/server3/Defaults
>
>which "read f" will read all at once making $f to be
>
>  "/server/server1/Defaults /server/server2/Defaults /server/server3/Defaults"

echo /server/server*/Defaults | xargs -n 1 |
    while read f; do perl -pi "$SCRIPT"; done

The xargs(1) man page says

    ... xargs reads items from the standard input ... and executes the
    command (default is /bin/echo) one or more times ...

    -n max-args

        Use at most max-args arguments per command line. ...


But I, too, still don't like that it doesn't handle shell
metacharacters in the filenames.

-- 
Tim McDaniel, tmcd@panix.com


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

Date: Mon, 06 Jul 2009 19:52:52 GMT
From: "Paul E. Schoen" <paul@peschoen.com>
Subject: Perl scalars as numbers or character strings
Message-Id: <oCs4m.1159$P5.1108@nwrddc02.gnilink.net>

I am trying to understand scalar variables, and I found the following:
http://www.tutorialspoint.com/perl/perl_scalars.htm

Here is an excerpt:

  #!/usr/bin/perl

  $number = "5";
  $exponent = "2 ** 8";
  $string = "Hello, PERL!";
  $float = 12.39;

  # We can also assign a scalar an empty (undefined) value:
  $nothing = undef;

  # Printing all the above values
  print "$number\n";
  print "$exponent\n";
  print "$string\n";
  print "$float\n";
  print "There is nothing: $nothing\n";

  This will give following result
  5
  2 ** 8
  Hello, PERL!
  12.39
  There is nothing:

My question is whether $number, $exponent, and $float are actually numbers 
or character strings, particularly those that are enclosed in quotes. Thus, 
what would be the result of:

  $mynum = $number * $float;
  print "$mynum";
  print $mynum;
  $mynum = 2 ** 8;
  print "$mynum"

And what happens if you add characters and variables in a print statement?

  print "This is a number$mynum2";

The information in the FAQ did not seem to address this except as follows:

  my $string = '0644';

	  print $string + 0;  # prints 644

  print $string + 44; # prints 688, certainly not octal!

It seems like the printf and sprintf functions work as I would expect,

  printf "0%o %d", $number, $number;

But what happens if you use the following:

  $number = "0123";
  $number = "A123";
  $number = "one";
  $number = 123;
  $number = 123 + 4.56;
  $number = "123 + 4.56";
  $number = "123" + "4.56";

Sorry for the noobish questions, but I am used to C and Delphi Pascal, 
where I am familiar with the syntax.

Thanks,

Paul 




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

Date: Mon, 6 Jul 2009 09:29:50 -0700 (PDT)
From: asim malik <asim.ssat@gmail.com>
Subject: Snake bite deaths highest in Sri Lanka
Message-Id: <470b652a-ec75-47f9-a0b9-51d4a5c5168b@m3g2000pri.googlegroups.com>

COLOMBO: The Sri Lankan government recorded some 33,000 snake bites in
2008, with most of the victims coming from remote villages.

for more details visit: www.nfa786.blogspot.com


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

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>


Administrivia:

#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc.  For subscription or unsubscription requests, send
#the single line:
#
#	subscribe perl-users
#or:
#	unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

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

#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.

#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V11 Issue 2504
***************************************


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