[10906] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4507 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Dec 28 16:37:10 1998

Date: Mon, 28 Dec 98 13:00:19 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Mon, 28 Dec 1998     Volume: 8 Number: 4507

Today's topics:
    Re: A big problem an Medium sized one and an Ickle one. mike@mjm.co.uk
    Re: A big problem an Medium sized one and an Ickle one. mike@mjm.co.uk
    Re: A big problem an Medium sized one and an Ickle one. mike@mjm.co.uk
    Re: A big problem an Medium sized one and an Ickle one. <gellyfish@btinternet.com>
    Re: C wrappers <r28629@email.sps.mot.com>
    Re: Checking for existance of a file <debot@xs4all.nl>
    Re: Checking for existance of a file (Groovy94)
    Re: Checking for existance of a file <dgris@moiraine.dimensional.com>
        ELO ranking system yavin4@new-york.crosswinds.net
    Re: Fixed length Database bug? <rick.delaney@home.com>
    Re: Improve speed of a perl-script medi@cybershell.com
    Re: Installing modules without PPM dturley@pobox.com
        MacPerl: deleting a file PETER@yaleads.ycc.yale.edu
        Need to create a detached process. hi@there.com
        Newest precompiled version of Perl? <Mukke@get2net.dk>
    Re: problem with specific language characters ("v,d,|,_ <Mukke@get2net.dk>
        Programmer Wanted (freelance) - CGI, Perl, C, SQL atomic@one.net
        Removal of NULL's <joe@santoroj.demon.co.uk>
    Re: Sendmail <johntalbert*@home.com>
        Site Search <lewisfre@clem.mscd.edu>
    Re: Splitting multiple |'s (Groovy94)
    Re: Syntactical weirdness? Or is it just me? <uri@sysarch.com>
    Re: When hashing won't work... <rick.delaney@home.com>
    Re: When hashing won't work... (Rick Freeman)
    Re: When hashing won't work... <jeromeo@atrieva.com>
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: Mon, 28 Dec 1998 19:04:10 GMT
From: mike@mjm.co.uk
Subject: Re: A big problem an Medium sized one and an Ickle one.
Message-Id: <3687d5bc.14663686@nntp.netcom.net.uk>

On Mon, 28 Dec 1998 17:50:43 -0000, "Wallace"
<niall_wallace@yahoo.com> wrote:

>Hi,
>
>I was wondering if anybody could help me with a problem,
>
>BIG Problem...
>
>I have in 2 strings the values [12/DEC/1998 and +0000].
>
>The first is the date and the second a time zone.
>
>Although the time zone is not needed
>I need to remove the [ and ] from both of them for part of my Web Log
>Analyser.
>
>I have been un able to think of a way that will work.
>
>The Medium Sized problem
>
>I have a percentage of 1.45343729537057439579749735
>But I only want it to store 1.453 in $Percentage.
>
>I know how to print it using Printf but it has to be stored rounded as well.

$Var=int((1000*$Var)+.5)/1000

>The Ickle problem sized problem...
>
>I need to Round a percentage up or down
>i.e. 0.5 goes to 1    0.4 goes to 0.

$Var=int((10*$Var)+.5)/10

>I have tried using Int but that only rounds down.
>
>I need this so that my graphs are more accurate as I want to base them on
>one block for 5%.
>So far i onlt have it for 1 block = 10%
>
>Tia
>
>Wallace
>
>
>
>

Mike
MjM Computer Publishing

http://www.mjm.co.uk


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

Date: Mon, 28 Dec 1998 19:09:21 GMT
From: mike@mjm.co.uk
Subject: Re: A big problem an Medium sized one and an Ickle one.
Message-Id: <3688d66a.14837553@nntp.netcom.net.uk>

On Mon, 28 Dec 1998 17:50:43 -0000, "Wallace"
<niall_wallace@yahoo.com> wrote:

>Hi,
>
>I was wondering if anybody could help me with a problem,
>
>BIG Problem...
>
>I have in 2 strings the values [12/DEC/1998 and +0000].
>
>The first is the date and the second a time zone.
>
>Although the time zone is not needed
>I need to remove the [ and ] from both of them for part of my Web Log

$Var=~s/\[//g;
$Var=~s/\]//g;

Will remove all occurences of "[" and "]" in the scalar $Var

Mike
>Analyser.
>
>I have been un able to think of a way that will work.
>
>The Medium Sized problem
>
>I have a percentage of 1.45343729537057439579749735
>But I only want it to store 1.453 in $Percentage.
>
>I know how to print it using Printf but it has to be stored rounded as well.
>
>This then leads on to the ickle problem
>
>
>The Ickle problem sized problem...
>
>I need to Round a percentage up or down
>i.e. 0.5 goes to 1    0.4 goes to 0.
>
>I have tried using Int but that only rounds down.
>
>I need this so that my graphs are more accurate as I want to base them on
>one block for 5%.
>So far i onlt have it for 1 block = 10%
>
>Tia
>
>Wallace
>
>
>
>

Mike
MjM Computer Publishing

http://www.mjm.co.uk


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

Date: Mon, 28 Dec 1998 19:12:14 GMT
From: mike@mjm.co.uk
Subject: Re: A big problem an Medium sized one and an Ickle one.
Message-Id: <3689d76a.15094158@nntp.netcom.net.uk>

On Mon, 28 Dec 1998 17:50:43 -0000, "Wallace"
<niall_wallace@yahoo.com> wrote:

>Hi,
>
>I was wondering if anybody could help me with a problem,
>
>BIG Problem...
>
>I have in 2 strings the values [12/DEC/1998 and +0000].
>
>The first is the date and the second a time zone.
>
>Although the time zone is not needed
>I need to remove the [ and ] from both of them for part of my Web Log
>Analyser.
>
>I have been un able to think of a way that will work.
>
>The Medium Sized problem
>
>I have a percentage of 1.45343729537057439579749735
>But I only want it to store 1.453 in $Percentage.
>
>I know how to print it using Printf but it has to be stored rounded as well.

$Var=int((1000*$Var)+.5)/1000

>The Ickle problem sized problem...
>
>I need to Round a percentage up or down
>i.e. 0.5 goes to 1    0.4 goes to 0.

Sorry my last message should have read....

$Var=int(($Var)+.5)


Mike

>I have tried using Int but that only rounds down.
>
>I need this so that my graphs are more accurate as I want to base them on
>one block for 5%.
>So far i onlt have it for 1 block = 10%
>
>Tia
>
>Wallace
>
>
>
>

Mike
MjM Computer Publishing

http://www.mjm.co.uk


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

Date: 28 Dec 1998 20:36:33 -0000
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: A big problem an Medium sized one and an Ickle one.
Message-Id: <768q4h$1dh$1@gellyfish.btinternet.com>

On Mon, 28 Dec 1998 17:50:43 -0000 Wallace <niall_wallace@yahoo.com> wrote:
> Hi,
> 
> I was wondering if anybody could help me with a problem,
> 
> BIG Problem...
> 

  Hmmm

> I have in 2 strings the values [12/DEC/1998 and +0000].
> 
> The first is the date and the second a time zone.
> 
> Although the time zone is not needed
> I need to remove the [ and ] from both of them for part of my Web Log
> Analyser.
> 
> I have been un able to think of a way that will work.
>

I wouldnt have started from there if I were you - you may haved wanted to
parse your log in a different way to start with.  The following snippet is
based on the Apache log on my system but YMMV:

 
#!/usr/bin/perl

while(<DATA>)
{
   if(m/(\d+\.\d+\.\d+\.\d+)\s        # IP Number of client
        (\S*)\s(\S*)\s                # User ?
        \[(.+?):(.+?)\s([+-]\d+)\]\s  # Time
        "([^"]*)"\s                   # Request
        (\d{3})\s                     # Status
        (\d*)$                        # Size of data xfered
       /x
      )
     {
  
       print "Address = ",$1,"\n";
       print "Date    = ",$4,"\n";
       print "Time    = ",$5,"\n";
       print "TZ      = ",$6,"\n";
       print "Request = ",$7,"\n";
       print "Status  = ",$8,"\n";
       print "Amount  = ",$9,"\n";
     }
}
__END__
195.99.59.141 - - [19/Sep/1998:21:06:41 +0000] "GET / HTTP/1.0" 200 1493
195.99.59.141 - - [19/Sep/1998:21:06:41 +0000] "GET /gif/suse_150.gif HTTP/1.0" 200 811

