[29830] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1073 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Nov 28 00:09:43 2007

Date: Tue, 27 Nov 2007 21:09:06 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Tue, 27 Nov 2007     Volume: 11 Number: 1073

Today's topics:
    Re: Applications Help! <uri@stemsystems.com>
    Re: Close function blocks forever when reading from pip <google@markginsburg.com>
    Re: Close function blocks forever when reading from pip <ben@morrow.me.uk>
    Re: Failed with exit code 65280. <shareef.jalloq@lightblueoptics.com>
    Re: Failed with exit code 65280. <shareef.jalloq@lightblueoptics.com>
    Re: Failed with exit code 65280. <shareef.jalloq@lightblueoptics.com>
    Re: Failed with exit code 65280. <krahnj@telus.net>
    Re: Failed with exit code 65280. <ben@morrow.me.uk>
        handling perl string containing '@' and '$' with system wong_powah@yahoo.ca
    Re: handling perl string containing '@' and '$' with sy <1usa@llenroc.ude.invalid>
    Re: handling perl string containing '@' and '$' with sy <krahnj@telus.net>
    Re: handling perl string containing '@' and '$' with sy wong_powah@yahoo.ca
    Re: handling perl string containing '@' and '$' with sy <1usa@llenroc.ude.invalid>
    Re: How much validation when using Mail::Sendmail? <noreply@gunnar.cc>
    Re: How much validation when using Mail::Sendmail? <glennj@ncf.ca>
    Re: interesting case of data corruption, and its cause <ben@morrow.me.uk>
        out of memory <aithalanirudh@gmail.com>
    Re: page 124 of the camel book <wade@zaxfuuq.net>
    Re: page 124 of the camel book <jurgenex@hotmail.com>
    Re: page 124 of the camel book <jurgenex@hotmail.com>
    Re: page 124 of the camel book <uri@stemsystems.com>
    Re: Path to Perl <nospam@somewhere.com>
    Re: Path to Perl <rkb@i.frys.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Wed, 28 Nov 2007 00:16:11 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Applications Help!
Message-Id: <x7d4tv2piw.fsf@mail.sysarch.com>

>>>>> "F" == Frieza  <leonard_plummer@hotmail.co.uk> writes:

  F> On 27 Nov, 20:37, Uri Guttman <u...@stemsystems.com> wrote:
  >> >>>>> "F" == Frieza  <leonard_plum...@hotmail.co.uk> writes:
  >> 
  F> Hi can anyone think up of at least five applications that could
  F> benefit from the use of arrays in Perl?
  >> 
  >> my @apps = ( 1 .. 5 ) ;

  F> thanks uri that helped alot, the other's that answered my question
  F> they were ridicolous answers! thanks anyway.

if you think you will get a good grade from my response, you are in need
of more perl education than is possible!

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: Tue, 27 Nov 2007 17:10:38 -0800 (PST)
From: Mark <google@markginsburg.com>
Subject: Re: Close function blocks forever when reading from piped output
Message-Id: <94c66e2c-6d0b-4f0f-ac83-122ac15c7ad9@d21g2000prf.googlegroups.com>

On Nov 27, 2:19 pm, Ben Morrow <b...@morrow.me.uk> wrote:
> This is probably your problem :). Try killing the process before closing
> the pipe: open '-|' returns a pid, and kill TERM => $pid should do
> something reasonable on Win32.
>
> Otherwise try IPC::Run, or do it all by hand with Win32::Process.

I tried killing the process from within my while(<$FH>) loop and that
did allowed the program to complete.  However, I was looking for a
more elegant solution.



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

Date: Wed, 28 Nov 2007 01:58:58 +0000
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: Close function blocks forever when reading from piped output
Message-Id: <2kuu15-q9i.ln1@osiris.mauzo.dyndns.org>


