[15919] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3332 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jun 12 18:06:04 2000

Date: Mon, 12 Jun 2000 15:05:25 -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: <960847525-v9-i3332@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Mon, 12 Jun 2000     Volume: 9 Number: 3332

Today's topics:
        [ RexExp ] Better way to write (string=~/(match)/)[0] ? <TheEx0rcist@fanclub.org>
    Re: [ RexExp ] Better way to write (string=~/(match)/)[ <aqumsieh@hyperchip.com>
    Re: [ RexExp ] Better way to write (string=~/(match)/)[ <TheEx0rcist@fanclub.org>
        ActiveState 5.6 still doesn't support alarm? (Windows) (Phil Tomson)
    Re: ANSI Perl: No Way !!! <htp@mac.com>
    Re: ANSI Perl: No Way !!! <dan@tuatha.sidhe.org>
    Re: ANSI Perl: No Way !!! <care227@attglobal.net>
    Re: ANSI Perl: No Way !!! <dan@tuatha.sidhe.org>
        Automating stuff through Perl <john69@raketnet.nl>
        Can't open perl script <webmaster@navarone.com>
        cgi.pm  if statements   and redirect problems <csorensen@uptimeresources.net>
    Re: cgi.pm  if statements   and redirect problems newsposter@cthulhu.demon.nl
    Re: cgi.pm  if statements   and redirect problems <csorensen@uptimeresources.net>
        Create dateformat yyyymmdd <hkamp1@hotmail.com>
        Creating a new folder and file. <shawnball@uswest.net>
    Re: Creating a new folder and file. <vikingrscup@rogue-spear.com>
    Re: Creating a new folder and file. <shawnball@uswest.net>
    Re: Creating a new folder and file. <tina@streetmail.com>
        Creating new folder and file and can't use mkdir() <shawnball@uswest.net>
    Re: Creating new folder and file and can't use mkdir() <tina@streetmail.com>
    Re: Diff. between putting & before a subroutine call (Tad McClellan)
    Re: Diff. between putting & before a subroutine call <aqumsieh@hyperchip.com>
    Re: Diff. between putting & before a subroutine call <tina@streetmail.com>
    Re: Diff. between putting & before a subroutine call (Bart Lateur)
    Re: Does Perl have a simple way to simulate C's "#INCLU (Bart Lateur)
    Re: Encrypting / decrypting. <todd@mrnoitall.com>
    Re: Encrypting / decrypting. (Bart Lateur)
        exec (cal) and split result into an array <lara@lodestone-sw.com>
    Re: I need some help with regex. (Bart Lateur)
        if ($perl_on_windows ne $perl_on_server) { print MAIL " <raphaelp@nr1webresource.com>
    Re: if ($perl_on_windows ne $perl_on_server) { print MA <lauren_smith13@hotmail.com>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Mon, 12 Jun 2000 20:23:32 +0200
From: "TheEx0rcist" <TheEx0rcist@fanclub.org>
Subject: [ RexExp ] Better way to write (string=~/(match)/)[0] ?
Message-Id: <8i39pl$ub5$1@news4.isdnet.net>

was wondering if there were a better way to write :

$matched = (string=~/(match)/[0])

any ideas?




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

Date: Mon, 12 Jun 2000 18:53:41 GMT
From: Ala Qumsieh <aqumsieh@hyperchip.com>
Subject: Re: [ RexExp ] Better way to write (string=~/(match)/)[0] ?
Message-Id: <7aln0abuiy.fsf@merlin.hyperchip.com>


"TheEx0rcist" <TheEx0rcist@fanclub.org> writes:

> was wondering if there were a better way to write :
> 
> $matched = (string=~/(match)/[0])

	($matched) = $string =~ /(match)/;

or

	$matched = $1 if $string =~ /(match)/;

or

	$string =~ /(match)/ and $matched = $1;

enough? ;-)

--Ala


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

Date: Mon, 12 Jun 2000 21:34:48 +0200
From: "TheEx0rcist" <TheEx0rcist@fanclub.org>
Subject: Re: [ RexExp ] Better way to write (string=~/(match)/)[0] ?
Message-Id: <8i3dv9$1et$1@news2.isdnet.net>

> > was wondering if there were a better way to write :
> >
> > $matched = (string=~/(match)/[0])
>
> ($matched) = $string =~ /(match)/;
>
> or
>
> $matched = $1 if $string =~ /(match)/;
>
> or
>
> $string =~ /(match)/ and $matched = $1;
>
> enough? ;-)

Hehe, more than I expected :-)

THANK YOU Ala !!




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

Date: 12 Jun 2000 14:14:35 -0700
From: ptkwt@user2.teleport.com (Phil Tomson)
Subject: ActiveState 5.6 still doesn't support alarm? (Windows)
Message-Id: <8i3jrr$qup$1@user2.teleport.com>

Seems I recall reading that alarm was going to be supported under windows
in Perl 5.6.  Today, I downloaded ActiveState 5.6 and tried the following
(a watchdog timer) code from the Perl Cookbook on a Win98 machine:

$SIG{ALRM} = sub { die "timeout"; };

eval{
   alarm(60);
      print "looping....\n";
      while (1) {}; 
   alarm(0);
};
if($@)
{
   if($@ =~ /timeout/)
   {
     print "hit timeout!\n";
   } else {
     alarm(0);
     die;
   }
}


And perl basically told me that the alarm function isn't supported.
Will alarm ever be supported under Windows Perl?

Is there another way to setup watchdog timers under Perl on Windows in the
absence of an alarm function?

Phil


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

Date: Tue, 13 Jun 2000 03:38:17 +0930
From: Henry <htp@mac.com>
Subject: Re: ANSI Perl: No Way !!!
Message-Id: <htp-C1A535.03381713062000@news.metropolis.net.au>

In article <nt715.111470$hT2.435404@news1.rdc1.ct.home.com>, Dan 
Sugalski <dan@tuatha.sidhe.org> wrote:

> I was't arguing that a formal standard was needed, merely that it
> would be a good thing. And it's possible that Gojira actually does
> have a legitimate issue with some undocumented change in behaviour. 

I seem to recall (and you'll correct me if I'm wrong) you saying that 
you were a member of the 'inner sanctum' (ex officio p5p)...

Now, I know very little about the p5p, but I get the impression that 
they are the ones who, ultimately, do the hard work and move the 
language forward.

If that's the case, then _their_ opinions are more important than anyone 
else's.

Does the p5p have consensus on this issue?

Would such a document help _them_ do their work.  Would it make _their_ 
lives easier?

Henry.


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

Date: Mon, 12 Jun 2000 19:06:18 GMT
From: Dan Sugalski <dan@tuatha.sidhe.org>
Subject: Re: ANSI Perl: No Way !!!
Message-Id: <Kwa15.276$Us2.395@news1.rdc1.ct.home.com>

Henry <htp@mac.com> wrote:
> In article <nt715.111470$hT2.435404@news1.rdc1.ct.home.com>, Dan 
> Sugalski <dan@tuatha.sidhe.org> wrote:

>> I was't arguing that a formal standard was needed, merely that it
>> would be a good thing. And it's possible that Gojira actually does
>> have a legitimate issue with some undocumented change in behaviour. 

> I seem to recall (and you'll correct me if I'm wrong) you saying that 
> you were a member of the 'inner sanctum' (ex officio p5p)...

Yup, as are a number of other folks here. Membership's not particularly
exclusive, though. :) It's as exclusive as the other big opensource
projects I know of.

