[16079] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3491 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jun 27 14:05:37 2000

Date: Tue, 27 Jun 2000 11:05:21 -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: <962129120-v9-i3491@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Tue, 27 Jun 2000     Volume: 9 Number: 3491

Today's topics:
    Re: Abigail's date line <flavell@mail.cern.ch>
    Re: Abigail's date line (Craig Berry)
        Arbitrary function calling in module <sun_tong_001@yahoo.com>
    Re: Arbitrary function calling in module <news@webneeds.com>
        binary and regular expressions doglovers@rocketmail.com
    Re: binary and regular expressions <tina@streetmail.com>
    Re: CGI Business Directory (Tad McClellan)
    Re: CGI Business Directory (Tad McClellan)
    Re: CGI code for downloading <mmulquin@angelfire.com>
    Re: Changing case in a file! (Jerome O'Neil)
    Re: Changing case in a file! (Jerome O'Neil)
    Re: Command line args to apps in perl?? <andyr@calmit.unl.edu>
    Re: Embedding images into Perl script <news@webneeds.com>
    Re: file input (Tad McClellan)
    Re: Get the matched position in regexp <danny@lennon.postino.com>
    Re: hash and translation <care227@attglobal.net>
    Re: hash and translation <mdemello@pound.ruf.rice.edu>
    Re: hash and translation (Tad McClellan)
    Re: hash and translation <care227@attglobal.net>
    Re: hash and translation <aqumsieh@hyperchip.com>
    Re: hash and translation <mdemello@pound.ruf.rice.edu>
    Re: hash and translation <care227@attglobal.net>
    Re: hash and translation (Abigail)
        How to test for file? <dsm@sandag.cog.ca.us>
    Re: iteration # with foreach (Bart Lateur)
    Re: Locales not loading at startup... <craigh@xsides.com>
    Re: matching question (http related) <mbmj@erols.com>
        newbie: overflow of a string-var ??? <hubert.ming@iggi.lu.ch>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Tue, 27 Jun 2000 18:33:38 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Abigail's date line
Message-Id: <Pine.GHP.4.21.0006271833140.26942-100000@hpplus03.cern.ch>

On Tue, 27 Jun 2000, Russ Jones wrote:

> MMCDXC = 2490
> September = IX = 9
> MCMXCIII = 1993
> 
> This is making me crazy.

http://www.tuxedo.org/~esr/jargon/html/entry/September-that-never-ended.html

-- 

        "Mir ist es ein Rätsel wie man mit minimalem Verstand so einen 
         Unfug fabrizieren kann."   - Adrian Knoth




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

Date: Tue, 27 Jun 2000 17:15:09 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Abigail's date line
Message-Id: <slho8tt9jev176@corp.supernews.com>

Russ Jones (russ_jones@rac.ray.com) wrote:
: > Andy Chantrill (andy@u2me3.com) wrote on MMCDXC September MCMXCIII in
: 
: She won't answer my email. So what's the scoop about these dates in
: Abigails' attribution lines? Is it some kind of an infernal joke that
: I'm just too dumb to get?
: 
: MMCDXC = 2490
: September = IX = 9
: MCMXCIII = 1993
: 
: This is making me crazy.

This should probably go into the FAQ. :)  In Ye Olden Days of the Net,
most net.newbies found their way online by virtue of attending college and
being given a Usenet-capable account by the school.  As a result, each
September, the net would be inundated with the usual newbie foolishness,
misbehavior, and occasional active evil.  Within a month or two things
would settle down again.

However, around 1993, net access became much wider, and newbies flowed in
from all sides, all year, without pause, and have continued to do so. 
Abigail considers it to have been one long September ever since. 

-- 
   |   Craig Berry - http://www.cinenet.net/users/cberry/home.html
 --*--  "Beauty and strength, leaping laughter and delicious
   |   languor, force and fire, are of us." - Liber AL II:20


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

Date: 27 Jun 2000 13:12:51 -0300
From: * Tong * <sun_tong_001@yahoo.com>
Subject: Arbitrary function calling in module
Message-Id: <sa8r99jje64.fsf@sun_tong_001.personal.yahoo.com>

Hi,

I used to use the following code to call functions which names are
constructed on the fly:

no strict "refs";
sub fdispatch {
    my $func_tocall=...;
    &$func_tocall(@_);
}

But after I move the above code into a module, perl started to
complain that "Undefined subroutine &fdispatch::..." 

or

"Scalar found where operator expected" when I tried to use
&main::$func_tocall(@_);

How should I fix it? Thanks

-- 
Tong (remove underscore(s) to reply)
  http://members.xoom.com/suntong001/
  - All free contribution & collection & music from the heavens


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

Date: Tue, 27 Jun 2000 11:15:14 -0600
From: "Dan Manion" <news@webneeds.com>
Subject: Re: Arbitrary function calling in module
Message-Id: <jn565.22$%%5.1434@news.uswest.net>

You're troubles are coming from how you are calling your sub routines.  From
what you wrote, the following example should give you the basic idea of how
to go about doing this.

*note the function call is made in "sub func_to_call"  it is called with
&{"functionname"} which automatically sends @_ so there is no need to try to
pass it ourselves.  This is also why I shifted the function name off of
@_(so it did not get passed to the function that was being called.

Hope this helps!

Dan M.

##file subref.pl
#!/usr/local/bin/perl -w

use strict;
use subref;

my $funcname = "testing";

subref::func_to_call($funcname,'arg one','arg 2', 'arg 3');

sub testing {
  print "We made it!\n$_[0]\n$_[1]\n$_[2]\n";
}

## file subref.pm
package subref;

sub func_to_call {
  &{"main::@{[shift]}"};
}

1;

"* Tong *" <sun_tong_001@yahoo.com> wrote in message
news:sa8r99jje64.fsf@sun_tong_001.personal.yahoo.com...
> Hi,
>
> I used to use the following code to call functions which names are
> constructed on the fly:
>
> no strict "refs";
> sub fdispatch {
>     my $func_tocall=...;
>     &$func_tocall(@_);
> }
>
> But after I move the above code into a module, perl started to
> complain that "Undefined subroutine &fdispatch::..."
>
> or
>
> "Scalar found where operator expected" when I tried to use
> &main::$func_tocall(@_);
>
> How should I fix it? Thanks
>
> --
> Tong (remove underscore(s) to reply)
>   http://members.xoom.com/suntong001/
>   - All free contribution & collection & music from the heavens




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

Date: Tue, 27 Jun 2000 16:07:49 GMT
From: doglovers@rocketmail.com
Subject: binary and regular expressions
Message-Id: <3958cfdd.53660066@news.erols.com>

Been thinking about this for days, but can't find the answer anywhere

if 109 eq ord("m") is true, and
if "m" = chr(109) is true, then
then why do all of the following evaluate to false?
"m" =~ / chr(109) /
"m" =~ /"chr(109) /
"m" =~ /(chr(109))/
"m" =~/{chr(109)}/

I am trying to do pattern matching on a binary string. I have searched
deja, and the perl docs, and don't seem to have the answer. Anyone
know where to look for complete information on how to manipuate,
search through, and match against binary strings?

Thanks.


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

Date: 27 Jun 2000 16:40:05 GMT
From: Tina Mueller <tina@streetmail.com>
Subject: Re: binary and regular expressions
Message-Id: <8jald5$5klk$2@ID-24002.news.cis.dfn.de>

hi,

doglovers@rocketmail.com wrote:
> Been thinking about this for days, but can't find the answer anywhere

didn't you get the answers to your other posting?

> if 109 eq ord("m") is true, and
> if "m" = chr(109) is true, then
> then why do all of the following evaluate to false?
> "m" =~ / chr(109) /
> "m" =~ /"chr(109) /
> "m" =~ /(chr(109))/
> "m" =~/{chr(109)}/

if you really want to do the above instead of using the
"m" =~ /\155/ # for m (octal) or 
the hex value \x6D
you could force perl to evaluate chr:
"m" =~ /@{[chr(109)]}/

tina

-- 
http://tinita.de    \  enter__| |__the___ _ _ ___
tina's moviedatabase \     / _` / _ \/ _ \ '_(_-< of
search & add comments \    \ _,_\ __/\ __/_| /__/ perception
"The Software required Win98 or better, so I installed Linux."


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

Date: Tue, 27 Jun 2000 10:24:29 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: CGI Business Directory
Message-Id: <slrn8lhe8t.9n6.tadmc@magna.metronet.com>

On Tue, 27 Jun 2000 00:55:38 -0700, Robb Charlton <robb@qnet.com> wrote:
>
>    I'm looking for


Use newsgroups for discussion.

Use a search engine for searching.


-- 
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Tue, 27 Jun 2000 10:25:31 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: CGI Business Directory
Message-Id: <slrn8lhear.9n6.tadmc@magna.metronet.com>

On Tue, 27 Jun 2000 06:19:23 -0400, Rob - Rock13.com <rob13@rock13.com> wrote:
>Robb Charlton wrote:
>> 
>>     I'm looking for

>Might have something at cgi-resouces.com or in CPAN
                         ^^^^^^^^^^^^^^^^       ^^^^ good code
                         ^^^^^^^^^^^^^^^^
                         ^^^^^^^^^^^^^^^^ awful code with security holes...


-- 
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Tue, 27 Jun 2000 17:30:04 GMT
From: Michael Mulquin <mmulquin@angelfire.com>
Subject: Re: CGI code for downloading
Message-Id: <slhp4si6jev12@corp.supernews.com>


Stacey Campbell wrote:
> 
>     I am trying to figure out CGI code that someone else wrote, which 
accepts
> form data, processes it into the correct path and filename for our unix 
system,
> and allows the user to download that file over the internet.  The 
problem is
> that I have never written CGI code for downloading files over the 
internet, the
> code is not mine, it has all kinds of HTML and perl mixed up all 
together (he
> didn't use CGI.pm), and I can't decipher it well enough to modify it.
>     His code downloads entire groups of files.  I was asked to add a 
function to
> the page that downloads individual files, but I might end up having to 
write the
> page over completely, just so I know what is going on.
>     Does anyone have some simple, maybe generic CGI code for downloading 
files
> from a unix system over the internet?  It could be for single files or 
groups of
> files.  I would appreciate the form code and the data handling code. If 
you are
> worried about security of your page, please let me know if you have a 
generic
> version, or point me to a book or website that will help me do these 
things.
> 
> Thanks,
> -Stacey Campbell-
> 
> 
> 

Why not just write a simple script that first verifies the user information
then if true.  "a href HTTP" the exact path meaning if they are 
downloading a file called test.zip and it is your path 
is ././script/data/downloads/test.zip this should automaticly prompt a 
download or you can shitch HTTP in the HREF call to FTP.

<html><head><title> test this</title>
<script language=JavaScript>

function downloadME(){

var valid=true;

if(document.form_data.firstN.value==""){
  valid=false;
  alert("Please re-type first name");
  }
return valid;
}

</script>
<body leftmargin=200>
<pre>
<form name="form_data" method=post 
action="http://www.angelfire.com/nt/resumeftp/downloads/Resume.doc" 
onSubmit="return downloadME();">
<INPUT maxLength=25 name=firstN size=15>
<INPUT TYPE="submit" value=" Test This">
<BR>
<A HREF="HTTP://resumerecon.webjump.com"><font face="Times New Roman" 
color="Blue">Click to View My Site!</font></A>
</pre>
</FORM>
</body>
</html>

--
Posted via CNET Help.com
http://www.help.com/


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

Date: Tue, 27 Jun 2000 18:32:19 GMT
From: jerome@activeindexing.com (Jerome O'Neil)
Subject: Re: Changing case in a file!
Message-Id: <Tq665.298$o7.50507@news.uswest.net>

Tom Phoenix <rootbeer@redcat.com> elucidates:
> On Mon, 26 Jun 2000, Jerome O'Neil wrote:
> 

>> > URLs are by definition case sensitive.  
>> 
>> I'm curious as to what definition of URL you are looking that would
>> lead you to make such a statement.
>> 
>> In fact, URL comparison for host and scheme parts in HTTP must
>> be case insensitive.
> 
> ...which is why I said "in general".

Right.  But even then, I would say that, in general URLs are 
case insensitve.

> Folks who want the whole story should read the RFCs. 

Right again.  But nothing in the RFCs says URLs are case sensitive.

In fact, most of the literature says the exact opposite.

> But this no longer has anything to do with Perl, does it?

Nope.  But it does go along with the "correct the bad gouge" theme
so popular here.

> Follow-ups set, in case there's any Perl-related follow-up. Cheers!

I reset them, so the OP can read the good gouge.

Thanks!


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

Date: Tue, 27 Jun 2000 18:33:36 GMT
From: jerome@activeindexing.com (Jerome O'Neil)
Subject: Re: Changing case in a file!
Message-Id: <4s665.299$o7.50989@news.uswest.net>

"Alan J. Flavell" <flavell@mail.cern.ch> elucidates:
> On Mon, 26 Jun 2000, Jerome O'Neil wrote:
> 
>> Indeed.
>> 
>> > URLs are by definition case sensitive.  
>> 
>> I'm curious as to what definition of URL you are looking that would
>> lead you to make such a statement.
> 
> Drat.  I originally typed " - well, at least the URLpath part - " and
> then trimmed that detail out again thinking that as I was off-topic,
> I'd better not go into too much detail.

I knew it had to be something like that.  

Whew!

Good Luck!


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

Date: Tue, 27 Jun 2000 12:39:26 -0500
From: "Andy Rutledge" <andyr@calmit.unl.edu>
Subject: Re: Command line args to apps in perl??
Message-Id: <8jaoq3$gm0$1@unlnews.unl.edu>

<wmcn@my-deja.com> wrote in message news:<8ja0o8$1l6$1@nnrp1.deja.com>...

<snip>

> how do I pass/read/parse the args from a perl script.

The arguments to the script from the command line are passed into the
special array @ARGV, with $ARGV[0] being the first argument, $ARGV[1] being
the second, and so on.

> How do I call the script from withing perl passing the arguements
> correctly.

After some error checking, you'd want the output to be:

print "/home/script $ARGV[0] $ARGV[1]";

or whatever.

-Andy




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

Date: Tue, 27 Jun 2000 11:50:53 -0600
From: "Dan Manion" <news@webneeds.com>
Subject: Re: Embedding images into Perl script
Message-Id: <LU565.31$%%5.1351@news.uswest.net>

I think what your subject should read is "Embedding images into HTML".

The <img> in html is simply a link to a server location where the browser
should connect and pull down an image.  Yes you can have perl kick out an
image .. but that has nothing to do with an HTML image tag.

You could have <img src="/path/to/a/perlfile.cgi">

and that perlfile could spit out an image.

Ex.
print "Content-type: image/gif\n\n";
print $fG; # assuming $fG is the image file in your example


"Vladimir Rybintsev" <vlad@soft-tronik.ru> wrote in message
news:8ja4om$22d5$1@storm.comstar.ru...
>           I find some Perl script, which generates HTML page with some
> images.
> Something like:
> $fG=<<'fC';
> M1TE&.#=A$@`/`+,``/_2+N.[*<>D)*J,'XYU&G)>%55&$#DO"QT8!@```/__
> M_____________________R'Y!`$```D`+``````2``\```1F,,E)C3DT4T0"
> M$(B6'0)@`H6$I*-WHE+!4NZ+D>&$E)]1$@D$P)`A``*%4`>!&`1RDD/@B2`2
> MF*594"`P-(D(Z:<(P`@"!XX'O1'<7B<B118<P,L9CJIF`HYR.R=L&E`)!29N
> %(@D1`#L`
>
> fC
> ...
> ...
>
> <img src=$fG>
> ...
> So in variable $fG is encoded image. But what kind of encoding is used?
> Does'nt seems like uuencode or Base64.
> I never meet before with such methods.
> May be, sombody knows?
>




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

Date: Tue, 27 Jun 2000 10:04:01 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: file input
Message-Id: <slrn8lhd2h.9n6.tadmc@magna.metronet.com>

On Tue, 27 Jun 2000 11:07:54 GMT, Christophe Gijbels <Gizzzmo@pandora.be> wrote:

>Is there a way to make sure that when I read a line from a file, and that
>line has the string $variable. That $variable gets his value and so when I
>print it, not $variable is printed but his value ?

>Is this possible or is it just a fantasie of me ?


It is a Frequently Asked Question. You must have missed it
when you checked the Perl FAQ before posting to the Perl
newsgroup:


   perldoc -q variable

   "How can I expand variables in text strings?"


Use a hash with $variable as the key rather than using
symbolic references.


-- 
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: 27 Jun 2000 14:55:29 GMT
From: <danny@lennon.postino.com>
Subject: Re: Get the matched position in regexp
Message-Id: <8jaf91$2ll$1@lennon.postino.com>

User-Agent: tin/1.4.2-20000205 ("Possession") (UNIX) (Linux/2.2.14-5.0 (i586))

Godzilla! <godzilla@stomp.stomp.tokyo> wrote:
> Uri Guttman wrote:
> Get your dirty diapers in any tighter of
> a knot, little boy, you are liable to suffer
> a fatal brain fart.
> Godzilla!

There definately is a child here, but it ain't Uri.
(Hmmm. Guess my 30 day kill expired.)

-- 
Danny Aldham     Providing Certified Internetworking Solutions to Business
www.postino.com  E-Mail, Web Servers, Web Databases, SQL PHP & Perl


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

Date: Tue, 27 Jun 2000 11:04:40 -0400
From: Drew Simonis <care227@attglobal.net>
Subject: Re: hash and translation
Message-Id: <3958C288.E60D36BC@attglobal.net>

"Clinton A. Pierce" wrote:
> 
> [Posted and mailed]

> > undef is a perfectly fine value for a hash key, but would not be
> > found by a defined() check, possibly causing unexpected behaviour.
> 

Reading this again, I see that I could have used clearer wording.  

key=>value

I was meaning to say that for a given key, undef would be a valid
value, not that the key itself could be undef.


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

Date: 27 Jun 2000 15:25:17 GMT
From: Martin Julian DeMello <mdemello@pound.ruf.rice.edu>
Subject: Re: hash and translation
Message-Id: <8jah0t$fc1$3@joe.rice.edu>

Drew Simonis <care227@attglobal.net> wrote:
> Martin Julian DeMello wrote:
 
>> Why exists() rather than defined(), though? (Apart from having a lower golf
>> score, of course :)). I'd have thought the right thing to do if someone used
>> undef to remove a hash entry would be to simply not translate the key,
>> rather than have the program generate an error and stop.

> undef is a perfectly fine value for a hash key, but would not be 
> found by a defined() check, possibly causing unexpected behaviour.

> Using exists() saves you that chance.

> Check out the discussion in the documentation:

> http://www.perl.com/pub/doc/manual/html/pod/perlfunc/exists.html

I did - it said

  A hash element can be TRUE only if it's defined, and defined if it exists,
  but the reverse doesn't necessarily hold true. 

Doesn't this mean that defined subsumes exists? 

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

  my %a = (undef => "foo", "bar" => undef);
  foreach (keys %a) { print "defined $a{$_} \n" if defined $a{$_}; }
  print "--- \n";
  foreach (keys %a) { print "exists $a{$_} \n" if exists $a{$_}; }

  my $text = "foo bar baz quux";
  $text =~ s/\b(\w+)\b/(defined($a{$1})?$a{$1}:$1)/ge;
  print $text."\n";

  $text = "foo bar baz quux";
  $text =~ s/\b(\w+)\b/(exists($a{$1})?$a{$1}:$1)/ge;
  print $text."\n";

Output:

  defined foo
  ---
  exists foo
  Use of uninitialized value at ./testundef.pl line 10.
  exists
  foo bar baz quux
  Use of uninitialized value at ./testundef.pl line 17.
  foo  baz quux

So the hash entry undef=>"value" does 'exist', and it doesn't even complain
until you actually try to use the key. Ought to use some sort of test that
breaks if either entry is undef, I guess.

-- 
Martin DeMello


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

Date: Tue, 27 Jun 2000 10:21:00 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: hash and translation
Message-Id: <slrn8lhe2c.9n6.tadmc@magna.metronet.com>

On Tue, 27 Jun 2000 11:38:25 +0200, Pascal POTTIER <ppo@infovista.fr> wrote:

>I'm sorry to as such a basic question, but i am not a Perl expert :(.


You do not need to be a Perl expert to ask a question.

You *DO* need to check the Perl FAQs *before* posting to
the Perl newsgroup though.

Please do that in the future.


>I have a hash with translations  { "bread" => "pain" , "stupid" => "stupide"
>, "Microsoft" => "split" } that i want to apply to a string.


An alternative to the answer that is already on your hard disk:


   my $strRE = join '|', keys %hash;
   s/\b($strRE)\b/$hash{$1}/g;


>My basic way of doing it is with foreach on the keys of the hash and then
>with replacement 


The FAQ answer notes that that way is extremely inefficient.


>(i need help on replacement too !!!)


Use the s/// operator.

If you need more help than that, then you need to describe
what you need help with.


>Is there any other way more efficient as the hash and the string will be
                             ^^^^^^^^^

   perldoc -q efficient

   "How do I efficiently match many regular expressions at once?"


>very large ?


Use the Benchmark.pm module to compare the speed of various
approaches with your real-world data.


-- 
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Tue, 27 Jun 2000 11:48:19 -0400
From: Drew Simonis <care227@attglobal.net>
Subject: Re: hash and translation
Message-Id: <3958CCC3.3797BEFE@attglobal.net>

Martin Julian DeMello wrote:
> 
> So the hash entry undef=>"value" does 'exist', and it doesn't even complain
> until you actually try to use the key. Ought to use some sort of test that
> breaks if either entry is undef, I guess.

exists() test if there is a key.  The value (key=>value) of that key
can be undefined.  The key itself cannot be undefined.  My wording the 
first time about was not as clear as it should have been, but the long
and the short of it is that a key can have an associated undef value.
They key iself, however, cannot be undefined.


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

Date: Tue, 27 Jun 2000 16:00:47 GMT
From: Ala Qumsieh <aqumsieh@hyperchip.com>
Subject: Re: hash and translation
Message-Id: <7a8zvrdsgf.fsf@merlin.hyperchip.com>


Drew Simonis <care227@attglobal.net> writes:

> exists() test if there is a key.  The value (key=>value) of that key
> can be undefined.  The key itself cannot be undefined. 

Who says so?

	% perl -Mstrict -wl
	my %x;
	my $y = undef;
	$x{$y} = 'YES';
	print $x{$y} if exists $x{$y};
	__END__
	Use of uninitialized value at - line 3.
	Use of uninitialized value at - line 3.
	Use of uninitialized value at - line 4.
	YES
 

>                                                        My wording the 
> first time about was not as clear as it should have been, but the long
> and the short of it is that a key can have an associated undef value.
> They key iself, however, cannot be undefined.

You are wrong. Both key and value can be undefined. Whether or not that
is useful is a totally different subject.

--Ala



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

Date: 27 Jun 2000 16:02:59 GMT
From: Martin Julian DeMello <mdemello@pound.ruf.rice.edu>
Subject: Re: hash and translation
Message-Id: <8jaj7j$jp6$1@joe.rice.edu>

Drew Simonis <care227@attglobal.net> wrote:

> exists() test if there is a key.  The value (key=>value) of that key
> can be undefined.  The key itself cannot be undefined.  My wording the 
> first time about was not as clear as it should have been, but the long
> and the short of it is that a key can have an associated undef value.
> They key iself, however, cannot be undefined.

Ah - went and RTFMd again; I'd missed the part about => automatically
defining its LHS as a string. Makes a lot more sense now :)

-- 
Martin DeMello


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

Date: Tue, 27 Jun 2000 12:54:51 -0400
From: Drew Simonis <care227@attglobal.net>
Subject: Re: hash and translation
Message-Id: <3958DC5B.4455ADC7@attglobal.net>

Ala Qumsieh wrote:
> 
> You are wrong. Both key and value can be undefined. Whether or not that
> is useful is a totally different subject.
> 
> --Ala


So I should say _should_not_ be undefined?


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

Date: 27 Jun 2000 14:00:52 EDT
From: abigail@delanet.com (Abigail)
Subject: Re: hash and translation
Message-Id: <slrn8lhs0h.ka1.abigail@alexandra.delanet.com>

Ala Qumsieh (aqumsieh@hyperchip.com) wrote on MMCDXCII September MCMXCIII
in <URL:news:7a8zvrdsgf.fsf@merlin.hyperchip.com>:
}} 
}} Drew Simonis <care227@attglobal.net> writes:
}} 
}} > exists() test if there is a key.  The value (key=>value) of that key
}} > can be undefined.  The key itself cannot be undefined. 
}} 
}} Who says so?
}} 
}} 	% perl -Mstrict -wl
}} 	my %x;
}} 	my $y = undef;
}} 	$x{$y} = 'YES';
}} 	print $x{$y} if exists $x{$y};
}} 	__END__
}} 	Use of uninitialized value at - line 3.
}} 	Use of uninitialized value at - line 3.
}} 	Use of uninitialized value at - line 4.
}} 	YES