Quoth Mark <google@markginsburg.com>:
> On Nov 27, 2:19 pm, Ben Morrow <b...@morrow.me.uk> wrote:
> > This is probably your problem :). Try killing the process before closing
> > the pipe: open '-|' returns a pid, and kill TERM => $pid should do
> > something reasonable on Win32.
> >
> > Otherwise try IPC::Run, or do it all by hand with Win32::Process.
> 
> I tried killing the process from within my while(<$FH>) loop and that
> did allowed the program to complete.  However, I was looking for a
> more elegant solution.

IPC::Run, as I said. It has a lot of options, but it makes the sort of
thing you are trying to do very simple.

Ben



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

Date: Tue, 27 Nov 2007 15:13:49 -0800 (PST)
From: lbo_user <shareef.jalloq@lightblueoptics.com>
Subject: Re: Failed with exit code 65280.
Message-Id: <6978ca5d-1e21-4a42-85e4-8cde473c6af1@w28g2000hsf.googlegroups.com>


> You're not proving anything there. Change to the directory, you
> think your program is changing to, and run the exact command
> you posted as your program's output.  Either that or use
> the full path in your program, to ensure the path or CWD
> isn't a problem.
>
> Also, you don't need the double quotes around flac.

OK, agreed.  The quotes are from the original author and I removed
them from "lame" but not from flac.  I've been hacking and not keeping
up.

I'll see if I confirm which directory it is being executed in.

Thanks.


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

Date: Tue, 27 Nov 2007 16:10:20 -0800 (PST)
From: lbo_user <shareef.jalloq@lightblueoptics.com>
Subject: Re: Failed with exit code 65280.
Message-Id: <fb4712d9-9ea6-4c21-88e8-a3d2f7b1f413@d27g2000prf.googlegroups.com>

OK, so I've got to the bottom of the problem and it's not what I would
have thought.  The directory paths were all fine but when I changed
the script to use an intermediate temp file instead of using the pipe
it all started working.

The original code was:

  my $convert_command = "$flaccmd @flacargs \"$quotedsrc\"" . " |
$lamecmd @lameargs - \"$tmpfilename\"";
  system($convert_command);

which bailed with the error above.  However, if I changed it to:

  my $flacoutname = $tmpfilename . "_tmp";
  my $flac_command = "$flaccmd @flacargs \"$quotedsrc\" -o
\"$flacoutname\"";
  my $lame_command = "$lamecmd @lameargs \"$flacoutname\"
\"$tmpfilename\"";
  system($flac_command);
  system($lame_command);
  unlink $flacoutname;

everything was fine.  What is it about that concatenation with the
pipe command that is wrong when used within Perl's system?


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

Date: Tue, 27 Nov 2007 16:38:32 -0800 (PST)
From: lbo_user <shareef.jalloq@lightblueoptics.com>
Subject: Re: Failed with exit code 65280.
Message-Id: <55d9e61e-bfde-47f9-80ee-003e44f290b3@d21g2000prf.googlegroups.com>

Right, I must apologise, it's late and I'm not thinking straight.
Ignore my last post as I have found the real reason this time.  I'm
using a FreeNAS server which doesn't seem to like me reading and
writing to it at the same time.  If I run the original script and
stream from the FreeNAS to my local machine everything is fine.  If I
stream from AND try to write to the FreeNAS it barfs.

Definitely not a Perl problem, but thanks for all the help.


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

Date: Wed, 28 Nov 2007 02:31:00 GMT
From: "John W. Krahn" <krahnj@telus.net>
Subject: Re: Failed with exit code 65280.
Message-Id: <474CD2C7.47554060@telus.net>

lbo_user wrote:
> 
> OK, so I've got to the bottom of the problem and it's not what I would
> have thought.  The directory paths were all fine but when I changed
> the script to use an intermediate temp file instead of using the pipe
> it all started working.
> 
> The original code was:
> 
>   my $convert_command = "$flaccmd @flacargs \"$quotedsrc\"" . " |
> $lamecmd @lameargs - \"$tmpfilename\"";
>   system($convert_command);
> 
> which bailed with the error above.  However, if I changed it to:
> 
>   my $flacoutname = $tmpfilename . "_tmp";
>   my $flac_command = "$flaccmd @flacargs \"$quotedsrc\" -o
> \"$flacoutname\"";
>   my $lame_command = "$lamecmd @lameargs \"$flacoutname\"
> \"$tmpfilename\"";
>   system($flac_command);
>   system($lame_command);
>   unlink $flacoutname;
> 
> everything was fine.  What is it about that concatenation with the
> pipe command that is wrong when used within Perl's system?

