[18074] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 234 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Feb 7 14:10:53 2001

Date: Wed, 7 Feb 2001 11:10:27 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <981573027-v10-i234@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Wed, 7 Feb 2001     Volume: 10 Number: 234

Today's topics:
    Re: how to remove item in the array? (Shawn Jamison)
    Re: Linux does reclaim memory from perl <joe+usenet@sunstarsys.com>
    Re: Logfile pattern search & print (Garry Williams)
        LWP::Simple issue? (Peter L. Berghold)
    Re: LWP::Simple issue? (Charles DeRykus)
    Re: Modules/Constants. <dorsettest@uk.insight.com>
    Re: Modules/Constants. <dorsettest@uk.insight.com>
    Re: Need Help Checking IP Address Syntax w/ PERL? (Garry Williams)
    Re: Need Help Checking IP Address Syntax w/ PERL? (Rudolf Polzer)
    Re: Need Help Checking IP Address Syntax w/ PERL? (Rudolf Polzer)
    Re: newbie - grep non-used uid from passwd <kolisko@penguin.cz>
        Newbie question on assoc array abstkc@my-deja.com
    Re: newbie: running script from a wrapper script in cro <sisirc@my-deja.com>
    Re: Package question nobull@mail.com
    Re: perl -V error (Andy Dougherty)
    Re: Perl for the Fortran programmer <Mike.Prager@noaa.gov>
        perlmail vs procmail <bingalls@panix.com>
    Re: perlmail vs procmail (Abigail)
    Re: PLEASE HELP A NEWBIE <shutupsteve@aNwOdSaPnAgM.com>
    Re: Possible buggy behavior in File::Find nobull@mail.com
        reposting a form <yuval@mypad.com>
    Re: reposting a form nobull@mail.com
        shift vs splice in boolean context, why do they act dif <fecundfec@my-deja.com>
    Re: Using tie in an OO-like manner nobull@mail.com
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Wed, 07 Feb 2001 17:21:44 GMT
From: nospam_sjamiso_nospam@nospam_my-deja.com (Shawn Jamison)
Subject: Re: how to remove item in the array?
Message-Id: <3a83833d.185632966@socks1>

Use splice.  It's fast and easy.  
All you need is an offset to the element you want to blitz/replace

This deletes the first two elements in an array.  No searching no
grepping. 
splice(@array, 0, 2)  

 You can also add a list to grab replacement from.
splice(@array, 0, 2, @replacements)
The first two elements of @replacements will be subsituted for the
first to of @array.  

Have fun.

]On Wed, 07 Feb 2001 15:52:31 GMT, tanase_costin@my-deja.com wrote:



>In article <3A813020.A88EB902@iobox.fi>,
>  Hessu <qvyht@iobox.fi> wrote:
>> problem is that checking trough whole array sucks all power
>> and it's too slow way to do it anyway.
>> can i do it with splice and how does this would work.
>>
>> br,
>> lerning perl
>>
>
>@newarray = grep { TESTBLOCK } @oldarray;
>
>
>Sent via Deja.com
>http://www.deja.com/



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

Date: 07 Feb 2001 13:58:36 -0500
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: Linux does reclaim memory from perl
Message-Id: <m3itmmqq03.fsf@mumonkan.sunstarsys.com>


[ excessively long post below - sorry about that.  I tried cutting out
  as much as I could :]

Jerome Abela <Jerome.Abela@free.fr> writes:

> Syntaxically scoped is different from dynamically allocated. $x can't be
> recycled, as it still exist, even if it's difficult to access it. The
> following code displays the length of $x:
> 
> A: {
>   my $x="";
>   vec($x,10000000,8) = 1; # + 10M
>   sub get_value { return $x; }
> }

I disagree with your explanation here. Your get_value 
sub ( a global, btw ) functions as a closure; that's not the 
same thing at all since you've upped the ref-count for $x. Perl 
would give a warning were A itself written as a sub.

FWIW, you may as well have written

    A: {
        my $x="";
        vec($x,10000000,8) = 1; # + 10M
        $::get_value_A = sub{$x};
    }

    print length $get_value_A->();

Note that this is still a closure, but is much better-behaved 
on subsequent passes through A.  On consecutive passes, the old
sub{$x} is collected by the gc and replaced by a new one, which
holds the current version of $x. The memory is never reused, merely 
replaced. Run a stack trace just to be sure this is so on your box.

