[19253] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1448 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Aug 6 03:05:57 2001

Date: Mon, 6 Aug 2001 00:05:12 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <997081512-v10-i1448@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Mon, 6 Aug 2001     Volume: 10 Number: 1448

Today's topics:
    Re: Additional questions (Alan Barclay)
    Re: Additional questions <Tassilo.Parseval@post.rwth-aachen.de>
    Re: Allowing ONLY letters and spaces in regular express <Tassilo.Parseval@post.rwth-aachen.de>
    Re: Allowing ONLY letters and spaces in regular express <bcaligari@fireforged.com>
    Re: Allowing ONLY letters and spaces in regular express (Logan Shaw)
    Re: Allowing ONLY letters and spaces in regular express <miscellaneousemail@yahoo.com>
    Re: Call Javascript from Perl (wade)
    Re: CGI.pm file upload problem - Please Help! <dan@nospam_dtbakerprojects.com>
    Re: comp.infosystems.www.authoring.cgi now moderated <SEE_MY_SIG@nospam.demon.co.uk>
    Re: config for @INC ... more info <dan@nospam_dtbakerprojects.com>
        config for @INC behavior on windows machine? <dan@nospam_dtbakerprojects.com>
    Re: Error installing packages using ActiveState ppm (Anthony_Barker)
        FAQ: How can I always keep my hash sorted? <faq@denver.pm.org>
        FAQ: What's the difference between "delete" and "undef" <faq@denver.pm.org>
    Re: FAQ: What's the difference between "delete" and "un <uri@sysarch.com>
    Re: filename expansion <andrew.savige@ir.com>
    Re: filename expansion <kevin@vaildc.net>
        help a senior citizen newbie <americamba@highstream.net>
    Re: help a senior citizen newbie (Logan Shaw)
    Re: help a senior citizen newbie <bwalton@rochester.rr.com>
    Re: How to print a binary string as picture to web page <ryan@bong.net>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 5 Aug 2001 22:23:35 GMT
From: gorilla@elaine.furryape.com (Alan Barclay)
Subject: Re: Additional questions
Message-Id: <997050163.64993@elaine.furryape.com>

In article <3B6CAD56.5010302@post.rwth-aachen.de>,
Tassilo von Parseval  <Tassilo.Parseval@post.rwth-aachen.de> wrote:
>Still very suspect. Mark this: $_ does not contain the first argument to 
>the subroutine call. It is just empty. Arguments are to be found in @_, 
>so the first argument is $_[0].

Of course it doesn't. However the original poster was asking for a function
which uses $_ as a default if it is not passed any arguments.



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

Date: Mon, 06 Aug 2001 08:05:13 +0200
From: Tassilo von Parseval <Tassilo.Parseval@post.rwth-aachen.de>
Subject: Re: Additional questions
Message-Id: <3B6E3399.4090702@post.rwth-aachen.de>

Alan Barclay wrote:

>In article <3B6CAD56.5010302@post.rwth-aachen.de>,
>Tassilo von Parseval  <Tassilo.Parseval@post.rwth-aachen.de> wrote:
>
>>Still very suspect. Mark this: $_ does not contain the first argument to 
>>the subroutine call. It is just empty. Arguments are to be found in @_, 
>>so the first argument is $_[0].
>>
>
>Of course it doesn't. However the original poster was asking for a function
>which uses $_ as a default if it is not passed any arguments.
>

Hmmh, reading the OP's two posts again, he indeed seems to have posted a 
somewhat different question as the one I had answered to. Yet, what you 
suggested wont work since a subroutine is lexically scoped so assigning 
$_ to a sub-variable in case @_ is empty will assign an empty value.

What he wants is probably this, if I understood that correctly now:

for (@array) {
    mysub;
}

where mysub should automatically be called with each array-element if 
not passed explicitely to the sub. I have not the faintest idea how this 
could be done or whether it is possible at all.


Tassilo

-- 
$a=[(74,116)];$b=[($a->[1]-1,$a->[1]++,0x20)];$c=[(97,110)];$d=[($c->
[1]+1,$b->[1],"her")];for(@{[$a,$b,$c,$d]}){for(@{$_}){$_=~/\d+/?print
(chr($_)):print;}}$c=sub{$l=shift;[(0x20+$l-1,0x50,0x65,0x73-0x01,108
),(0x20,0x68,0x61,)]};print(map{chr($_)}@{($c->(1))});$h={a=>33*3,b=>
10**2+7,c=>"1"."0"."1",d=>0162};@h=sort(keys(%$h));for(@h){print(chr(
ord(chr($h->{$_}))))};





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