When you use a piped stream perl's system() invokes a shell to (parse
and) run the command(s).  Without the pipe the command(s) are run
without a shell.



John
-- 
use Perl;
program
fulfillment


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

Date: Wed, 28 Nov 2007 02:53:26 +0000
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: Failed with exit code 65280.
Message-Id: <6q1v15-oii.ln1@osiris.mauzo.dyndns.org>


Quoth "John W. Krahn" <krahnj@telus.net>:
> lbo_user wrote:
> > 
> > OK, so I've got to the bottom of the problem and it's not what I would
> > have thought.  The directory paths were all fine but when I changed
> > the script to use an intermediate temp file instead of using the pipe
> > it all started working.
> > 
> > The original code was:
> > 
> >   my $convert_command = "$flaccmd @flacargs \"$quotedsrc\"" . " |
> > $lamecmd @lameargs - \"$tmpfilename\"";
> >   system($convert_command);
> > 
> > which bailed with the error above.  However, if I changed it to:
> > 
> >   my $flacoutname = $tmpfilename . "_tmp";
> >   my $flac_command = "$flaccmd @flacargs \"$quotedsrc\" -o
> > \"$flacoutname\"";
> >   my $lame_command = "$lamecmd @lameargs \"$flacoutname\"
> > \"$tmpfilename\"";
> >   system($flac_command);
> >   system($lame_command);
> >   unlink $flacoutname;
> > 
> > everything was fine.  What is it about that concatenation with the
> > pipe command that is wrong when used within Perl's system?
> 
> When you use a piped stream perl's system() invokes a shell to (parse
> and) run the command(s).  Without the pipe the command(s) are run
> without a shell.

" counts as a shell metacharacter (perl doesn't want to try to
understand your shell's quoting rules) and will still cause perl to use
the shell. Since avoiding the shell is usually a good thing, this
example would be better written

    system @$_ for
        [$flaccmd, @flacargs, $quotedsrc, -o => $flacoutname],
        [$lamecmd, @lameargs, $flacoutname, $tmpfilename];

having first made sure that there is no quoting of the parameters:
$quotedsrc, for instance, sounds like it's been quoted (:)), and mustn't
be.

Ben



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

Date: Tue, 27 Nov 2007 17:53:21 -0800 (PST)
From: wong_powah@yahoo.ca
Subject: handling perl string containing '@' and '$' with system function
Message-Id: <638c7b6c-b259-4438-84c5-3ec7fff60cef@j44g2000hsj.googlegroups.com>

If I had a perl string $newpw which is inputed by a user and it may
contain special characters such as '@' and '$' (e.g. "5a@Wf7$X").  How
to pass it to the system function properly?
This does not work:
system("/usr/local/bin/acthw -pw \"$newpw\"");
__________________


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

Date: Wed, 28 Nov 2007 02:25:41 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: handling perl string containing '@' and '$' with system function
Message-Id: <Xns99F5D9F9E6466asu1cornelledu@127.0.0.1>

wong_powah@yahoo.ca wrote in news:638c7b6c-b259-4438-84c5-
3ec7fff60cef@j44g2000hsj.googlegroups.com:

> If I had a perl string $newpw which is inputed by a user and it may
> contain special characters such as '@' and '$' (e.g. "5a@Wf7$X").  How
> to pass it to the system function properly?
> This does not work:
> system("/usr/local/bin/acthw -pw \"$newpw\"");

The simplest way would be to bypass the shell:

system '/usr/local/bin/acthw', '-pw', $newpw;

perldoc -f system


Sinan