That however doesn't proof anything. Or would you say that hash keys
can be references as well?

   	% perl -Mstrict -wl
   	my %x;
   	my $y = [1, 2, 3];
   	$x{$y} = 'YES';
   	print $x{$y} if exists $x{$y};
   	__END__
   	YES

}} 
}} >                                                        My wording the 
}} > first time about was not as clear as it should have been, but the long
}} > and the short of it is that a key can have an associated undef value.
}} > They key iself, however, cannot be undefined.
}} 
}} You are wrong. Both key and value can be undefined. Whether or not that
}} is useful is a totally different subject.


No, the key *cannot* be undefined. As the documentation says, all keys get
stringified. A stringified undef is the empty string:

      #!/opt/perl/bin/perl -wl
      use strict;
      my %foo   = (undef, "foo");
      $foo {""} = "bar";

      print scalar keys %foo;
      print values %foo;
      __END__
      Use of uninitialized value in list assignment at ./try line 3.
      1
      bar



Abigail
-- 
package Just_another_Perl_Hacker; sub print {($_=$_[0])=~ s/_/ /g;
                                      print } sub __PACKAGE__ { &
                                      print (     __PACKAGE__)} &
                                                  __PACKAGE__
                                            (                )


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

Date: Tue, 27 Jun 2000 09:09:53 -0700
From: "Don Smith" <dsm@sandag.cog.ca.us>
Subject: How to test for file?
Message-Id: <8jajkj$14hb$1@thoth.cts.com>

