[21826] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4030 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Oct 25 18:11:44 2002

Date: Fri, 25 Oct 2002 15:10:20 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Fri, 25 Oct 2002     Volume: 10 Number: 4030

Today's topics:
        Missing assignment operator <occitan@esperanto.org>
    Re: Newbie question : unable to runn perl test script w <Graham.T.Wood@oracle.com>
        Newbie question : unable to runn perl test script with  (Guy Bonin)
    Re: Overloading and recursion; how to turn '""' overloa <nobull@mail.com>
    Re: Overloading and recursion; how to turn '""' overloa <goldbb2@earthlink.net>
    Re: Overloading and recursion; how to turn '""' overloa <heather710101@yahoo.com>
        Perl Help (PeteA)
    Re: Perl Help <nobull@mail.com>
    Re: PoCo::IRC dcc chat example / code snipped / help ? <troc@netrus.net>
    Re: Q: does there exist an HTTP redirect script ? <smillet751@nospammersplz.hotmail.com>
        RegExpr (Mary Wong)
    Re: RegExpr <shondell@cis.ohio-state.edu>
    Re: Regular Expression <none@none.com>
    Re: Replacing string in binary file develop@gistenson.com
    Re: Replacing string in binary file develop@gistenson.com
    Re: Replacing string in binary file <tassilo.parseval@post.rwth-aachen.de>
    Re: Replacing string in binary file <goldbb2@earthlink.net>
    Re: Slow code, improvements requested <comdog@panix.com>
    Re: Tk help, please. <penny1482@attbi.com>
        use constant CONST_HASH => {...} in regex ? <Hyra@none.none>
    Re: use constant CONST_HASH => {...} in regex ? (Tad McClellan)
    Re: use constant CONST_HASH => {...} in regex ? (Tad McClellan)
    Re: What is a file XXX.pl.swp ?? (Steve)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Sat, 26 Oct 2002 00:02:11 +0200
From: Daniel Pfeiffer <occitan@esperanto.org>
Subject: Missing assignment operator
Message-Id: <20021026000211.28804792.occitan@esperanto.org>

Hi,

looking at perlop with all its clever operators I feel that one is missing in Perl:

$x ?= 1 : 2

would be equivalent to the more redundant

$x = $x ? 1 : 2

Does anyone like this?

coralament / best Grötens / liebe Grüße / best regards / elkorajn salutojn
Daniel Pfeiffer

-- 
 -- http://dapfy.bei.t-online.de/sawfish/
  --


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

Date: Fri, 25 Oct 2002 18:48:24 +0100
From: Graham Wood <Graham.T.Wood@oracle.com>
Subject: Re: Newbie question : unable to runn perl test script with Internet  Explorer 6
Message-Id: <3DB983E8.7DD2F55@oracle.com>

Guy Bonin wrote:

> I am trying to run simple Perl scripts on my local server. I am
> working under the Windows XP Home Edition environment and using
> version 6 of Internet Explorer.
>
> I installed Sambar Server 5.2 as a local server and installed
> ActivePerl 5.6.1 build 633 (namely the
> ActivePerl-5.6.1.633-MSWin32-x86.msi package) as Perl interpreter.
>
> I am trying to run the following basic script just to test my local
> server:
>
> #!C:\Perl\bin\perl.exe
>
> print "Content-type: text/html\n\n";
>
> print "<HTML><HEAD><TITLE>Test de l'interpréteur
> Perl</TITLE></HEAD><BODY>";
> print "Hello from ActivePerl!";
> print "<H3>Montre moi la lanterne magique avec mon serveur
> personnel</H3>";
> print "</BODY></HTML>";
>
> When I type the script file name with its .pl extension from my
> browser window, I get the following output:
>
> #!C:\Perl\bin\perl.exe print "Content-type: text/html\n\n"; print "";
> print "Hello from ActivePerl!"; print "
> Montre moi la lanterne magique avec mon serveur personnel
> "; print "";
>
> instead of displaying only the "Montre moi la lanternet magique avec
> mon serveur personnel" sentence.
>
> It seems that the either shebang line does not work properly or the
> print command is not recognized, except when containing HTML tags.
>
> Can someone help me understand how can I fix this problem.
>
> Thanks,
>
> P.S.: When  running the same test from a C-Shchell, I get this output
> which seems to me the correct one:
>
> Content-type: text/html
>
> <HTML><HEAD><TITLE>Test de l'interprÚteur
> Perl</TITLE></HEAD><BODY>Hello from ActivePerl!<H3>Montre moi la
> lanterne magique avec mon serveur personnel</H3></BODY></HTML>