If you have any trouble understanding what is going on there you should read
the perlre manpage.

> The Medium Sized problem
> 

Hmmm

> I have a percentage of 1.45343729537057439579749735
> But I only want it to store 1.453 in $Percentage.
> 
> I know how to print it using Printf but it has to be stored rounded as well.
> 

Of course there is also sprintf ...

> This then leads on to the ickle problem
> 

Hmmm

> 
> The Ickle problem sized problem...
> 
> I need to Round a percentage up or down
> i.e. 0.5 goes to 1    0.4 goes to 0.
> 
> I have tried using Int but that only rounds down.
> 

Again you want to look at [s]printf as is discussed in perlfaq4 although as
I understand it if you want 0.5 to round to 1 then you will have to add .1 to
it before processing with sprintf.


#!/usr/bin/perl

$lower = 0.4;
$middle = 0.5;
$upper = 0.6;

printf "%2.0f\t%2.0f\t%2.0f",$upper,$middle,$lower;

will produce:

 1	0	0



> I need this so that my graphs are more accurate as I want to base them on
> one block for 5%.
> So far i onlt have it for 1 block = 10%
> 

Check out perlfaq4 this discusses most of the issues associated with rounding
and so forth.

You might also want to read the perfunc manpage for more on sprintf.

/J\
-- 
Jonathan Stowe <jns@btinternet.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>


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

