[22812] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5033 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat May 24 06:05:45 2003

Date: Sat, 24 May 2003 03:05:06 -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           Sat, 24 May 2003     Volume: 10 Number: 5033

Today's topics:
    Re: counter <no.spam@this.addy.ta>
    Re: counter <no.spam@this.addy.ta>
    Re: counter <jurgenex@hotmail.com>
    Re: counter <no.spam@this.addy.ta>
    Re: counter <bwalton@rochester.rr.com>
    Re: counter <bwalton@rochester.rr.com>
    Re: counter <no.spam@this.addy.ta>
    Re: counter <jurgenex@hotmail.com>
        Expanding a newcommand in latex (Niels L. Ellegaard)
    Re: Expanding a newcommand in latex <tassilo.parseval@rwth-aachen.de>
    Re: Expanding a newcommand in latex <abigail@abigail.nl>
        Help with my game <mail@annuna.com>
        Help!: Problem Passing Values to ::Graph (Think its for (entropy123)
        mime parser <nothing@home.yet>
        o conf urllist <waty@powerup.com.au>
        Perl and geometry <ericw@nospam.ku.edu>
        Problem with Addition - doesn't interpret as a number? (Dave)
    Re: Problem with Addition - doesn't interpret as a numb (Dave)
    Re: Problem with Addition - doesn't interpret as a numb (Malcolm Dew-Jones)
    Re: Problem with Addition - doesn't interpret as a numb <ericw@nospam.ku.edu>
    Re: Problem with Addition - doesn't interpret as a numb <laocoon@fastmail.fm>
        Send Yourself $1,000 Cash - Straight Away! Guaranteed! (Free Cash Loop-hole - Hurry!)
    Re: Using GD::Graph in a CGI <bwalton@rochester.rr.com>
    Re: Where should I look? <mbudash@sonic.net>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Sat, 24 May 2003 02:08:30 +0100
From: "Brian H供" <no.spam@this.addy.ta>
Subject: Re: counter
Message-Id: <hCzza.11500$Mu3.224865@newsfep4-glfd.server.ntli.net>

X-No-Archive: Yes
My monitor and keyboard are coffee coloured.
I had a mouthful of coffee when I noticed Bob Walton said:

> Bob Walton wrote:
>
>> Brian H供 wrote:
> ...
>>    $hash{y/a-zA-Z_//}++ while(<>);
>
>
> Oops, make that:
>
>
>       $hash{y/a-zA-Z_0-9//}++ while(<>);
>
>
> to include the numeric characters.

If you mean as follows, it just hangs :-(

use strict;

my ( $line, %hash, @array, $key, $value, $i );

open( F, $ARGV[0] );

while( chomp( $line = <F> ) ) {

 $hash{y/a-zA-Z_0-9//}++ while(<>);

}

foreach $key ( sort { $a <=> $b } ( keys( %hash ) ) ) {

 printf( "%2d\t%3d\n", $key, $hash{ $key } );

}




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

Date: Sat, 24 May 2003 02:10:59 +0100
From: "Brian H供" <no.spam@this.addy.ta>
Subject: Re: counter
Message-Id: <CEzza.11501$Mu3.223996@newsfep4-glfd.server.ntli.net>

X-No-Archive: Yes
My monitor and keyboard are coffee coloured.
I had a mouthful of coffee when I noticed Cat said:

> "Brian H供" wrote:
>>
>> Hi.
>> Would someone be kind enough to amend the following *.pl so that I can count
>> alphanumerics please.
>> Sorry to ask, but I'm going round in circles here.
>>
>> TIA
>> Brian
>>
>> use strict;
>>
>> my ( $line, %hash, @array, $key, $value, $i );
>>
>> open( F, $ARGV[0] );
>>
>> while( chomp( $line = <F> ) ) {
>>
>>  $hash{ int( $line ) } += 1;
>>
>> }
>>
>> foreach $key ( sort { $a <=> $b } ( keys( %hash ) ) ) {
>>
>>  printf( "%2d\t%3d\n", $key, $hash{ $key } );
>>
>> }
>
> Dood, can you post a few lines of the $ARGV[0] file and a brief explanation
> of what you are trying to achieve with that input.

They are just going to be entries like

fred001
joe27
fred001
pete441
fred001
joe27
fred001
pete441
pete441
fred001
joe27




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

Date: Sat, 24 May 2003 01:50:09 GMT
From: "J黵gen Exner" <jurgenex@hotmail.com>
Subject: Re: counter
Message-Id: <ldAza.475$IK4.209@nwrddc03.gnilink.net>

Brian H供 wrote:
> Would someone be kind enough to amend the following *.pl so that I
> can count alphanumerics please.

The fasted and easiest way is probably to simply use tr():
    "[...]It returns the number of characters replaced[...]"

my $_='Whatever your 1234 text is *&$%';
print "The text '$_' contains ", tr/a-zA-Z0-9//, " alphanumeric characters";

jue




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

Date: Sat, 24 May 2003 02:55:56 +0100
From: "Brian H供" <no.spam@this.addy.ta>
Subject: Re: counter
Message-Id: <LiAza.11510$Mu3.225226@newsfep4-glfd.server.ntli.net>

J黵gen Exner said:

> Brian H供 wrote:
>> Would someone be kind enough to amend the following *.pl so that I
>> can count alphanumerics please.
>
> The fasted and easiest way is probably to simply use tr():
>     "[...]It returns the number of characters replaced[...]"
>
> my $_='Whatever your 1234 text is *&$%';
> print "The text '$_' contains ", tr/a-zA-Z0-9//, " alphanumeric characters";
>
> jue

Sorry but you've completely lost me now, is it possible to redo my example with
what you are saying please?
I'm learning from a few examples that I've been given, and a book.

Thanks
Brian




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

Date: Sat, 24 May 2003 02:35:29 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: counter
Message-Id: <3ECED85A.8020304@rochester.rr.com>

Brian H供 wrote:

 ...


>>Bob Walton wrote:
>>
>>
>>>Brian H供 wrote:
>>>
>>...
>>
>>>   $hash{y/a-zA-Z_//}++ while(<>);
>>>
>>
>>Oops, make that:
>>
>>
>>      $hash{y/a-zA-Z_0-9//}++ while(<>);
>>
>>
>>to include the numeric characters.
>>
> 
> If you mean as follows, it just hangs :-(
> 
> use strict;
> 
> my ( $line, %hash, @array, $key, $value, $i );
> 
> open( F, $ARGV[0] );
> 
> while( chomp( $line = <F> ) ) {
> 
>  $hash{y/a-zA-Z_0-9//}++ while(<>);
> 
> }
> 
> foreach $key ( sort { $a <=> $b } ( keys( %hash ) ) ) {
> 
>  printf( "%2d\t%3d\n", $key, $hash{ $key } );
> 
> }
 ...

No, I meant as per the example at the end of my previous post, with that 
one line changed to include numerics in the count.  That is, like this:

    use strict;
    use warnings;
    my %hash;
    $hash{y/a-zA-Z_0-9//}++ while(<>);
    for(sort {$a<=>$b} keys %hash){
       printf "%2d\t%3d\n",$_,$hash{$_};
    }

-- 
Bob Walton



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

Date: Sat, 24 May 2003 02:51:11 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: counter
Message-Id: <3ECEDC06.6060500@rochester.rr.com>

Brian H供 wrote:

 ... 
>>"Brian H供" wrote:
 ...


>>Dood, can you post a few lines of the $ARGV[0] file and a brief explanation
>>of what you are trying to achieve with that input.
>>
> 
> They are just going to be entries like
> 
> fred001
> joe27
> fred001
> pete441
> fred001
> joe27
> fred001
> pete441
> pete441
> fred001
> joe27
 ...

So you want to count how many times 'fred001' appears, and how many 
times 'joe27' appears, etc?  If so:

    my %hash;
    chomp $_,$hash{$_}++ while(<>);
    for(sort {$a cmp $b} keys %hash){
       printf "%10s\t%3d\n",$_,$hash{$_};
    }

-- 
Bob Walton



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

Date: Sat, 24 May 2003 04:10:51 +0100
From: "Brian H供" <no.spam@this.addy.ta>
Subject: Re: counter
Message-Id: <_oBza.11530$Mu3.225044@newsfep4-glfd.server.ntli.net>

Bob Walton said:

> Brian H供 wrote:
>
> ...
>>> "Brian H供" wrote:
> ...
>
>
>>> Dood, can you post a few lines of the $ARGV[0] file and a brief explanation
>>> of what you are trying to achieve with that input.
>>>
>>
>> They are just going to be entries like
>>
>> fred001
>> joe27
>> fred001
>> pete441
>> fred001
>> joe27
>> fred001
>> pete441
>> pete441
>> fred001
>> joe27
> ...
>
> So you want to count how many times 'fred001' appears, and how many
> times 'joe27' appears, etc?  If so:
>
>     my %hash;
>     chomp $_,$hash{$_}++ while(<>);
>     for(sort {$a cmp $b} keys %hash){
>        printf "%10s\t%3d\n",$_,$hash{$_};
>     }

Brilliant, thank you very much.




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

Date: Sat, 24 May 2003 04:58:11 GMT
From: "J黵gen Exner" <jurgenex@hotmail.com>
Subject: Re: counter
Message-Id: <DZCza.3618$8i4.2714@nwrddc02.gnilink.net>

Brian H供 wrote:
> J黵gen Exner said:
>
>> Brian H供 wrote:
>>> Would someone be kind enough to amend the following *.pl so that I
>>> can count alphanumerics please.
>>
>> The fasted and easiest way is probably to simply use tr():
>>     "[...]It returns the number of characters replaced[...]"
>>
>> my $_='Whatever your 1234 text is *&$%';
>> print "The text '$_' contains ", tr/a-zA-Z0-9//, " alphanumeric
>> characters";
>>
>> jue
>
> Sorry but you've completely lost me now, is it possible to redo my
> example with what you are saying please?

Really simple. You want to count alphanumeric characters.
So I am using tr() to replace all alphanumeric characters (a-zA-Z0-9) with
whatever and tr will return the number of replacements made. That is the
wanted number of alphanumeric characters in that string.

If your string contains non-English characters you will have to modify the
list of characters accordingly.

jue




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

Date: 24 May 2003 07:15:40 +0200
From: gnalle@ruc.dk (Niels L. Ellegaard)
Subject: Expanding a newcommand in latex
Message-Id: <7w3cj57wn7.fsf@dirac.ruc.dk>


When I write latex I make frequent use of newcommands such as
\newcommand{\pt}[3]{\left(\frac{\partial#2}{\partial#1}\right)_{#3}}

Sadly I have problems if I wish to share my tex-file with other
people. Therefore I am looking for a perlscript that can produce a new
latex-file where the newcommand has been expanded. 

I am not a great master of perl and I guess that I should sit down and
learn instead of asking stupid questions usenet groups, but still I
would be very grateful if someone could point me to an example of perl
code that expands a latex newcommand that takes arguments.

                        Thanks in advance
                       
                                 Niels

-- 
Niels L Ellegaard  http://dirac.ruc.dk/~gnalle/


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

Date: 24 May 2003 08:32:20 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de>
Subject: Re: Expanding a newcommand in latex
Message-Id: <banamk$9rf$1@nets3.rz.RWTH-Aachen.DE>

Also sprach Niels L. Ellegaard:

> When I write latex I make frequent use of newcommands such as
> \newcommand{\pt}[3]{\left(\frac{\partial#2}{\partial#1}\right)_{#3}}
> 
> Sadly I have problems if I wish to share my tex-file with other
> people. Therefore I am looking for a perlscript that can produce a new
> latex-file where the newcommand has been expanded. 
> 
> I am not a great master of perl and I guess that I should sit down and
> learn instead of asking stupid questions usenet groups, but still I
> would be very grateful if someone could point me to an example of perl
> code that expands a latex newcommand that takes arguments.

That's a tough task considering the fact that LaTeX has the tendency to
nest parens in an unpleasant way (I think). I am not very familiar with
it but since your problem is interesting I looked up a few bits and came
up with a little script that expands \newcommand. Put these macro
definitions into a file "macro" and run it with 

    perl latex.pl document.tex > expanded.tex

I can't guarantee that it'll work for arbitrary \newcommand definitions
and I can't explain either why it works at all with my test data. :-)
That's because I find recursive regexpes highly magical and miraculous.

But perhaps it does what you want:

#! /usr/bin/perl -w

use re 'eval';
my ($macro, $curlies);

$macro = qr/\\newcommand\{(.*?)\}(?:\[(\d)\])?\{([^ ]*)\}/;
$curlies = qr/
    \{(
        (
            (?> [^{}]+?)
            |
            (??{ $curlies })
        )*
    )\}
/x;

# get \newcommand definitions from external file
open MACROS, "macros" or die $!;
my %hash;
while (<MACROS>) {
    $hash{ quotemeta($1) } = [ $2 || 0, $3 ] if /$macro/;
}

# this will be the mapping from real strings within original document
# to the new strings that are the expansions of the \newcommand definitions
my %actual_replacements;

# the unexpanded document is retrieved here
my $latex = do { local $/; open DOC, shift or die $!; <DOC> };

# iterate over all macro definitions
for my $m (keys %hash) {
    my ($num, $repl) = @{ $hash{$m} };
    my ($cmd) = $repl =~ /^(\\\w+)/;
    my $arguments = join "", $curlies, "{$num}";
    while ($latex =~ /($m($arguments))/g) {
        my $replace_this = $1;
        my $args = $2;
        my @args = split_args($args);
        (my $replace_with = $replace_this) =~ s/$m/$cmd/;
        $replace_with =~ s/#(\d+)/{$args[$1-1]\}/g;
        $actual_replacements{ quotemeta($replace_this) } = $replace_with;
    }
}

while (my ($orig, $new) = each %actual_replacements) {
    $latex =~ s/$orig/$new/g;
}
print $latex;


sub split_args {
    my $string = shift;
    my @args;
    my $find;
    $find = sub {
        my $s = shift;
        if ($s =~ s/$curlies//) {
            push @args, $1;
            $find->($s);
        } else {    # no curlies in argument
            push @args, $s;
        }
    };
    $find->($string);
    return @args;
}
__END__

The program is highly recursive (see the $curlies pattern and the
$find function-reference in split_args(). Also, the variable names leave
a lot to be desired (%hash should probably be named %macros or so).

I tested it with this pseudo-tex document:

\begin{document}
Some text
\pt{{{1}}{2}{3}}{1}{2}
\pt{hello}{foo}{bar}
\test{1+2}
\empty
\end{document}

and with these \newcommands:

\newcommand{\pt}[3]{\left(\frac{\partial#2}{\partial#1}\right)_{#3}}
\newcommand{\test}[1]{\bla#1}
\newcommand{\empty}{\nonempty}

The scripts expands that to

\begin{document}
Some text
\left{{{1}}{2}{3}}{1}{2}
\left{hello}{foo}{bar}
\bla{1+2}
\nonempty
\end{document}

Tassilo
-- 
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval


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

Date: 24 May 2003 10:03:22 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: Expanding a newcommand in latex
Message-Id: <slrnbcugra.kuj.abigail@alexandra.abigail.nl>

Niels L. Ellegaard (gnalle@ruc.dk) wrote on MMMDLIII September MCMXCIII
in <URL:news:7w3cj57wn7.fsf@dirac.ruc.dk>:
:}  
:}  When I write latex I make frequent use of newcommands such as
:}  \newcommand{\pt}[3]{\left(\frac{\partial#2}{\partial#1}\right)_{#3}}
:}  
:}  Sadly I have problems if I wish to share my tex-file with other
:}  people. Therefore I am looking for a perlscript that can produce a new
:}  latex-file where the newcommand has been expanded. 

This isn't as straightforward as you may think. But what makes you
think this will solve your problem? If you share a LaTeX file, what
is the reason for sharing? I presume the people you share it with
will do "latex yourfile.tex" to create a dvi file, for viewing or
to translate it into something else. But I've never heard of a latex
that can't deal with \newcommand. Perhaps your problem lies elsewhere.

Also, why ask in a Perl group? You're better off asking in a latex or
tex group. After all, does it matter if the program exanding commands
was written in Perl, Python, C, Java or even as a LaTeX package?



Abigail
-- 
perl5.004 -wMMath::BigInt -e'$^V=Math::BigInt->new(qq]$^F$^W783$[$%9889$^F47]
 .qq]$|88768$^W596577669$%$^W5$^F3364$[$^W$^F$|838747$[8889739$%$|$^F673$%$^W]
 .qq]98$^F76777$=56]);$^U=substr($]=>$|=>5)*(q.25..($^W=@^V))=>do{print+chr$^V
%$^U;$^V/=$^U}while$^V!=$^W'


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

Date: Sat, 24 May 2003 02:29:50 -0500
From: Joe Creaney <mail@annuna.com>
Subject: Help with my game
Message-Id: <3ECF1F6E.1070708@annuna.com>

I am writing a game and it is posted at www.annuna.com/perl5

It is rpg 1.2 beta.  My problem is that I put weapons and armor which 
are objects in a another object player and when I try to print them out 
they don't show up.  The equipment that starts with the player will 
print out.  I am really stumped.  The program is pretty long about 700 
lines long.  I  hope on you gurus out there can explain to me what the 
problem is and if I can fix it.  I have put flags in so I know the items 
are in the array in the object but why they won't print out.  I know I 
have a ways to go to get the program better written and other bugs 
worked out.

I think the game is pretty cool for a self taught amateur programmer.



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

Date: 24 May 2003 00:20:05 -0700
From: email_entropy123@yahoo.com (entropy123)
Subject: Help!: Problem Passing Values to ::Graph (Think its format...)
Message-Id: <90cdce37.0305232320.207e8605@posting.google.com>

Hey all,

I'm trying to get the Graph::Directed module to work and, if I type in
an array manually

$g->add_edges(qw(a b  a c  b c  c e));

I get a fine result. However, I need to read my values in from a file
and so have

$input = a b  a c  b c  c e #basically the 'string' my program creates
from the input file.

$g->add_edges(qw($input));

This puts me into an endless loop.

My suspicions:

1) I'm not passing it a string, the module believes it has a variable.
(Print statements show that the $input is identical to the manually
entered string right before it goes into the module...

2) Something else is going on.....

Any suggestions?

entropy


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

Date: Fri, 23 May 2003 23:39:01 -0700
From: "Shane Mosely" <nothing@home.yet>
Subject: mime parser
Message-Id: <vcu4tlimk3t2ca@corp.supernews.com>

I am working on a newsgroup reader. I want to download the messages and
parse out all the pictures, viruses etc. but I am having a problem. I am
using the code below to parse out the data but most of the times it just
writes a text or html file with the file data stream. Am I missing
something. I did notice that it has no problems with newsgroup messages that
have multipart tags but everything else it just spits out intact.

sub parser{
 my $file = @_[0];

  my ($parsed) = (basename($0))[0];

  my $parser = new MIME::Parser;
  $parser->output_prefix($parsed);
  $parser->output_dir($opd);
  $parser->output_to_core;
  $parser->parse_data($file);

}#close parser subroutine




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

Date: Sat, 24 May 2003 04:09:46 GMT
From: "Alan Watson" <waty@powerup.com.au>
Subject: o conf urllist
Message-Id: <egCza.335$ES.3231@news-server.bigpond.net.au>

I can't seem to reset the default ftp site in CPAN. Can anyone tell me how?
I think the command is something like:

o conf urllist

Thanks,

Alan




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

Date: Sat, 24 May 2003 04:57:57 GMT
From: Eric Wilhelm <ericw@nospam.ku.edu>
Subject: Perl and geometry
Message-Id: <pan.2003.05.23.23.54.41.632676.13926@nospam.ku.edu>

Are there many programmers using Perl for geometry processing?  It seems
that whenever I search for something like the area of a triangle or
another geometry processing algorithm/method that everything comes back in
C.

I realize that most of the graphics and modeling applications are going to
use C for the speed in computationally intensive tasks, and I have noticed
big penalties for doing things like for($i=0;$i<1000;$i++){for($j=0 .....
and I have just learned to change the algorithms when possible to avoid
this sort of thing (e.g. it is faster to call two subs from inside the
loop than to have a loop inside of two subs).  Does C have a huge speed
gain on Perl in iteration?

Most of the work I'm doing is prototype or single-use, so it isn't really
worth all of the trouble of allocating data structures and the other fun
things to do with C that Perl handles for you.  But, it is frustrating
that there seems to be a lack of modules for handling geometry and few
libraries come with a Perl interface.

Glancing through CPAN, I see only a few mathematics modules and in my
work with SWIG, it seems that most of the scientific use comes from
python and other high-level languages.  But why not Perl?

It seems like a lot of people associate Perl with Web and therefore don't
think to choose it when learning a language, or that it just isn't taught
in most academic programs.  

It could also be that I'm not looking in the right places.  Any thoughts?

--Eric


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

Date: 23 May 2003 19:58:39 -0700
From: nipper1999@aol.com (Dave)
Subject: Problem with Addition - doesn't interpret as a number?
Message-Id: <ad817f81.0305231858.723f07a5@posting.google.com>

I have a tab-delimited input file I am trying to parse.  I load the
lines into an array and when I try to add to the numbers in one of the
columns, it doesn't seem to be converting the array values to numbers.
 I am using UWIN on Windows XP.  Here is sample code:

while (<INPUT>) {
        $_ =~ s/(\r|\n)//g;
        @array = split("\t",$_);
        print "*$array[13]*\t";
        $test = $array[13] + 1;
        print "$test\n";   
} 

Output is similar to this:
*0*      1
*0.05*   1
*0.05*   1
*0*      1
*0.1*    1
*3.95*   1

What am I missing?  I want to do simple addition and I can't seem to
get it to work.  Your help is greatly appreciated!


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

Date: 23 May 2003 19:41:07 -0700
From: nipper1999@aol.com (Dave)
Subject: Re: Problem with Addition - doesn't interpret as a number?
Message-Id: <ad817f81.0305231841.140498d5@posting.google.com>

AWESOME - you guys rock!  I tried each of these and they both cleaned it right up.
$array[13]=~ y/\000-\037//d;
$array[13] =~ y/0-9.-//cd;

I have two questions:
(1) How do I know if I have non-printing conrol characters?
(2) What exactly is this matching on?

Thanks for all your help!  You've saved me many headaches.


"John W. Krahn" <krahnj@acm.org> wrote in message news:<3ECDB5DD.2084B879@acm.org>...
> Bob Walton wrote:
> > 
> > You don't say what your OS is, or to what device your output is being
> > sent.  My guess is that $array[13] contains one or more leading
> > non-printing control characters which are both preventing the string
> > from being interpreted as a number and also are not showing up on your
> > output.  You could try removing any such characters, perhaps with
> > something like:
> > 
> >      $array[13]=~y/\000-\037//d;
> > 
> > prior to your prints and see if the behavior changes.
> 
> This looks better and might even work better.  :-)
> 
>       $array[13] =~ y/0-9.-//cd;
> 
> 
> 
> John


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

Date: 23 May 2003 21:12:01 -0800
From: yf110@vtn1.victoria.tc.ca (Malcolm Dew-Jones)
Subject: Re: Problem with Addition - doesn't interpret as a number?
Message-Id: <3ecef111@news.victoria.tc.ca>

Dave (nipper1999@aol.com) wrote:
: AWESOME - you guys rock!  I tried each of these and they both cleaned it right up.
: $array[13]=~ y/\000-\037//d;
: $array[13] =~ y/0-9.-//cd;

: I have two questions:
: (1) How do I know if I have non-printing conrol characters?

on unix, use `od' to dump the data.

On windows/dos search for a similar tool (cygwin utilities should have
this).

Or use an editor that shows you what data you really have in your files. 



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

Date: Sat, 24 May 2003 05:37:30 GMT
From: Eric Wilhelm <ericw@nospam.ku.edu>
Subject: Re: Problem with Addition - doesn't interpret as a number?
Message-Id: <pan.2003.05.24.00.34.14.703994.13926@nospam.ku.edu>

On Fri, 23 May 2003 21:58:39 -0500, Dave wrote:

> I have a tab-delimited input file 

>         @array = split("\t",$_);

> 
> What am I missing?  I want to do simple addition and I can't seem to get
> it to work.  Your help is greatly appreciated!

pasted from the bash shell:
echo "1 2 3 4 5" | perl -e 'while ($a=<STDIN>) {

        @array = split("\s+",$a);
        print "*$array[3]*\t";
        $test = $array[3] + 1;
        print "$test\n";
}'
**      1

echo "1 2 3 4 5" | perl -e 'while ($a=<STDIN>) {

        @array = split(/\s+/,$a);
        print "*$array[3]*\t";
        $test = $array[3] + 1;
        print "$test\n";
}'
*4*     5

you need the /regex/ to be marked as /such/

--Eric


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

Date: Sat, 24 May 2003 11:26:49 +0200
From: Lao Coon <laocoon@fastmail.fm>
Subject: Re: Problem with Addition - doesn't interpret as a number?
Message-Id: <Xns9385748836265laocoon@62.153.159.134>

nipper1999@aol.com (Dave) wrote in news:ad817f81.0305231858.723f07a5
@posting.google.com:

> I have a tab-delimited input file I am trying to parse.  I load the
> lines into an array and when I try to add to the numbers in one of the
> columns, it doesn't seem to be converting the array values to numbers.
>  I am using UWIN on Windows XP.  Here is sample code:

use warnings;
use strict;


> while (<INPUT>) {
>         $_ =~ s/(\r|\n)//g;
>         @array = split("\t",$_);
>         print "*$array[13]*\t";
>         $test = $array[13] + 1;
>         print "$test\n";   
> } 
> 
*snip*

Works fine here. Are you sure this is all you're doing?
Could you post a snippet of your input data?

Lao


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

Date: Sat, 24 May 03 04:38:55 GMT
From: e-solutions4u@ziplip.com(Free Cash Loop-hole - Hurry!)
Subject: Send Yourself $1,000 Cash - Straight Away! Guaranteed!
Message-Id: <0305240438551702@news.fish.co.uk>

 
You Will Love This ... Because It Works! 

Not a PROGRAM - Just A LOOP-HOLE!
 
This is too easy! (Need quick cash?..read this!) 

        $$$ - Pay Yourself $1,000 - $$$ 

Yes, It sounds Crazy, But It's True!! 

If you have a US Bank account you can send yourself $1,000 straight to your account simply by faxing a Two Page form to the number of the bank shown on the form.
 
This is a one-off payment...you can only do it once! 

This totally legal and above-board maneouver, utilizes a loop-hole in the banking system which has gone largely unnoticed. The "powers-that-be", have known about this for years. 
Why haven't they closed this loop-hole? ......Who knows!! 

However, you can guarantee that it won't last long now that it is in the public domain...so get your $1,000 cash NOW! 

All you have to do is fax two simple forms to the number provided - and No, you are not asked to give your banking details on them. They will be requested within 24 hours, but that request will come directly from the bank involved - so you can deposit YOUR $1,000 CASH! 

Remember, ALL you need is a US bank account. You do not have to provide your SSN, you do not even need to be a US citizen!! 

When I heard about this, I was as skeptical as you probably are - but I tried it anyway...and within 24hours I got $1,000 cash paid directly into my account from the bank. Now! As I have said, this is a one-off payment...at least 1 x $1,000 per bank account...if you have more than 1 account you are in luck! 

But, as I have already got my free $1,000 (as have all my friends and family, and their friends and families etc) I would like to make a little more while the opportunity still exists. Therefore, if you are interested - and who wouldn't be interested in $1,000 cash - I will send the details of where to go to download and print these forms for the princely sum of $19.95. 

I have been totally upfront with you in admitting that I would like to make a little more cash out of this loop-hole in the system before it is swiftly and without warning, closed forever. I don't believe that $19.95 is too much to pay for an immediate and guaranteed return of $1,000 - Do you? 

And, YES it is Guaranteed! 

But NO you haven't seen this before!... At least I seriously doubt it.  This is NOT that "quick cash secret banking system" nonsense that was going round a year or two back!

This DOES Work!

It works for everyone, as long as they have a US bank account. Everyone...Everytime - NO Exeptions! 

If you want to claim your FREE $1,000 send your payment of $19.95 
to: 

E-gold account # : 480831

Stormpay : e-solutions@ziplip.com

Cashcards International : 286018

Then e-mail us at e-solutions@ziplip.com and provide details of your payment. We will then rush you the URL where you can download your forms from the official site (not our site) and instructions to claim your $1,000 cash! 

The choice is yours - but I can assure you that it will be very difficult to find out about this without our help. (I heard about this from a friend of mine who works within the banking system.) And the longer you wait, the longer it gives the "powers-that-be" to close this loop-hole forever. 

Regards 
Chris & Maxxy
E-solutions

PS If you fail to get your $1,000 cash - ie; if the loop-hole is closed before your request is processed, let us know asap and we will give you a full refund of your $19.95. 





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

Date: Sat, 24 May 2003 01:12:09 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: Using GD::Graph in a CGI
Message-Id: <3ECEC4D8.9070702@rochester.rr.com>

Fernando wrote:

 ... 
> Im using GD::Graph in a CGI to show a graphic whith values taken from a
> form.
> 
> When i click submit button, the graphic that appears is not the one with the
> values i have filled, is the one generated before that one.
> 
 ...


> Maybe this is a problem in the browser, but how can i force it to represent
> allways the new graphic?
> 
> Writing the graphic to a png file with a random name, and then open it whith
> <img src="graphic$random.png"> is a solution that works, but filling the
> directory with many png files doesnt seem to be an 'elegant' solution.
> Moreover, if for any reason two consecutive random numbers are equal, the
> file that is shown is the previous, once again.
> 
> Any suggestions?
 ...


> Fernando
 ...


Try this example program and see how it fares for you.  If it works, you 
can follow after it:


use CGI qw(:standard);
use GD;
if(param('image')){
	print "Content-type: image/png\n\n";
	binmode STDOUT;
	$im = new GD::Image(100,100);
	$lightpurple=$im->colorAllocate(255,200,255);
	$black=$im->colorAllocate(0,0,0);
	$im->interlaced('true');
	$im->line(param('n1'),param('n2'),param('n3'),
		param('n4'),$black);
	print $im->png;
	exit;
}
print header,
	start_html('GD Example'),
	h1('GD Example'),
	start_form,
	textfield('n1'),p,
	textfield('n2'),p,
	textfield('n3'),p,
	textfield('n4'),p,
	"Enter four numbers from 0 to 100 and submit",p,
	submit,
	end_form,
	hr;
if(param()){
	print img{src=>'GDtest.pl?n1='.param('n1').
	'&n2='.param('n2').'&n3='.param('n3').
	'&n4='.param('n4').'&image=yes',width=>100,height=>100};
}
print end_html;

-- 
Bob Walton



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

Date: Sat, 24 May 2003 03:45:59 GMT
From: Michael Budash <mbudash@sonic.net>
Subject: Re: Where should I look?
Message-Id: <mbudash-4DE81B.20460023052003@typhoon.sonic.net>

In article <vct5qv17c33ndc@corp.supernews.com>,
 "Steve" <porter96@lycos.com> wrote:

> Thanks for the help everyone.  Between Michael sending me to a good
> description of the java window.open stuff and Chris pointing out a couple of
> form/html things ... I've got it working.  Thanks for taking the time!
> 
> Best Regards,
> Steve
> 
> 

that's javascipt (not java) 'window.open' - big difference

-- 
Michael Budash


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

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


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