Looks like the server doesn't know that .pl is a perl script.   I don't
know anything about Sambar but with Apache you have to put your script
into a specific cgi-bin directory.  I think this is a server
configuration question rather than a perl one.  If the browser displays
your script instead of running it, it is a server issue.

Graham Wood



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

Date: 25 Oct 2002 10:05:02 -0700
From: guybonin@iquebec.com (Guy Bonin)
Subject: Newbie question : unable to runn perl test script with Internet Explorer 6
Message-Id: <986d1d6.0210250905.43186cb5@posting.google.com>

I am trying to run simple Perl scripts on my local server. I am
working under the Windows XP Home Edition environment and using
version 6 of Internet Explorer.

I installed Sambar Server 5.2 as a local server and installed
ActivePerl 5.6.1 build 633 (namely the
ActivePerl-5.6.1.633-MSWin32-x86.msi package) as Perl interpreter.

I am trying to run the following basic script just to test my local
server:

#!C:\Perl\bin\perl.exe

print "Content-type: text/html\n\n";

print "<HTML><HEAD><TITLE>Test de l'interpréteur
Perl</TITLE></HEAD><BODY>";
print "Hello from ActivePerl!";
print "<H3>Montre moi la lanterne magique avec mon serveur
personnel</H3>";
print "</BODY></HTML>";

When I type the script file name with its .pl extension from my
browser window, I get the following output:

#!C:\Perl\bin\perl.exe print "Content-type: text/html\n\n"; print "";
print "Hello from ActivePerl!"; print "
Montre moi la lanterne magique avec mon serveur personnel
"; print "";

instead of displaying only the "Montre moi la lanternet magique avec
mon serveur personnel" sentence.

It seems that the either shebang line does not work properly or the
print command is not recognized, except when containing HTML tags.

Can someone help me understand how can I fix this problem.

Thanks,


P.S.: When  running the same test from a C-Shchell, I get this output
which seems to me the correct one:

Content-type: text/html

<HTML><HEAD><TITLE>Test de l'interprÚteur
Perl</TITLE></HEAD><BODY>Hello from ActivePerl!<H3>Montre moi la
lanterne magique avec mon serveur personnel</H3></BODY></HTML>


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

Date: 25 Oct 2002 17:21:04 +0100
From: Brian McCauley <nobull@mail.com>
Subject: Re: Overloading and recursion; how to turn '""' overloading off?
Message-Id: <u9y98m4hhr.fsf@wcl-l.bham.ac.uk>

Da Witch <heather710101@yahoo.com> writes:

> Suppose I overload "" for some Perl object.  Is there a way to locally
> disable this overloading...

Not elegantly.

> ...so that I may recover the original behavior of "" on the object?

The original behavior of "" is availble though the function
overload::StrVal().

This information and much more can be found in "perldoc overload" :-)

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: Fri, 25 Oct 2002 17:25:11 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Overloading and recursion; how to turn '""' overloading off?
Message-Id: <3DB9B6B7.41801E4A@earthlink.net>

Da Witch wrote:
> 
> Suppose I overload "" for some Perl object.  Is there a way to locally
> disable this overloading so that I may recover the original behavior
> of "" on the object?
> 
> One application for this would be to avoid recursion in an overloading
> of "" that just wants to amplify "", not to rewrite it from scratch.
> For example, as written, the following code leads to a deep recursion
> fault:
> 
> use overload '""' => \&stringify;
> 
> sub stringify {
>   "Just call me $_[0]"    # Produces a deep recursion fault
> }
> 
> Is there a way around this unwanted recursion? 