> Now, I know very little about the p5p, but I get the impression that 
> they are the ones who, ultimately, do the hard work and move the 
> language forward.

> If that's the case, then _their_ opinions are more important than anyone 
> else's.

Well, Larry Wall's opinion is the most important. After that it's the more
senior p5p folk.

> Does the p5p have consensus on this issue?

Don't think anyone much cares, really. I expect Chip'd like to have one,
as it would make his work on Topaz much less trecherous, that's for sure.

> Would such a document help _them_ do their work.  Would it make _their_ 
> lives easier?

Yep. More than once someone's had to play with older interpeters (back to
perl 1, IIRC) to see how things behave when a change, often inadvertent,
in behavior was made. Sometimes things get reverted, sometimes not. It
doesn't happen much, and most folks know where the fuzzy bits are, but it
does sometimes happen.

						Dan


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

Date: Mon, 12 Jun 2000 15:32:22 -0400
From: Drew Simonis <care227@attglobal.net>
Subject: Re: ANSI Perl: No Way !!!
Message-Id: <39453AC6.638289CE@attglobal.net>

Dan Sugalski wrote:

> Yep. More than once someone's had to play with older interpeters (back to
> perl 1, IIRC) to see how things behave when a change, often inadvertent,
> in behavior was made. Sometimes things get reverted, sometimes not. It
> doesn't happen much, and most folks know where the fuzzy bits are, but it
> does sometimes happen.   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

