[30921] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2166 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jan 28 00:09:49 2009

Date: Tue, 27 Jan 2009 21:09:13 -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 Jan 2009     Volume: 11 Number: 2166

Today's topics:
    Re: Help: Odd Output <rvtol+usenet@xs4all.nl>
    Re: Help: Odd Output <tadmc@seesig.invalid>
    Re: How to remove a module from CPAN? <brian.d.foy@gmail.com>
        How trigger a smart link? <cosmo_general@yahoo.com>
    Re: How trigger a smart link? <tim@burlyhost.com>
    Re: inputting the ephemerides <rvtol+usenet@xs4all.nl>
    Re: inputting the ephemerides <larry@example.invalid>
    Re: inputting the ephemerides <larry@example.invalid>
    Re: inputting the ephemerides <jimsgibson@gmail.com>
    Re: Is syswrite faster or print <smallpond@juno.com>
    Re: Is syswrite faster or print <saurabh.hirani@gmail.com>
    Re: Perl Peeves <whynot@pozharski.name>
    Re: Perl Peeves <jjcassidy@gmail.com>
    Re: Perl Peeves (Tim McDaniel)
    Re: Perl Peeves (Tim McDaniel)
    Re: Perl Peeves <uri@stemsystems.com>
    Re: There is no such thing as Circular Lists (was: FAQ  <brian.d.foy@gmail.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Tue, 27 Jan 2009 20:35:23 +0100
From: "Dr.Ruud" <rvtol+usenet@xs4all.nl>
Subject: Re: Help: Odd Output
Message-Id: <497f61fb$0$184$e4fe514c@news.xs4all.nl>

Amy Lee wrote:

> #!/usr/bin/perl -w
> 
> use warnings;
> use strict;

The combination "-w" and "use warnings;" is odd.



> my $location = $ARGV[0];
> open my $LOCATION, '<', "$location";

   open my $LOCATION, '<', $location or die $!;



> my @stack;
> while (<$LOCATION>)
> {
>   chomp;
>   my $raw_seq_id = (split /\s+/)[0];

Replace /\s+/ by " ". Then remove it, because it is the default.


>   my $mature_start = (split /\s+/)[1];
>   my $mature_end = (split /\s+/)[2];

Alternative:

     my ($raw_seq_id, $mature_start, $mature_end) = split;



>   my $mature_id = (split /_/, $raw_seq_id)[3];
>   my $i;
>   my $num = 0;
>   open my $CT, '<', "$raw_seq_id"."\.ct";

     open my $CT, '<', "$raw_seq_id.ct" or die $!;

-- 
Ruud


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

Date: Tue, 27 Jan 2009 14:47:08 -0600
From: Tad J McClellan <tadmc@seesig.invalid>
Subject: Re: Help: Odd Output
Message-Id: <slrngnusmc.9f8.tadmc@tadmc30.sbcglobal.net>

Dr.Ruud <rvtol+usenet@xs4all.nl> wrote:
> Amy Lee wrote:


>> my $location = $ARGV[0];
>> open my $LOCATION, '<', "$location";
>
>    open my $LOCATION, '<', $location or die $!;


Amy,


When good programming practices are shown to you here, please adopt
those practices in all future posts.

Otherwise, folks will stop helping you, or get tired of repeating
the good practice over and over.

It was pointed out to you that you should check the return value
from open() back in August 2007.

Please adopt a coding style that includes always checking the
return value from open().


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


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

Date: Tue, 27 Jan 2009 14:49:01 -0600
From: brian d  foy <brian.d.foy@gmail.com>
To: Steve Roscio <Steve.Roscio@hp.com>
Subject: Re: How to remove a module from CPAN?
Message-Id: <270120091449018446%brian.d.foy@gmail.com>

[[ This message was both posted and mailed: see
   the "To," "Cc," and "Newsgroups" headers for details. ]]

In article <gll9gt$jp$1@usenet01.boi.hp.com>, Steve Roscio
<Steve.Roscio@hp.com> wrote:


> My question: How can I remove one of my modules from CPAN?  I don't mean
> a module I installed using CPAN, but from CPAN.org itself.   Do I delete
> it from PAUSE?  Nothing there indicates that it'll go away from CPAN if
> I do that.

First, you can delete the files in the PAUSE interface:

   https://pause.perl.org/pause/authenquery?ACTION=delete_files

There is a couple days delay in the deleteion to give you a chance to
change your mind. The next time the master CPAN server syncs from PAUSE
after the deletion, your files should start disappearing from the
servers that sync from the master, and so on down the chain. This could
take a several days for everything to catch up.

Next, if you completely want the module and its to disappear, you can
tell PAUSE to forget about the module. Go to the "Edit Module Metadata"
itam, choose the module you want to affect, then at the bottom of the
metadata page there is a setting called "Lifecycle". Choose "Can be
deleted from database"

https://pause.perl.org/pause/authenquery?ACTION=edit_mod

This doesn't remove the files from BackPAN, which is the historical
archive of CPAN. If you have to do that for some reason, such as
someone taking legal action against you, send me a personal email and I
can get you started on that. I don't control that stuff, but I know the
people who do. 

In general, you can also write to modules AT perl DOT org to get the
attention of the PAUSE admins (I'm one of them) for help dealing with
module administration issues.

Good luck,


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

Date: Tue, 27 Jan 2009 18:05:34 -0800 (PST)
From: Muddy Coder <cosmo_general@yahoo.com>
Subject: How trigger a smart link?
Message-Id: <42e30618-c9cb-4301-b091-e8089700e0e6@f11g2000vbf.googlegroups.com>

Hi All,

A smart link, such as:

form action="http://login.adomain.com/cgi-bin/login.cgi?
fp=DFtkog3JAt1oEGIvh5" method="post"

with escape characters fp=DFtkog3JAt1oEGIvh5 attached, to provide
state identifiers of CGI script. If I fill the form and click the
Submit button, the form will be uploaded. However, I want to submit
the form by manually input the web address. I know that there are two
fields in the login page, username and password. So, if there are
escape characters fp=DFtkog3JAt1oEGIvh5, I can do the loggin by typing
in the address entry as:

http://login.adomain.com/cgi-bin/login.cgi?username=myID&password=secret

Here, the myID and secret are my real userID and password. Then, I can
loggin my account without filling the HTML form and click the Submit
button.

But, with the escape characters fp=DFtkog3JAt1oEGIvh5 around, I
failed. I got an error message as:

cgi-bin/login.cgi was not found. I know the CGI script login.cgi was
there.

Somebody can help? I tried to find a book to read, but didn't get one.
How can I trigger the CGI script without being bothered by the ugly
escape characters?

Thanks!




Muddy Coder



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

Date: Tue, 27 Jan 2009 18:19:14 -0800
From: Tim Greer <tim@burlyhost.com>
Subject: Re: How trigger a smart link?
Message-Id: <_iPfl.28708$2o3.14096@newsfe10.iad>

Muddy Coder wrote:

> Hi All,
> 
> A smart link, such as:
> 
> form action="http://login.adomain.com/cgi-bin/login.cgi?
> fp=DFtkog3JAt1oEGIvh5" method="post"
> 
> with escape characters fp=DFtkog3JAt1oEGIvh5 attached, to provide
> state identifiers of CGI script. If I fill the form and click the
> Submit button, the form will be uploaded. However, I want to submit
> the form by manually input the web address. I know that there are two
> fields in the login page, username and password. So, if there are
> escape characters fp=DFtkog3JAt1oEGIvh5, I can do the loggin by typing
> in the address entry as:
> 
>
http://login.adomain.com/cgi-bin/login.cgi?username=myID&password=secret
> 
> Here, the myID and secret are my real userID and password. Then, I can
> loggin my account without filling the HTML form and click the Submit
> button.
> 
> But, with the escape characters fp=DFtkog3JAt1oEGIvh5 around, I
> failed. I got an error message as:
> 
> cgi-bin/login.cgi was not found. I know the CGI script login.cgi was
> there.
> 
> Somebody can help? I tried to find a book to read, but didn't get one.
> How can I trigger the CGI script without being bothered by the ugly
> escape characters?
> 
> Thanks!
> 
> 
> 
> 
> Muddy Coder

Why not just use: 

http://login.example.com/cgi-bin/login.cgi?username=myID&password=secret&fp=DFtkog3JAt1oEGIvh5

Of course, I can't tell exactly what your issue is to say that's the
solution.  How exactly were you trying the p=DFtkog3JAt1oEGIvh5 in the
URL where it resulted in a 404 (file/page not found) error?
-- 
Tim Greer, CEO/Founder/CTO, BurlyHost.com, Inc.
Shared Hosting, Reseller Hosting, Dedicated & Semi-Dedicated servers
and Custom Hosting.  24/7 support, 30 day guarantee, secure servers.
Industry's most experienced staff! -- Web Hosting With Muscle!


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

Date: Tue, 27 Jan 2009 20:23:13 +0100
From: "Dr.Ruud" <rvtol+usenet@xs4all.nl>
Subject: Re: inputting the ephemerides
Message-Id: <497f5f21$0$199$e4fe514c@news.xs4all.nl>

Jim Gibson wrote:

>   my @s = split /\s+/, $line;

When people write

     split /\s+/

they are almost most often looking for

     split " "

-- 
Ruud


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

Date: Tue, 27 Jan 2009 13:23:39 -0700
From: Larry Gates <larry@example.invalid>
Subject: Re: inputting the ephemerides
Message-Id: <4if01unz5naa$.1279dvz6a5sxj.dlg@40tude.net>

On Tue, 27 Jan 2009 12:01:45 +0000, RedGrittyBrick wrote:

> Larry Gates wrote:
> 
>> These are not the habits of a dullard.
> 
> I agree.
> 
> Have you read "The camel has two humps"?
> http://www.cs.mdx.ac.uk/research/PhDArea/saeed/paper1.pdf *
> 
> Some people fall into the "inconsistent" group - looking for meaning 
> where it does not exist. These people will probably not succeed as 
> programmers despite their intelligence and capacity for success in other 
> fields.
> 
> Just my ¤0.02 worth.

It makes for an interesting skim.  I thought it was going to tie into perl
with the camel reference, but it instead points to bi-modal achievement.

I popped in on my uncle a few years back, who is director of mathematical
comp sci at SLU.  He was finishing up a course in logic design and saw
exactly the same curve.  The one hump got A's and B's, the other, CDF.

I got an A in fortran at BYU, something that Uri Guttman won't believe.
-- 
larry gates

That being said, I think we should immediately deprecate any string
concatenation that combines "19" with "99".   :-)
             -- Larry Wall in <199811242002.MAA26850@wall.org>


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

Date: Tue, 27 Jan 2009 14:30:12 -0700
From: Larry Gates <larry@example.invalid>
Subject: Re: inputting the ephemerides
Message-Id: <12dg1hj34pets$.p21zbcmg2lw8$.dlg@40tude.net>

On Mon, 26 Jan 2009 17:37:55 -0800, Jim Gibson wrote:

> Hope this helps.

Constructive comments do.  Adding in the NOOP lines gives me the output I'm
looking for:

use strict;
use warnings;
 
# open input file
my $filename = 'eph9.txt';
open(my $fh, '<', $filename) or 
  die "cannot open $filename for reading: $!";

# open output file
my $filename2 = 'outfile11.txt';
open(my $gh, '>', $filename2) or 
  die "cannot open $filename2 for writing: $!";

# process all lines in input file
while( my $line = <$fh> ) {
  chomp($line);

  # get rid of °, + and ER
  $line =~ s/ER//g;
  $line =~ s/°//g;
  $line =~ s/\+//g;
  my @s = split /\s+/, $line;

  # modify fields
  $s[1] =~ s/h//;
  $s[2] =~ s/m//;
  $s[3] =~ s/s//;
  $s[5] =~ s/'//;

  # print modified fields
  for my $i (0..$#s) {
    print "s[$i] = $s[$i]\n";
  }

  # write modified fields to output file
  my $outline = join(' ', @s);
  print $gh "$outline\n";
}

# close input and output files
close($gh) or die("Error closing $filename2: $!");
close($fh) or die("Error closing $filename: $!");

__END__
   
# perl reg15.pl

C:\MinGW\source>type outfile11.txt
Sun 20 41 55 -18 15.1 0.985 31.290 28.986 Up
Mercury 19 37 21 -18 9.2 0.703 23.506 43.890 Up
Venus 23 38 15 -1 11.5 0.589 49.918 -29.062 Up
Moon 21 48 14 -11 42.6 62.2 42.389 12.334 Up
Mars 19 44 11 -22 12.5 2.363 21.142 39.928 Up
Jupiter 20 30 48 -19 23.6 6.088 29.121 31.156 Up
Saturn 11 30 46 5 30.8 8.631 -46.580 155.929 Set
Uranus 23 25 19 -4 32.5 20.818 47.940 -22.647 Up
Neptune 21 43 12 -14 4.3 30.982 39.839 13.351 Up
Pluto 18 8 33 -17 44.6 32.377 9.447 60.368 Up

C:\MinGW\source>

I'm gonna continue this on the fortran side.  This was the hardest regex
I've done by the longest of shots, and I couldn't have done it without your
(plural) help.

Above is the current ephemeris for Albuquerque.  The sun is almost on top
of Jupiter, rendering him invisible.  Well ahead of it on the ecliptic is
Pluto.  Closer in to the the sun are Mercury and Mars together.  They must
be visible as morning stars.  Neptune is almost in the same place as the
new Moon, both invisible.  Saturn is invisible above China.  Uranus is near
Venus, which is the only planet that offers convenient viewing.  She has
started her pro-grade motion, which is in the direction of the greater
planets.

Cheers,
-- 
larry gates

It is, of course, written in Perl.  Translation to C is left as an
exercise for the reader.  :-)  -- Larry Wall in
<7448@jpl-devvax.JPL.NASA.GOV>


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

Date: Tue, 27 Jan 2009 17:07:03 -0800
From: Jim Gibson <jimsgibson@gmail.com>
Subject: Re: inputting the ephemerides
Message-Id: <270120091707035534%jimsgibson@gmail.com>

In article <12dg1hj34pets$.p21zbcmg2lw8$.dlg@40tude.net>, Larry Gates
<larry@example.invalid> wrote:

> On Mon, 26 Jan 2009 17:37:55 -0800, Jim Gibson wrote:
> 
> > Hope this helps.
> 
> Constructive comments do.  Adding in the NOOP lines gives me the output I'm
> looking for:

It was not the lines themselves that are "NOOP", as you have shown
yourself. It was the fact that you were applying them to a scalar
variable that was then ignored and over-written with the next input
line that made your lines "no-operations".

> 
> use strict;
> use warnings;
>  
> # open input file
> my $filename = 'eph9.txt';
> open(my $fh, '<', $filename) or 
>   die "cannot open $filename for reading: $!";
> 
> # open output file
> my $filename2 = 'outfile11.txt';
> open(my $gh, '>', $filename2) or 
>   die "cannot open $filename2 for writing: $!";
> 
> # process all lines in input file
> while( my $line = <$fh> ) {
>   chomp($line);
> 
>   # get rid of °, + and ER
>   $line =~ s/ER//g;
>   $line =~ s/°//g;
>   $line =~ s/\+//g;
>   my @s = split /\s+/, $line;
> 
>   # modify fields
>   $s[1] =~ s/h//;
>   $s[2] =~ s/m//;
>   $s[3] =~ s/s//;
>   $s[5] =~ s/'//;
> 
>   # print modified fields
>   for my $i (0..$#s) {
>     print "s[$i] = $s[$i]\n";
>   }
> 
>   # write modified fields to output file
>   my $outline = join(' ', @s);
>   print $gh "$outline\n";
> }
> 
> # close input and output files
> close($gh) or die("Error closing $filename2: $!");
> close($fh) or die("Error closing $filename: $!");
> 
> __END__
>    
> # perl reg15.pl
> 
> C:\MinGW\source>type outfile11.txt
> Sun 20 41 55 -18 15.1 0.985 31.290 28.986 Up
> Mercury 19 37 21 -18 9.2 0.703 23.506 43.890 Up
> Venus 23 38 15 -1 11.5 0.589 49.918 -29.062 Up
> Moon 21 48 14 -11 42.6 62.2 42.389 12.334 Up
> Mars 19 44 11 -22 12.5 2.363 21.142 39.928 Up
> Jupiter 20 30 48 -19 23.6 6.088 29.121 31.156 Up
> Saturn 11 30 46 5 30.8 8.631 -46.580 155.929 Set
> Uranus 23 25 19 -4 32.5 20.818 47.940 -22.647 Up
> Neptune 21 43 12 -14 4.3 30.982 39.839 13.351 Up
> Pluto 18 8 33 -17 44.6 32.377 9.447 60.368 Up
> 
> C:\MinGW\source>
> 
> I'm gonna continue this on the fortran side.  This was the hardest regex
> I've done by the longest of shots, and I couldn't have done it without your
> (plural) help.

Well in fact you didn't do it at all. I and several other people had to
write the code for you. Perl is much better suited for this type of
task than Fortran (I have coded in both). Sticking with Perl and
learning enough Perl to do this job would make you a better programmer.
However, they may not be your goal.

There is nothing difficult about this program. There are certainly no
hard regular expressions. There is a sequence of substitution
operators, each performing a simple task of removing something from
your input. I think you had problems with the concepts of reading and
writing files. Reading from one file and writing to another file is the
simplest way to deal with the problem of modifying a file.

Good luck with the Fortran.

-- 
Jim Gibson


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

Date: Tue, 27 Jan 2009 14:33:55 -0800 (PST)
From: smallpond <smallpond@juno.com>
Subject: Re: Is syswrite faster or print
Message-Id: <14c96167-60b4-4caf-a216-5b3253112b41@y1g2000pra.googlegroups.com>

On Jan 27, 8:05=A0am, saurabh hirani <saurabh.hir...@gmail.com> wrote:
> Hi guys,
>
> I am working on a logging module. I was just studying the existing
> perl log modules and read that - syswrite is useful in a condition
> like logging as during its write operation it prevents someone else
> from writing at the same time. To verify that I wrote a small perl
> program:
>
> #!/usr/bin/perl -w
> use strict;
> use Fcntl;
> use Data::Dumper;
> $| =3D 1;
>
> sub testme {
> =A0 =A0 my ($flag, $data) =3D @_;
> =A0 =A0 if ($flag =3D=3D 1) {
> =A0 =A0 =A0 =A0 sysopen(FILE, 'bangbang', =A0O_WRONLY | O_APPEND | O_CREA=
T);
> =A0 =A0 =A0 =A0 while (1) {
> =A0 =A0 =A0 =A0 =A0 =A0 syswrite FILE, "$data\n";
> =A0 =A0 =A0 =A0 }
> =A0 =A0 } else {
> =A0 =A0 =A0 =A0 open(FILE, ">>bangbang");
> =A0 =A0 =A0 =A0 while (1) {
> =A0 =A0 =A0 =A0 =A0 =A0 print FILE "$data\n";
> =A0 =A0 =A0 =A0 }
> =A0 =A0 }
> =A0 =A0 close(FILE);}
>
> testme($ARGV[0], $ARGV[1]);
>
> Testing both for syswrite and print - I found that $data printing in
> file is corrupted when I run 2 instances of the same program together.
> But using syswrite saves me from that. It has every line intact and no
> line is a mix of different data sets of the 2 programs.
>
> But what struck me more was the size of the files created when I ran
> the following programs together:
>
> 1. ./program 1 first
> 2. ./program 1 second
>
> this uses syswrite to write and check whether 'first' and 'second'
> clobber each other. During this run, I got the following stats:
>
> 1st run - 30 seconds - file size 40 MB
> 2nd run - 50 seconds - file size 61 MB
>
> Now for the print run,
>
> 1. ./program 2 first
> 2. ./program 2 second
>
> this uses print to write and check whether 'first' and 'second'
> clobber each other. During this run, I got the following stats:
>
> 1st run - 30 seconds - file size 315 MB
> 2nd run - 50 seconds - file size 586 MB
>
> I was running a VM so I know that my profiling wouldn't be so
> accurate. But still, I had done autoflush for both syswrite and print.
> And I read somewhere that for output greater than 3 KB syswrite is
> faster?
>
> Is print this faster than syswrite? Is my testing flawed? Am I missing
> something? What would you use if you had to write a logging module in
> perl - print or syswrite? and why?
>
> Thanks for going through it.


print does buffered output while syswrite is direct.  That
is the reason for both the performance difference and the
non-overlapping behavior.

Why do you care about performance for log messages?


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

Date: Tue, 27 Jan 2009 20:42:52 -0800 (PST)
From: saurabh hirani <saurabh.hirani@gmail.com>
Subject: Re: Is syswrite faster or print
Message-Id: <31830bc3-2df4-4b1e-96ff-2113f58f1758@u18g2000pro.googlegroups.com>


> print does buffered output while syswrite is direct. =A0That
> is the reason for both the performance difference and the
> non-overlapping behavior.

Does print do buffered output even after autoflush is on? I have added
$| =3D 1 in the beginning of my code.

>
> Why do you care about performance for log messages?

Why shouldn't I? The faster my log method is, the earlier I return and
get control back to my main programs.



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

Date: Wed, 28 Jan 2009 00:43:07 +0200
From: Eric Pozharski <whynot@pozharski.name>
Subject: Re: Perl Peeves
Message-Id: <slrngnv3fr.pbd.whynot@orphan.zombinet>

On 2009-01-27, Tim McDaniel <tmcd@panix.com> wrote:
> In article <x7fxj5kufk.fsf@mail.sysarch.com>,
> Uri Guttman  <uri@stemsystems.com> wrote:
>>>>>>> "JE" == Jürgen Exner <jurgenex@hotmail.com> writes:
>>
>>  JE> tmcd@panix.com (Tim McDaniel) wrote:
>>  >> Just venting.
>>  >> 
>>  >> (1) I hate that
>>  >> 
>>  >> Unary "+" has no effect whatsoever, even on strings.
>>
>>  JE> Agree, that is not very user friendly.
>>
>>unless you use it as intended which is to disambiguate parsing issues
>>like print (3 + 4) * 5 vs print +(3 + 4) * 5.
>
> While this particular case could be handled via print((3 + 4) * 5),
> are there cases that an extra set of parens can't handle?
> Maybe cases with a leading "{"?

Consider giving up idea that C<+> is "unary plus".  It's not.  It's a
special that hints B<perl> that's an expression that comes next.
C<perldoc -f map> has more.

-- 
Torvalds' goal for Linux is very simple: World Domination
Stallman's goal for GNU is even simpler: Freedom


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

Date: Tue, 27 Jan 2009 18:33:24 -0800 (PST)
From: A Dude <jjcassidy@gmail.com>
Subject: Re: Perl Peeves
Message-Id: <c47f7471-65fd-41cf-bb2d-fa8265369239@k36g2000pri.googlegroups.com>

On Jan 27, 12:46=A0am, t...@panix.com (Tim McDaniel) wrote:
> In article <7crsn4hardgt8fvgn3p0uopfv1mtgdf...@4ax.com>,
> J=FCrgen Exner =A0<jurge...@hotmail.com> wrote:
>
> >> [Perl] doesn't define "true". =A0
>
> >Why should it? There is no point in repeating the definition of true
> >for every single operator or function that returns a boolean value.
>
> If I want to write it to a properties file to be read in again later,
> or to output it for debugging.
> =A0 =A0 my $output_value =3D (CONDITION) ? 1 : 0;
> just feels amateurish and too verbose to me.

Then write (the perlish way)

    my $output_value =3D CONDITION || '0';

or

    printf "SHOULD_I_OUTPUT=3D%s\n", ( CONDITION || '0' );

> [...] Perl 5 doesn't have a
> boolean type, but uses strings and integers. =A0So they can't go
> preaching type purity to me. =A0

Like most things in Perl, it's an implicit thing. Most of the time
you'll be dealing with

    if ( $my_value < 17 ) { ...

or
    do_something_else() unless $command eq 'proceed';


But if you have to capture a condition, name your boolean variables
obvious names like

    $name_is_ambiguous

You were talking about one specific case, which can be addressed. As
for output

    $my_boolean=3D

is illustrative to me. (Unless it might be a ' ')

But if you use Data::Dumper or Smart::Comments, it won't be an issue.

I'm with Jurgen. It doesn't need it. And along with that, if you're
going to use it in computations:

    my $sign =3D -1 ** ( $my_var < 10 ? 1 : 0 );

doesn't look as much like c-hack, and explicitly transforms the
boolean condition to the value you think you're getting in the first
place.


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

Date: Tue, 27 Jan 2009 21:47:07 -0600
From: tmcd@panix.com (Tim McDaniel)
Subject: Re: Perl Peeves
Message-Id: <r21556-n1g.ln1@tmcd.austin.tx.us>

In article <c47f7471-65fd-41cf-bb2d-fa8265369239@k36g2000pri.googlegroups.com>,
A Dude  <jjcassidy@gmail.com> wrote:
>On Jan 27, 12:46 am, t...@panix.com (Tim McDaniel) wrote:
>> In article <7crsn4hardgt8fvgn3p0uopfv1mtgdf...@4ax.com>,
>> Jürgen Exner  <jurge...@hotmail.com> wrote:
>>
>> >> [Perl] doesn't define "true".

That's an incorrect summary.  "man perlsyn" defines it.  "man perlop"
is where I expected it, with the conditional operators that return
true or false.  "man perlop" doesn't define it, and doesn't point at
"man perlsyn" or anywhere else to define it.

>> If I want to write it to a properties file to be read in again
>> later, or to output it for debugging.
>>     my $output_value = (CONDITION) ? 1 : 0;
>> just feels amateurish and too verbose to me.
>
>Then write (the perlish way)
>
>    my $output_value = CONDITION || '0';

That depends on knowing that a conditional operator that evaluates to
true is 1, and I had some little trouble finding that definition.

>As for output
>
>    $my_boolean=
>
>is illustrative to me. (Unless it might be a ' ')

Or "\t" or whatever.  (Looking at that, I wouldn't be sure that I
didn't forget to actually print $my_boolean.)  (And, of course, if
it's read in again, it's not the special false value unless I !! it or
something.)

>But if you use Data::Dumper or Smart::Comments, it won't be an
>issue.

As it happens, at the moment I'm writing scalars to properties files,
but I'll keep that in mind if I'm dumping general data structures.

-- 
Tim McDaniel; Reply-To: tmcd@panix.com


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

Date: Tue, 27 Jan 2009 21:52:26 -0600
From: tmcd@panix.com (Tim McDaniel)
Subject: Re: Perl Peeves
Message-Id: <qc1556-n1g.ln1@tmcd.austin.tx.us>

In article <slrngnv3fr.pbd.whynot@orphan.zombinet>,
Eric Pozharski  <whynot@pozharski.name> wrote:
>Consider giving up idea that C<+> is "unary plus".  It's not.  It's a
>special that hints B<perl> that's an expression that comes next.
>C<perldoc -f map> has more.

That calls it 'a unary "+"'.

Thank you for the pointer.  Looking at the examples, I don't see how
Perl decides BLOCK versus EXPR based on changes inside {...}, but
- it gives me a notion of when unary + is useful
- it gives me something to twiddle if Perl misparses a map or grep
  that I try to run

-- 
Tim McDaniel; Reply-To: tmcd@panix.com


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

Date: Tue, 27 Jan 2009 23:47:57 -0500
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Perl Peeves
Message-Id: <x7pri8dojm.fsf@mail.sysarch.com>

>>>>> "AD" == A Dude <jjcassidy@gmail.com> writes:

  AD> Then write (the perlish way)

  AD>     my $output_value = CONDITION || '0';

that is a poor choice of a false value. sure it works but 0 (no quotes)
or '' would be better. they are more common (perl uses them itself) and
should be trivially faster as '0' would require more work to test for
falsehood.

  AD> You were talking about one specific case, which can be addressed. As
  AD> for output

  AD>     $my_boolean=

  AD> is illustrative to me. (Unless it might be a ' ')

' ' is a true value. it would be foolish to ever use it as just a
boolean if you want to print it.

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: Tue, 27 Jan 2009 14:57:58 -0600
From: brian d  foy <brian.d.foy@gmail.com>
Subject: Re: There is no such thing as Circular Lists (was: FAQ 4.47 How do I handle circular lists?)
Message-Id: <270120091457580660%brian.d.foy@gmail.com>

In article <hj6sn49nm0eugiu202hpa0n3n2f6pga87j@4ax.com>,
<sln@netherlands.com> wrote:

> On Mon, 26 Jan 2009 12:03:01 -0800, PerlFAQ Server <brian@stonehenge.com>
> wrote:
> 
> [snip FAQ pre-self cudos]
> >
> >4.47: How do I handle circular lists?
> >
> >   
> > 
> >    (contributed by brian d foy)

> At least get your head out of your ass FAQ workers.

You've said "workers" before like there is some cabal. As noted in the
answer, I'm the only one potentially with my head up my ass. Insult the
right person at least.

You might also look into the givernment conspiracy that created this
thing that does not exist:

http://www.nist.gov/dads/HTML/circularlist.html


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

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


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