Date: Mon, 06 Aug 2001 07:52:49 +0200
From: Tassilo von Parseval <Tassilo.Parseval@post.rwth-aachen.de>
Subject: Re: Allowing ONLY letters and spaces in regular expression??
Message-Id: <3B6E30B1.6010508@post.rwth-aachen.de>

Carlos C. Gonzalez wrote:

>In article <9kl546$e0q$1@bob.news.rcn.net>, Eric Bohlman at 
>ebohlman@omsdev.com says...
>
>>Because, in English, your test reads "if there are no ASCII letters in the
>>string" whereas you want it to read "if there's anything other than ASCII
>>letters in the string"; one way to accomplish that is:
>>
>>if ($string =~ /[^a-zA-Z]/)
>>
>
>Thanks Eric but I still don't understand.  Your example does exactly what 
>I want but I don't undertand why.  The following works...
>
>my $string = "San Jose";
>
>if ($string =~ /[^a-zA-Z]/) {
>  print "Invalid characters in string." # WHY?  Aren't letters valid??
>}	  
>else {
>  print "Valid chars in string."	  
>}	  	  
>
>since I only want letters to be valid.  No spaces or any other 
>characters.  Would you read the above as saying "if $string starts with 
>any lowercase or upper case letters".  Is this right?  
>

No. It reads:

If $string does not containg one of the letters in a-z and A-Z. [ ] 
denotes a set of characters to match. The ^ inside the brackets (and 
only there) negate the character class.

A regex that would read as you said (if $string starts with lower- or 
uppercase letter) would be this:
if ($string =~ /^[a-zA-Z]/)

Mark the difference between the up-arrow being inside the brackets (thus 
negating a set of characters) or outside indicating the beginning of a 
string.

>Or maybe "if $string starts with an "a" followed by any lower or upper 
>case letters"?  
>

No, this would be:
if ($string =~ /^a[a-zA-Z]/)

>What I don't get is why the above code flags all letters as Valid while 
>the inclusion of a space is flagged as invalid?  
>

This happens because the space was not included in the character-class [ 
]. If you want to allow it, write /[^a-zA-Z\s]/ where \s stands for a 
whitespace.
You should check 'perldoc perlre' to learn more about the Perl regular 
expressions.

Tassilo


-- 
$a=[(74,116)];$b=[($a->[1]-1,$a->[1]++,0x20)];$c=[(97,110)];$d=[($c->
[1]+1,$b->[1],"her")];for(@{[$a,$b,$c,$d]}){for(@{$_}){$_=~/\d+/?print
(chr($_)):print;}}$c=sub{$l=shift;[(0x20+$l-1,0x50,0x65,0x73-0x01,108
),(0x20,0x68,0x61,)]};print(map{chr($_)}@{($c->(1))});$h={a=>33*3,b=>
10**2+7,c=>"1"."0"."1",d=>0162};@h=sort(keys(%$h));for(@h){print(chr(
ord(chr($h->{$_}))))};





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

Date: Mon, 6 Aug 2001 06:18:21 -0000
From: "B. Caligari" <bcaligari@fireforged.com>
Subject: Re: Allowing ONLY letters and spaces in regular expression??
Message-Id: <9kl5gr02ugl@enews1.newsguy.com>


"Carlos C. Gonzalez" <miscellaneousemail@yahoo.com> wrote in message
news:MPG.15d7c103a020f8a989709@news.edmonton.telusplanet.net...
> Hi everyone,
>
> Given the following code why does it print out "Valid chars in string."?
>
> In other words why does the space between "San" and "Jose" not make the
> if expression true?
>
> my $string = "San Jose";
>
> if ($string !~ /[a-zA-Z]/) {
>   print "Invalid characters in string."
> }
> else {
>   print "Valid chars in string."
> }
>