What a horrible way to have something be.  What about the remaining
folks who don't know what or where the "fuzzy bits" are?  I can't 
think of a better case for the need of a standard.


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

Date: Mon, 12 Jun 2000 19:57:17 GMT
From: Dan Sugalski <dan@tuatha.sidhe.org>
Subject: Re: ANSI Perl: No Way !!!
Message-Id: <xgb15.3$My2.326@news1.rdc1.ct.home.com>

Drew Simonis <care227@attglobal.net> wrote:
> Dan Sugalski wrote:

>> Yep. More than once someone's had to play with older interpeters (back to
>> perl 1, IIRC) to see how things behave when a change, often inadvertent,
>> in behavior was made. Sometimes things get reverted, sometimes not. It
>> doesn't happen much, and most folks know where the fuzzy bits are, but it
>> does sometimes happen.   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

> What a horrible way to have something be.  What about the remaining
> folks who don't know what or where the "fuzzy bits" are?  I can't 
> think of a better case for the need of a standard.

This is the reason that I think having a standards doc would be a good
thing. There's nothing wrong with parts of a language being left
undefined, but its nice to know which parts and, more importantly, to know
what the parts that are defined are supposed to do.

					Dan


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

Date: Mon, 12 Jun 2000 21:35:11 +0200
From: "john69" <john69@raketnet.nl>
Subject: Automating stuff through Perl
Message-Id: <KnsPGYK1$GA.557@asd24-aux-005.tis.telfort.net>

Hi,

I am looking for a way to automatically jump from one HTML (with limited
HTML-support) to another one. With limited support I mean: no way to use a
meta-tag or a vb or javascript.
Looking for other possibiliets I found that I can run Perl scripts... Have
seen that all the elements seem to be there... but I just havn't been able
to put things together.
It seems that I should use the <img src=""> tag to load a GIF or so... and
that this should automatically redirect me ba means of code in rest of the
script.
As I'am not an experienced Perl user.. maybe someone can help me on my way.

Thanks in advance

John Groome
Brummen, Holland




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

Date: Mon, 12 Jun 2000 14:46:26 -0700
From: "Roger Brown" <webmaster@navarone.com>
Subject: Can't open perl script
Message-Id: <jSc15.2521$k2U.9109742@news.randori.com>

My apologies for the length of this post.  I just want to provide all the
info up front that I think someone might ask....

I have downloaded and installed ActivePerl 5.6, build 613 (the current
version).  The only change I made is to install on drive e: instead of c:.
Installation went fine.  Added path to E:\PERL\BIN.
In e:\perl\eq threre is a test file called example.pl.  I was told to run
this like so: "perl example".  I did.  It worked just fine, displaying on
the screen "Hello from ActivePerl!" as it should.  Then...