Date: Mon, 28 Dec 1998 14:17:16 -0600
From: Tk Soh <r28629@email.sps.mot.com>
Subject: Re: C wrappers
Message-Id: <3687E74C.510DA4CC@email.sps.mot.com>

g00f@mjollnir.org wrote:
> 
> Greetings Perl People:
> 
> Question - if I create a C wrapper for a perl script does this C binary
> suck in the perl script before compile so that I can distribute only
> the C binary, or do I still need to send out the perl script with it?

you are into the "How can I hide the source for my Perl program?"
business. Check perlfaq on this topic.

-TK


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

Date: Mon, 28 Dec 1998 19:01:23 +0100
From: Frank de Bot <debot@xs4all.nl>
Subject: Re: Checking for existance of a file
Message-Id: <3687C773.46DDFF9E@xs4all.nl>

With this line if ( -e "$filename") can you see if the file exists. If the
'ouput' is true the file exist.
You can delete a file with this command: unlink $filename

Stephen Benjamin wrote:

> I am writing a program which generates a fairly random number and then
> writes to a file by that name.   How can I check to see if that file
> already exists or not? Also, how can I delete a file from within perl?
>
> Stephen Benjamin
> Steve.Benjamin@juno.com



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

Date: 28 Dec 1998 19:23:33 GMT
From: groovy94@aol.com (Groovy94)
Subject: Re: Checking for existance of a file
Message-Id: <19981228142333.16504.00002950@ng115.aol.com>

To check the existence of a file,do a -e. This example uses an "if" statement.