Hello, I'll start off by saying, I'm new to perl!  :-)
I need some help with a script I have.
I have a Solaris 7 system for our Intranet, and an NT system for the audio
server.
What I am trying to do is have a link on out Intranet to our audio server so
our users can listen to certain meetings, etc.
The script first does a test to see if there is any audio being sent, if
not, a message displays that says "No meetings at this time"
The problem I'm having is, I don't know how to make the perl script test for
the audio server file on the NT system.  It doesn't see the audio file, the
path is correct.  Even when I put the IP address in the path, it has the
same result.
Here's what I have so far:
#!/usr/local/bin/perl
############################################################
# This script checks to see if the broadcast is available, #
# then directs to the appropriate page.                    #
############################################################

if (-e "file://Audio/stream/Station1.asx") {

  print "Content-type:text/html\n\n";
  print "<html><head><title>MeetingBoard Audio&nbsp;&nbsp;&nbsp;&nbsp;
</title></head>\n";
  print "<body bgcolor=white>\n";
  print "<center><font face=arial size=2><p><br><br>\n";
  print "\n</body></html>\n";
  print "This broadcast requires Windows Media Player 6.4 or above. ";
  print "If you already have it, <A
HREF=file://Audio/stream/Station1.asx>click here</A> for the broadcast. ";
  print "Otherwise you can <A
HREF=http://www.microsoft.com/windows/mediaplayer/download/default.asp><IMG
SRC=/images/getmedia_whi
te.gif WIDTH=65 HEIGHT=57 BORDER=0 VSPACE=7></A>";

} else {

  print "Content-type:text/html\n\n";
  print "<html><head><title>Meeting Board Audio&nbsp;&nbsp;&nbsp;&nbsp;
</title></head>\n";
  print "<body bgcolor=white>\n";
  print "<center><font face=arial size=2><p><br><br>\n";
  print "\n</body></html>\n";
  print "There is nothing to broadcast right now. Please check ";
  print "the meeting schedule on our What's New page for the ";
  print "next meeting to be broadcast. Thank you.";
}