Because there ARE valid chars in the string to
match with that expression!!!

    if ($string !~ m/^[a-zA-Z]*$/)    {

should work as you expect it

B





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

Date: 6 Aug 2001 00:36:35 -0500
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: Allowing ONLY letters and spaces in regular expression??
Message-Id: <9klad3$apd$1@charity.cs.utexas.edu>

In article <MPG.15d7cf43920d3d9698970b@news.edmonton.telusplanet.net>,
Carlos C. Gonzalez  <miscellaneousemail@yahoo.com> wrote:
>Thanks Eric but I still don't understand.  Your example does exactly what 
>I want but I don't undertand why.  The following works...
>
>my $string = "San Jose";
>
>if ($string =~ /[^a-zA-Z]/) {
>  print "Invalid characters in string." # WHY?  Aren't letters valid??
>}	  
>else {
>  print "Valid chars in string."	  
>}	  	  
>
>since I only want letters to be valid.  No spaces or any other 
>characters.  Would you read the above as saying "if $string starts with 
>any lowercase or upper case letters".  Is this right?  

No.  The carat has that meaning when it's the very first character of
the regular expression, but only then.  When the carat occurs as the
first character inside square brackets, it means that the characters
following it are the ones to be excluded from the set.  So, while 

	[a-zA-Z]

matches any one character from the list

	abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ

the expression

	[^a-zA-Z]

matches any character not in that list.

>Or maybe "if $string starts with an "a" followed by any lower or upper 
>case letters"?  
>
>What I don't get is why the above code flags all letters as Valid while 
>the inclusion of a space is flagged as invalid?  

The above regular expression is "looking for" a single character which
isn't a lowercase or uppercase letter.  Since the space character
isn't, the regular expression matches it, and the conditional is true.

  - Logan
-- 
"Our grandkids love that we get Roadrunner and digital cable."
(Advertisement for Time Warner cable TV and internet access, July 2001)


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

Date: Mon, 06 Aug 2001 06:41:26 GMT
From: Carlos C. Gonzalez <miscellaneousemail@yahoo.com>
Subject: Re: Allowing ONLY letters and spaces in regular expression??
Message-Id: <MPG.15d7ea32bfbdc78598970c@news.edmonton.telusplanet.net>

In article <3B6E30B1.6010508@post.rwth-aachen.de>, Tassilo von Parseval 
at Tassilo.Parseval@post.rwth-aachen.de says...

> The ^ inside the brackets (and 
> only there) negate the character class.
> 

That explains it.  For the life of me I couldn't figure out why the ^ 
character was included and it's effect.  Everywhere I read it said that 
this character tied the match to the beginning of the string but I just 
couldn't figure out what that had to do with a space character in the 
middle of the string. 

I don't remember seeing that including it inside brackets made it into 
something else.  

This is what can make Perl so confusing sometimes.  That different 
symbols can mean different things in the context.  When Perl is confusing 
like this I suppose it is tantamount to learning how to speak Chinese.  I 
understand that words in that language are also somewhat dependent on the 
context in which they are spoken.  

Thanks Tassilo and to everyone who responded.  I kept looking and 
reading, looking and reading some more all over the place (including my 
own copy of Learning Perl) and just couldn't figure it out.

-- 
Carlos 
www.internetsuccess.ca


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

Date: 5 Aug 2001 23:43:34 -0700
From: jjchen@alumni.ice.ntnu.edu.tw (wade)
Subject: Re: Call Javascript from Perl
Message-Id: <4259465b.0108052243.944e061@posting.google.com>

"Ron Savage" <ron@savage.net.au> wrote in message news:<E63b7.4447$257.197569@ozemail.com.au>...
> Xingfu
> 
> See below.
> 
> 
> Xingfu Wu <wuxf@ece.northwestern.edu> wrote in message news:3B6B1001.5483E73E@ece.northwestern.edu...
> > I use CGI.pm to pass a variable value to Javascript, I need to pass a
> > variable value from Javascript to Perl. I heard that PerlConnect of
> > mozilla.org can do that, but I do not know where I can get the version
> > for linux.
> 
> Any Perl script can pass data back and forth between Perl variables and JavaScript variables.
> 
> See tut 39 for a demo: http://savage.net.au/Perl-tutorials.html

use "form" in HTML, normally, you can use 
<INPUT type=hidden name=YOUR_VAR_NAME value=V>
 ....
use CGI qw(param);
my $YOUR_VAR_NAME = param ('YOUR_VAR_NAME');


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

Date: Sun, 05 Aug 2001 22:23:37 GMT
From: Dan Baker <dan@nospam_dtbakerprojects.com>
Subject: Re: CGI.pm file upload problem - Please Help!
Message-Id: <3B6DC7B3.DB0692D8@nospam_dtbakerprojects.com>



"John W. Krahn" wrote:

> > [snip]
> >
> >         # figure out filename to save it as, and make sure it is "legal"
> >         # -----
> >         $UploadedImage =~ s/.*[\\|\/](.+)$/$1/ ; # grab end of path passed in
>                                  ^^^^^
> You're looking a '\' or a '|' or a '/' in the file path. What would
> happen with the file '/home/dan/html/foo|bar.jpg'?
-------------

this and other points well taken.... after all it is a snip from an
*old* project I had going. Not really meant to be bulletproof. Assuming
a "polite" user in several cases, and not checking system returns as
noted. ;)