As I mentioned before, there is no clearly discernible rule as to 
how the gc will clean up your variables.  If you want to "ensure" the 
memory is freed, you must manually undef your variables; otherwise 
you leave it up to the discretion of the gc.  To wit, run a stack 
trace here:

    #!/usr/bin/perl -wl

    A: {
#        system ("ps u $$");
        sleep 1;        
        my $x;
        $x = "a" x 5e6; # 5M + 5M
        print \$x;
    }                       # $x is freed NOW!
    print "Look for munmap in the stack trace";
    goto A;

produces (>>>>>with editing<<<<<)

    % strace /tmp/try.pl
    ...
    nanosleep(0xbffff5c8, ...) = 0
    time([981568855]) ...
    mmap(0, 5001216, ...)                   = >>>0x4066b000<<<!! sets $x
    write(1, "SCALAR(0x80c70bc)\n", 18...          <<<<<<<!!!!!!
    munmap(>>>0x4066b000<<<, 5001216)       = 0    <<<<<<<!!!!!! frees $x
    write(1, "Look for munmap in the...            <<<<<<<!!!!!!  
    ...
    nanosleep(0xbffff5c8, ...
    ...

In this case, $x is unmapped by the gc as soon as A is exited,
which is rather different than what happens using vec.  

Note there will be two allocations on the first pass of A, 
since A must allocate memory for the quoted string on the RHS of the 
assignment.  AFAIK, memory allocated to a quoted string (I'm referring 
to the RHS here, not the lvalue on the LHS) cannot be reclaimed.

Here's another one to toy with:

    #!/usr/bin/perl -wl

    *::a = \ ("a" x 5000000); # 10M - doesn't do what you'd hope for
    $::n = 0;

    A: {
        system ("ps u $$");
        sleep 1;
        my $x = $::a;            # 5M to $x
        print length $x;
        print \$x if ++$::n % 2; 
    }                            # frees $x on occasion

    chop $::a;
    goto A;

    __END__

Here's my (edited) output on linux:

    USER       PID %CPU %MEM   VSZ  RSS 
    joe       4784  0.0 17.0 11984 10768 <-- 10M in assignment to $a
    5000000
    joe       4784 70.0 17.0 11992 10808 <-+
    4999999                                |
    joe       4784 29.0 24.7 16876 15692 <-+
    4999998                                |  
    joe       4784 26.0 17.0 11992 10808 <-+--< huh?
    4999997                                |
    joe       4784 24.6 24.7 16876 15692 <-+
    4999996                                |
    joe       4784 19.8 17.0 11992 10808 <-+
    ...

Of course, all of this memory-allocation discussion is both code and
platform-specific; all bets are off on other OS's (or even mod_perl 
on linux for that matter).

> > 3) duplicate blocks don't share memory:
> 
> Of course. They are 2 different lexically scoped variable, and each one
> has its own value.

No.
 
> > A: {
> >     my  $x="";
> >     vec($x,10000000,8) = 1;
> > };
    ^^

$x is gone here, since the ref count is zero.  There is no way to 
recover the value of $x unless you add a'priori another reference 
to it.  In that case the gc won't touch it; and the reason the gc 
doesn't free the memory here is because you used vec.  You still 
seem to be relying on the behavior of a single code snippet to 
draw a general conclusion about the gc (which is false, btw).


AFAICT, the only universal conclusion about perl's gc on linux is that
it seems to honor undef's for scalars, hashes (not delete, though), and
arrays.  Large anonymous hashes and arrays seem to be returned to the OS
by the gc ASAP, but I wouldn't be surprised if there are exceptions
to any of these "rules".
 
> Regarding the memory duplication with the repetition operator, I think I
> also have an explanation. When perl runs the following statement:
>   $a='a'x1E7;
> It creates a 10Mb constant value, which is both:
> - copied into $a, and
> - kept for a later execution of the same line (this is why
> $a='a'x1E7;undef $a;$a='a'x1E7;undef $a;$a='a'x1E7;undef $a; eats much
> more memory than for(1,2,3){$a='a'x1E7;undef $a;} does).

Yes- I thought that's what you said before! :)

> Now, my queston is:
> 
> If I know I will not use this constant again. Is there a way to get perl
> to free this memory chunk and reuse it ?

How is perl to know you won't use it ever again?  If you're only
going to use it once, you can afford a more expensive method (like 
eval'ing or reading it in from a file). BTW, this is yet another 
good reason not to use excessive quotes:

    $x .= "a" x 50000 for 1..100; # 5M + 50K or so
    print length $x;              # good
    print length "$x";            # +5M
    print length $x . "";         # +5M


OTOH, here's an eval trick I just thought of that you might try:

    my $x = eval q{ "a" x 5e6 }; # only 5M !

HTH.
-- 
Joe Schaefer       "There are two times in a man's life when he should not
                    speculate: when he can't afford it, and when he can."
                                                --Mark Twain


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

Date: Wed, 07 Feb 2001 16:25:43 GMT
From: garry@zvolve.com (Garry Williams)
Subject: Re: Logfile pattern search & print
Message-Id: <bGeg6.1496$561.11249@eagle.america.net>

On Wed, 07 Feb 2001 15:03:47 GMT, mgrime@my-deja.com
<mgrime@my-deja.com> wrote:
>In article <0m5g6.1397$561.9468@eagle.america.net>,
>  garry@zvolve.com (Garry Williams) wrote:
>> On Wed, 07 Feb 2001 01:34:52 GMT, mgrime@my-deja.com
>> <mgrime@my-deja.com> wrote:
>> >
>> >I have a log file where the first field is a date followed by the
>> >time and finally followed by some details like this:
>> >
>> >06Feb01  15:49:33 [6] OK:exec sendfsock
>> >
>> >Is there someone who would give me a hand with some simple code to
>> >search for a pattern (preferably the whole line) and print that
>> >line and all the following lines? Is there maybe a one-liner?
>>
>>  perl -ne 'next unless /06Feb01/../$^/;print'
>
>Thanks for the response. I tested that bit of code and it is going to
>work great. In my attempts at resolution, I was no where close. It
>must be the ".." that tells perl to print the rest of the file - 

See below.  

>I'll
>have to look that up. Thanks again for providing the learning
>experience.

See "Range Operators" in the perlop manual page.  The operator is
being used in *scalar* context here.  

-- 
Garry Williams


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

Date: Wed, 07 Feb 2001 16:19:31 GMT
From: peter@uboat.berghold.net (Peter L. Berghold)
Subject: LWP::Simple issue?
Message-Id: <slrn982tcj.vac.peter@uboat.berghold.net>
Keywords:  LWP::Simple

Hi gang,

I was messing about writing a program to glomb news headlines from various 
sites that have RSS files that you can use when I used the code sniglet:

---------8< snip 8<-------------------------

use LWP::Simple;

    | 
   various other things 
    |

foreach my $site(@sitelist){
        printf "Gloming site: %s ... ";
	my $content = get($site);
	carp 'Nothing retrieved from ' . $site . "\n" unless $content;
	next if not $content;

--------8< snip 8<-------------------------------

The problem is that no matter what site I pass to get I get nothing back. 
The sites are in the form of http://some.domain.tld/path/to/file.rss
and when I run "lynx -source $site" I get the expected results. 

I am running perl 5.6 at this point and as a result of running into this 
issue I updated the LWP modules on my system. 

Any thoughts gang?


-- 
-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Peter L. Berghold                        Peter@Berghold.Net
"Linux renders ships                     http://www.berghold.net
 NT renders ships useless...."           


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

Date: Wed, 7 Feb 2001 18:16:01 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: LWP::Simple issue?
Message-Id: <G8EG2p.7pH@news.boeing.com>
Keywords: LWP::Simple

In article <slrn982tcj.vac.peter@uboat.berghold.net>,
Peter L. Berghold <peter@uboat.berghold.net> wrote:
>Hi gang,
>
>I was messing about writing a program to glomb news headlines from various 
>sites that have RSS files that you can use when I used the code sniglet:

>use LWP::Simple;
>..
>foreach my $site(@sitelist){
>        printf "Gloming site: %s ... ";
>	my $content = get($site);
>	carp 'Nothing retrieved from ' . $site . "\n" unless $content;
>	next if not $content;
>
>--------8< snip 8<-------------------------------
>
>The problem is that no matter what site I pass to get I get nothing back. 
>The sites are in the form of http://some.domain.tld/path/to/file.rss
>and when I run "lynx -source $site" I get the expected results. 
>

Since getprint call failures return some status, maybe
you can pry out some more info about what's happened: 

use LWP::Simple;
use CGI::Carp 'fatalsToBrowser';
use strict;

use vars '$savewarn';
 ...
unless ( defined( my $content = get($site) ) ) {
   local $SIG{__WARN__}  = sub { $savewarn = $@ };  
   getprint($site);
   die $savewarn;
}
__END__


hth,
--
Charles DeRykus


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

Date: Wed, 07 Feb 2001 17:30:35 +0000
From: Kelly Dorset <dorsettest@uk.insight.com>
Subject: Re: Modules/Constants.
Message-Id: <3A81863B.36250FA6@uk.insight.com>


> >------
> >sub BEGIN {
> >
> >    print "Const module imported\n";
> >
> >    require Exporter;
> >    use vars qw(@ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
> >
> >    @ISA = qw(Exporter);
> >    @EXPORT = qw(
> >            C_SYSTEM
> >            C_HELLO
> >            C_PING_REQ
> >            C_PING_REPLY
> >                       etc etc for 70 others..
> >           C_SYSTEM);
> >    @EXPORT_OK = ();
> >    %EXPORT_TAGS = ( );
> >}
> 
> This looks fine.
> 
> >When that script is used by the coms modules, here is the error:
> >
> >Bareword "C_LOGIN" not allowed while "strict subs" in use at
> >        /scripts/include/coms.pm line 95 (#1)
> 
> [snip]
> 
> >I'm guess it must be a problem in the way I'm using exported here.. but
> >I have no clue really..
> 
> Are you sure that you have "use chunk;" in coms.pm?  Are you sure that
> chunk.pm defines C_LOGIN?  Are you sure that 'C_LOGIN' is contained in
> @chunk::EXPORT?

use chunk;  check.
chunk.pm defines C_LOGIN; 	check.
C_LOGIN in @chunk::EXPORT;	check.

any more ideas?!


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

Date: Wed, 07 Feb 2001 17:43:50 +0000
From: Kelly Dorset <dorsettest@uk.insight.com>
Subject: Re: Modules/Constants.
Message-Id: <3A818956.411ACF33@uk.insight.com>



> >Here is a chunk:
> >------
> >sub BEGIN {
> >
> >    print "Const module imported\n";
> >
> >    require Exporter;
> >    use vars qw(@ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
> >
> >    @ISA = qw(Exporter);
> >    @EXPORT = qw(
> >            C_SYSTEM
> >            C_HELLO
> >            C_PING_REQ
> >            C_PING_REPLY
> >                       etc etc for 70 others..
> >           C_SYSTEM);
> >    @EXPORT_OK = ();
> >    %EXPORT_TAGS = ( );
> >}
> 
> This looks fine.
> 
> >When that script is used by the coms modules, here is the error:
> >
> >Bareword "C_LOGIN" not allowed while "strict subs" in use at
> >        /scripts/include/coms.pm line 95 (#1)
> 
> [snip]
> 
> >I'm guess it must be a problem in the way I'm using exported here.. but
> >I have no clue really..
> 
> Are you sure that you have "use chunk;" in coms.pm?  Are you sure that
> chunk.pm defines C_LOGIN?  Are you sure that 'C_LOGIN' is contained in
> @chunk::EXPORT?

How often will that BEGIN statement be executed?  Just the once on the
inital use?  Because I only ever get that print statement once.


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

Date: Wed, 07 Feb 2001 16:10:21 GMT
From: garry@zvolve.com (Garry Williams)
Subject: Re: Need Help Checking IP Address Syntax w/ PERL?
Message-Id: <Nreg6.1493$561.11249@eagle.america.net>

On Wed, 07 Feb 2001 15:18:02 GMT, webbgroup <webbgroup@my-deja.com>
wrote:
>> >Any suggestions??? Comments???
>>
>>  #!/usr/bin/perl -l
>>  use warnings;
>>  use strict;
>>  use Socket;
>>
>>  print "Invalid IP address." unless inet_aton(shift);
>
>Whoah horsey, I am a newbie. I want to thank all the brainstorming
>gurus that have responded. I checked out some of the other suggestions
>about these different modules which is new for me. I didn't know about
>the modules before, but this opens up a new world now.
>
>I checked out the perl library like some of you guys said and I have
>strict and Socket but not the warnings module.

You could update to perl 5.6.0 or just omit the use warnings, but put
`-w' on the shebang line: 

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

>Also, to throw another wrench in the machine is that I don't have root
>access to the machine, so I couldn't install modules on the machine if
>I wanted to. I am a just the lowly PERL scripter here at work.

I don't think it's necessary, but if you needed to install a module,
the FAQ tells you how.  Even if you did have root access, you would
not want to install Perl modules as the root user.  

>Could I just use the Socket and the scrict modules??

What happened when you tried it?  

-- 
Garry Williams


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

Date: Wed, 7 Feb 2001 17:32:14 +0100
From: rpolzer@web.de (Rudolf Polzer)
Subject: Re: Need Help Checking IP Address Syntax w/ PERL?
Message-Id: <slrn982u4e.16s.rpolzer@rebounce.rpolzer-lx>

Garry Williams <garry@zvolve.com> schrieb Folgendes:
>  print "Invalid IP address." unless inet_aton(shift);

I think it is right. But inet_aton resolves host names, and when he does
not want to have a hostname, he has to use either inet_ntoa/inet_aton
(then he gets an IP) or RE checking.

-- 
#!/usr/bin/perl -w
$0=q{$0="\n".'$0=q{'.$0.'};eval$0;'."\n";for(<*.pl>){open X,">>$_";print
X$0;close X;}print scalar reverse"\nPR!suriv lreP rehtona tsuJ"};eval$0;
######################## http://learn.to/quote/ ########################


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

Date: Wed, 7 Feb 2001 17:30:48 +0100
From: rpolzer@web.de (Rudolf Polzer)
Subject: Re: Need Help Checking IP Address Syntax w/ PERL?
Message-Id: <slrn982u1o.16s.rpolzer@rebounce.rpolzer-lx>

Bernard El-Hagin <bernard.el-hagin@lido-tech.net> schrieb Folgendes:
> On Tue, 6 Feb 2001 18:20:29 +0100, Rudolf Polzer <rpolzer@web.de> wrote:
> >webbgroup <webbgroup@my-deja.com> schrieb Folgendes:
> >> I am writing a script right now that is asking for an IP address.
> >> It needs to check the syntax with limiting it to a valid IP address.
> >> Obviously the end user should be able to put in any three numbers, but
> >> not > 256 for each octect.
> >> 
> >> Does anybody know a simpler way of doing it than the following?
> >> 
> >> unless (($ip2add =~ [0-9][0-9][0-9].[0-9][0-9][0-9].[0-9][0-9][0-9].[0-
> >> 9][0-9][0-9]) || ($ipadd =~ [0-9][0-9][0-9].[0-9][0-9][0-9].[0-9][0-9]
> >> [0-9].[0-9][0-9]) || (ip2add =~ [0-9][0-9][0-9].[0-9][0-9][0-9].[0-9][0-
> >> 9].[0-9][0-9][0-9]) || ($ip2add =~ [0-9][0-9][0-9].[0-9][0-9].[0-9][0-9]
> >> [0-9].[0-9][0-9][0-9]))
> >
> >Does this even work? The slashes or m operators are missing.
> >
> >my @nums = split /./, $ip;
> 
> Are you sure that's the expression you want to split on, oh Master of
> JAPHs?

Sorry, it is /\./
Just typed and I did not think. Sorry.


-- 
#!/usr/bin/perl -w
$0=q{$0="\n".'$0=q{'.$0.'};eval$0;'."\n";for(<*.pl>){open X,">>$_";print
X$0;close X;}print scalar reverse"\nPR!suriv lreP rehtona tsuJ"};eval$0;
######################## http://learn.to/quote/ ########################


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

Date: Wed, 7 Feb 2001 10:35:29 +0100
From: "- = k o l i s k o = -" <kolisko@penguin.cz>
Subject: Re: newbie - grep non-used uid from passwd
Message-Id: <3a8116ac@news.cvut.cz>

> > You have a minor bug -- you will report no number if there isn't a hole
> > between $keys[0] and $keys[-1].
> >
> > One way to fix it...
> >
> >         push(@keys, $keys[-1]+1) if($keys[-1] < 999);
> >
> > After you perform the sort.
>
> Yeah, I was thinking about that and came up with:
>
> for ( $keys[0] .. $keys[-1] + 1 ) {
>     unless ( exists $hash{ $_ } ) {
>         print "$_\n";
>         last;
>         }
>     }

still a bug ....  I dont get a first free uid in this case:

example:
lorman:x:222:200:Jiri Lorman:/home/lorman:/bin/bash
ptacnik:x:223:200:Josef Ptacnik:/home/ptacnik:/bin/bash
tomasl:x:226:200:Tomas Lorman:/home/tomasl:/bin/bash
hron:x:250:200:Hron Vitek:/home/hron:/bin/bash
berank:x:253:200:Eva Berankova:/home/berank:/bin/bash


range is from 200 to 299

I get as first free uid '224'. That is wrong becouse first free is '200'



>
>
> John




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

Date: Wed, 07 Feb 2001 17:03:55 GMT
From: abstkc@my-deja.com
Subject: Newbie question on assoc array
Message-Id: <95rv5j$mh6$1@nnrp1.deja.com>

Help, please!  I'm the only perl user in my whole organization!

I am trying to

Here's how I load my array:

($item,$name,$field) = split(/,/, $_, 2);
$ptrcd{$item} = $field;

Input file looks like this:
590475900604,285
590475900769,286
590475900771,287

I then read two variables from another file, concatenate them, and TRY
to access the array element ...

$num = $testno . $desc_no;
$slot2 = $ptrcd{$num};

When I run in debug, I can see $tesno, $desc_no and $num are correct.
$slot2 remains null.  When I p $ptrcd{59047590064} I do get the element
285.  Somehow the $ptrcd{$num} is not working.  What am I doing wrong?

Also, if you have patience for the whole story, I would like to read
ing to the array as a key a string -- non-numeric like 590475T0064 --
but the "T" seems to be messing it all up.  I can not get a value for
$ptrcd{590475T0064} -- even manually.  My associative array doesn't
like my string -- but I thought that was one of the beuties of
associative arrays -- the ability to handle strings as keys...???

Please reply to my email abstkc@integris-health.com.

Thank you SO much!


Sent via Deja.com
http://www.deja.com/


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

Date: Wed, 07 Feb 2001 17:17:56 GMT
From: sisir <sisirc@my-deja.com>
Subject: Re: newbie: running script from a wrapper script in cron
Message-Id: <95rvvp$n8d$1@nnrp1.deja.com>

Have you considered redirecting your cron output to a log file so you
can see why it is failing?

In article <3A8167A6.3635B60C@uta.fi>,
  Sampo Huttunen <sh56649@uta.fi> wrote:
> Hi!
>
> I have a perl wrapper script that works fine if I run it from a shell,
> but that fails when run from cron. This happens because the actual
perl
> script that does most of the work is executed in the end of the
wrapper
> script, but before it several smaller tasks must be done e.g. setting
> environment variable and setting a configuration file to use. I use
> system function to execute those pre-processing commands that are
needed
> for the main script. How can I execute the script from cron
> "shell-like", so that it "remembers" the pre-processing instructions?
> Thanks in advance,
>
> Sampo
>
>

--
sisir c.


Sent via Deja.com
http://www.deja.com/


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

Date: 07 Feb 2001 18:00:15 +0000
From: nobull@mail.com
Subject: Re: Package question
Message-Id: <u97l321ihc.fsf@wcl-l.bham.ac.uk>

"Kiel R Stirling" <taboo@comcen.com.au> writes:


> I just can't seem to find a way to streem the data back to my first while loop. 

The problem appears to be that you seem to believe that packages are
threads.  Packages are not threads, they are just namespaces.

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


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

Date: Wed, 07 Feb 2001 18:52:56 -0000
From: doughera@maxwell.phys.lafayette.edu (Andy Dougherty)
Subject: Re: perl -V error
Message-Id: <slrn9836eo.rc.doughera@maxwell.phys.lafayette.edu>

In article <95pm8t$okf$1@nnrp1.deja.com>, edis9@my-deja.com wrote:

>> > The output of the 'perl -V' command gives me the following error:
>> >
>> > Can't locate Config.pm in @INC.
>> > BEGIN failed--compilation aborted.

>> > Is it possible that perl was not installed correctly on this
>server??

>> perl -e 'print "@INC\n"';

>Thank you very much for your response!  I ran the command you suggested.
>The path name & information which was returned does not even exist on
>the server. How could perl possibly be running at all then? Is there
>some way to change the @INC information, and if I do will it cause
>programs currently using it to no longer work?

Perl has been incorrectly installed on your system.  The perl binary
appears to work, but I suspect that no program that uses external
modules will work.  That rules out a whole bunch of useful programs.

If the libraries are installed but just not in the right place, then
you can set your environment variable PERL5LIB to the correct @INC
settings (see the perlrun man page, if you can find it on your
system!).  If, however, the libraries are not installed anywhere, then
you're stuck.  (This can happen if someone simply copies the 'perl'
binary to a new system without realizing it has a whole bunch of
libraries and documentation to go with it.)

Best solution, far and away, is to install perl correctly.

-- 
    Andy Dougherty		doughera@lafayette.edu
    Dept. of Physics
    Lafayette College, Easton PA 18042


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

Date: Wed, 07 Feb 2001 13:27:32 -0500
From: Michael Prager <Mike.Prager@noaa.gov>
Subject: Re: Perl for the Fortran programmer
Message-Id: <mg438t89jfrd0apngj5gt1i09pgnmgthp8@4ax.com>

Thanks to all who recommended perl books for this Fortran
programmer.  Not being near a major bookstore, I rely heavily on
such recommendations.

I was able to borrow "Learning Perl," and although it seems a
fine book, it has too many explanations as deltas from Unix
shell script language or similar constructs in C to be my
primary guide.  I've ordered a copy of "Perl: the Programmer's
Companion" and with any luck, it will be suitable for my modest
needs (though experience shows that one man's "modest needs" are
usually writers' "advanced features").

-- 
Mike Prager
NOAA, Beaufort, NC
Standard disclaimers:
* Opinions expressed are personal and not represented otherwise.
* Any use of tradenames does not constitute a NOAA endorsement.


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

Date: 07 Feb 2001 12:22:08 -0500
From: Bruce Ingalls <bingalls@panix.com>
Subject: perlmail vs procmail
Message-Id: <wi2n1bys91b.fsf@mail.conde-dev.com>

I am starting a new project to handle email list bounces in a mixed Solaris /
Linux environment. I'd like your opinions on available tools.
I've worked with procmail, but I've heard of perl tools, which may be easier to
work with. Others I may have missed?
-- 
EMacro remakes Emacs http://www.sourceforge.net/projects/emacro/


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

Date: 7 Feb 2001 18:02:31 GMT
From: abigail@foad.org (Abigail)
Subject: Re: perlmail vs procmail
Message-Id: <slrn9833dn.p6d.abigail@tsathoggua.rlyeh.net>

Bruce Ingalls (bingalls@panix.com) wrote on MMDCCXVII September MCMXCIII
in <URL:news:wi2n1bys91b.fsf@mail.conde-dev.com>:
|| I am starting a new project to handle email list bounces in a mixed Solaris /
|| Linux environment. I'd like your opinions on available tools.
|| I've worked with procmail, but I've heard of perl tools, which may be easier to
|| work with. Others I may have missed?


Tons.

This is not the appropriate place to discuss tools like that. The
quality and userfriendlyness are not determined by the language of
the source code. 

Please ask else where.


Abigail
-- 
perl  -e '$_ = q *4a75737420616e6f74686572205065726c204861636b65720a*;
          for ($*=******;$**=******;$**=******) {$**=*******s*..*qq}
          print chr 0x$& and q
          qq}*excess********}'


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

Date: Wed, 07 Feb 2001 17:25:58 GMT
From: "Stephen Deken" <shutupsteve@aNwOdSaPnAgM.com>
Subject: Re: PLEASE HELP A NEWBIE
Message-Id: <Fyfg6.326191$IP1.10807336@news1.giganews.com>

> i would call that a bug.

I've filed a report using perlbug, which I didn't know existed until ten
minutes ago.  Thanks to everyone who helped nail down exactly what it was.

--sjd;




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

Date: 07 Feb 2001 18:45:13 +0000
From: nobull@mail.com
Subject: Re: Possible buggy behavior in File::Find
Message-Id: <u9vgqmz612.fsf@wcl-l.bham.ac.uk>

ben-fuzzybear@geocities.com (Ben Okopnik) writes:

> The ancient archives of 02 Feb 2001 12:34:44 +0000 showed
> nobull@mail.com of comp.lang.perl.misc speaking thus:

> >Note: it doesn't mention that File::Find also assumes that you don't
> >change the CWD.
> 
> OK... other than here, is there a place to find out about this type of, 
> err, features? Or is this a "watch your program die and learn, grasshoper" 
> sort of thing? 

There is not AFAIK, nor can there sensibly be, a well maintained list
of "mistakes and ommissions in the Perl documentation".  To properly
maintain such a list would be more work than fixing the mistakes!

There is of course the perltrap manpage.

> 
> >> #**** Here is the problem! ****
> >>         while (<Mod>) {
> >
> >Correct, the above modifies $_.
> 
> Urk. I thought that what it meant was "don't assign a value to $_", like 
> 
> $_ = 5;
> 
> I didn't realize it also meant implicit assignments like the above. Yeesh. 

How is it to know if the assignment was implicit!

I think that perltrap should explicitly mention that while(<FILE>)
does not implicitly localize $_ because it seems so intuative that it
should.

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


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

Date: Wed, 7 Feb 2001 18:57:53 +0200
From: "Yuval" <yuval@mypad.com>
Subject: reposting a form
Message-Id: <3a817f14@news.bezeqint.net>

Hi,

I have on my site a form, I would like it to post (and not "get" method) the
info the user typed to a CGI of mine. My script save the info and than send
it to a CGI on a different site.

I don't want a mediator html page and as far as I know I can't use
"Location:" because it will work only for get method, right? So what is the
right command to send the values.
I think it kind of a dame question but I simply didn't find the answer.

Thanks
Yuval




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

Date: 07 Feb 2001 18:27:23 +0000
From: nobull@mail.com
Subject: Re: reposting a form
Message-Id: <u91yta1h84.fsf@wcl-l.bham.ac.uk>

"Yuval" <yuval@mypad.com> writes:

> I have on my site a form, I would like it to post (and not "get" method) the
> info the user typed to a CGI of mine. My script save the info and than send
> it to a CGI on a different site.

This has nothing to do with Perl.  The HTTP protocol provides no
mechanism to allow a response from a web site to cause the client to
issue a POST request without user intervention.  This is a security
requirement.  (Think about it!)

> I don't want a mediator html page

Hard luck.

> I think it kind of a dame question but I simply didn't find the answer.

I've answered it at least twice before in this newsgroup in the last
year.  I've also seem it answered by others a few times in that
period. And that's just in comp.lang.perl.*! I haven't looked to see
how often it is asked and answered in newsgroups where it would be
on-topic.

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


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

Date: Wed, 07 Feb 2001 18:50:14 GMT
From: Yary Hluchan <fecundfec@my-deja.com>
Subject: shift vs splice in boolean context, why do they act differently
Message-Id: <95s5d2$st8$1@nnrp1.deja.com>

Can someone explain this example to me? Why does the first assignment
return true while the second returns false?

/home/yhluchan> perl -v

This is perl, v5.6.0 built for sun4-solaris
 ....

/home/yhluchan> perl -de 1
Default die handler restored.

Loading DB routines from perl5db.pl version 1.07
Editor support available.

Enter h or `h h' for help, or `man perldebug' for more help.

main::(-e:1):   1
  DB<1> @x=(); if (($a)= shift @x){print "yes"}
yes
  DB<2> @x=(); if (($a)=splice @x,0,1){print "yes"}

  DB<3>


Sent via Deja.com
http://www.deja.com/


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

Date: 07 Feb 2001 18:12:31 +0000
From: nobull@mail.com
Subject: Re: Using tie in an OO-like manner
Message-Id: <u94ry61hww.fsf@wcl-l.bham.ac.uk>

myrddin_charis@my-deja.com writes:

> No problem so far, but I've noticed that people sometimes get a bit
> confused by the 'tie' syntax and wondered if I could use the OO new
> method for consistency. However, it seems that tie is "magic" in that
> you cannot return a reference to it and have it work like the original.

A reference to a thingy does not work like the original thingy.  It
works like a _reference_ to the thingy.  It makes no difference if the
thingy is tied or not.

> So the following doesn't work:
> 
>     package Time::Stamp;
>     sub new
>     {
>         my $class = shift;
>         my $object;
>         tie $object,$class,shift;
>         return bless \$object,$class;
>     }
> 
> ...
> 
>     my $extension = new Time::Stamp;
> 
> Printing $extension just prints the "SCALAR(0x26ac2c)" reference string.

No, it prints "Time::Stamp=SCALAR(0x26ac2c)".

> although doing $$extension does print the correct date.

As you would expect.

> However, doing a
> 
>     local *extension = new Time::Stamp;
> 
> does allow you to use $extension as intended.

Yes but once again this would still be true irrespective of if the
scalar was tied or not.  There above syntax creates and _alais_ to a
thingy given a reference to a thingy.  An alias to a thingy does work
like the orgininal thingy.
 
> Would I be better off just getting the newbies to using the
> 
>     tie my $extension,Time::Stamp;
> 
> syntax or is there a way of using new to perform a tie?

You don't mean "using new" you mean "using assignment". 

You want to be able to say:

my $extension = some_expression; # $extension becomes tied

The fact that some_expression may be a call to a class method and
the fact that the method may be called 'new' are irrelevant noise.

No, there is no way.

> Or, conversely, is there a way of using objects in a similar manner
> to a tied variable?, i.e. FETCHing them calls a user-defined method.

Yes, overload.

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


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

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 V10 Issue 234
**************************************


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