Try this:

use vars ($stringify_recursion);
sub stringify {
   return $_[0] if $stringify_recursion;
   local $stringify_recursion = 1;
   "Just call me $_[0]";
}
[untested]

> It would be nice to be able to turn the ""-overloading off within the
> function used to redefine the overload.
> 
> Thanks!
> 
> hk

-- 
my $n = 2; print +(split //, 'e,4c3H r ktulrnsJ2tPaeh'
 ."\n1oa! er")[map $n = ($n * 24 + 30) % 31, (42) x 26]


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

Date: Fri, 25 Oct 2002 21:49:00 +0000 (UTC)
From: Da Witch <heather710101@yahoo.com>
Subject: Re: Overloading and recursion; how to turn '""' overloading off?
Message-Id: <apce8c$8u$1@reader1.panix.com>

In <3DB9B6B7.41801E4A@earthlink.net> Benjamin Goldberg <goldbb2@earthlink.net> writes:
>use vars ($stringify_recursion);
>sub stringify {
>   return $_[0] if $stringify_recursion;
>   local $stringify_recursion = 1;
>   "Just call me $_[0]";
>}

Cool!

hk




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

Date: 25 Oct 2002 08:35:04 -0700
From: pallia@hotmail.com (PeteA)
Subject: Perl Help
Message-Id: <2965ae60.0210250735.57cc23bb@posting.google.com>

Anyone out there have any or all solutions to the problems in the PERL
How to Program book by Deitel?


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

Date: 25 Oct 2002 17:30:15 +0100
From: Brian McCauley <nobull@mail.com>
Subject: Re: Perl Help
Message-Id: <u9smyu4h2g.fsf@wcl-l.bham.ac.uk>

pallia@hotmail.com (PeteA) writes:

> Subject: Perl Help

Please put the subject of your post in the Subject of your post.  If
in doubt try this simple test.  Imagine you could have been bothered
to have done a search before you posted.  Next imagine you found a
thread with your subject line.  Would you have been able to recognise
it as the same subject?

> Anyone out there have any or all solutions to the problems in the PERL
> How to Program book by Deitel?

Hell, you could almost have fit the whole thing in the subject line!

BTW: It's Perl not PERL.

Anyhow, back to the question, the answer is "yes".  According to the
Prentice Hall web site the product in question[1] is in-stock.  I've
not looked on other book retailers' web sites but doubtless many other
stockists have it too.

Or did I miss-understand?

[1] Instructor's Resource CD-ROM that accompanies Perl How to Program 
 
-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: Fri, 25 Oct 2002 20:10:04 -0000
From: Rocco Caputo <troc@netrus.net>
Subject: Re: PoCo::IRC dcc chat example / code snipped / help ?
Message-Id: <slrnarj98o.8ma.troc@eyrie.homenet>

POE::Component::IRC's author answered you on POE's mailing list:

| Mailing-List: contact poe-help@perl.org; run by ezmlm
| List-Subscribe: <mailto:poe-subscribe@perl.org>
| Date: Fri, 25 Oct 2002 08:32:32 -0700
| From: Dennis Taylor <dennis@funkplanet.com>
| To: Jeroen van Wissen <jeroen.van.wissen@twoop.com>
| Cc: poe@perl.org
| Subject: Re: PoCo::IRC dcc chat working code / example / help ?
| 
| On Fri, Oct 25, 2002 at 01:00:19PM +0200, Jeroen van Wissen wrote:
| 
| > The example that comes with the PoCo::IRC package only shows file
| > sending/getting.
| 
|         Look at examples/moo.pl in the P::C::IRC distribution.

-- Rocco Caputo / troc@pobox.com / poe.perl.org / poe.sf.net


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

