[18498] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 666 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Apr 10 09:10:47 2001

Date: Tue, 10 Apr 2001 06:10:23 -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: <986908222-v10-i666@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Tue, 10 Apr 2001     Volume: 10 Number: 666

Today's topics:
    Re: save a value of a variable between subroutines run. (Anno Siegel)
    Re: save a value of a variable between subroutines run. <webmaster@webdragon.unmunge.net>
    Re: save a value of a variable between subroutines run. <NO_SPAM_klubbheads@home.com>
    Re: save a value of a variable between subroutines run. <NO_SPAM_klubbheads@home.com>
    Re: save a value of a variable between subroutines run. <NO_SPAM_klubbheads@home.com>
    Re: save a value of a variable between subroutines run. (Anno Siegel)
    Re: sendmail script - got to be something simple dcutter@gmx.de
    Re: sendmail script - got to be something simple nobull@mail.com
    Re: So what do YOU use Perl for? <bart.lateur@skynet.be>
    Re: So what do YOU use Perl for? <lmoran@wtsg.com>
    Re: To run perl in the backround <wayne.keenan@ntlworld.com>
    Re: Touch dcutter@gmx.de
    Re: Touch nobull@mail.com
        Using a Unix Script in a Perl script.vvp <vprasad@americasm01.nt.com>
        Using a Unix script in a Perl Script <vprasad@americasm01.nt.com>
    Re: Using a Unix script in a Perl Script (Bernard El-Hagin)
    Re: Using a Unix script in a Perl Script (Tad McClellan)
        Using References <lmoran@wtsg.com>
    Re: Want Lisp-like state machine impl. <bart.lateur@skynet.be>
    Re: We have 'use strict' and 'my', and now 'our', but n nobull@mail.com
    Re: We have 'use strict' and 'my', and now 'our', but n (Mark Jason Dominus)
    Re: wordsearcher-please help with my script (Anno Siegel)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 10 Apr 2001 10:02:23 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: save a value of a variable between subroutines run... (++)
Message-Id: <9aulnf$hq7$1@mamenchi.zrz.TU-Berlin.DE>

According to Roman Filippov <NO_SPAM_klubbheads@home.com>:
> Thanx for responce...
> 
> That is not exactly what i wanted.

You are dismissing Uri's suggestion too hastily.  No, it is not
exactly what you wanted, but it shows you the tools to build what
you want.

Uri's code was:

    {
            my $foo ;
    
            sub bar {
    
                    return ++$foo ;
            }
    }


The idea was to inspire you to *apply* this to your problem:

    # untested code

    {   my $filename = '';
        my @contents;

        sub bar {
            my $newfile = shift;
            if ( $newfile ne $filename ) {
                $filename = $newfile;
                open( my $f, $filename) or die "Can't read $filename: $!";
                @contents = <$f>;
            }
            # do something with @contents
        }
    }

This will only read the file once in a series of calls of bar( $file)
with the same $file.  It also keeps $filename and @contents in private
variables that only bar (and other functions defined in that block)
can access.

> Actually I am talking about the example from Perl Cookbook. It's in section
> "Automatization in Web" - "Creating HTML templates" (20.9) - I am not sure
> it's called exactly like that, because my book is in Russian.

[snip]

Uri understood quite well what you wanted.  You didn't understand that
he solved your problem.

Anno


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

Date: 10 Apr 2001 11:00:26 GMT
From: "Scott R. Godin" <webmaster@webdragon.unmunge.net>
Subject: Re: save a value of a variable between subroutines run... (++)
Message-Id: <9aup4a$jis$0@216.155.33.76>

In article <slrn9d4u2c.te8.tjla@thislove.dyndns.org>,
 tjla@guvfybir.qlaqaf.bet (Gwyn Judd) wrote:

 | I was shocked! How could Roman Filippov <NO_SPAM_klubbheads@home.com>
 | say such a terrible thing:
 | 
 | >When i fetch data from SQL server, I want to display it as HTML, but using
 | >templates. So i this case, i have a template that looks like this:
 | >
 | ><tr>
 | >    <td>%%something%%</td>
 | ></tr>
 | >
 | >and I call this template for each row. If there are 100 rows, it is going to
 | >open file 100 times. And template() could be run from anywhere in the
 | >program... I need the the subrouting to remember the file that has beed
 | >opened...
 | 
 | Sounds like you have the priorities inside out. If the function is being
 | called repeatedly, why not have the calling function load the template
 | and then pass it to the function as a parameter, rather than trying to
 | do the static variable trick?