D


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

Date: Mon, 6 Aug 2001 05:42:04 +0100
From: James Taylor <SEE_MY_SIG@nospam.demon.co.uk>
Subject: Re: comp.infosystems.www.authoring.cgi now moderated
Message-Id: <ant060404345fNdQ@oakseed.demon.co.uk>

In article <9kiclb$dma$2@news1.Radix.Net>,
revjack <revjack@revjack.net> wrote:
>
> James Taylor wrote:
> >
> > Hey, Godzilla's got a point. I wouldn't want to post to
> > that group without spam blocking my address. 
> 
> That's a different point. Don't post with a bogus address.

Why not? If I always include my real address in my sig then
I can still be contacted privately by anyone who really
feels they must. Having said that I'd *much* rather have my
news posts answered in the group than by private email. Too
many people (annoyingly redundantly) email their news
replies to me as it is so I am only too glad that a side
effect of spam blocking my address is that people on Usenet
have to really *want* to email me in order to do so.

Also, it's not like I'm trying to remain anonymous and
unaccountable or anything, but even if I were, isn't it
everyone's right to remain anonymous if they choose?

> Doing so only foists the problem onto someone else.

I'm not sure what you mean by this.

> Stand up and fight, or don't complain.

Hey, I've got a life. Where do you imagine I should conjure
up the time to do all this fighting? What kind of fighting
are you advocating anyway? And who said I was complaining?

I think you're picking on the wrong guy. I given the issue
of spam blocking on Usenet considerable thought, and for me
the best compromise is the one I'm now using.

-- 
James Taylor <james (at) oakseed demon co uk>
Based in Southam, Cheltenham, UK.
PGP key available ID: 3FBE1BF9
Fingerprint: F19D803624ED6FE8 370045159F66FD02



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

Date: Mon, 06 Aug 2001 02:52:27 GMT
From: Dan Baker <dan@nospam_dtbakerprojects.com>
Subject: Re: config for @INC ... more info
Message-Id: <3B6E06B2.837F07E3@nospam_dtbakerprojects.com>

a little more testing confirms that the machine that behaves as expected
considers the working directory ./ to be the dir that whatever.pl is
executed in via the double-click.  The machine that DOESN'T work "right"
always treats ./ like it is c:\usr\bin , which is where the perl.exe is
installed.

This *may* be the root of the issues for me, so my question is:

- in windows98, how can I change the double-click execution of a perl
script to use the dir that the script is in as the default working
directory for the MS-DOS process that opens and runs, rather than using
the dir that the perl executable is in?

thanx,

D


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

Date: Mon, 06 Aug 2001 01:17:27 GMT
From: Dan Baker <dan@nospam_dtbakerprojects.com>
Subject: config for @INC behavior on windows machine?
Message-Id: <3B6DF06F.2CEE2E19@nospam_dtbakerprojects.com>

I have perl installed on two machines at home. One is a desktop where
everything works as expected... Both are installed with the same version
of perl, but at different times. Perl on the laptop *mostly* works as
expected, but has one thing in particular that is strange when I execute
a utility script by double-clicking in a windows explorer window. I
can't seem to find a difference between the way I have perl setup, but
it certainly acts different!

What is happening is that @INC doesn't seem to behave the same on the
laptop. Even though "." is in @INC, it doesn't seem to "find" a local
sub that I require"" in the main script unless I put in the entire path. 

Anyone familiar enough with the perl installation and possible MD-DOS
configuration issues to help with this? files I should check?
configuration for the dble-click to work correctly?

thanx,

D


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