While 'screwing around where I probably shouldn't be', in windows explorer,
I double clicked on config.pl.  (I'm not sure if this caused my problem.)
Now, the dos command, still in the ~eg sub-dir, I receive the response
"Can't open perl script "example": No such file or directory".  The
example.pl is still there.  I have copied it to perl\bin and tried there;
same result. It's as though perl.exe is looking for "example.pl" in a place
where it doesn't exist instead of looking under its own nose. BUT...

When I dbl-click example.pl from the explorer, I can see the dos window
display the "Hello, etc." properly.

Anyone have any ideas what I have done wrong and how to fix it?

Thanks in advance for all who read and or respond to this post/question.




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

Date: 12 Jun 2000 16:24:57 EDT
From: Chris Sorensen <csorensen@uptimeresources.net>
Subject: cgi.pm  if statements   and redirect problems
Message-Id: <39454707.8FFF4DCA@uptimeresources.net>

well .. the following script seems to work fine .. except for one little
thing ... when it tries to redirect it send the user to
"http://www.insuremybiz.com/cgi-bin/confirmation.htm"  rather than
"http://www.insuremybiz.com/confirmation.htm"

any idea why ?



#!/usr/bin/perl -w
use strict;
use CGI ':cgi';


# check for cookie  if there  print to lstrans app


if cookie('idnet')       {

open IDNT, ">>lstrans.txt" or die "can't write file: $!";
print IDNT cookie('ident'). "\n";
close IDNT;

print header('text/html'),
print redirect('http://www.insuremybiz.com/confirmation.htm');

}

# if no cookie just redirect
else         {

print header('text/html'),
print redirect('http://www.insuremybiz.com/confirmation.htm');

}



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

Date: 12 Jun 2000 20:39:39 GMT
From: newsposter@cthulhu.demon.nl
Subject: Re: cgi.pm  if statements   and redirect problems
Message-Id: <8i3hqb$opg$1@internal-news.uu.net>

Chris Sorensen <csorensen@uptimeresources.net> wrote:
> well .. the following script seems to work fine .. except for one little
> thing ... when it tries to redirect it send the user to
> "http://www.insuremybiz.com/cgi-bin/confirmation.htm"  rather than
> "http://www.insuremybiz.com/confirmation.htm"

> any idea why ?

If you get behaviour you don't understand, consult the documentation,
it might give you some clues.

perldoc CGI

     The redirect() function redirects the browser to a different
     URL.  If you use redirection like this, you should not print
     out a header as well.

Erik



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

Date: 12 Jun 2000 16:42:38 EDT
From: Chris Sorensen <csorensen@uptimeresources.net>
Subject: Re: cgi.pm  if statements   and redirect problems
Message-Id: <39454B2C.E0CBDEB2@uptimeresources.net>

Thanks - I saw that but when I try to redirect without printing a header .. it
doesn't work  ... I'm not sure why

newsposter@cthulhu.demon.nl wrote:

> Chris Sorensen <csorensen@uptimeresources.net> wrote:
> > well .. the following script seems to work fine .. except for one little
> > thing ... when it tries to redirect it send the user to
> > "http://www.insuremybiz.com/cgi-bin/confirmation.htm"  rather than
> > "http://www.insuremybiz.com/confirmation.htm"
>
> > any idea why ?
>
> If you get behaviour you don't understand, consult the documentation,
> it might give you some clues.
>
> perldoc CGI
>
>      The redirect() function redirects the browser to a different
>      URL.  If you use redirection like this, you should not print
>      out a header as well.
>
> Erik



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

Date: Tue, 13 Jun 2000 05:22:10 +0200
From: "Hans Kamp" <hkamp1@hotmail.com>
Subject: Create dateformat yyyymmdd
Message-Id: <eg1jAuK1$GA.193@net025s>

For an application I need a dateformat yyyymmdd in a textbox. How can I
realize that with perl: something like:

$dateparameter = date(yyyymmdd),  but this doesn't work. I hope there is a
simple solution possible ;)

E-mail: h_kamp@yahoo.com
Much thanks when you can help me!




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

Date: Mon, 12 Jun 2000 14:31:30 -0700
From: "Ferk Da Jerk" <shawnball@uswest.net>
Subject: Creating a new folder and file.
Message-Id: <ECa15.573$UU6.26747@news.uswest.net>