particularly when you can

#!perl -w
use strict;
use CGI qw/:standard/;

my @tabledata = qw/one two three four five six seven/;

print table("\n",
        map { Tr(td($_)), "\n"} @tabledata,
      );

with CGI.pm you can literally create your HTML template using the 
function-oriented interface of the CGI module. MUCH simpler, unless your 
HTML is so blastedly complex this would be otherwise impossible.. That's 
for you to decide. 

:) HTH

-- 
unmunge e-mail here:
#!perl -w
print map {chr(ord($_)-3)} split //, "zhepdvwhuCzhegudjrq1qhw"; 
# ( damn spammers. *shakes fist* take a hint. =:P )


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

Date: Tue, 10 Apr 2001 12:19:36 GMT
From: "Roman Filippov" <NO_SPAM_klubbheads@home.com>
Subject: Re: save a value of a variable between subroutines run... (++)
Message-Id: <sTCA6.197879$A6.43915858@news4.rdc1.on.home.com>


"Scott R. Godin" <webmaster@webdragon.unmunge.net> wrote in message
news:9aup4a$jis$0@216.155.33.76...
> In article <slrn9d4u2c.te8.tjla@thislove.dyndns.org>,
>  tjla@guvfybir.qlaqaf.bet (Gwyn Judd) wrote:
>
>  | I was shocked! How could Roman Filippov <NO_SPAM_klubbheads@home.com>
>  | say such a terrible thing:
>  |
>  | >When i fetch data from SQL server, I want to display it as HTML, but
using
>  | >templates. So i this case, i have a template that looks like this:
>  | >
>  | ><tr>
>  | >    <td>%%something%%</td>
>  | ></tr>
>  | >
>  | >and I call this template for each row. If there are 100 rows, it is
going to
>  | >open file 100 times. And template() could be run from anywhere in the
>  | >program... I need the the subrouting to remember the file that has
beed
>  | >opened...
>  |
>  | Sounds like you have the priorities inside out. If the function is
being
>  | called repeatedly, why not have the calling function load the template
>  | and then pass it to the function as a parameter, rather than trying to
>  | do the static variable trick?
>
>
> particularly when you can
>
> #!perl -w
> use strict;
> use CGI qw/:standard/;
>
> my @tabledata = qw/one two three four five six seven/;
>
> print table("\n",
>         map { Tr(td($_)), "\n"} @tabledata,
>       );
>
> with CGI.pm you can literally create your HTML template using the
> function-oriented interface of the CGI module. MUCH simpler, unless your
> HTML is so blastedly complex this would be otherwise impossible.. That's
> for you to decide.
>

As i said, I don't like modules. And btw, i implemented my own include
feature in templates.


> :) HTH
>
> --
> unmunge e-mail here:
> #!perl -w
> print map {chr(ord($_)-3)} split //, "zhepdvwhuCzhegudjrq1qhw";
> # ( damn spammers. *shakes fist* take a hint. =:P )




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

Date: Tue, 10 Apr 2001 12:22:43 GMT
From: "Roman Filippov" <NO_SPAM_klubbheads@home.com>
Subject: Re: save a value of a variable between subroutines run... (++)
Message-Id: <nWCA6.197890$A6.43918266@news4.rdc1.on.home.com>


"Anno Siegel" <anno4000@lublin.zrz.tu-berlin.de> wrote in message
news:9aulnf$hq7$1@mamenchi.zrz.TU-Berlin.DE...
> According to Roman Filippov <NO_SPAM_klubbheads@home.com>:
> > Thanx for responce...
> >
> > That is not exactly what i wanted.
>
> You are dismissing Uri's suggestion too hastily.  No, it is not
> exactly what you wanted, but it shows you the tools to build what
> you want.
>
> Uri's code was:
>
>     {
>             my $foo ;
>
>             sub bar {
>
>                     return ++$foo ;
>             }
>     }
>
>
> The idea was to inspire you to *apply* this to your problem:
>
>     # untested code
>
>     {   my $filename = '';
>         my @contents;
>
>         sub bar {
>             my $newfile = shift;
>             if ( $newfile ne $filename ) {
>                 $filename = $newfile;
>                 open( my $f, $filename) or die "Can't read $filename: $!";
>                 @contents = <$f>;
>             }
>             # do something with @contents
>         }
>     }
>