Date: Wed, 16 Oct 2002 17:25:05 +0200
From: Gros Loup <smillet751@nospammersplz.hotmail.com>
Subject: Re: Q: does there exist an HTTP redirect script ?
Message-Id: <MPG.181782f8ad66965498968d@news.free.fr>

It works fine, thanks a lot.

Gros Loup.


In article <H41xFs.7J2@news.boeing.com>, ced@bcstec.ca.boeing.com 
says...
> In article <MPG.18163d9dce81146398968c@news.free.fr>,
> Gros Loup  <smillet751@nospammersplz.hotmail.com> wrote:
> >Hello,
> >
> >I need to trace HTTP connections between two given points and an easy 
> >way to proceed would be insert a PERL script, that would just listen and 
> >forward datas in telnet format (thus, not necessarily port 80) in both 
> >directions (and log it).
> >
> >Do you know of a PERL script that is capable of doing it (I didn't find 
> >in CPAN) ?
> >
> 
> httpsniffer [a Perl script] can do this:
> 
>  http://www.schmerg.com/WrapUp.asp?file=HttpSniffer.html
> 
> I seem to recall something similar in the 'Perl Cookbook' [authors 
> Christiansen,T and Torkington,N] but I'm not positive.
> 
> --
> Charles DeRykus
> 


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

Date: 25 Oct 2002 11:46:11 -0700
From: mary_wong1232002@yahoo.com (Mary Wong)
Subject: RegExpr
Message-Id: <5b85cd30.0210251046.63a8dfb3@posting.google.com>

Hi,

I am searching some words
Is there any better way to do that?

to find words contain 3 or more pairs 
of double letters
([a-z][a-z]){3}

to find words have their letters in
alphabetical order
                                    
/a?b?c?d?e?f?g?h?i?j?k?l?m?n?o?p?q?r?s?t?u?v?w?x?y?z?/
     or
                                   
/^[a-z]+$/


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

Date: 25 Oct 2002 15:31:29 -0400
From: Ryan Shondell <shondell@cis.ohio-state.edu>
Subject: Re: RegExpr
Message-Id: <xcw8z0muxgu.fsf@psi.cis.ohio-state.edu>

mary_wong1232002@yahoo.com (Mary Wong) writes:

> Hi,
> 
> I am searching some words
> Is there any better way to do that?
> 
> to find words contain 3 or more pairs 
> of double letters
> ([a-z][a-z]){3}

That looks like it would match any 6 lowercase letters. I don't think
that's what you want. Perhaps something like...

sub check_pairs {
  my $word = shift;
  my $count;
  while ($word =~ /([a-z])\1/g) { $count++ }
  return $count >= 3;
}


> to find words have their letters in
> alphabetical order
>                                     
> /a?b?c?d?e?f?g?h?i?j?k?l?m?n?o?p?q?r?s?t?u?v?w?x?y?z?/
>      or
>                                    
> /^[a-z]+$/

Ugh.

sub is_alphabetical {
  my @letters = split //,shift;

  foreach (1..$#letters) {
    if (($letters[$_] cmp $letters[$_-1]) < 1) {
      return 0;
    }
  }
  return 1;
}

You might want to read 'perldoc perlre' again. You are making some
interesting regexen that aren't doing what you think they are doing.

-- 
Ryan Shondell <shondell@cis.ohio-state.edu>


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

Date: Fri, 25 Oct 2002 21:12:05 GMT
From: "MR" <none@none.com>
Subject: Re: Regular Expression
Message-Id: <Fsiu9.81$jk4.6377533@newssvr14.news.prodigy.com>


"hubert depesz lubaczewski" <depesz@depesz.pl> wrote in message
news:slrn.pl.argo52.a4v.depesz@depeszws.depesz.pl...
> R.Noory wyrze¼bi³(a):
> > Now I have words with hyphen. I would like to write a single rule to
> > take care of every word that have hyphen or apostrophe.
>
> my (and others) reply to your last request, should be more than
> sufficent for anyone with at least 3 brain-cells to find out solution to
> your new problem. why don't you do it yourself?