When I use:

open (TEST, ">test/test.log");
print TEST ("Test");
close (TEST)

it does not work.  There folder "test" is not made yet.  So I want it to
create a folder called "test" and put a file called "test.log" inside of
that folder.  But my problem is it won't create the folder.  Does anyone
know how to create a folder or if there is something I'm doing wrong?




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

Date: Mon, 12 Jun 2000 21:20:06 +0200
From: "Viking" <vikingrscup@rogue-spear.com>
Subject: Re: Creating a new folder and file.
Message-Id: <8i3d4s$t8$1@news1.skynet.be>

you need to sue the perl command mkdir();

try this:

mkdir("test/") or die "Couldn't make directory test: $!";
chdir("test/");
open (TEST, ">test/test.log") or die "Couldn't create file test.log: $!";
print TEST "test";
close(TEST);

not sure if the relatives paths work tough..

VIking

Ferk Da Jerk <shawnball@uswest.net> wrote in message
news:ECa15.573$UU6.26747@news.uswest.net...
> When I use:
>
> open (TEST, ">test/test.log");
> print TEST ("Test");
> close (TEST)
>
> it does not work.  There folder "test" is not made yet.  So I want it to
> create a folder called "test" and put a file called "test.log" inside of
> that folder.  But my problem is it won't create the folder.  Does anyone
> know how to create a folder or if there is something I'm doing wrong?
>
>




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

Date: Mon, 12 Jun 2000 14:43:11 -0700
From: "Ferk Da Jerk" <shawnball@uswest.net>
Subject: Re: Creating a new folder and file.
Message-Id: <BNa15.592$UU6.26903@news.uswest.net>

Thanks for the help.

Viking <vikingrscup@rogue-spear.com> wrote in message
news:8i3d4s$t8$1@news1.skynet.be...
> you need to sue the perl command mkdir();
>
> try this:
>
> mkdir("test/") or die "Couldn't make directory test: $!";
> chdir("test/");
> open (TEST, ">test/test.log") or die "Couldn't create file test.log: $!";
> print TEST "test";
> close(TEST);
>
> not sure if the relatives paths work tough..
>
> VIking
>
> Ferk Da Jerk <shawnball@uswest.net> wrote in message
> news:ECa15.573$UU6.26747@news.uswest.net...
> > When I use:
> >
> > open (TEST, ">test/test.log");
> > print TEST ("Test");
> > close (TEST)
> >
> > it does not work.  There folder "test" is not made yet.  So I want it to
> > create a folder called "test" and put a file called "test.log" inside of
> > that folder.  But my problem is it won't create the folder.  Does anyone
> > know how to create a folder or if there is something I'm doing wrong?
> >
> >
>
>




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

Date: 12 Jun 2000 19:46:10 GMT
From: Tina Mueller <tina@streetmail.com>
Subject: Re: Creating a new folder and file.
Message-Id: <8i3em2$3tmj6$6@fu-berlin.de>

hi,

Viking <vikingrscup@rogue-spear.com> wrote:
> you need to sue the perl command mkdir();

> try this:

> mkdir("test/") or die "Couldn't make directory test: $!";
> chdir("test/");
> open (TEST, ">test/test.log") or die "Couldn't create file test.log: $!";
> print TEST "test";
> close(TEST);

> not sure if the relatives paths work tough..

nope :-)

try it without chdir.

tina