Any help would be greatly appreciated!
Thanks,
Don






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

Date: Tue, 27 Jun 2000 15:28:47 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: iteration # with foreach
Message-Id: <395ec747.26952850@news.skynet.be>

Philip Taylor wrote:

>Is there a tidy way to establish the iteration number within a foreach
>loop without having to create a variable and increment it manually. ie
>to avoid this:-
>
>my $i=0;
>foreach (@myArray) {
>	$i++;
>	print $i, $_
>}

Short answer: not yet. This has been brought up before, and some people
were in particular in favor of recycling the obsolete special variable
$# (not $#array !) for this purpose.

Perhaps your problem isn't as bad as you think. First of all, in the
standard for loop,

	for(my $i = 0; $i < @array; $i) { 	
		dostuff;
	}

You DO create a special variable, and increment it manually. It might
not be so in y'er fac, but it's there nonetheless.

And lastly, this is the clean way to do it:

	my $i=0;
	foreach (@myArray) {
	    print $i, $_;
	} continue {
	    $i++;
	}

-- 
	Bart.


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

Date: Tue, 27 Jun 2000 09:05:51 -0700
From: Craig Hagerman <craigh@xsides.com>
Subject: Re: Locales not loading at startup...
Message-Id: <3958D0DF.267605D7@xsides.com>