Why be so rude? No problem with telling him which doc to look in but it CAN
be done wtihout being so rude you know. Rude as in implying with the brain
cell comment and such. You assume he knows a lot more than he probably does.
It's a bad assumption. If he's asking multiple questions he might not
understand what is in the docs, which many more exeriecned people fail to
take into accounts before making posts like this.

Not everyone is born knowing how to understand the language, the docs, or
have to use the docs effectively.

Thank about it, if you are someone who isn't particularly computer savy,
especially if you never used a doc system like perldoc or man (man if you're
on a *nix system), it's quite posible to become intimidated by it all.

It would help more if less negative assumptions would be made about a poster
and if you're going to post please try not let your ego do the writing,
thanks.




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

Date: Fri, 25 Oct 2002 21:29:52 +0000 (UTC)
From: develop@gistenson.com
Subject: Re: Replacing string in binary file
Message-Id: <apcd4g$fbf$1@flood.xnet.com>

Jue,

I tried opening the file and then doing:

<DAT> =~ s/abc/xyz/;

Although the file contained the string: abc, nothing happened; it was not 
replaced with: xyz. In other words, the statement did nothing.

Any ideas?

Dan

 <jurgenex@hotmail.com> wrote:
: develop@gistenson.com wrote:
:> I want to replace a string in a binary file. For example, I want to
:> replace the string "abc" with the string "xyz". Is there a way to do
:> this? Something similar to replacing a string in a scalar? (e.g.
:> $variable =~ s/abc/xyz/;)

: What happened when you tried it?
: Seriously, a file is a file is a file and Perl doesn't care about its
: content type.
: You just need to be careful about the automatic line end transformation
: (perldoc -f binmode) and the concept of a 'line' may not make much sense on
: binary files.

: jue




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

Date: Fri, 25 Oct 2002 21:32:55 +0000 (UTC)
From: develop@gistenson.com
Subject: Re: Replacing string in binary file
Message-Id: <apcda7$fbf$2@flood.xnet.com>


David,

I tried opening the file and then doing:

<DAT> =~ s/abc/xyz/;

Although the file contained the string: abc, nothing happened; it was 
not replaced with: xyz. In other words, the statement did nothing.

Any ideas?

Dan
David K. Wall <usenet@dwall.fastmail.fm> wrote:
:  <develop@gistenson.com> wrote on 25 Oct 2002:

:> I want to replace a string in a binary file. For example, I want to 
:> replace the string "abc" with the string "xyz". Is there a way to do this? 
:> Something similar to replacing a string in a scalar? (e.g. $variable =~ 
:> s/abc/xyz/;)

: What happened when you tried s/// ?

: -- 
: David K. Wall - usenet@dwall.fastmail.fm
: "Oook."


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

Date: 25 Oct 2002 21:38:59 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@post.rwth-aachen.de>
Subject: Re: Replacing string in binary file
Message-Id: <apcdlj$cvv$1@nets3.rz.RWTH-Aachen.DE>