-- 
http://www.tinita.de \  enter__| |__the___ _ _ ___
tina's moviedatabase  \     / _` / _ \/ _ \ '_(_-< of
search & add comments  \    \ _,_\ __/\ __/_| /__/ perception


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

Date: Mon, 12 Jun 2000 15:11:46 -0700
From: "Ferk Da Jerk" <shawnball@uswest.net>
Subject: Creating new folder and file and can't use mkdir()
Message-Id: <pcb15.618$UU6.28728@news.uswest.net>

When I use:

open (TEST, ">test/test.log");
print TEST ("Test");
close (TEST)

it does not work.  There folder "test" is not made yet.  So I want it to
create a folder called "test" and put a file called "test.log" inside of
that folder.  But my problem is it won't create the folder.  Does anyone
know how to create a folder or if there is something I'm doing wrong?  I
also can't use mkdir(), because it brings up an error.




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

Date: 12 Jun 2000 20:07:04 GMT
From: Tina Mueller <tina@streetmail.com>
Subject: Re: Creating new folder and file and can't use mkdir()
Message-Id: <8i3ft8$3tmj6$7@fu-berlin.de>

hi,

Ferk Da Jerk <shawnball@uswest.net> wrote:
> When I use:

> open (TEST, ">test/test.log");
> print TEST ("Test");
> close (TEST)

would you please not start another thread for this?
try mkdir($directory,0766) instead of
mkdir($directory)
because mkdir needs two arguments.
you could have known that by reading the perl documentation on
mkdir:
perldoc -f mkdir

tina


-- 
http://www.tinita.de \  enter__| |__the___ _ _ ___
tina's moviedatabase  \     / _` / _ \/ _ \ '_(_-< of
search & add comments  \    \ _,_\ __/\ __/_| /__/ perception


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

Date: Mon, 12 Jun 2000 13:09:02 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Diff. between putting & before a subroutine call
Message-Id: <slrn8ka69e.17n.tadmc@magna.metronet.com>

On Mon, 12 Jun 2000 17:09:47 GMT, EnderW <ender29@my-deja.com> wrote:

> I am newbie to Perl. I use it from time to time. I was looking at
>subroutines. I have seen that they guy calls it like &my_sub instead of
>my_sub(). Is there a diff. between those two forms ? Thanks


Subroutines are documented in the perlsub.pod standard doc.

   perldoc perlsub


If you are having trouble understanding something that is says
there, then you will need to tell us what that is if you want
us to help you understand it.


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


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

Date: Mon, 12 Jun 2000 19:06:27 GMT
From: Ala Qumsieh <aqumsieh@hyperchip.com>
Subject: Re: Diff. between putting & before a subroutine call
Message-Id: <7ag0qibtxp.fsf@merlin.hyperchip.com>


"Paul R. Andersen" <andersen+@rchland.ibm.com> writes:

> EnderW wrote:
> > 
> > Hi,
> >  I am newbie to Perl. I use it from time to time. I was looking at
> > subroutines. I have seen that they guy calls it like &my_sub instead of
> > my_sub(). Is there a diff. between those two forms ? Thanks

 ...

> I am not aware of any difference in function.  The &my_sub is, in my
> opinion, not as nice to read as my_sub().  The & notation is old but
> still works.  If there is a difference, I've not run into it.

Then why bother replying if you can't help?

Subroutines, as others have shown, are documented in perlsub. The second
page tells it all:

   To call subroutines:

       NAME(LIST);    # & is optional with parentheses.
       NAME LIST;     # Parentheses optional if predeclared/imported.
       &NAME;         # Makes current @_ visible to called subroutine.

--Ala



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

Date: 12 Jun 2000 19:10:12 GMT
From: Tina Mueller <tina@streetmail.com>
Subject: Re: Diff. between putting & before a subroutine call
Message-Id: <8i3cik$3tmj6$4@fu-berlin.de>

hi,

EnderW <ender29@my-deja.com> wrote:
>  I am newbie to Perl. I use it from time to time. I was looking at
> subroutines. I have seen that they guy calls it like &my_sub instead of
> my_sub(). Is there a diff. between those two forms ? Thanks

yes, there is a difference.
please read
perldoc perlsub

there it is all explained with examples.

tina

-- 
http://www.tinita.de \  enter__| |__the___ _ _ ___
tina's moviedatabase  \     / _` / _ \/ _ \ '_(_-< of
search & add comments  \    \ _,_\ __/\ __/_| /__/ perception


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

Date: Mon, 12 Jun 2000 20:52:14 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Diff. between putting & before a subroutine call
Message-Id: <394d4beb.9057187@news.skynet.be>

Paul R. Andersen wrote:

>I am not aware of any difference in function.  The &my_sub is, in my
>opinion, not as nice to read as my_sub().  The & notation is old but
>still works.  If there is a difference, I've not run into it.

There are a few differences. In fact, there is a merge form between the
two: &my_sub(). "&" was necessary in Perl 4, but not in any Perl that is
newer than a few years.

	&my_sub;

Does not localize @_, so you pass any parameters in the calling sub (if
any) along to the called sub. Faster, if that sub doesn't ned
parameters.

	&my_sub();
	my_sub();

Basically the same thing. @_ is localized, and cleared. my_sub will see
an empty array.

Note that if you're reusing a perl keyword for your function name, the
"&" will help distinuish your custom function and Perl's built-in.

A fourth form is a bit dangerous:

	my_sub;

This will ONLY work if Perl has seen the sub definition, or a sub
declaration, before encountering this in source code. So, if my_sub is
defined in a use()d module, or in a sub in the script in front of where
this code line is, it will work. Otherwise, 

	mysub;

will be equivalent to 

	"mysub";

   HTH,
   Bart.


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

Date: Mon, 12 Jun 2000 20:29:08 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Does Perl have a simple way to simulate C's "#INCLUDE"?
Message-Id: <394a4721.7831316@news.skynet.be>

Trevor Sky Garside wrote:

>I now have partial success using "require", however I would like to have a
>"global" hash available to all subroutines - even those inclluded in the
>"require"'d files.  What I am finding is that each file is using its own
>namespace.

You're wrong. If you don't use a "package" statement anywhere,
everything will be put into package "main" by default.

Even if you use packages, you can still use "::" as a shortcut for
"main::". For example:

	package Foo::Bar;
	$::test = "Hi, there!\n";
	package Baz;
	print $::test;

In the same way, you can use %::hash and @::array. (Excuse me for
stating the obvious.)

-- 
	Bart.


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

Date: Mon, 12 Jun 2000 12:41:30 -0600
From: Todd Anderson <todd@mrnoitall.com>
Subject: Re: Encrypting / decrypting.
Message-Id: <39452ED5.45AAFD9D@mrnoitall.com>



Vivek Khera wrote:

> >>>>> "DW" == David Wall <darkon@one.net> writes:
>
> DW> mattking@techie.com (Matt King) wrote in
> DW> <8hnsjq$fhm$1@news1.transmedia.de>:
>
> >> Hi. I need a way to encrypt and decrypt a small string (between 8 and 16
> >> chars). I have looked on CPAN, but all I find are add-in modules. I need
>
> DW> perldoc -f crypt
>
> So, how would you recommend he DECRYPT what you just told him to
> encrypt using crypt()
>
> If you're gonna answer, at least answer correctly.
>
> --

$characters = crypt($characters, Salt)

Crypt can not be un-encrypted.



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

Date: Mon, 12 Jun 2000 19:10:13 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Encrypting / decrypting.
Message-Id: <39463571.3303903@news.skynet.be>

Todd Anderson wrote:

>$characters = crypt($characters, Salt)
>
>Crypt can not be un-encrypted.

Just like you can't reconstruct the contents of a file from it's CRC
alone.

-- 
	Bart.


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

Date: Mon, 12 Jun 2000 14:13:06 -0700
From: Lara Fabans <lara@lodestone-sw.com>
Subject: exec (cal) and split result into an array
Message-Id: <39455164.4ADCF679@lodestone-sw.com>

Hi,

I'm trying to create a very simple calendar (I've been trying to get
HTML::CalendarMonth to work, but it's taking more time then I
have at the moment...I'm trying to put together something quickly,
and would then go back and debug HTML::CalendarMonth) by
open(CAL, "cal |");
then I am trying to split.

The output of cal looks like this:
      June 2000
Su Mo Tu We Th Fr Sa
             1  2  3
 4  5  6  7  8  9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30

So I thought @data = [split];
would work, but it's not.

I tried to get a localized version by putting the data at the 
__END__
and reading it in.  It only read in 7 chunks (line by line instead
of splitting it up) (And it read in uninitialized data).

So, do I need to do 2 splits?  Do I need to split on a different
regex?

I searched the archives & can find nothing about this.  You'd
think it was so simple :-)

Thanks,
Lara
-- 
Lara J. Fabans          lara@lodestone-sw.com
Software Consultant     http://www.lodestone-sw.com
Lodestone Software, Inc.


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

Date: Mon, 12 Jun 2000 21:14:41 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: I need some help with regex.
Message-Id: <394e4f65.9947961@news.skynet.be>

john abbott wrote:

>The line,
><a href="contact.html"><img src="artwork/contact.gif" width="83"
>height="21" border=0 alt="Contact Us"></a><a href="sitemap.html"><img
>src="artwork/sitemap.gif" width="57" height="21" border=0 alt="Site
>Map"></a><a href="search.html"><img src="artwork/search.gif" width="95"
>height="21" border=0 alt="Search our Site"></a>
>
>and I am using,
>$body =~ s/\<img src=.*alt=\"(.*)">/$1/gi

You call that a "line"? It's not illegal for HTML tags to be spread over
multiple lines. So, in order for this regex to work, you need the //s
modifier so that '.' matches a newline too. BTW, you need nongreedy
matches, but you already knew that. And what if the "alt" attribute
isn't the last one in the list?

Maybe try out HTML::Parser anyway. HTML::TokeParser works very similar
to what you're used to: instead of reading one line at a time, it reads
one tag/processing instruction/comment at a time.

-- 
	Bart.


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

Date: Mon, 12 Jun 2000 22:03:29 +0200
From: "Raphael Pirker" <raphaelp@nr1webresource.com>
Subject: if ($perl_on_windows ne $perl_on_server) { print MAIL "to: Newsgroup" } ;-)
Message-Id: <8i3fl3$q5e$1@news.online.de>