-- 
A. Sinan Unur <1usa@llenroc.ude.invalid>
(remove .invalid and reverse each component for email address)
clpmisc guidelines: <URL:http://www.augustmail.com/~tadmc/clpmisc.shtml>



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

Date: Wed, 28 Nov 2007 02:39:01 GMT
From: "John W. Krahn" <krahnj@telus.net>
Subject: Re: handling perl string containing '@' and '$' with system function
Message-Id: <474CD4A7.94F475F2@telus.net>

wong_powah@yahoo.ca wrote:
> 
> If I had a perl string $newpw which is inputed by a user and it may
> contain special characters such as '@' and '$' (e.g. "5a@Wf7$X").  How
> to pass it to the system function properly?
> This does not work:
> system("/usr/local/bin/acthw -pw \"$newpw\"");

Why does it not work?  What error message, if any, does it produce? 
Which version of Perl are you using?  What operating system and version
are you using?  Does:

/usr/local/bin/acthw -pw 5a@Wf7$X

work on the command line?



John
-- 
use Perl;
program
fulfillment


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

Date: Tue, 27 Nov 2007 19:28:43 -0800 (PST)
From: wong_powah@yahoo.ca
Subject: Re: handling perl string containing '@' and '$' with system function
Message-Id: <f30dc5b0-5f4e-4303-999a-9cd9efebaec1@a35g2000prf.googlegroups.com>

On Nov 27, 9:39 pm, "John W. Krahn" <kra...@telus.net> wrote:
> wong_po...@yahoo.ca wrote:
>
> > If I had a perl string $newpw which is inputed by a user and it may
> > contain special characters such as '@' and '$' (e.g. "5a@Wf7$X").  How
> > to pass it to the system function properly?
> > This does not work:
> > system("/usr/local/bin/acthw -pw \"$newpw\"");
>
> Why does it not work?  What error message, if any, does it produce?
> Which version of Perl are you using?  What operating system and version
> are you using?  Does:
>
> /usr/local/bin/acthw -pw 5a@Wf7$X
>
> work on the command line?
>
> John
> --
> use Perl;
> program
> fulfillment

This does not work:
system("/usr/local/bin/acthw -pw \"$newpw\"");
The error message is:
Error:  The password you provided is incorrect.



# perl -v
This is perl, v5.8.8 built for i386-linux-thread-multi

Copyright 1987-2006, Larry Wall


OS is FC6 linux.
# uname -a
Linux pc1 2.6.18-1.2798.fc6 #1 SMP Mon Oct 16 14:54:20 EDT 2006 i686
i686 i386 GNU/Linux


This work ("acthw successful" message appeared), as suggested by
Sinan:
system "/usr/local/bin/acthw", "-pw", "$newpw";


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

Date: Wed, 28 Nov 2007 04:08:37 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: handling perl string containing '@' and '$' with system function
Message-Id: <Xns99F5EB6DBC88Dasu1cornelledu@127.0.0.1>

wong_powah@yahoo.ca wrote in news:f30dc5b0-5f4e-4303-999a-9cd9efebaec1
@a35g2000prf.googlegroups.com:

> 
> This work ("acthw successful" message appeared), as suggested by
> Sinan:
> system "/usr/local/bin/acthw", "-pw", "$newpw";

I am glad it worked. But here is what I originally suggested:

system '/usr/local/bin/acthw', '-pw', $newpw ;

Note the differences.

perldoc -q always

Sinan


-- 
A. Sinan Unur <1usa@llenroc.ude.invalid>
(remove .invalid and reverse each component for email address)
clpmisc guidelines: <URL:http://www.augustmail.com/~tadmc/clpmisc.shtml>



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

Date: Wed, 28 Nov 2007 00:39:07 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: How much validation when using Mail::Sendmail?
Message-Id: <5r3o13F12mea1U1@mid.individual.net>