I don't understant then, what are the most outer brackets are for? Is it
another function?


> This will only read the file once in a series of calls of bar( $file)
> with the same $file.  It also keeps $filename and @contents in private
> variables that only bar (and other functions defined in that block)
> can access.
>
> > Actually I am talking about the example from Perl Cookbook. It's in
section
> > "Automatization in Web" - "Creating HTML templates" (20.9) - I am not
sure
> > it's called exactly like that, because my book is in Russian.
>
> [snip]
>
> Uri understood quite well what you wanted.  You didn't understand that
> he solved your problem.
>
> Anno




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

Date: Tue, 10 Apr 2001 12:25:30 GMT
From: "Roman Filippov" <NO_SPAM_klubbheads@home.com>
Subject: Re: save a value of a variable between subroutines run... (++)
Message-Id: <_YCA6.197901$A6.43921559@news4.rdc1.on.home.com>


"Joe Schaefer" <joe+usenet@sunstarsys.com> wrote in message
news:m3n19p8kyr.fsf@mumonkan.sunstarsys.com...
> "Roman Filippov" <NO_SPAM_klubbheads@home.com> writes:
>
> > "Joe Schaefer" <joe+usenet@sunstarsys.com> wrote in message
> > news:m3zodp8xdl.fsf@mumonkan.sunstarsys.com...
>
> > >   sub some_sub {
> > >     my %cache if 0;         # static variable trick
> >
> > Can u tell me more about that please or just tell me the part of
reference
> > or place where I can read?
> >
> > And how would %cache get saved in between the sessions?
>
> It's a trick(bug?)- I don't think it's documented anywhere.  Basically
> it has the same effect as writing this
>
>     {   my %cache;
>         sub some_sub {
>         ...
>         }
>     }
>
> #!/usr/bin/perl -wl
> use strict;
> sub foo {
>   my %cache if 0;
>   $cache{$_[0]} ||= warn "making cache for $_[0]";
>   keys %cache;
> }
>
> foo($_) for 1..5;
> foo($_) for 1..5;
>
> print foo(1);
>
> __END__
>
> Output:
> making cache for 1 at /tmp/try.pl line 5.
> making cache for 2 at /tmp/try.pl line 5.
> making cache for 3 at /tmp/try.pl line 5.
> making cache for 4 at /tmp/try.pl line 5.
> making cache for 5 at /tmp/try.pl line 5.
> 12345
>
> It's based on some compile-time/run-time magic that I can't
> adequately explain, so I won't try. There was some discussion
> of this idiom on p5p some time ago and IIRC the consensus was
> that this is not a bug ( i.e. nobody's planning to "fix" it ).
>


Do you have a link to that discussion? I would like to read it, if it's
still available.

> YMMV
>
> --
> Joe Schaefer       "Technological progress is like an axe in the hands of
a
>                                    pathological criminal."
>                                                --Albert Einstein




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

Date: 10 Apr 2001 12:47:21 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: save a value of a variable between subroutines run... (++)
Message-Id: <9auvcp$hq7$2@mamenchi.zrz.TU-Berlin.DE>

According to Roman Filippov <NO_SPAM_klubbheads@home.com>:
> 
> "Anno Siegel" <anno4000@lublin.zrz.tu-berlin.de> wrote in message
> news:9aulnf$hq7$1@mamenchi.zrz.TU-Berlin.DE...
> > According to Roman Filippov <NO_SPAM_klubbheads@home.com>:

[...]

> > The idea was to inspire you to *apply* this to your problem:
> >
> >     # untested code
> >
> >     {   my $filename = '';
> >         my @contents;
> >
> >         sub bar {
> >             my $newfile = shift;
> >             if ( $newfile ne $filename ) {
> >                 $filename = $newfile;
> >                 open( my $f, $filename) or die "Can't read $filename: $!";
> >                 @contents = <$f>;
> >             }
> >             # do something with @contents
> >         }
> >     }
> >
> 
> 
> I don't understant then, what are the most outer brackets are for? Is it
> another function?

It's what we call a bare block.

Do you know how lexical variables work?  They are only accessible from
within the closest enclosing block.  A block, for practical purposes,
is Perl code enclosed in {}.

So actually the outer brackets are not needed for the code to function
as described, we might as well leave them off.  But then the variables
$filename and @contents would be file scoped lexicals (the content of
a source file also forms a block), and every other subroutine in the file
could access them.  The bare block creates a lexical name space to
isolate the variables.  This was an express requirement in your original
posting.

Anno


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

Date: 10 Apr 2001 11:40:22 GMT
From: dcutter@gmx.de
Subject: Re: sendmail script - got to be something simple
Message-Id: <9aurf6$v4n$1@news.netmar.com>

In article <uHJz6.53601$hf.23315624@news1.elmhst1.il.home.com>, Wes
<theXYZtenor@attXYZ.XYZnet> writes:
>I appologize for posting this here, but I'm not sure if I've got a perl,
>sendmail or server problem. This has got to be something so obvious: I'm
>trying to run a simple sendmail script on an AT&T small business hosting
>server and I have yet to be able to send mail. So far the folks at AT&T
>haven't been very helpful.
>
>script follows:
>
>if ( !open(MAIL, "|/usr/lib/sendmail -t") ) {
>            print "Open mail failed\n";
>            exit;
>}
>print MAIL "To: me\@noplace.com\n";
>print MAIL "From: me\@somewhere.net\n";
>print MAIL "Subject: Testing mail script\n\n";
>print MAIL "This is a test\n\n";
>
>close (MAIL);
>....remaining script generates html
>
>The subsequent html in my script gets generated indicating the script
>finishes. If I run with -d option I get the following output.
>
>
>main::(/usr/local/apache/htdocs/hosts/meetinga/cgi-local/TestMail.pl:36):
>36: if ( !open(MAIL, "|/usr/lib/sendmail -t") ) {
>  DB<1> Can't modify constant item in scalar assignment at (eval 3) line 2,
>at EOF
>
>  DB<2>

I've done things like this before and it worked. I think you just screwed up
that open by writing ! in front of it. Try one of these:

unless ( open(MAIL, "|/usr/lib/sendmail -t") ) { ... 

or

open(MAIL, "|/usr/lib/sendmail -t") || die "Open mail failed\n";

which is what everybody else writes and works fine with me.

Daniel


 -----  Posted via NewsOne.Net: Free (anonymous) Usenet News via the Web  -----
  http://newsone.net/ -- Free reading and anonymous posting to 60,000+ groups
   NewsOne.Net prohibits users from posting spam.  If this or other posts
made through NewsOne.Net violate posting guidelines, email abuse@newsone.net


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

Date: 10 Apr 2001 13:00:08 +0100
From: nobull@mail.com
Subject: Re: sendmail script - got to be something simple
Message-Id: <u9n19p9d87.fsf@wcl-l.bham.ac.uk>

dcutter@gmx.de writes:

> In article <uHJz6.53601$hf.23315624@news1.elmhst1.il.home.com>, Wes
> <theXYZtenor@attXYZ.XYZnet> writes:

> >if ( !open(MAIL, "|/usr/lib/sendmail -t") ) {

> I've done things like this before and it worked.

> unless ( open(MAIL, "|/usr/lib/sendmail -t") ) { ... 

Daniel is giving out cargo-cult advice suggesting that changing "if
not" to "unless" may help.

Daniel, take a look at Godzilla's posts to see where this path leads.

OP, obvious question - is /usr/lib/sendmail on the server?  Are you
allowed to use it?

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


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

Date: Tue, 10 Apr 2001 09:27:32 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: So what do YOU use Perl for?
Message-Id: <5hk5dt43oj31s3f1o6al9lsjtra16ejd7t@4ax.com>

Elaine Ashton wrote:

>True but far and away the most searched for items on search.cpan.org are
>DBI, CGI, LWP, MIME::*, HTML::* and XML. While this doesn't
>indicate usage it does indate that 80% of the queries are related to
>CGI and the web in some form or another. 

You're assuming too much. Nothing indicates that DBI is related to CGI
whatsoever.

-- 
	Bart.


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

Date: Tue, 10 Apr 2001 08:42:24 -0400
From: Lou Moran <lmoran@wtsg.com>
Subject: Re: So what do YOU use Perl for?
Message-Id: <2sv5dtced9113qlbttp5jnl8l6kmhlrjlp@4ax.com>

On Sat, 07 Apr 2001 20:43:01 -0400, Szilvia Oszko <soszko@gmu.edu>
wrote wonderful things about sparkplugs:

>One recurring theme in this newsgroup seems to be that Perl!=CGI and
>that while Perl is often used to write CGI scripts, it can also be used
>to do a lot of other things. I'd be curious to see what non-CGI stuff
>you do with Perl.


I used Perl to learn programming.  And I find myself using it over the
other languages I have picked up along the way.

--
print "\x{263a}" 


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

Date: Tue, 10 Apr 2001 08:09:18 +0100
From: "wayne.keenan" <wayne.keenan@ntlworld.com>
Subject: Re: To run perl in the backround
Message-Id: <3AD2B19E.3B8E1EA@ntlworld.com>

a recipe is in the cookbook, it goes along the lines of using a bootstrapping
perl script:
credits go to Tom Christiansen & Nathan Torkington
http://www.oreilly.com/catalog/cookbook/


#!/usr/bin/perl -w
# loader - starts Perl scripts without the annoying DOS window
use strict;
use Win32;
use Win32::Process;

# Create the process object.

Win32::Process::Create($Win32::Process::Create::ProcessObj,
    'C:/perl5/bin/perl.exe',            # Whereabouts of Perl
    'perl realprogram',                 #
    0,                                  # Don't inherit.
    DETACHED_PROCESS,                   #
    ".") or                             # current dir.
die print_error();

sub print_error() {
    return Win32::FormatMessage( Win32::GetLastError() );
}

T_Boss wrote:

> I have developed a perl program wich has to monitor some PsrtMasters.
> to run it, I have to open the comment promt box. and run the program.
> To keep it running I have to keep this box open.
> Is there anyway to let perl run in the backround, so that i can close this
> box??
>  I have Active perl 5.6 on Win NT 4.0  Sp 5.0



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

Date: 10 Apr 2001 11:31:47 GMT
From: dcutter@gmx.de
Subject: Re: Touch
Message-Id: <9auqv3$ui3$1@news.netmar.com>

In article <WFUz6.85670$Xx6.942390@Flipper>, Waarddebon
<Waarddebon@chello.nl> writes:
>When I try this:
>$file="..\loper.txt";
>touch -t 200104100303.55 $file;
>
>I get the error message:
>syntax error at loper.pl line 13, near "touch -t "
>Scalar found where operator expected at loper.pl line 13, at end of line
>    (Missing operator before ?)
>Execution of loper.pl aborted due to compilation errors
>
>But I can't figure out what is wrong with it

Quite simple: Perl doesn't know that touch is an external command. Tell him zu
execute it (with backticks).

$file = "..\loper.txt";
`touch -t 200104100303.55 $file`;


Daniel

 -----  Posted via NewsOne.Net: Free (anonymous) Usenet News via the Web  -----
  http://newsone.net/ -- Free reading and anonymous posting to 60,000+ groups
   NewsOne.Net prohibits users from posting spam.  If this or other posts
made through NewsOne.Net violate posting guidelines, email abuse@newsone.net


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

Date: 10 Apr 2001 12:53:31 +0100
From: nobull@mail.com
Subject: Re: Touch
Message-Id: <u9puel9dj8.fsf@wcl-l.bham.ac.uk>

dcutter@gmx.de writes:

> execute it (with backticks).

See FAQ for why this is generally considered bad advice.

perldoc -q backticks

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


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

Date: Tue, 10 Apr 2001 05:05:38 -0400
From: "Prasad, Victor [FITZ:K500:EXCH]" <vprasad@americasm01.nt.com>
Subject: Using a Unix Script in a Perl script.vvp
Message-Id: <3AD2CCE2.41D21073@americasm01.nt.com>

Hello,

I have a unix script that accepts up to two parameters.  Once entered it
performs its task and spits out output as it is working.

I would like to use this script in a perl script.

I have to pass the parameters to the Unix script - but am not sure how
to get the output from the script to Perl.

Basically it the Unix script looks like this:

Catalog?  10
Item? 5

Working...

Updated catalog 10
Max items 100
Inserted 5
New total 5

Successful.

I was going to use the system command to make the script run.  But am
not sure how to get the output to let the use know all is OK.

Any advice?

Thanks,

V


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

Date: Tue, 10 Apr 2001 05:04:36 -0400
From: "Prasad, Victor [FITZ:K500:EXCH]" <vprasad@americasm01.nt.com>
Subject: Using a Unix script in a Perl Script
Message-Id: <3AD2CCA4.2B4E71EB@americasm01.nt.com>

Hello,

I have a unix script that accepts up to two parameters.  Once entered it
performs its task and spits out output as it is working.

I would like to use this script in a perl script.

I have to pass the parameters to the Unix script - but am not sure how
to get the output from the script to Perl.

Basically it the Unix script looks like this:

Catalog?  10
Item? 5

Working...

Updated catalog 10
Max items 100
Inserted 5
New total 5

Successful.

I was going to use the system command to make the script run.  But am
not sure how to get the output to let the use know all is OK.

Any advice?

Thanks,

V


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

Date: Tue, 10 Apr 2001 09:21:43 +0000 (UTC)
From: bernard.el-hagin@lido-tech.net (Bernard El-Hagin)
Subject: Re: Using a Unix script in a Perl Script
Message-Id: <slrn9d5k4g.cs8.bernard.el-hagin@gdndev32.lido-tech>

On Tue, 10 Apr 2001 05:04:36 -0400, Prasad, Victor [FITZ:K500:EXCH]
<vprasad@americasm01.nt.com> wrote:
>Hello,
>
>I have a unix script that accepts up to two parameters.  Once entered it
>performs its task and spits out output as it is working.
>
>I would like to use this script in a perl script.
>
>I have to pass the parameters to the Unix script - but am not sure how
>to get the output from the script to Perl.
>
>Basically it the Unix script looks like this:
>
>Catalog?  10
>Item? 5
>
>Working...
>
>Updated catalog 10
>Max items 100
>Inserted 5
>New total 5
>
>Successful.
>
>I was going to use the system command to make the script run.  But am
>not sure how to get the output to let the use know all is OK.
>
>Any advice?

Read about backticks in:

perldoc perlop

Cheers,
Bernard
--
#requires 5.6.0
perl -le'* = =[[`JAPH`]=>[q[Just another Perl hacker,]]];print @ { @ = [$ ?] }'


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

Date: Tue, 10 Apr 2001 07:17:10 -0400
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Using a Unix script in a Perl Script
Message-Id: <slrn9d5qtm.41h.tadmc@tadmc26.august.net>

Prasad, Victor [FITZ:K500:EXCH] <vprasad@americasm01.nt.com> wrote:

>I have to pass the parameters to the Unix script - but am not sure how
>to get the output from the script to Perl.

>I was going to use the system command to make the script run.  But am
                        ^^^^^^
>not sure how to get the output to let the use know all is OK.
>
>Any advice?


Yes.

Read the documentation for the functions that you use.

The answer to your question is given by:

   perldoc -f system


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


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

Date: Tue, 10 Apr 2001 08:39:42 -0400
From: Lou Moran <lmoran@wtsg.com>
Subject: Using References
Message-Id: <qav5dts37g3v1i4qel1or5kopfnblcmhc2@4ax.com>

--Been writing Perl stuff again (mostly for Sys Admining) and I was
reading my books and while I am not confused as to how references work
I am wondering what I would use them for.

--In Johnson's book (which I find the easiest to read (find stuff) he
has an excellent example of how references work:

my $outer;
{
	my $inner = 42;
	$outer = \$inner;
}
print "$$outer\n" ; #prints 42

Makes perfect sense.  

Why would I do this?  When would this be useful? 

--
print "\x{263a}" 


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

Date: Tue, 10 Apr 2001 10:33:29 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Want Lisp-like state machine impl.
Message-Id: <kco5dtc1u0lm5pg658461f6m13m474lhul@4ax.com>

Logan Shaw wrote:

>Hmm.  I'm not sure how that makes it prettier.  Maybe I'm
>misunderstanding, but how do you protect against using a state
>definition picking a subroutine name that's already used?

Putting the state subs in a separate package?

-- 
	Bart.


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

Date: 10 Apr 2001 12:27:51 +0100
From: nobull@mail.com
Subject: Re: We have 'use strict' and 'my', and now 'our', but no 'use local-scope' -   why?
Message-Id: <u9snjh9eq0.fsf@wcl-l.bham.ac.uk>

Phil Voris <pvoris@nekophile.com> writes:

> I've long been baffled that there is no pragma to automatically declare
> all variables as default locally-scoped.  This way, rather than typing
> 'my' everywhere, one could just type the ocassional 'our' and assume
> everything else is local (er, my'd).  I understand that there would be
> problems with older code, but it sure would be a nice pragma to invoke
> on new code.
> 
> Thoughts?

Bloody awfull idea.

The reason that using my() is good is not because lexically scoped
variables in Perl are a little faster than package scoped ones.  The
reason my() is good is because it is good practice, in all
programmming languages, to limit varaiables' lifetime and scope to the
smallest appripriate enclosing scope.  Also requiring explicit
declaration of variables helps prevent typos in variable names causing
hard to track bugs.

There's no way for your pragma to know what the appropriate scope.  If
you are going to declare all your variables with file-scope you may as
well just switch off strict and use package scope.  If you are going
to implictly scope all variable to the first scope in which they are
seen you are really going to cause confusion.

It is much more effort (and hense much more error prone) for the
programmer to have to think for each variable "will the implicit
scoping wizard get it right or do I have to explicitly scope this
variable" rather than explicitly scope every variable.

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


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

Date: Tue, 10 Apr 2001 04:02:23 GMT
From: mjd@plover.com (Mark Jason Dominus)
Subject: Re: We have 'use strict' and 'my', and now 'our', but no 'use local-scope' -  why?
Message-Id: <3ad285ce.327a$28e@news.op.net>

In article <3AD2864E.68F8FBCF@nowhere.com>,
Phil Voris  <pvoris@nekophile.com> wrote:
>I've long been baffled that there is no pragma to automatically declare
>all variables as default locally-scoped.  

Because nobody knows what that would mean.

>This way, rather than typing 'my' everywhere, one could just type the
>ocassional 'our' and assume everything else is local (er, my'd).

But local to what?  The file? The innermost block in which it appears?
Neither of those are sensible.

>Thoughts?

I think you haven't thought this through carefully enough.

-- 
@P=split//,".URRUU\c8R";@d=split//,"\nrekcah xinU / lreP rehtona tsuJ";sub p{
@p{"r$p","u$p"}=(P,P);pipe"r$p","u$p";++$p;($q*=2)+=$f=!fork;map{$P=$P[$f^ord
($p{$_})&6];$p{$_}=/ ^$P/ix?$P:close$_}keys%p}p;p;p;p;p;map{$p{$_}=~/^[P.]/&&
close$_}%p;wait until$?;map{/^r/&&<$_>}%p;$_=$d[$q];sleep rand(2)if/\S/;print


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

Date: 10 Apr 2001 08:46:37 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: wordsearcher-please help with my script
Message-Id: <9auh9d$ds1$2@mamenchi.zrz.TU-Berlin.DE>

According to Armin Nolte  <armin.nolte@aktion-mensch.de>:
> -=-=-=-=-=-
> 
> my skript 'search.pl' does not finish his work and I don't know why
> 
> So heres a summary:
>    Task:
>     search in all  files / subdirectories for a key - word.
>    Process:
>    saves files/directory names in a hash., goes through them and after
> work is done, it  'undefs' the hash-values.
>    Problem:
>     in large dir-trees not  all values are 'undef', debugger says '100
> levels deep in subroutine calls'.(???)
> 
> Question:
> Is there any option which causes this (mis)behavior? Does someone know
> this problem? Is there an
> existing script which does this work (probably it is but what's it's
> name)

You posted this five days ago and got two replies, one from myself and
one from MJD (Himself).  Did you read them?

Anno


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

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


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