Date: 5 Aug 2001 19:06:41 -0700
From: anthony_barker@hotmail.com (Anthony_Barker)
Subject: Re: Error installing packages using ActiveState ppm
Message-Id: <899f842.0108051806.33307921@posting.google.com>

Just incase anyone else has this problem... I re-downloaded the
ActiveState package - reinstalled and voila ! no more problems....

Anthony

anthony_barker@hotmail.com (Anthony_Barker) wrote in message news:<899f842.0107310537.3e7ce53b@posting.google.com>...
> Hi
> 
> I am using 5.6.1 of ActiveState perl (unfortunately must be Windoze).
> Trying to install different pod packages.
> 
> Get the error:
> 
> Error installing package 'Net-DNS': Read a PPD for 'Net-DNS', but it
> is not intended for this build of Perl (MSWin32-x86-multi-thread).
> 
> Also go to activestate site directly, download and install from hard
> drive - same error. Tried many other packages... all same error.
> 
> Is there a problem with this version of ActiveState? I read somewhere
> else that another person downgraded his version and the error went
> away.
> 
> Any suggestions?
> 
> Anthony Barker


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

Date: Mon, 06 Aug 2001 00:17:01 GMT
From: PerlFAQ Server <faq@denver.pm.org>
Subject: FAQ: How can I always keep my hash sorted?
Message-Id: <1mlb7.49$T3.171032576@news.frii.net>

This message is one of several periodic postings to comp.lang.perl.misc
intended to make it easier for perl programmers to find answers to
common questions. The core of this message represents an excerpt
from the documentation provided with every Standard Distribution of
Perl.

+
  How can I always keep my hash sorted?

    You can look into using the DB_File module and tie() using the $DB_BTREE
    hash bindings as documented in the section on "In Memory Databases" in
    the DB_File manpage. The Tie::IxHash module from CPAN might also be
    instructive.

- 

Documents such as this have been called "Answers to Frequently
Asked Questions" or FAQ for short.  They represent an important
part of the Usenet tradition.  They serve to reduce the volume of
redundant traffic on a news group by providing quality answers to
questions that keep coming up.

If you are some how irritated by seeing these postings you are free
to ignore them or add the sender to your killfile.  If you find
errors or other problems with these postings please send corrections
or comments to the posting email address or to the maintainers as
directed in the perlfaq manual page.

Answers to questions about LOTS of stuff, mostly not related to
Perl, can be found by pointing your news client to

    news:news.answers

or to the many thousands of other useful Usenet news groups.

Note that the FAQ text posted by this server may have been modified
from that distributed in the stable Perl release.  It may have been
edited to reflect the additions, changes and corrections provided
by respondents, reviewers, and critics to previous postings of
these FAQ. Complete text of these FAQ are available on request.

The perlfaq manual page contains the following copyright notice.

  AUTHOR AND COPYRIGHT

    Copyright (c) 1997-1999 Tom Christiansen and Nathan
    Torkington.  All rights reserved.

This posting is provided in the hope that it will be useful but
does not represent a commitment or contract of any kind on the part
of the contributers, authors or their agents.

                                                           04.58
-- 
    This space intentionally left blank


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

Date: Mon, 06 Aug 2001 06:17:01 GMT
From: PerlFAQ Server <faq@denver.pm.org>
Subject: FAQ: What's the difference between "delete" and "undef" with hashes?
Message-Id: <xDqb7.58$T3.171032576@news.frii.net>

This message is one of several periodic postings to comp.lang.perl.misc
intended to make it easier for perl programmers to find answers to
common questions. The core of this message represents an excerpt
from the documentation provided with every Standard Distribution of
Perl.