zaphod wrote:
> Gunnar Hjalmarsson wrote:
>> As regards "a valid email regex", how do you define "valid", and what 
>> kind of regex do you think will take care of that?
> 
> Well, I appreciate the only truly valid email address is one that 
> conforms strictly to the relevant RFC but Mail::Sendmail comes with its 
> own regex which is supposed to be reliable for most real-world cases.

Most isn't good enough, is it? Why annoy users with perfectly fine 
addresses?

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl


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

Date: 27 Nov 2007 23:41:00 GMT
From: Glenn Jackman <glennj@ncf.ca>
Subject: Re: How much validation when using Mail::Sendmail?
Message-Id: <slrnfkpaod.qp6.glennj@smeagol.ncf.ca>

At 2007-11-27 06:02PM, "zaphod" wrote:
>  Well, I appreciate the only truly valid email address is one that conforms 
>  strictly to the relevant RFC but Mail::Sendmail comes with its own regex 
>  which is supposed to be reliable for most real-world cases.


The following subroutine generates a regular expression to validate an
RFC822 email address (taken from Friedl's Mastering Regular Expressions)

sub getRFC822AddressSpec
{
    my ($esc, $space, $tab, $period) = ('\\\\', '\040', '\t', '\.');
    my ($lBr, $rBr, $lPa, $rPa)      = ('\[', '\]', '\(', '\)');
    my ($nonAscii, $ctrl, $CRlist)   = ('\200-\377', '\000-\037', '\n\015');

    my $qtext       = qq{ [^$esc$nonAscii$CRlist] }; # within "..."
    my $dtext       = qq{ [^$esc$nonAscii$CRlist$lBr$rBr] }; # within [...]
    my $ctext       = qq{ [^$esc$nonAscii$CRlist()] }; # within (...)
    my $quoted_pair = qq{ $esc [^$nonAscii] }; # an escaped char
    my $atom_char   = qq{ [^()$space<>\@,;:".$esc$lBr$rBr$ctrl$nonAscii] };
    my $atom        = qq{ $atom_char+     # some atom chars
                          (?!$atom_char)  # NOT followed by part of an atom
                        };
    # rfc822 comments are (enclosed (in parentheses) like this)
    my $cNested     = qq{ $lPa (?: $ctext | $quoted_pair )* $rPa };
    my $comment     = qq{ $lPa (?: $ctext | $quoted_pair | $cNested )* $rPa };

    # whitespace and comments may be scattered liberally
    my $X           = qq{ (?: [$space$tab] | $comment )* };

    my $quoted_str  = qq{ " (?: $qtext | $quoted_pair )* " };
    my $word        = qq{ (?: $atom | $quoted_str ) };
    my $domain_ref  = $atom;
    my $domain_lit  = qq{ $lBr (?: $dtext | $quoted_pair )* $rBr };
    my $sub_domain  = qq{ (?: $domain_ref | $domain_lit ) };
    my $domain      = qq{ $sub_domain (?: $X $period $X $sub_domain )* };
    my $local_part  = qq{ $word (?: $X $period $X $word )* };
    my $addr_spec   = qq{ $local_part $X \@ $X $domain };

    # return a regular expression object
    return qr{$addr_spec}ox;
}

my $spec = getRFC822AddressSpec();
if ($an_email_address =~ /$spec/) {print "ok: $an_email_address\n"}


-- 
Glenn Jackman
"You can only be young once. But you can always be immature." -- Dave Barry


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

Date: Tue, 27 Nov 2007 23:55:30 +0000
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: interesting case of data corruption, and its cause
Message-Id: <icnu15-iph.ln1@osiris.mauzo.dyndns.org>


Quoth "jl_post@hotmail.com" <jl_post@hotmail.com>:
> On Nov 23, 3:34 am, bugbear <bugbear@trim_papermule.co.uk_trim> wrote:
> >
> > Oh, all agreed. I now understand (and have done) the localisation of $_.
> >
> > My point is that this syndrome is fairly easy to fall into,
> > and doesn't appear to be widely known or spoken of.
> 
<snip: $\, -l and print>
> 
>    Like your issue, mine is also one that doesn't appear to be widely
> known or spoken of.

From perldoc perlvar:

       You should be very careful when modifying the default values of
       most special variables described in this document. In most cases
       you want to localize these variables before changing them, since
       if you don’t, the change may affect other modules which rely on
       the default values of the special variables that you have
       changed. This is one of the correct ways to read the whole file
       at once:

           open my $fh, "foo" or die $!;
           local $/; # enable localized slurp mode
           my $content = <$fh>;
           close $fh;

Any time you use or change the value of a global, you need to think if
it needs to be localized.

Ben



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

Date: Tue, 27 Nov 2007 20:57:27 -0800 (PST)
From: aniait <aithalanirudh@gmail.com>
Subject: out of memory
Message-Id: <04e40e32-58da-4a64-9a34-6d334135ca55@a39g2000pre.googlegroups.com>

Is there any way to solve the 'out of memory exception' of perl on
windows? I got this when i tried to dump a large hash into a file
using Dumper.


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

Date: Tue, 27 Nov 2007 18:11:28 -0700
From: "Wade Ward" <wade@zaxfuuq.net>
Subject: Re: page 124 of the camel book
Message-Id: <1196211821_7989@sp12lax.superfeed.net>


<jl_post@hotmail.com> wrote in message 
news:0adffdf2-93fb-4867-bca7-23d460e606c1@s19g2000prg.googlegroups.com...
> On Nov 27, 7:46 am, Lars Haugseth <n...@larshaugseth.com> wrote:
>>
>> I find it more readable to put the extra set of curly braces
>> inside the do-while:
>>
>>   do {{ # allow early exit using 'last'
>>       last if $x = $y ** 2;
>>       # do something here
>>   }} while $x++ <= $z;
>
>
>   That won't work, Lars.  With "last", the braces have to be outside
> the do{}while loop, or else the do{}while loop will keep iterating.
> Let me explain with an example:
>
>      my $x = 0;
>      do {{
>             last  if $x == 2;
>             print $x;
>         }} while $x++ < 5;
>
> This looks like we want to break out of the loop when $x equals 2, but
> in fact we just jump to the end of it, and let the while() condition
> "re-loops" us back to the top of the loop, setting $x to 3.  In this
> case, "last" can be replaced with "next" and nothing will change.
> Basically, the above code will print "01345".  ("345" is printed
> because the loop is never completely broken out of when $x == 2.)
>
>   If we want to completely break out of the loop when $x is 2, we
> would write something like this instead:
>
>      my $x = 0;
>      {
>         do {
>               last  if $x == 2;
>               print $x;
>            } while $x++ < 5;
>      }
>
> This code prints only "01", showing that the loop is fully exited when
> $x is 2.
>
>
>> Then again, I find it even more readable to avoid using do-while
>> altogether...
>
>
>   Yes, do{}while loops can be a bit confusing, but they're not that
> bad if you avoid using "next" and "last" (and "redo") in them.  But if
> you really want to use them inside a do{}while loop, you can; you just
> have to use one of the work-arounds mentioned on page 124 of the Camel
> book.
Thanks for the elaboration, Picard.

Control loops are strange things.  For better or worse, I'm gonna try to get 
back on the perl horse that has bucked me off fifty times already on this 
one simple prog.  I was astonished when I couldn't
break;
,  like you do in C.

That's when I started throwing the camel book around like an angry gorilla. 
Page 124 is on the largest-surviving chunk.

cheers,
-- 
wade ward

wade@zaxfuuq.net
435 -838-7760 



----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----


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

Date: Wed, 28 Nov 2007 01:43:40 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: page 124 of the camel book
Message-Id: <gJ33j.14791$Jy1.3782@trndny02>

Wade Ward wrote:
> already on this one simple prog.  I was astonished when I couldn't
> break;
> ,  like you do in C.

May I suggest you take an introductory class in structured programming? Then 
you don't need those remnants of goto.
Yes, there are rare circumstances where breaking out of a loop in its middle 
seems to be convenient. But is never a necessity and usually indicates the 
programmer is not all that familiar with modern program design.

> That's when I started throwing the camel book around like an angry
> gorilla. Page 124 is on the largest-surviving chunk.

Of course structured programming and good program design is independant of 
the programming language used.

jue 




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

Date: Wed, 28 Nov 2007 01:54:41 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: page 124 of the camel book
Message-Id: <BT33j.22064$rg1.5789@trndny04>

jl_post@hotmail.com wrote:
>   If we want to completely break out of the loop when $x is 2, we
> would write something like this instead:
>
>      my $x = 0;
>      {
>         do {
>               last  if $x == 2;
>               print $x;
>            } while $x++ < 5;
>      }
>
> This code prints only "01", showing that the loop is fully exited when
> $x is 2.

Now, why so confusing? Wouldn't

my $x = 0;
while ($x <=5 and $x !=2) {
    print $x;
    $x++; # doing a $x++ as a side effect
          # in the condition is poor style
}

work just as well with much less huff and puff?

jue 




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

Date: Wed, 28 Nov 2007 02:25:16 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: page 124 of the camel book
Message-Id: <x7sl2r14z7.fsf@mail.sysarch.com>

>>>>> "JE" == Jürgen Exner <jurgenex@hotmail.com> writes:


  JE> May I suggest you take an introductory class in structured
  JE> programming? Then you don't need those remnants of goto.

ditto.

  JE> Yes, there are rare circumstances where breaking out of a loop in
  JE> its middle seems to be convenient. But is never a necessity and
  JE> usually indicates the programmer is not all that familiar with
  JE> modern program design.

i have always taught others to use smaller subs with return instead of
needing goto to get out of a deep loop. it usually is much cleaner. but
some coders stick to the 'exit only at the end of a sub' rule that was
pushed when structured programming was hot. i think that rule should be
ignored as early return is as useful as next/last inside a loop.

and i can't recall the last time i used a label or goto in perl (if
ever). i do use magic goto rarely but that is really a different beast.

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: Tue, 27 Nov 2007 19:23:46 -0500
From: "Thrill5" <nospam@somewhere.com>
Subject: Re: Path to Perl
Message-Id: <eqGdnTm8XuWOKNHanZ2dnUVZ_oKhnZ2d@comcast.com>


"chuck" <chuck@no.where> wrote in message 
news:fiha0p$ddc$1@nrc-news.nrc.ca...
> Hi,
>
> New to Linux and Apache and Perl so I appreciate any help i can get.
>
> I have a user who needs to move his perl scripts from his Windows 
> development machine to our Linux web server.  How can I easily change the 
> path to all the perl scripts that will get transfered over ?  Or is there 
> another alternative such as adding an environment variable for the 
> "apache" user ?
>
> Thanks
>
My question would be why is he using a shebang for the perl path on a 
windows machine in the first place? 




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

Date: Tue, 27 Nov 2007 20:49:38 -0800 (PST)
From: Ron Bergin <rkb@i.frys.com>
Subject: Re: Path to Perl
Message-Id: <c8573d9a-ba71-4fe0-9589-0a80bedf2099@s36g2000prg.googlegroups.com>

On Nov 27, 9:01 am, Gunnar Hjalmarsson <nore...@gunnar.cc> wrote:
> Sherman Pendley wrote:
> > "chuck" <ch...@no.where> writes:
>
> >> from his Windows development machine to our Linux web server.
>
> Sounds like CGI scripts to me ...
>
> > Just use "#!/usr/bin/perl" - Windows uses its file-type associations to find
> > the Perl binary anyway, so it won't care.
>
> ... and if so, that's not true. CGI scripts need the correct path to
> perl also on Windows.
>
> --

Sorry Gunnar, but that's not true.  Apache can be configured to use
the Windows registry to locate perl instead of using the shebang
line.  Here's the required config line.

ScriptInterpreterSource registry

http://httpd.apache.org/docs/1.3/mod/core.html#scriptinterpretersource


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

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 1073
***************************************


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