[23302] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5522 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Sep 18 09:05:45 2003

Date: Thu, 18 Sep 2003 06:05:08 -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           Thu, 18 Sep 2003     Volume: 10 Number: 5522

Today's topics:
    Re: @_ in subroutine corrupts data? (Tad McClellan)
    Re: copy list until... (Helgi Briem)
    Re: copy list until... (Anno Siegel)
    Re: current path <spikey-wan@bigfoot.com>
    Re: DBI.pm fetchrow() issue <REMOVEsdnCAPS@comcast.net>
    Re: I know I can do this with a regex, but... (Philip Lees)
    Re: kill command in a perl script <bart.lateur@pandora.be>
    Re: list-parsing problem <abigail@abigail.nl>
    Re: Newbie Question: Could someone show me how to imple <bart.lateur@pandora.be>
        Opening file units recursively (John Ramsden)
    Re: Opening file units recursively (Anno Siegel)
    Re: package problem? [was Re: @_ in subroutine corrupts (Tad McClellan)
    Re: Pattern Matching in file with invisible char <bart.lateur@pandora.be>
        perl sub and perl modules (fabre)
    Re: perl sub and perl modules (Anno Siegel)
    Re: Quoting "$vars" and open() (Anno Siegel)
    Re: string to integer <Mark.Fenbers@noaa.gov>
    Re: string to integer (Helgi Briem)
    Re: wtf is the deal? (Tad McClellan)
    Re: wtf is the deal? (Tad McClellan)
    Re:  <bwalton@rochester.rr.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Thu, 18 Sep 2003 07:20:05 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: @_ in subroutine corrupts data?
Message-Id: <slrnbmj8nl.a5h.tadmc@magna.augustmail.com>

synthespian <synthespian@uol.com.br> wrote:
> Sam Holden wrote:
>> On Wed, 17 Sep 2003 23:28:39 -0300, synthespian <synthespian@uol.com.br> wrote:
>> 

>>>   I can find no reasonable explanation for this behavior. 


See the "Foreach Loops" section in perlsyn.pod.


>>>@array = subthis(1, 2, 3, 4);
>>>
>>>sub subthis {
>>>
>>>	@array = @_;
>>>	foreach (@array) {
>> 
>> 
>> That will set $_ to 1, then 2, then 3, then 4.
>> 
>> 
>>>		print "$array[$_]\n";
>> 
>> 
>> Since arrays start at element 0 (well, in sane code anyway) that will
>> print the second element when $_ is 1, the third when $_ is 2, the
>> fourth when $_ is 3, and the fifth when $_ is 4.
>> 
> 
>   Yes, it's obvious!


>   So this is about context, is it? 


If you mean list context vs. scalar context, then no, this
is not about context.

This is about how foreach loops work in Perl.


> $_ will be the placeholder for an 
> array indexed when $array[$_], otherwise it is not 0-indexed, that is, 


You can manipulate lists using foreach without any explicit 
indexing at all.


> is $_ in the case of print "$_\n" evaluating to the number of elements? 
> Or is it a placeholder for the /elements/ themselves?


The correct term is "alias" rather than "placeholder".


>   What's up with this (perceived) inconsistency?


It sounds like you haven't read up on the operation of foreach.


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Thu, 18 Sep 2003 10:52:34 GMT
From: f_baggins80@hotmail.com (Helgi Briem)
Subject: Re: copy list until...
Message-Id: <3f698e69.240518066@News.CIS.DFN.DE>

On Wed, 17 Sep 2003 16:54:27 -0400, Chris Mattern <syscjm@gwu.edu>
wrote:

>Brian Helterline wrote:
>> 
>> Last I checked, there is a 'Bush' on both sides on 'Clinton'
>> 
>Isn't there always?

He he.
--
Helgi Briem  hbriem AT simnet DOT is

Excuse the munged address.  My last
e-mail address was killed by spammers.


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

Date: 18 Sep 2003 11:01:41 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: copy list until...
Message-Id: <bkc3al$qah$4@mamenchi.zrz.TU-Berlin.DE>

Uri Guttman  <uri@stemsystems.com> wrote in comp.lang.perl.misc:
> >>>>> "J'P" == Jeff 'japhy' Pinyan <pinyaj@rpi.edu> writes:
> 
>   >>> @oldpresidents = grep { "true" .. $_ eq "Bush" } @presidents
>   >> 
>   >> I was trying to understand how this worked but it seems it does not :-)
> 
>   J'P> Wow, I did so many wrong things.  I thought the operand had to be numeric
>   J'P> for Perl to implicitly compare it to $., and I expected scalar context IN
>   J'P> the grep (shouldn't it be?), and I thought the flip-flop operator would
>   J'P> work in this case.  It doesn't seem to work easily.
> 
> grep EXPR is done in scalar context but the block provides list context
> it seems. i don't think that is comparing anything to $. the problem is
> .. in list context is trying to make a range of vals from 'true' to
> undef or whatever eq returns as false. so list .. barfs since one of the args
> is a string and the other is a number.
> 
> and with a little fooling around i can't seem to get the .. to work
> either. i think it seems to be freshly evaluated when entering the block
> so it gets reset. not sure. but i have used scalar .. many times in
> plain conditionals.

".." does an implicit compare with $. when it sees a literal.  (It
would be nicer if it only did that for numeric literals.)  The solution
is to use a non-literal expression.  "do { 1}" and "do { 0}" work
nicely for true and false.  So:

    my @oldpresidents = grep { do { 1} .. $_ eq 'Bush' } @presidents;

Anno



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

Date: Thu, 18 Sep 2003 10:52:19 +0100
From: "Richard S Beckett" <spikey-wan@bigfoot.com>
Subject: Re: current path
Message-Id: <bkbvb6$io2$1@newshost.mot.com>

> how can I find the current path my Perlscript is started ?


use Cwd;
my $pwd = cwd; $pwd =~ s!/!\\!g;
print "Current path is $pwd\n";

-- 
R.
GPLRank +79.699




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

Date: Thu, 18 Sep 2003 07:44:44 -0500
From: "Eric J. Roode" <REMOVEsdnCAPS@comcast.net>
Subject: Re: DBI.pm fetchrow() issue
Message-Id: <Xns93FA58EFEF29Esdn.comcast@206.127.4.25>

-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1

"superfly2" <darius_fatakia@yahoo.com> wrote in
news:bkatrs$215$1@news.Stanford.EDU: 

> Hi, the while loop I use to print each result of my SQL query seems to
> stop when it encounters the FIRST NULL value (although there are other
> non-NULL values still left to be printed. How can I avoid this so that
> I print all the non-NULL values? Thanks.
> 
> My code is as follows:
> 
>   my $sthv=$dbh->prepare($queryv);
>   $sthv->execute();
> 
>   Now, for every output value
>   while(my $val = $sthv->fetchrow())
>   {
>         print OUTPUT "$val\n";
>   }
> 
> It prints:
> 
>| Klk7             |
>| D10Ucla1         |
>| Whsc2h           |
>| Oaz2             |
> 
> Instead of (from a query done directly in SQL):
>| Klk7             |
>| D10Ucla1         |
>| Whsc2h           |
>| Oaz2             |
>| NULL             |
>| Slc25a2          |
>| Slc25a15         |
 ...

First of all, please copy/paste your real code, instead of re-typing it.  
DBI does not have a fetchrow() method for statement handles, afaik.  
Also, your print statement doesn't have any "|" symbols in it, so that's 
not the output from that code fragment.  Who knows what other differences 
there are between your real code and what you posted?

Second, NULL is generally represented as undef.  So your while condition:

    while (my $val = $sthv->fetchrow())

(if such a method existed) would return undef for a NULL column value, 
which is false, which would terminate your loop.  Consider using 
fetchall_arrayref to grab them all at once, then iterating over the 
returned array refernce.  Or, the following should work (warning: 
untested):

    while (my ($val) = $sthv->fetchrow_array)

- -- 
Eric
$_ = reverse sort $ /. r , qw p ekca lre uJ reh
ts p , map $ _. $ " , qw e p h tona e and print

-----BEGIN xxx SIGNATURE-----
Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com>

iQA/AwUBP2morGPeouIeTNHoEQIsDQCg7+TIfuXOuc/UPADiPrAg7PCzDMEAn1lY
4dvcSdW95zXL2PpA1QDymz2j
=Aj2U
-----END PGP SIGNATURE-----


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

Date: Thu, 18 Sep 2003 10:45:28 GMT
From: pjlees@ics.forthcomingevents.gr (Philip Lees)
Subject: Re: I know I can do this with a regex, but...
Message-Id: <3f698bab.79161265@news.grnet.gr>

On Thu, 18 Sep 2003 02:06:53 GMT, "Tman" <nerdy1@snet.net> wrote:

>Need to strip comments from VBScript code.
>
>Tried to use a state machine to tell if I was in quotes, but got very
>confused.  I know I can use a regex, although I may have to call it
>repeatedly to eat quoted strings.  Anyone have ideas?
>
>I need to whack everything after the first comment character...

The Perl FAQ gives a regex for doing this kind of splitting. However,
as you're only concerned about breaking into two pieces, it might be
easier to do it this way (if you don't care about efficiency).

while (<DATA>){
    chomp;
    my $line = "";
    foreach( split // ){
        unless ( /"/ ... /"/ ){ last if /'/ }
        $line .= $_
    }
    print "$line\n" if $line;
}
	
__DATA__
this is not a comment
'this line is fully commented
the comment 'in this line starts after ' the word comment
there "is no 'comment" in this line
but in "this 'line" there 'is a "comment" before the word "is"
'this line is "fully" commented

Phil

-- 
Ignore coming events if you wish to send me e-mail


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

Date: Thu, 18 Sep 2003 10:45:06 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: kill command in a perl script
Message-Id: <q23jmvc9kbeed9lc8hsvfjldf5tansnlm7@4ax.com>

Ted Zlatanov wrote:

>I should warn you that the "largest" PID is meaningless - new
>processes do not necessarily have larger PIDs than older processes on
>any OS I have used, including Linux.

Indeed. The reason is simple: wraparound beyond a fixed number of bits
for the ID numbers. So after a while they start back at zero. (Or 1...?)

-- 
	Bart.


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

Date: 18 Sep 2003 10:05:46 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: list-parsing problem
Message-Id: <slrnbmj0rq.9rt.abigail@alexandra.abigail.nl>

Marcus Claesson (m.claesson@student.ucc.ie) wrote on MMMDCLXX September
MCMXCIII in <URL:news:e818c15b.0309180119.47e7d9c9@posting.google.com>:
^^  Hi People,
^^  
^^  I have a silly little list-parsing problem that I can't get my head
^^  around, and I'm sure some of you have come across it before.
^^  
^^  I have a list like this:
^^  
^^  1	a
^^  2	b
^^  2	c
^^  3	a
^^  4	d
^^  4	d
^^  4	e
^^  4	f
^^  5	g
^^  
^^  and I want to make the first column non-redundant and collect the
^^  second column values on the same line, like this:
^^  
^^  1	a
^^  2	b,c
^^  3	a
^^  4	d,e,f
^^  5	g
^^  
^^  Please note that line 4 only has one 'd'.
^^  
^^  I've tried with both hashes and arrays (don't want to confuse you so I
^^  won't display them here), but nothing really works...

I saw a few solutions, but neither of them tried to keep the order
of the input as much as possible. The following solution does:

#!/usr/bin/perl

use strict;
use warnings;

my (@keys, %data);

while (<DATA>) {
    chomp;
    my ($key, $value) = split /\s+/ => $_, 2;
    push @{$data {$key}} => $value;
    push @keys => $key;
}

my %h;
foreach my $key (grep {!$h {$_} ++} @keys) {
    my %h;
    print "$key   ", join (", " => grep {!$h {$_} ++} @{$data {$key}}), "\n";
}


__DATA__
1       a  
2       b
2       c
3       a
4       d
4       d
4       e 
4       f
5       g



Abigail
-- 
sub f{sprintf$_[0],$_[1],$_[2]}print f('%c%s',74,f('%c%s',117,f('%c%s',115,f(
'%c%s',116,f('%c%s',32,f('%c%s',97,f('%c%s',0x6e,f('%c%s',111,f('%c%s',116,f(
'%c%s',104,f('%c%s',0x65,f('%c%s',114,f('%c%s',32,f('%c%s',80,f('%c%s',101,f(
'%c%s',114,f('%c%s',0x6c,f('%c%s',32,f('%c%s',0x48,f('%c%s',97,f('%c%s',99,f(
'%c%s',107,f('%c%s',101,f('%c%s',114,f('%c%s',10,)))))))))))))))))))))))))


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

Date: Thu, 18 Sep 2003 10:57:37 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: Newbie Question: Could someone show me how to implement options
Message-Id: <a73jmvs5btf518kdfb25tr3c2gcdu0saqd@4ax.com>

Andreas Kahari wrote:

>use Getopt::Std;

My preferred way it to use Getopt::Long, like this:

	use Getopt::Long;
	GetOptions(\my %opt, 'id=i', 'verbose', 'foo=s');

	# see what we got:
	use Data::Dumper;
	print Dumper \%opt;

use like:

	perl test.pl -verbose -id=123 -foo=abc FILES

You may use single or double hyphens.

-- 
	Bart.


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

Date: 18 Sep 2003 05:12:22 -0700
From: john_ramsden@sagitta-ps.com (John Ramsden)
Subject: Opening file units recursively
Message-Id: <d27434e.0309180412.76bea366@posting.google.com>

I have an application that reads a list of pathnames, and the
list can contain "include" lines each of which specifies the
path of a file to go off and process, just like recursive C
includes.

However, I am having a lot of trouble getting the file units
to open and close properly. The following is a short extract
of the relevant code, which works apart from the fact that
when wd_runcr() tries to close the 'include'd file the next
level file turns out to be closed at the same time.

Why do Perl file units have to be so _damned_ complicated
and obscure, when being passed between functions? Couldn't
the guy who first developed the language simply have used
ordinary variables for them?!

(I've also tried 'our' instead of 'local' No idea what
either does, but the examples I've seen seem to indicate
that for some reason something other than the usual 'my'
is required.)

     use strict;

      :::

   sub wd_runcr
   {
      local ($filename, $fileunit) = @_;

      no strict 'refs';

      open $fileunit, "< $filename"
         or wd_die "open ('$filename', 'r') failed:\n   $!";

      use strict 'refs';

      while (<$fileunit>)
      {
         :::

         if ($arg[0] eq '%include')
         {
            wd_runcr ($arg[1], ++$fileunit);

            next;
         }

         :::
      }
      
      close $fileunit
         or wd_die "close ('$filename') failed:\n   $!";
   }

   #------------------------------------------------------------

      :::

      foreach my $subsys (@subsys)
      {
         my $file = "$subsys/$target_os_dir/wdruncr.txt";

         wd_runcr ("$subsys/$target_os_dir/wdruncr.txt", 'A00');
      }


Thanks in anticipation.


Cheers

John Ramsden (john_ramsdenNO@SPAMsagitta-ps.com)


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

Date: 18 Sep 2003 12:49:48 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Opening file units recursively
Message-Id: <bkc9lc$571$1@mamenchi.zrz.TU-Berlin.DE>

John Ramsden <john_ramsden@sagitta-ps.com> wrote in comp.lang.perl.misc:
> I have an application that reads a list of pathnames, and the
> list can contain "include" lines each of which specifies the
> path of a file to go off and process, just like recursive C
> includes.
> 
> However, I am having a lot of trouble getting the file units
> to open and close properly. The following is a short extract
> of the relevant code, which works apart from the fact that
> when wd_runcr() tries to close the 'include'd file the next
> level file turns out to be closed at the same time.
> 
> Why do Perl file units have to be so _damned_ complicated
> and obscure, when being passed between functions? Couldn't
> the guy who first developed the language simply have used
> ordinary variables for them?!

Well, the guy apparently thought he could get away with filehandles
that were global symbols.

But times have changed and you *can* have filehandles in arbitrary
variables these days.

> (I've also tried 'our' instead of 'local' No idea what
> either does,

That's look-uppable.  See "perldoc perlvar", "perldoc -f our",
and "perldoc -f local".

>              but the examples I've seen seem to indicate
> that for some reason something other than the usual 'my'
> is required.)

To the contrary, it's filehandles in lexical (my-) variables that makes
a smooth solution to the include problem possible.  

[code snipped]

Here is an example that prints out the lines as they arrive.  Any other
kind of processing could happen instead.

    sub copy_including {
        my $file = shift;
        open my $fh, $file or die "Can't read $file: $!";
        while ( <$fh> ) {
            if ( my $incl = extract_incl( $_) ) {
                copy_including( $incl);
            } else {
                print;
            }
        }
    }

    sub extract_incl {
        local $_ = shift;
        /#include\s*(.*)/;
        $1;
    }

The significant bit in this code is "my $fh" in the open statement.
This creates a new lexical $fh each time through, so opening $fh
doesn't close a file that has been opened in this variable before.
After return from a recursive call, the previous $fh is still around
and points to the right place.

Anno


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

Date: Thu, 18 Sep 2003 07:24:01 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: package problem? [was Re: @_ in subroutine corrupts data?]
Message-Id: <slrnbmj8v1.a5h.tadmc@magna.augustmail.com>

synthespian <synthespian@uol.com.br> wrote:

> While we're on this, it got weird with "strict" and "warnings". Why?


use warnings has nothing to do with it, there are no warning
messages below.


> @arrayb = subthat(1, 2, 3, 4);

> $ perl subrout3.pl
> Global symbol "@arrayb" requires explicit package name at subrout3.pl 
> line 5.


When you put "use strict" in your program, you are making this
promise to perl:

   I will declare all of my variables before I use them.

If you break your promise, perl will refuse to run your program.

You are using @arrayb without declaring it, you've broken your promise.

So, either declare the variable:

   my @arrayb = subthat(1, 2, 3, 4);

or use an explicit package name:

   @main::arrayb = subthat(1, 2, 3, 4);


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Thu, 18 Sep 2003 11:00:05 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: Pattern Matching in file with invisible char
Message-Id: <qu3jmvg6b1g900vi0bdk5dkst2toa4rob3@4ax.com>

M Pires wrote:

>I am currently working on a Perl script that will parse out values from an
>"almost" text file.  The reason I say this is because there are "invisible"
>chars in the file such as the ASCII SUB char ( 0x1A ). This chars confuse
>the <HANDLE> and cause a premature EOF.

It's not quite premature... On ancient systems (think DOS and earlier)
this was used as a end-of-file marker on text files. That's why
binmode() fixes this.

Don't forget you'll now have to delete unnecessary CR characters (=
"\r") yourself.

-- 
	Bart.


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

Date: Thu, 18 Sep 2003 12:45:56 +0100
From: pedro.fabre@gen.gu.se (fabre)
Subject: perl sub and perl modules
Message-Id: <pedro.fabre-1809031245560001@192.168.0.5>

Hi all,


I am new in perl and I am having some difficulties in getting used to it.
I have an array of array:

my @hap = (
     [qw/ a c g t g c/],
     [qw/ c g ? t a g/],
     [qw/ a c t t ? c/]);


and as during the process I will need to print how this evolves during the
process, I tried to place a print sub:


sub MyPrint {
    my (@arr) =@_;

    for my $i (0..$#arr){
        for my $j (0..$#{$arr[$i]}){
            print $arr[$i][$j]."\t";
        }
        print "\n";
    }
}


if I call my print as reference:

MyPrint(\@hap);

I get:
ARRAY(0x541c)   ARRAY(0x7b944)  ARRAY(0x7b884)

instead if I pass the array as value:

MyPrint(@hap);

I get the answer I was trying to get.

a       c       g       t       g       c
c       g       ?       t       a       g
a       c       t       t       ?       c


But As I think that passing as value (creates a variable that we are not
going to use anymore ) I think the best idea was passing by reference,
but..

How I do that?


Alternatively I was thinking to place My sub in a module. How this will
work on that situation?


Thanks in advance for you help

P


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

Date: 18 Sep 2003 12:14:29 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: perl sub and perl modules
Message-Id: <bkc7j5$2un$1@mamenchi.zrz.TU-Berlin.DE>

fabre <pedro.fabre@gen.gu.se> wrote in comp.lang.perl.misc:
> Hi all,
> 
> 
> I am new in perl and I am having some difficulties in getting used to it.
> I have an array of array:
> 
> my @hap = (
>      [qw/ a c g t g c/],
>      [qw/ c g ? t a g/],
>      [qw/ a c t t ? c/]);
> 
> 
> and as during the process I will need to print how this evolves during the
> process, I tried to place a print sub:
> 
> 
> sub MyPrint {
>     my (@arr) =@_;
> 
>     for my $i (0..$#arr){
>         for my $j (0..$#{$arr[$i]}){
>             print $arr[$i][$j]."\t";
>         }
>         print "\n";
>     }
> }

That's more complicated than it has to be.  Don't use array indices in
Perl unless you have to.  Here is a simplified version:

    sub MyPrint {
        for ( @_ ) {
            print join( "\t", @$_), "\n";
        }
    }


> 
> 
> if I call my print as reference:
> 
> MyPrint(\@hap);
> I get:
>
> ARRAY(0x541c)   ARRAY(0x7b944)  ARRAY(0x7b884)
> 
> instead if I pass the array as value:
> 
> MyPrint(@hap);
> 
> I get the answer I was trying to get.
> 
> a       c       g       t       g       c
> c       g       ?       t       a       g
> a       c       t       t       ?       c
> 

Sure.  That calls MyPrint with a single scalar parameter, which is
a listref.  The way you layed out the routine, it expects a list
(of listrefs).

> But As I think that passing as value (creates a variable that we are not
> going to use anymore ) I think the best idea was passing by reference,
> but..
> 
> How I do that?

To make it work with a reference, change the loop control in "for"

    sub MyPrint {
        for ( @{ shift()} ) {
            print join( "\t", @$_), "\n";
        }
    }

> Alternatively I was thinking to place My sub in a module. How this will
> work on that situation?

You would define the routine in a module exactly the way you do it
in your main file.

Anno


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

Date: 18 Sep 2003 10:47:30 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Quoting "$vars" and open()
Message-Id: <bkc2g2$qah$2@mamenchi.zrz.TU-Berlin.DE>

Tassilo v. Parseval <tassilo.parseval@post.rwth-aachen.de> wrote in comp.lang.perl.misc:
> Also sprach Tad McClellan:
> 
> > I thought we were talking about useless uses of double quotes,
> > without regard to what the variable's value is, nor where
> > the variable is used.
> > 
> > You _never_ need
> > 
> >    "$vars"
> > 
> > because
> > 
> >   $vars
> > 
> > will always work in its place.
> 
> It should, and actually will for all Perl-builtins. Yet there is a
> difference on the inside between these two (which makes your points even
> more valid):

[internal workings snipped]

There is another case where "$vars" and $vars are different, quite on
the surface.  It happens when $vars is an object whose stringification
is overloaded.  Obviously, $var is the object, but "$var" can be anything.

In the presence of overloading a few basic rules in Perl don't apply
anymore.  Variable stringification is one example, and "\ @$x", "\ %$x"
and "\ $$x" aren't necessarily no-ops for overloaded $x.

Anno


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

Date: Thu, 18 Sep 2003 07:28:59 -0400
From: Mark Fenbers <Mark.Fenbers@noaa.gov>
Subject: Re: string to integer
Message-Id: <3F6996FA.275A4C5A@noaa.gov>

This is a multi-part message in MIME format.
--------------15FDB7A6F4AF00FCF883F279
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

I don't post very often to newsgroups because there always has to be some
condescending know-it-all to chime in his two cents.  Someone always finds a way
to be rude...  Tad, your comments were critical, not helpful.  *sigh*  I guess I
expected better etiquette from a professional...

Mark

Tad McClellan wrote:

> Mark Fenbers <Mark.Fenbers@noaa.gov> wrote:
>
> > This is a multi-part message in MIME format.
>
> Why is this is a multi-part message in MIME format?
>
> Usenet is a plain text medium.
>
> Using MIME means that less people will see your posts.
>
> > I have an interesting problem...
>
> No, you have discovered a very fundamental aspect of computer science,
> the difference between "code" and "data".
>
> > Perl seems to convert hex numbers which are explicit constants in the code
>
> Because then it is "code".
>
> > if $val is assigned from reading 0xFF from a file or user input,
>
> Because then it is "data".
>
> > $val is treated like a string instead of
> > a number.
>
> Good, since it *is* a string instead of a number.
>
> > I am required to "use strict;" and so I get warnings
>
> "use strict" does NOT issue warnings.
>
> "use warnings" issues warnings.
>
> > The bottom line is how can I convert a string into an integer or a float??
>
> You can't.
>
> You can, however, convert a hex string into the corresponding
> numerical value. The answer to that question ends up sounding
> like you are joking with us...
>
>    perldoc -f hex
>
> :-)
>
> --
>     Tad McClellan                          SGML consulting
>     tadmc@augustmail.com                   Perl programming
>     Fort Worth, Texas

--------------15FDB7A6F4AF00FCF883F279
Content-Type: text/x-vcard; charset=us-ascii;
 name="Mark.Fenbers.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: Card for Mark Fenbers
Content-Disposition: attachment;
 filename="Mark.Fenbers.vcf"

begin:vcard 
n:Fenbers;Mark
tel;work:513-383-0430
x-mozilla-html:TRUE
url:http://www.erh.noaa.gov/ohrfc
org:Ohio River Forecast Center;DOC/NOAA/NWS/OHRFC
adr:;;1901 South State Route 134;Wilmington;OH;45177-9708;USA
version:2.1
email;internet:Mark.Fenbers@noaa.gov
title:Sr. HAS Meteorologist
fn:Mark J Fenbers
end:vcard

--------------15FDB7A6F4AF00FCF883F279--



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

Date: Thu, 18 Sep 2003 11:44:47 GMT
From: f_baggins80@hotmail.com (Helgi Briem)
Subject: Re: string to integer
Message-Id: <3f6998cf.243179844@News.CIS.DFN.DE>

On Thu, 18 Sep 2003 07:28:59 -0400, Mark Fenbers
<Mark.Fenbers@noaa.gov> wrote:

Don't top-post.  Top-posting is rude and severely
damages your chances of having your posts
read by a competent professional. If you do it
again you will be killfiled by everybody left worth
listening to.  Many have already done so.

For posting guidelines ot comp.lang.perl.misc,
read the regular Posting Guidelines:

http://mail.augustmail.com/~tadmc/clpmisc.shtml

For more information about netiquette in general, 
see the "Netiquette Guidelines" at:

http://andrew2.andrew.cmu.edu/rfc/rfc1855.html

>This is a multi-part message in MIME format.

Don't do that.  Usenet is a text-only medium.
Posting in MIME is rude and severely
damages your chances of having your posts
read by a competent professional.  If you do it
again you will be killfiled by everybody left worth
listening to.  Many have already done so.

>I don't post very often to newsgroups because there 
>always has to be some condescending know-it-all to 
>chime in his two cents.  

Yes, that describes you perfectly.

>Someone always finds a way to be rude...  

Indeed.

>Tad, your comments were critical, not helpful.  *sigh*  I guess I
>expected better etiquette from a professional...

Tad's comments are invariably helpful and professional.
If you bothered to read them and follow them you would
find out exactly how helpful they are.  Instead you
choose to whine and complain and derive no benefit
at all.

I could  find not a single comment in his post which is
not 100% accurate and if followed, would help
you solve your problem quickly.  Now go and
read perldoc -f hex and stop whining.

And don't top post in MIME again.
--
Helgi Briem  hbriem AT simnet DOT is

Excuse the munged address.  My last
e-mail address was killed by spammers.


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

Date: Thu, 18 Sep 2003 07:33:24 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: wtf is the deal?
Message-Id: <slrnbmj9gk.a5h.tadmc@magna.augustmail.com>

Tom <tom@nosleep.net> wrote:
> I'm sorry, there must be something wrong with my isp news again, as I don't
> see any responses at all.
> I'm not sure why yours showed up, but the others didn't. I did not cross
> post, so they must have showed up out of my thread.


You've been asked to stop top-posting, yet you are still top-posting.

Many people will killfile you for that. Maybe that is why you aren't
getting enough helpful responses...



[snip TOFU]

-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Thu, 18 Sep 2003 07:34:48 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: wtf is the deal?
Message-Id: <slrnbmj9j8.a5h.tadmc@magna.augustmail.com>

Tom <tom@nosleep.net> wrote:

> actually, I can't see his posts anywhere.


Whose posts?

It is customary to quote a bit of context (and an attribution)
when referring to something earlier in the thread.


If your newserver is dropping articles, try looking for them at Google:

   http://groups.google.com/


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Sat, 19 Jul 2003 01:59:56 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: 
Message-Id: <3F18A600.3040306@rochester.rr.com>

Ron wrote:

> Tried this code get a server 500 error.
> 
> Anyone know what's wrong with it?
> 
> if $DayName eq "Select a Day" or $RouteName eq "Select A Route") {

(---^


>     dienice("Please use the back button on your browser to fill out the Day
> & Route fields.");
> }
 ...
> Ron

 ...
-- 
Bob Walton



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

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.  

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

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

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


------------------------------
End of Perl-Users Digest V10 Issue 5522
***************************************


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