[ please don't top-post ]

Also sprach develop@gistenson.com:

> I tried opening the file and then doing:
> 
><DAT> =~ s/abc/xyz/;
> 
> Although the file contained the string: abc, nothing happened; it was not 
> replaced with: xyz. In other words, the statement did nothing.

Then look again carefully: It threw a fatal error.

Why do you think that in-place changing the return value of a readline
would change the content of the file?

The approach is somewhat different:

    1. open 'file' for reading
    2. open 'newfile' for writing
    3. go through 'file' linewise, assigning it to a variable
    4. change content of the variable with s/// for instance
    5. write the changed variable into the new file
    
Tassilo
-- 
$_=q!",}])(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus;})(rekcah{lrePbus;})(lreP{rehtonabus;})(rehtona{tsuJbus!;
$_=reverse;s/sub/(reverse"bus").chr(32)/xge;tr~\n~~d;eval;


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

Date: Fri, 25 Oct 2002 17:54:17 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Replacing string in binary file
Message-Id: <3DB9BD89.15BACA4B@earthlink.net>

develop@gistenson.com wrote:
> 
> Hi,
> 
> I want to replace a string in a binary file. For example, I want to
> replace the string "abc" with the string "xyz". Is there a way to do
> this?  Something similar to replacing a string in a scalar? (e.g.
> $variable =~ s/abc/xyz/;)

Assuming you're on a machine which doesn't need binmode:
   perl -pi~ -e s/abc/xyz/ thefile

If you need binmode, and you are using perl 5.8.0:
   perl -Mopen=IO,:bytes -pi~ -e s/abc/xyz/ thefile

Otherwise, you need to explicitly open the file, binmode the handle,
open the output file, binmode the handle, loop to read from the input
file, perform the substitution, print tot he output handle.

-- 
my $n = 2; print +(split //, 'e,4c3H r ktulrnsJ2tPaeh'
 ."\n1oa! er")[map $n = ($n * 24 + 30) % 31, (42) x 26]


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

Date: Fri, 25 Oct 2002 10:54:00 -0500
From: brian d foy <comdog@panix.com>
Subject: Re: Slow code, improvements requested
Message-Id: <251020021054000731%comdog@panix.com>

In article <e47a84bf.0210241733.2a3e81d3@posting.google.com>, Jan Fure <jan_may2002_fure@attbi.com> wrote:

> I suspect my sort operation takes most of the computer resources.

don't suspect - know!

CPAN has a lot of good profilers, such as Devel::SmallProf or Devel::DProf.

   http://www.ddj.com/documents/s=1498/ddj0104pl/

-- 
brian d foy <comdog@panix.com> - Perl services for hire
The Perl Review - a new magazine devoted to Perl 
<http://www.theperlreview.com>


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

Date: Fri, 25 Oct 2002 17:28:50 GMT
From: "Dick Penny" <penny1482@attbi.com>
Subject: Re: Tk help, please.
Message-Id: <mbfu9.104483$La5.329226@rwcrnsc52.ops.asp.att.net>

I too am/was new to Tk and found LOTS of help from the Widget demo programs.
At a command prompt just type 'widget' and this will run widget.bat which
will run the widget demos.

Good luck.
Dick Penny
"Richard S Beckett" <spikey-wan@bigfoot.com> wrote in message
news:apb2vl$9bq$1@newshost.mot.com...
> Hello.
>
> I'm creating my first GUI, using active state on win32. I seem to be able
to
> find slightly better documentation for Tk, so I'm going with that.
>
> I'm having a problem with the menu bar command. If I run the script as is,
I
> get the following error:
> Failed to AUTOLOAD 'Tk::Frame::command' at script.pl line 31
>
> If I add "use Tk::Frame::command;", I get:
> Can't locate Tk/Frame/command.pm in @INC (@INC contains: D:/Perl/lib
> D:/Perl/site/lib .) at script.pl line 6.
> BEGIN failed--compilation aborted at script.pl line 6.
>
> I tried using PPM to install Tk::Frame::command, but got this:
> Installing package 'Tk-Frame-command'...
> Error installing package 'Tk-Frame-command': Could not locate a PPD file
for
> package Tk-Frame-command
>
> Please help me! :-)
>
> Also, does anyone have any useful information on how to position buttons,
> labels, etc within the window?
>
> Thanks.
>
> R.
>
> Here's my current snippet, ripped from something else...
>
> use strict;
> use warnings;
> use Tk;
> use Tk::Menu;
> use Tk::Widget;
>
> # setup new window
> my $main = new MainWindow;
>
> # title window
> $main->configure(-title => " My title", -background => "dark blue");
>
> # set location on screen
> $main->geometry ("+100+100");
>
> # set window size
> $main->minsize (qw(800 800));
>
> # add a label
> $main->Label(-text =>'Written by me.',
> -width => 80, -background => "blue", -foreground => "white")->pack (-side
=>
> "top", -fill => "x");
>
> # a menu bar
> my $menu_bar=$main->Frame(-relief => "groove",
> -borderwidth => 3,
> -background => "grey")
> ->pack (-side => "top", -fill => "x");
>
> my $menu=$menu_bar->Menubutton(-text=>"File",
> -background => "grey",
> -activebackground => "light grey",
> -foreground => "white")
> ->pack (-side => "left");
>
> # menu bar command
> $menu_bar->command(-label => "Exit", -command => sub{$main->destroy});
>
> # a quit button
> $main->Button(-text => "Quit!",
> -command => sub{$main->destroy})->pack;
>
> MainLoop;
>
>
>




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