Many times there is no en_US complement to the POSIX 'C' best thing to do in
this case is just put in a symbolic link from C to en_US (ln -s C en_US).


Anthony Lalande wrote:

> On RedHat, Sybperl has recently started spewing out warnings at startup
> saying that it couldn't load locales:
>
> warning: setlocale(LC_CTYPE, "") failed.
> warning: LC_ALL = "en_US", LC_CTYPE = "(null)", LANG = "en_US",
> warning: falling back to the "C" locale.
>
> I have looked into the locales documentation, and installed glibc-2.1.3
> (without a restart; is Linux like a Mac where you need to restart after
> installations??).
>
> All the necessary locales seem to be in place in /usr/share/locale/, and my
> LC_ALL and LANG variables equal to 'en_US'. My
> /opt/sybase/locales/locales.dat file does have an en_US entry:
>
> [linux]
>         locale = en_US, us_english, iso_1
>
> ... and in the /opt/sybase/locales/ directory is another directory named
> us_english, containing a file called 'iso_1'.
>
> I don't have a SYBASE env variable; do I need one? How do I make the
> warnings go away?
>
> Thanks,
> - Anthony Lalande

--
Craig Hagerman
Xsides Inc.
821 Second Ave.
Seattle, WA 98104-1504
206-336-1600




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