+
  What's the difference between "delete" and "undef" with hashes?

    Hashes are pairs of scalars: the first is the key, the second is the
    value. The key will be coerced to a string, although the value can be
    any kind of scalar: string, number, or reference. If a key "$key" is
    present in the array, "exists($key)" will return true. The value for a
    given key can be "undef", in which case "$array{$key}" will be "undef"
    while "$exists{$key}" will return true. This corresponds to ("$key",
    "undef") being in the hash.

    Pictures help... here's the "%ary" table:

              keys  values
            +------+------+
            |  a   |  3   |
            |  x   |  7   |
            |  d   |  0   |
            |  e   |  2   |
            +------+------+

    And these conditions hold

            $ary{'a'}                       is true
            $ary{'d'}                       is false
            defined $ary{'d'}               is true
            defined $ary{'a'}               is true
            exists $ary{'a'}                is true (Perl5 only)
            grep ($_ eq 'a', keys %ary)     is true

    If you now say

            undef $ary{'a'}

    your table now reads:

              keys  values
            +------+------+
            |  a   | undef|
            |  x   |  7   |
            |  d   |  0   |
            |  e   |  2   |
            +------+------+

    and these conditions now hold; changes in caps:

            $ary{'a'}                       is FALSE
            $ary{'d'}                       is false
            defined $ary{'d'}               is true
            defined $ary{'a'}               is FALSE
            exists $ary{'a'}                is true (Perl5 only)
            grep ($_ eq 'a', keys %ary)     is true

    Notice the last two: you have an undef value, but a defined key!

    Now, consider this:

            delete $ary{'a'}

    your table now reads:

              keys  values
            +------+------+
            |  x   |  7   |
            |  d   |  0   |
            |  e   |  2   |
            +------+------+

    and these conditions now hold; changes in caps:

            $ary{'a'}                       is false
            $ary{'d'}                       is false
            defined $ary{'d'}               is true
            defined $ary{'a'}               is false
            exists $ary{'a'}                is FALSE (Perl5 only)
            grep ($_ eq 'a', keys %ary)     is FALSE

    See, the whole entry is gone!

- 

Documents such as this have been called "Answers to Frequently
Asked Questions" or FAQ for short.  They represent an important
part of the Usenet tradition.  They serve to reduce the volume of
redundant traffic on a news group by providing quality answers to
questions that keep coming up.

If you are some how irritated by seeing these postings you are free
to ignore them or add the sender to your killfile.  If you find
errors or other problems with these postings please send corrections
or comments to the posting email address or to the maintainers as
directed in the perlfaq manual page.

Answers to questions about LOTS of stuff, mostly not related to
Perl, can be found by pointing your news client to

    news:news.answers

or to the many thousands of other useful Usenet news groups.

Note that the FAQ text posted by this server may have been modified
from that distributed in the stable Perl release.  It may have been
edited to reflect the additions, changes and corrections provided
by respondents, reviewers, and critics to previous postings of
these FAQ. Complete text of these FAQ are available on request.

The perlfaq manual page contains the following copyright notice.

  AUTHOR AND COPYRIGHT

    Copyright (c) 1997-1999 Tom Christiansen and Nathan
    Torkington.  All rights reserved.

This posting is provided in the hope that it will be useful but
does not represent a commitment or contract of any kind on the part
of the contributers, authors or their agents.

                                                           04.59
-- 
    This space intentionally left blank


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

Date: Mon, 06 Aug 2001 06:24:35 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: FAQ: What's the difference between "delete" and "undef" with hashes?
Message-Id: <x7hevlzoww.fsf@home.sysarch.com>