Date: Fri, 25 Oct 2002 17:03:41 GMT
From: "Hya J." <Hyra@none.none>
Subject: use constant CONST_HASH => {...} in regex ?
Message-Id: <3DB978C1.FC63780C@none.none>

How can a constant hash be used in a regex expression? Like this:
(And yes I looked at the docs and faqs, mainly the pragma/constant one)

     use constant CONST_HASH = {"a" => "aaa", "b" => "bbb"};

     s/CONST_HASH{a}/.../;


I've ven tried
     s/CONST_HASH{"a"}/.../;
and
     s/CONST_HASH{'a'}/.../;

as well as changing to ${\...} style I saw somwhere:
     s/${\CONST_HASH{a}}/.../;
     s/${\CONST_HASH{"a"}}/.../;
     s/${\CONST_HASH{'a'}}/.../;
which seems to work with a normal scalara constant but not a hash
cosntant.

Thanks!



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

Date: Fri, 25 Oct 2002 13:27:08 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: use constant CONST_HASH => {...} in regex ?
Message-Id: <slrnarj37s.1sl.tadmc@magna.augustmail.com>

Hya J. <Hyra@none.none> wrote:
> How can a constant hash be used in a regex expression? Like this:
> (And yes I looked at the docs and faqs, mainly the pragma/constant one)
> 
>      use constant CONST_HASH = {"a" => "aaa", "b" => "bbb"};
                               ^
                               ^
                               ^

Look (closely) at "perldoc constant" one more time.


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


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

Date: Fri, 25 Oct 2002 13:48:14 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: use constant CONST_HASH => {...} in regex ?
Message-Id: <slrnarj4fe.21k.tadmc@magna.augustmail.com>

Tad McClellan <tadmc@augustmail.com> wrote:
> Hya J. <Hyra@none.none> wrote:
>> How can a constant hash be used in a regex expression? Like this:
>> (And yes I looked at the docs and faqs, mainly the pragma/constant one)
>> 
>>      use constant CONST_HASH = {"a" => "aaa", "b" => "bbb"};
>                                ^
>                                ^
>                                ^
> 
> Look (closely) at "perldoc constant" one more time.


Errr, but fixing that mistake doesn't answer your question.

The progma implements CONST_HASH as a subroutine, so your
question becomes this FAQ:

   "How do I expand function calls in a string?"
   

Applying that to the double-quotish regex:

   s/@{[  CONST_HASH->{a}  ]}/.../;


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


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

Date: Fri, 25 Oct 2002 20:40:45 GMT
From: THISISAFAKE@ADDRESS.000 (Steve)
Subject: Re: What is a file XXX.pl.swp ??
Message-Id: <3db9ac7e.22147279@news.earthlink.net>

On Wed, 23 Oct 2002 06:04:57 GMT, THISISAFAKE@ADDRESS.000 (Steve)
wrote:

>Hi,
>
>I just had a programmer write a script for my web site. When I
>installed it, there were a couple of files ending in .swp. This script
>was installed on a Linux server.
>
>What type of file is this? 
>

<<snip>>

Hi,

Thanks to everyone for their help. I emailed the programmer and he
told me they were from his word processor and could be deleted.

Thanks again for your help.

Steve

My real email address is dealsgalore[A-T]earthlink.net

www.cheap-land.com


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

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


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