Date: Tue, 27 Jun 2000 11:49:33 -0400
From: Mike Johnson <mbmj@erols.com>
Subject: Re: matching question (http related)
Message-Id: <3958CD0D.204D4A7@erols.com>

Tad McClellan wrote:

> Note the quality of the answers given by the the two different
> styles, and decide for yourself who you want to emulate  :-)

I humbly bow in your presence.

And, btw, the File::Basename module worked very nicely.  Thank you.

Mike



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

Date: Tue, 27 Jun 2000 17:38:35 +0200
From: "Hubert Ming" <hubert.ming@iggi.lu.ch>
Subject: newbie: overflow of a string-var ???
Message-Id: <8jahn5$poe$1@pollux.ip-plus.net>

dear perl-gurus,

i found a a cgi-perl-script which is able to send email's with attachments.
at a certain size of the attachment the script hangs at the following
statements.
here are my questions:
a) what does the regex search for and what is done in the line beginning
with $res .=....
b) the string-var $res seems to overflow if the attachment is to big. how
can control how much size this var is able to handle ??

my ($res) = "";
while ($_[0] =~ /(.{1,45})/gs)

         $res .= substr(pack('u', $1), 1);
         chop($res);
         }

thanx alot
hubert




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

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


Administrivia:

The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

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 V9 Issue 3491
**************************************


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