>>>>> "PS" == PerlFAQ Server <faq@denver.pm.org> writes:

  PS>     Hashes are pairs of scalars: the first is the key, the second is the
  PS>     value. The key will be coerced to a string, although the value can be
  PS>     any kind of scalar: string, number, or reference. If a key "$key" is
  PS>     present in the array, "exists($key)" will return true. The value for a
  PS>     given key can be "undef", in which case "$array{$key}" will be "undef"
  PS>     while "$exists{$key}" will return true. This corresponds to ("$key",
                 ^
no $

  PS>             defined $ary{'a'}               is true
  PS>             exists $ary{'a'}                is true (Perl5 only)

does that perl5 comment need to be there?

  PS>             defined $ary{'a'}               is FALSE
  PS>             exists $ary{'a'}                is true (Perl5 only)

same

  PS>             exists $ary{'a'}                is FALSE (Perl5 only)

one more time.

well, shouldn't they told to read the docs on exists? 

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture and Stem Development ------ http://www.stemsystems.com
Search or Offer Perl Jobs  --------------------------  http://jobs.perl.org


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

Date: Mon, 6 Aug 2001 10:37:57 +1000
From: "Knob" <andrew.savige@ir.com>
Subject: Re: filename expansion
Message-Id: <FFlb7.3$9x.1171@news0.optus.net.au>


"Sean Hamilton" <sh@planetquake.com> wrote in message
news:W66b7.28381$b_3.2357462@news0.telusplanet.net...
> What would be the best way to expand a filename, ie
>
> ~user/dir/../file
>
> to
>
> /home/user/file
>
> etc, etc?
> Must this be done manually?
>
> sh
>
>
For the ~, you have to scan for it manually and
replace with getpwnam() (see perlfaq5).
Converting a path containing '.', '..' etc into a 'canonical'
absolute path is more interesting. Most Unices have a
realpath function, callable from C.
I searched the Perl C sources for realpath and found nothing.
I don't how to do this nicely in Perl and would be interested
to know the best way to do it.





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

Date: Sun, 05 Aug 2001 22:24:03 -0400
From: Kevin Michael Vail <kevin@vaildc.net>
Subject: Re: filename expansion
Message-Id: <050820012224030456%kevin@vaildc.net>

In article <FFlb7.3$9x.1171@news0.optus.net.au>, Knob
<andrew.savige@ir.com> wrote:

> "Sean Hamilton" <sh@planetquake.com> wrote in message
> news:W66b7.28381$b_3.2357462@news0.telusplanet.net...
> > What would be the best way to expand a filename, ie
> >
> > ~user/dir/../file
> >
> > to
> >
> > /home/user/file
> >
> > etc, etc?
> > Must this be done manually?
> >
> > sh
> >
> >
> For the ~, you have to scan for it manually and
> replace with getpwnam() (see perlfaq5).
> Converting a path containing '.', '..' etc into a 'canonical'
> absolute path is more interesting. Most Unices have a
> realpath function, callable from C.
> I searched the Perl C sources for realpath and found nothing.
> I don't how to do this nicely in Perl and would be interested
> to know the best way to do it.

File::Spec, available on CPAN if it's not already part of your
installation.

-- 
Kevin Michael Vail | a billion stars go spinning through the night,
kevin@vaildc.net   | blazing high above your head.
 . . . . . . . . .  | But _in_ you is the presence that
 . . . . . . . . . | will be, when all the stars are dead.  (Rainer Maria Rilke)


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

Date: Sun, 5 Aug 2001 21:40:23 -0400
From: "Frank Gerace" <americamba@highstream.net>
Subject: help a senior citizen newbie
Message-Id: <9kkt6q$5oe$1@news.chatlink.com>

ihave to learn PERL. I want an interactive tutorial. the use SSh and not
telnet on my server. I can't figure out SSh so meanwhile I wnat to put the
lessons into CGI scripts and run them from the web.  Am I on the right
track? CAn this be done? Any tips? Know any tutorials that will help me with
how to do this? Thanks, Frank, old but still functioning, the mind that
is...

--

 ............................................................................
 .....................................
Inglés, ESL, Libros, Cassettes, Cursos, Diccionarios
Niños, Familia, Salud, Superación Personal, Vida y Costumbres de EUA
http://www.LeerEsPoder.com




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

Date: 5 Aug 2001 21:19:34 -0500
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: help a senior citizen newbie
Message-Id: <9kkurm$9bf$1@charity.cs.utexas.edu>

In article <9kkt6q$5oe$1@news.chatlink.com>,
Frank Gerace <americamba@highstream.net> wrote:
>ihave to learn PERL. I want an interactive tutorial. the use SSh and not
>telnet on my server. I can't figure out SSh so meanwhile I wnat to put the
>lessons into CGI scripts and run them from the web.  Am I on the right
>track?

It seems like the hard way.  Why not just install Perl onto your
machine?  You can get it from http://www.perl.com/ .  If you're using
Windows, you can get a nice Windows version from
http://www.activestate.com/ .  They're both free.

Also, you will eventually need to figure out how to use ssh, so that
you can figure out problems on the web server itself.

  - Logan
-- 
"Our grandkids love that we get Roadrunner and digital cable."
(Advertisement for Time Warner cable TV and internet access, July 2001)


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

Date: Mon, 06 Aug 2001 03:02:27 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: help a senior citizen newbie
Message-Id: <3B6E0902.B584AE45@rochester.rr.com>

Frank Gerace wrote:
> 
> ihave to learn PERL. I want an interactive tutorial. the use SSh and not

Let's see...if I understand you correctly, you want to write an
interactive tutorial for something else, using Perl to write the
interactive tutorial. I think that's already been done, and that you
should be able to get either free, shareware, or commericial versions of
such tutorial software.  You might want to check that out before
reinventing the wheel.

> telnet on my server. I can't figure out SSh so meanwhile I wnat to put the

SSH isn't any harder or more difficult to use than Telnet.  Just get a
copy of a terminal emulator program that does SSH as well as Telnet.  I
use Tera Term Pro version 2.3 (on Windoze 98SE), which seems to work
great.

> lessons into CGI scripts and run them from the web.  Am I on the right
> track? CAn this be done? Any tips? Know any tutorials that will help me 
with

Yes, CGI scripts would be one way to accomplish this.  It can be (and
has been many times) done pretty neatly using template HTML files for
the content and a fairly simple Perl CGI script to navigate between the
pages, insert text or radio button response fields, and check the
answers based on info in the template HTML files.  I would recommend you
start with the book Learning Perl 3rd edition, then read the module docs
for the CGI module, trying the example code.  The template HTML files
can be just ordinary HTML files with extra tags you define yourself. 
You then read these files via your CGI script, parse the extra tags and
replace the extra tags with the appropriate real HTML code to accomplish
the actions you want to perform, and send that on to the user's web
browser.  But unless you goal is to learn, you should probably just use
one that's already been done.

> how to do this? Thanks, Frank, old but still functioning, the mind that
> is...
> 
> --
> 
> ............................................................................
> .....................................
> Inglés, ESL, Libros, Cassettes, Cursos, Diccionarios
> Niños, Familia, Salud, Superación Personal, Vida y Costumbres de EUA
> http://www.LeerEsPoder.com


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

Date: Mon, 06 Aug 2001 00:52:29 GMT
From: "Ryan Gralinski" <ryan@bong.net>
Subject: Re: How to print a binary string as picture to web page
Message-Id: <hTlb7.64262$d26.526610@news1.wwck1.ri.home.com>

I made a perl program to display a picture
it is very simple

#!/usr/local/bin/perl
print "Content-type:image/gif\n\n";
print `cat /dirname/$ENV{'QUERY_STRING'}`;
# end code -------------------------------------


thats is, then if you do like http://.../image.cgi?car.gif
it will in fact show up as /dirname/car.gif

Ryan


"Benjamin Goldberg" <goldbb2@earthlink.net> wrote in message
news:3B6D9DC4.C0DBF790@earthlink.net...
> Kin wrote:
> >
> > Dear all,
> >     I store jpeg pictures into Sybase as BLOB type and extract it to a
> > variable in the CGI program. It is a binary string. How can I print it
> > as a picture inside a web page directly without saving it to a
> > temporary file first ? Is there any module that can help me to finish
> > this task ?
>
> If your CGI is creating html, you can't do it all in one pass (ie, you
> can't have it print the html, followed by the image, and expect it to
> work).  What you can do is have the html have the image locations be of
> the form <IMG SRC="/cgi-bin/getimage_from_sysbase.cgi/foo=bar/baz.jpg">,
> which will call the cgi program getimage_from_sysbase.cgi with the
> environment variable PATH_INFO set to "foo=bar/baz.jpg", which you would
> then parse into a sysbase query.
>
> To decrease overhead, you may want to do caching.  For server-side
> caching, use CGI::Cache; this will allow you do not re-query sysbase for
> identical requests.
>
> It doesn't cut down any on data transmission, though.
>
> For that, you have to do something to enable client-side and proxy
> caching:  Check if there's an "If-Modified-Since" http header (which
> will be in the environment variable "HTTP_IF_MODIFIED_SINCE") first, and
> act appropriately if so (avoiding a retransmission), and when you do
> need to send the actual file, include a "Last-Modified" and
> "Content-Length" header (otherwise the browser or proxy won't cache).
>
> If images don't get changed once they go into sysbase, you probably
> don't need to know the change date of the image, but can instead use the
> change date of the cgi script.  This can be gotten with something like
> (stat(DATA))[9].
>
> Note that you probably don't have to parse the date into a number, just
> compare whether the datestring is equal to the datestring of the actual
> last modified date (after all, it's not going to get younger, and if
> it's not younger, nor equal, then it must be newer).
>
> If you're using CGI::Cache, make sure you *don't* get the "Status: 304
> not modified" responses in the cache, that would be bad :)  Likewise for
> "Status: 404 No such image in database" if it's not in your sysbase db.
>
> --
> I need more taglines. This one is getting old.




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

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


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