Hi,

I have the following code on my Windows Workstation using Active Perl which
works very well. The same code on the Server results in nothing!

read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
@pairs = split(/&/, $buffer);
foreach $pair (@pairs) {
   ($name, $value) = split(/=/, $pair);
   $name =~ tr/+/ /;
   $name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
   $name =~ s/<!--(.|\n)*-->//g;
   $name =~ s/<([^>]|\n)*>//g;
   $value =~ tr/+/ /;
   $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
   $value =~ s/<!--(.|\n)*-->//g;
   $value =~ s/<([^>]|\n)*>//g;
   $FORM{$name} = $value;
}
foreach $key (keys(%FORM)) {
       $email_message .= "<input type=\"hidden\" name=\"".$key."\"
value=\"".$FORM{$key}."\">\n";
}

Any advice?




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

Date: Mon, 12 Jun 2000 13:27:16 -0700
From: "Lauren Smith" <lauren_smith13@hotmail.com>
Subject: Re: if ($perl_on_windows ne $perl_on_server) { print MAIL "to: Newsgroup" } ;-)
Message-Id: <8i3h1h$sak$1@brokaw.wa.com>


Raphael Pirker <raphaelp@nr1webresource.com> wrote in message
news:8i3fl3$q5e$1@news.online.de...
>
> read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
> @pairs = split(/&/, $buffer);
> foreach $pair (@pairs) {
>    ($name, $value) = split(/=/, $pair);
>    $name =~ tr/+/ /;
>    $name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
>    $name =~ s/<!--(.|\n)*-->//g;
>    $name =~ s/<([^>]|\n)*>//g;
>    $value =~ tr/+/ /;
>    $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
>    $value =~ s/<!--(.|\n)*-->//g;
>    $value =~ s/<([^>]|\n)*>//g;
>    $FORM{$name} = $value;
> }
> foreach $key (keys(%FORM)) {
>        $email_message .= "<input type=\"hidden\" name=\"".$key."\"
> value=\"".$FORM{$key}."\">\n";
> }
>
> Any advice?

Check out the CGI.pm module.  Lots of helpful functionality in there.

Lauren





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

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


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