if (-e file.txt) {
     do something
}
else {
print "file.txt cannot be found";


Regards,
Gil Hildebrand, Jr.
Dynamic Scripts

Email: groovy94@aol.com
ICQ UIN: 16678754


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

Date: 28 Dec 1998 13:59:34 -0700
From: Daniel Grisinger <dgris@moiraine.dimensional.com>
Subject: Re: Checking for existance of a file
Message-Id: <m367awq8y1.fsf@moiraine.dimensional.com>

groovy94@aol.com (Groovy94) writes:

> To check the existence of a file,do a -e. This example uses an "if"
> statement.
>
> if (-e file.txt) {
>      do something
> }
> else {
> print "file.txt cannot be found";

This doesn't do what you think it does, unless you think that it
checks for the existence of a file (or a directory, or a symlink, etc)
named `filetxt'.  -w would have flagged this for you, and strict would
have made it a fatal error.

dgris
-- 
Daniel Grisinger          dgris@moiraine.dimensional.com
perl -Mre=eval -e'$_=shift;;@[=split//;;$,=qq;\n;;;print 
m;(.{$-}(?{$-++}));,q;;while$-<=@[;;' 'Just Another Perl Hacker'


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

Date: Mon, 28 Dec 1998 19:09:10 GMT
From: yavin4@new-york.crosswinds.net
Subject: ELO ranking system
Message-Id: <768l0l$bg$1@nnrp1.dejanews.com>

Hello,

Does anyone have a program that can be used to keep track of rankings using
the ELO rating system?

Thanks.

Matthew Schultheis

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Mon, 28 Dec 1998 18:08:28 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: Fixed length Database bug?
Message-Id: <3687CAE3.893AA03A@home.com>

[posted & mailed]

Slick! wrote:
> 
> This is only when Amy's age is set to 26, if I change it to 25, or 27
> all works just fine.  I can look at the file created in my hex-editor
> and I can see the value 1A (26) in the correct spot.  Is this a perl
> bug, or am I missing something?  I'm using Active Perl build 508 under
> Win32 (NT4 SP4).

You're missing the fact that for some crazy reason, Win32 treats text
files differently from binary files.

> open(A,"+>d");

You should check the success of open here, but that's not your problem.
Add this after each open:

    binmode A;

perldoc -f binmode

-- 
Rick Delaney
rick.delaney@shaw.wave.ca


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

Date: Mon, 28 Dec 1998 20:38:51 GMT
From: medi@cybershell.com
Subject: Re: Improve speed of a perl-script
Message-Id: <768q8r$4pj$1@nnrp1.dejanews.com>

In article <368744EF.703FD54@iae.nl>,
  Marcel Beekmans <beekmans@iae.nl> wrote:
> I'm building an application for the web. It is a very big appliction, it
> is about 10,000 code-lines. The speed of the appliction is really bad.
> What can I do?
> (It is not  impossible to cut the file into 2 or more separate files).
>
>
I don't believe you can not break your code into multiple files, but
that wouldn't help much any way. Best you get some smaller symbol
tables if you use packaging.

But before you go there, where is your application spending much of
its time. Is it waiting for an answer perhaps (just kidding :-)).
Run time(1) on your program. time(1) is a quick profiling tool. Then
we will talk more.

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Mon, 28 Dec 1998 20:28:01 GMT
From: dturley@pobox.com
Subject: Re: Installing modules without PPM
Message-Id: <768pkf$4a4$1@nnrp1.dejanews.com>

In article <768ejp$qm1$1@nnrp1.dejanews.com>,
  kate_stafford@my-dejanews.com wrote:

>
> I would really love to figure this out. Its not a firewall issue, though,
> because I get the same errors when I try to install locally. I posted the
> error last week, but noone has responded, so I'll stick it out here again:
>
> no element found at line 1, column 0, byte -1 at
> D:\PERL\site\lib/XML/Parser.pm line 117
>
This same error was being  discussed on the AA mailing list last week. No
solutions were reported yet. My guess is that AS broke something on the PPM
server. But it works for me now.

Check the perl-win32-user mailing list at
http://www.activestate.com/support/mailing_lists.htm

You'll have to scroll down, the nav link at the top of the page hasn't worked
ever, and the AS webmaster has never fixed it.

cheers,

David Turley
dturley@pobox.com
http://www.binary.net/dturley/

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Mon, 28 Dec 98 14:54:46 EST
From: PETER@yaleads.ycc.yale.edu
Subject: MacPerl: deleting a file
Message-Id: <1803AD1B6S86.PETER@yaleads.ycc.yale.edu>

Hi.  What is the most elegant way of deleting/erasing files under MacPerl?


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

Date: Sun, 27 Dec 1998 10:04:56 GMT
From: hi@there.com
Subject: Need to create a detached process.
Message-Id: <3686050e.7481688@news.freeserve.net>

Hi.

I'm looking for some Perl sourcecode which will demonstrate EXACTLY
how to create a detached process from a CGI program.  I want my CGI
program to return some HTML to the browser while another process gets
on with something else without the user having to wait until it's
finished.

I've read all the man pages on this stuff but there's NO example code
apart from a few lines, no complete programs.

Any help would be much appreciated.

Please reply to:
nc@cyberdude.com

Thanks.



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

Date: Mon, 28 Dec 1998 15:04:47 +0100
From: "Thomas Turn Jensen" <Mukke@get2net.dk>
Subject: Newest precompiled version of Perl?
Message-Id: <bEQh2.295$Ou1.678@news.get2net.dk>

Hi there

I am currently running perl 5.004_02 (not the activestate thing - the other
one :) but everybody keeps talking about 5.005, so I was wondering if I'm
missing something important with my current version. Problem is I haven't
been able to found a never version anywhere, as I have no c-compiler - nor
do I have any interest in doing my own compilation as I want to have a
version as compatible as posible to what is used at the various
webservers...

SO... what I really would like to know: Is there a newer version foro me out
there somewhere?

Thank you in advance

***
Thomas Turn Jensen
Icq uin => 8128636
IRC, Undernet => Mukke
***
So long, and thanks for all the fish
***





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

Date: Mon, 28 Dec 1998 14:47:46 +0100
From: "Thomas Turn Jensen" <Mukke@get2net.dk>
Subject: Re: problem with specific language characters ("v,d,|,_")
Message-Id: <aEQh2.294$Ou1.678@news.get2net.dk>

Well... How do you deal with other special characters? Data sent via a form
or in the URL is URL-encoded, meaning that space ( ) is changed to + and
characters with ascii value of 128+ are converted to %xx where xx is the
HEX-equiliant of the ascii value. This means that whenever you gather data
from a form, you need to do something like this:

$Value =~ s/+/ /g;
$Value =~ s/%(..)/pack("c",hex($1))/ge;

Where $Value should hold the bare data form the start.
Notice that you CANNOT do this from the very beginning if you need to
seperate the form-inputs into diferent key = value pairs, as the above
translation may result in extra =; the user may have typed = in the input
fields too....

Per standard, I use this to get my data as I want it:

@in = split(/&/,$in);
foreach $i (0 .. $#in)
{
  $in[$i] =~ s/\+/ /g;
  ($key, $val) = split(/=/,$in[$i],2);
  $key =~ s/%(..)/pack("c",hex($1))/ge;
  $val =~ s/%(..)/pack("c",hex($1))/ge;
  $in{$key} .= $val;
}

Before this you need to assign $in to the form input....
After you have run the above, you will be able to access the form data in
this maner (for simplicity, we say we had a form holding "Firstname"- and
"Surname"-fields):
$Firstname = $in{Firstname}
$Surname = $in{Surname}

That is - to get the value of a key(Name of a field) use value = $in{key}

Hope this helped you.

***
Thomas Turn Jensen
Icq uin => 8128636
IRC, Undernet => Mukke
***
So long, and thanks for all the fish
***


Martin Schager skrev i meddelelsen <36863AAF.93BA5AB5@vienna.at>...
>If someone submits information via a form, that contains v,d,|,_, I get
>strange %something instead of these characters, when I process the form.
>Is there any solution to this problem?
>
>




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

Date: Mon, 28 Dec 1998 20:18:38 GMT
From: atomic@one.net
Subject: Programmer Wanted (freelance) - CGI, Perl, C, SQL
Message-Id: <768p2s$3r1$1@nnrp1.dejanews.com>

To whom it may concern,

Our company is looking for an honest, dedicated, programmer, to develope a
dynamic internet database. Must have a large amount of experience with any
of the following: Perl, C, C++, or SQL.

Please submit resume and references in MS word or text format to -
atomic@one.net  Telecommuters welcome!

Michael M. Burch
Atomic Computers and Design

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Mon, 28 Dec 1998 19:36:37 +0000
From: Joe Santoro <joe@santoroj.demon.co.uk>
Subject: Removal of NULL's
Message-Id: <3687DDC5.4563B4DC@santoroj.demon.co.uk>

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


Hi,

I have a number of files which have NULL's in them

i.e.

1234.ABCD.NULLNULLNULL  NULL.5678

How do I remove just the NULL's from the files ?

Thanks

Joe..

--------------92D102AE4A4209A6E652F5CE
Content-Type: text/x-vcard; charset=us-ascii;
 name="joe.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: Card for Joe Santoro
Content-Disposition: attachment;
 filename="joe.vcf"

begin:vcard 
n:Santoro;Joe 
tel;work:(+44) 958 402172
x-mozilla-html:TRUE
org:J.S Unix Consultants Ltd;Technical Support
adr:;;;;;;England
version:2.1
email;internet:joe@santoroj.demon.co.uk
note;quoted-printable:All unsolicited commercial E-mail sent to this address is =0D=0Asubject to a download and archival fee in the amount of =A3500=0D=0AE-mailing denotes acceptance of these terms.
x-mozilla-cpt:;-1
fn:Joe  Santoro
end:vcard

--------------92D102AE4A4209A6E652F5CE--



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

Date: Mon, 28 Dec 1998 20:24:39 GMT
From: "John Talbert" <johntalbert*@home.com>
Subject: Re: Sendmail
Message-Id: <bORh2.3778$Uv.315@news.rdc1.va.home.com>

I appreciate the information... I will give it a try...


J.

--

*** Remove the *s from my E-Mail address to reply ***

Mike Schechter wrote in message <3682b239.16586770@news.earthlink.net>...

>You can also try Blat, which you can find at:
>
>http://gepasi.dbs.aber.ac.uk/softw/Blat.html
>
>I have successfully used it on NT and 95 machines.
>
>Mike Schechter
>




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

Date: Mon, 28 Dec 1998 11:16:27 -0700
From: creep <lewisfre@clem.mscd.edu>
Subject: Site Search
Message-Id: <3687CAFB.EFDB9216@clem.mscd.edu>

I was wondering if anyone know of a script that would allow a personal
to do a site search of a web site from a frame and search content
through keywords and target the output HTML file to it's parent
frameset?

13alone@netscape.net




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

Date: 28 Dec 1998 19:26:12 GMT
From: groovy94@aol.com (Groovy94)
Subject: Re: Splitting multiple |'s
Message-Id: <19981228142612.16504.00002955@ng115.aol.com>

Thanks, but someone earlier helped me and I got it working great. I didn't
dismiss | from being a regular variable. In other words, I forgot to do /\|/


Regards,
Gil Hildebrand, Jr.
Dynamic Scripts

Email: groovy94@aol.com
ICQ UIN: 16678754


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

Date: 28 Dec 1998 12:59:27 -0500
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Syntactical weirdness? Or is it just me?
Message-Id: <x7pv94gnb4.fsf@sysarch.com>

>>>>> "DG" == Daniel Grisinger <dgris@moiraine.dimensional.com> writes:

  DG> Uri Guttman <uri@sysarch.com> writes:
  F> Print thinks that
     ^^^^^
i did a mental s/print/perl/

  F> everything is a list unless you tell it otherwise. Since your list
  >> 
  >> how untrue. perl doesn't think about your code at all. context is
  >> provided by the operator(s) next to the the given op and by their
  >> precedence and syntax. you can always predict the context by looking at
  >> the code. there is NO default context.

  DG> Perhaps you misread.  The poster was right in that C<print> is
  DG> always a listop unless one takes steps to force scalar context
  DG> (in which case, print is still a listop, but it's arguments may
  DG> be evaluated otherwise).

guess what. i just reread the original post and my brain must have not
woke up. i read "print" as "perl". 

i need new eyeballs. i even said in another post that i am asleep right
now.

uri

-- 
Uri Guttman  -----------------  SYStems ARCHitecture and Software Engineering
Perl Hacker for Hire  ----------------------  Perl, Internet, UNIX Consulting
uri@sysarch.com  ------------------------------------  http://www.sysarch.com
The Best Search Engine on the Net -------------  http://www.northernlight.com


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

Date: Mon, 28 Dec 1998 18:19:29 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: When hashing won't work...
Message-Id: <3687CD77.E9989F6C@home.com>

[posted & mailed]

Rick Freeman wrote:
> 
> Sometimes, though, when I want to do something like that, I can't
> because hash keys can only consist of certain characters.  For
> instance, I can't use a hash to do the above mentioned sorts of things
> with a list of email addresses... foo@bar.com will not work as a hash
> key.

You can use any kind of characters in a hash key since the key is just a
string. 

    $key = 'foo@bar.com';
    $hash{$key} = 'Value for foo.';
    print $hash{'foo@bar.com'};

This prints 'Value for foo.'  

What kind of code do you have that isn't working?  Are you trying to
code the keys unquoted?  $hash{foo@bar.com} will surely give you
problems, but it is never necessary to do this.

> Is there a way around this kind of situation?

Yes.  Quote your strings.  

-- 
Rick Delaney
rick.delaney@shaw.wave.ca


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

Date: Mon, 28 Dec 1998 18:29:25 GMT
From: rick@marinweb.com (Rick Freeman)
Subject: Re: When hashing won't work...
Message-Id: <368bcdee.5781437@nntp2.ba.best.com>

On Mon, 28 Dec 1998 17:53:54, in comp.lang.perl.misc,  I wrote:
>I'm relatively new to Perl

There's the problem!

Sorry for posting my invalid assumption regarding acceptable values
for hash keys.

And thanks for the help!

Rick


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

Date: Mon, 28 Dec 1998 10:20:37 -0800
From: Jerome O'Neil <jeromeo@atrieva.com>
To: rick@marinweb.com
Subject: Re: When hashing won't work...
Message-Id: <3687CBF5.9EC2E1B8@atrieva.com>

Rick Freeman wrote:

> Sometimes, though, when I want to do something like that, I can't
> because hash keys can only consist of certain characters.  For
> instance, I can't use a hash to do the above mentioned sorts of things
> with a list of email addresses... foo@bar.com will not work as a hash
> key.

Without code, I'm not quite sure what the problem is, (although I'll
make a guess).

#!/usr/local/bin/perl -w
my(%hash) = (
                'jeromeo@atrieva.com' => 'Cool Daddy!',
                'president@whitehouse.gov' => 'Shugar Daddy!',
                'billg@microsoft.com' => 'Big Daddy!',
            );

print $hash{'jeromeo@atrieva.com'}, qq{\n};

vortex% hashkey
Cool Daddy!

However, I'm willing to bet you are trying to do this (or something
similar)

#!/usr/local/bin/perl
my(%hash) = (
                "jeromeo@atrieva.com" => 'Cool Daddy!', #Note double
quote.
                "president@whitehouse.gov" => 'Shugar Daddy!',
                "billg@microsoft.com" => 'Big Daddy!',
            );

print $hash{"jeromeo@atrieva.com"}, qq{\n};

vortex% hashkey
Literal @atrieva now requires backslash at hashkey line 3, within string
Literal @whitehouse now requires backslash at hashkey line 4, within
string
Literal @microsoft now requires backslash at hashkey line 5, within
string
Execution of hashkey aborted due to compilation errors.

So escape the @:   $email =~ s/@/\@/; # Untested, YMMV

or use single quotes.  Also, see the perlop manpage and pay attention to
the quote and quote-like operators.

Good Luck! 

-- 
Jerome O'Neil, Operations and Information Services
Atrieva Corporation, 600 University St., Ste. 911, Seattle, WA 98101
jeromeo@atrieva.com - Voice:206/749-2947 
The Atrieva Service: Safe and Easy Online Backup  http://www.atrieva.com


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

Date: 12 Dec 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Special: Digest Administrivia (Last modified: 12 Dec 98)
Message-Id: <null>


Administrivia:

Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing. 

]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body.  Majordomo will then send you instructions on how to confirm your
]subscription.  This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.

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.misc (and this Digest), send your
article to perl-users@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.

The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.

The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.

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 V8 Issue 4507
**************************************

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