[11823] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5423 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Apr 20 00:12:41 1999

Date: Mon, 19 Apr 99 21:00:18 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Mon, 19 Apr 1999     Volume: 8 Number: 5423

Today's topics:
        [Q] Please help with eval problem <qa3653@email.mot.com>
    Re: [Q] Please help with eval problem (Larry Rosler)
    Re: Adding TCPIP # <wyzelli@yahoo.com>
    Re: array names same as file names (Abigail)
    Re: attach a subroutine to a filehandle <aperrin@mcmahon.qal.berkeley.edu>
        Automatic e-mail reminder (simple) <rauch@ai.mit.edu>
    Re: Books (Abigail)
        C directives <555034897s@acadiau.ca>
        CGI/Telnet?? <ztrexler@heehaw.com>
        Eliminate to another array <555034897s@acadiau.ca>
    Re: FAQ 3.24: How can I get C<#!perl> to work on [MS-DO (Larry Rosler)
        for (my $i;;) doesn't work like I think it should raylutz@adaptra.com
    Re: Interpolating Variables for 'use' (Andrew Allen)
    Re: Interpolating Variables for 'use' <kubla_khan@rocketmail.com>
        Making grep insensitive <slanicky@students.uiuc.edu>
        obtaining user's PATH statement <j_joy@my-dejanews.com>
        Perl 'split' function in C?? (Krusty276)
        Perl cookbook ... <rereidy@uswest.net>
        Perl, VB, or Java??? <jdurkin@gw.total-web.net>
    Re: Top 10 newbie errors? (Clinton Pierce)
    Re: Top 10 newbie errors? (Clinton Pierce)
    Re: VB and Perl <bhilton@kc.net>
        Wow, thought he'd be much older... <mpersico@erols.com>
    Re: Wow, thought he'd be much older... (Damian Conway)
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: Mon, 19 Apr 1999 17:48:21 -0500
From: Mark Newman <qa3653@email.mot.com>
Subject: [Q] Please help with eval problem
Message-Id: <371BB2B5.311620E8@email.mot.com>

I'm trying to modify the contents of a variable in a loop,
using the eval command.  When I run this code, I get the following
error:

(newmanmb): perl_temp

Can't modify concatenation in scalar assignment at
/export/home/newmanmb/perl_temp line 10, near "'Hello There')"
Execution of /export/home/newmanmb/perl_temp aborted due to compilation
errors.

We are using perl 5.004_01.

I have been able to find a way to do this (see the commented out part at
the 
end), but I can't understand why this doesn't work.  

Anyone?

Thanks,

Mark N

#!/usr/local/bin/perl
$test_id0="TRY";
$test_id1="TO CHANGE";
$test_id2="ME";
foreach $variable (0..2) {
	$tempvar=eval{'$test_id' . $variable};
	$tempdata=eval $tempvar;
	printf("Variable name is $tempvar\n");
	printf("Data in $tempvar is $tempdata\n\n\n");
	eval("\$test_id" . $variable = 'Hello There');
	printf("$test_id0\n");

# THIS WORKS:
#	$str="\$test_id" . $variable;
#	eval "$str='Hello There'";
#	printf("$test_id0\n");

} #end foreach $variable


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

Date: Mon, 19 Apr 1999 18:33:49 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: [Q] Please help with eval problem
Message-Id: <MPG.11857955d6da616d9898e5@nntp.hpl.hp.com>

[Posted and a courtesy copy mailed.]

In article <371BB2B5.311620E8@email.mot.com> on Mon, 19 Apr 1999 
17:48:21 -0500, Mark Newman <qa3653@email.mot.com> says...
> I'm trying to modify the contents of a variable in a loop,
> using the eval command.  When I run this code, I get the following
> error:
> 
> (newmanmb): perl_temp
> 
> Can't modify concatenation in scalar assignment at
> /export/home/newmanmb/perl_temp line 10, near "'Hello There')"
> Execution of /export/home/newmanmb/perl_temp aborted due to compilation
> errors.
 ...
> 	eval("\$test_id" . $variable = 'Hello There');

  	eval("\$test_id$variable = 'Hello There'");

or, better (if that is possible for such a horror):

  	${"test_id$variable"} = 'Hello There';  

But this is *all wrong* because you are using symbolic references when 
there is absolutely no need.  (Losing count how many times this has come 
up in the past week!!!  Look for Tom Christiansen's repeated eloquent 
posts on this theme.)

  my %test_id;
  $test_id{$variable} = 'Hello There';

or in your case, because you are using small non-negative integers,

  my @test_id;
  $test_id[$variable] = 'Hello There';

-- 
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Tue, 20 Apr 1999 10:03:32 +0930
From: "Wyzelli" <wyzelli@yahoo.com>
Subject: Re: Adding TCPIP #
Message-Id: <vXPS2.52$my2.3643@vic.nntp.telstra.net>

You came closest...

What I ultimately end up using is:

    /Framed-IP-Address = (\d+\.\d+\.\d+\.\d+)/;
    $ip = $1;

This works fine...

Let me know if you are interested in the final product

Wyzelli

Jonathan Stowe wrote in message <371b06c8@newsread3.dircon.co.uk>...
>Wyzelli <wyzelli@yahoo.com> wrote:
>> I have a short Perl script which parses a file and extracts information
>> which is incremented to three arrays by key $user.
>>
><snip>
>
>> A sample of the file to be parsed is below.
>>
>> Wed Mar 31 18:10:17 1999
>>  Acct-Session-Id = "0F00007B"
>>
>
>Hmm,  Radius. Appalling logfile output.  I thought I had a program that
>does exactly (or nearly) what you wanted however I discovered it was a
shell
>script and not exactly something you would show in front of the children.
>
>Anyhow to match dotted quad IP number you could use:
>
>/(d+\.d+\.d+\.d+)/
>
>On a more general note what we do with this stuff is hack it around a bit
>to remove duplicates and create a '|' separated file that is then loaded
>into a MySQL database on a different server - bear in mind that these logs
>can get huge - and thus we can create reports without worrying about the
>nasty file format.
>
>/J\
>--
>Jonathan Stowe <jns@gellyfish.com>
>




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

Date: 20 Apr 1999 03:45:58 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: array names same as file names
Message-Id: <7fgt9m$hvg$1@client2.news.psi.net>

Tom Christiansen (tchrist@mox.perl.com) wrote on MMLV September MCMXCIII
in <URL:news:3718f4fa@cs.colorado.edu>:
<> 
<>     for $critter ( qw(aardwolf armadillo ankylosaur) ) { 
<> 	@{ $hash{"dog"} } = do { local @ARGV = ("$DIR/$critter"); <> };
<>     }


That should be:

       for $critter ( qw(aardwolf armadillo ankylosaur) ) { 
   	   @{ $hash{$critter} } = do { local @ARGV = ("$DIR/$critter"); <> };
       }


Abigail
-- 
sub f{sprintf'%c%s',$_[0],$_[1]}print f(74,f(117,f(115,f(116,f(32,f(97,
f(110,f(111,f(116,f(104,f(0x65,f(114,f(32,f(80,f(101,f(114,f(0x6c,f(32,
f(0x48,f(97,f(99,f(107,f(101,f(114,f(10,q ff)))))))))))))))))))))))))


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

Date: Mon, 19 Apr 1999 17:01:41 -0700
From: Andrew Perrin <aperrin@mcmahon.qal.berkeley.edu>
Subject: Re: attach a subroutine to a filehandle
Message-Id: <371BC3E5.3F633687@mcmahon.qal.berkeley.edu>

I'm afraid I don't really get what you're trying to do, but here are some
thoughts:

1.) How about having your sub read the information into an array instead of
the sort of virtual filehandle you're trying to produce, then do your
operations on the array? It's quite simple to pass the array back and forth.

2.) Alternatively, how about passing back and forth a reference to a
filehandle (trivial using use FileHandle;) which would allow you to have a
variety of subs do the processing on the file?

3.) Maybe it's not in the snippet you posted, but I'm not sure where you use
SQLPLUS, since you first open it then read from QUERY which I take to be your
virtual filehandle.

Hope this helps-
Andy

Corey Saltiel wrote:

> On 19 Apr 1999 00:31:07 GMT, Broc Seib <bseib@jade.cc.purdue.edu> wrote:
> >Corey Saltiel <corey@americanrecruitment.com> wrote:
> >
> >> Is it possible to open a filehandle as a pipe ( or alias/reference ...
> >> thingy ) to a subroutine within the same script?
> >
> >> Am I even making any sense?   (c;
> >
> >You might look at 'perldoc perltie' which talks about how to write
> >code to implement a "tied" perl variable. Specifically, look at TIEHANDLE
> >in the docs. This lets you do "something" when activity takes place
> >on a filehandle.
> >
>
>   OK - after trying your suggestion ( thanks, by the way! ), and
>   after a days worth of attempting a variety of possible solutions,
>   I am, once again, quite stumped.
>
>   All I want is to create a pipe which I print a command to, then
>   be able to read the resulting output of that pipe, line-by-line.
>
>   Here's code:
>
> #!/usr/local/bin/perl
>
> package EventEmails;
>
> $| = 1;
>
> sub TIEHANDLE { my $i; bless \$i, shift }
>
> sub READLINE {
>
>    print SQLPLUS <<"EOF";
>
> select stuff from table;
>
> EOF
>
> #exit;  <<--- !
>
> };
>
> tie(*QUERY,'EventEmails');
>
> open(SQLPLUS, '|sqlplus') or
>    die "Could not open pipe to sql*plus: $!\n";
>
> while (<QUERY>) {
>
>    print "\$_ is $_"; <<--- ?!
>
> }
>
>    All I want ( as can hopefully be seen ) is to simply
>    grab the output of the sql query and parse it. (!!)
>
>    I get the output that I expect ( a bunch of email addresses
>    and some other junk I intend to discard before printing
>    out ), but it all gets thrown out at once as soon I hit the
>    while loop, but "$_" only ever contains '1', and
>    only gets printed in HUGE spurts intermittently, and ONLY if
>    I uncomment the 'exit' -- but then the code just loops on
>    forever - first chunking out the sql results, and then
>    chunking out a huge clump of "$_ is 1"'s ...  Ack!
>
>    This *couldn't* be too difficult a task, what am I not
>    understanding here?
>
> Please help,
> Thanks so much --
>
> Corey



--
-------------------------------------------------------------
Andrew J. Perrin - NT/Unix/Access Consulting -  (650)938-4740
aperrin@mcmahon.qal.berkeley.edu (Remove the Junk Mail King)
     http://www.geocities.com/SiliconValley/Grid/7544/
-------------------------------------------------------------




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

Date: 20 Apr 1999 00:09:48 GMT
From: Erik Rauch <rauch@ai.mit.edu>
Subject: Automatic e-mail reminder (simple)
Message-Id: <7fggkc$hu7@senator-bedfellow.MIT.EDU>


Here's a little script to automatically e-mail you reminding you about
events. I like to use it by cutting-and-pasting a date from an e-mail
announcing a talk or event.

You could use a calendar program for this, but this script is useful
to people who check their e-mail much more often than they check their
calendar.

The ultimate version of this would automatically scan an e-mail and
pick out the date and time. Anyone up to doing that? 

#!/usr/local/bin/perl
#
# remind.pl - sends e-mail reminding you in advance about an event 
# Erik Rauch, 4/13/99
#
# This program takes a date in almost any format, and outputs a crontab
# line that will send you mail reminding you about an event in advance. 
# 
# It takes the date on the command line, and can understand formats
# such as:
#   Tuesday, April 27,  2:00pm
#   4/27/99 2:00 
#   27 Apr, 2pm
#   Tue Apr 27 14:00:00 EDT 1999
# See the Time::ParseDate manual page for a full list. 
#
# If the hour is less than 9, it assumes PM. 
# It will send the mail $hours_in_advance hours before the event, 
# unless the event takes place before the hour of $morning_cutoff,
# in which case it sends the mail $morning_hours_in_advance hours before
# the event. This takes into account the fact that people may not read
# their e-mail in the morning before an early event, so it can send
# it the evening or day before. 
#
# The last argument is a message to include in the e-mail; 
# Example:
#
# remind Tues, April 27,  2:00pm, "Talk in room 234" 
#
# If you make a setuid root script, you can then append the crontab
# line from stdout to your crontab, e.g.
#   remind.pl $* >>/var/spool/cron/crontabs/<userid>


use Time::ParseDate;
# get this from CPAN

#change this
$userid = "<userid>"; 

$hours_in_advance = 4;
$morning_cutoff = 13;
$morning_hours_in_advance = 16;


$message = $ARGV[$#ARGV];
splice(@ARGV, $#ARGV);

$_ = join(' ', @ARGV);

s/,//g;

#s/([A-Za-z][A-Za-z][A-Za-z])\./$1/;
s/\.//g;

s/January/Jan/;
s/February/Feb/;
s/March/Mar/;
s/April/Apr/;
s/May/May/;
s/June/Jun/;
s/July/Jul/;
s/August/Aug/;
s/September/Sep/;
s/October/Oct/;
s/November/Nov/;
s/December/Dec/;

s/Sunday/Sun/;
s/Monday/Mon/;
s/Tuesday/Tue/;
s/Tues/Tue/;
s/Wednesday/Wed/;
s/Weds/Wed/;
s/Thursday/Thu/;
s/Thurs/Thu/;
s/Friday/Fri/;
s/Saturday/Sat/;

#print $_, "\n";

$seconds_since_jan1_1970 = parsedate($_, FUZZY => 1);


($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) 
  = localtime($seconds_since_jan1_1970);
$mon++;        

if ($hour < 9)
# && !index($_, "am"))
{ $hour += 12; 
  $seconds_since_jan1_1970 += 12*60*60;
}

if ($min == 0)
{ $minutes = "00"; }
else
{ $minutes = $min; }

print STDERR $mon, "/", $mday, "/", $year, " ", $hour, ":", $minutes, "\n";

if ($hour < $morning_cutoff)
{ $mailtime = $seconds_since_jan1_1970 - $morning_hours_in_advance*60*60; }
else  
{ $mailtime = $seconds_since_jan1_1970 - $hours_in_advance*60*60; }


($sec,$min,$remind_hour,$mday,$mon,$year,$wday,$yday,$isdst) 
  = localtime($mailtime);
$mon++;        

print $min, " ", $remind_hour, " ", $mday, " ", $mon, 
  " * echo \"$message $hour:$minutes\"|mail $userid\n";





--

-------------------------------------------------------------------------
Erik Rauch                                               545 Tech. Square
rauch@mit.edu                                         Cambridge, MA 02139



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

Date: 20 Apr 1999 03:51:05 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Books
Message-Id: <7fgtj9$hvg$2@client2.news.psi.net>

Randal L. Schwartz (merlyn@stonehenge.com) wrote on MMLVI September
MCMXCIII in <URL:news:m190bpol6q.fsf@halfdome.holdit.com>:
:: >>>>> "Ken" == Ken Robbins <puyrebel@prodigy.net> writes:
:: 
:: Ken> Programming Perl is the Camel Book as shown at amazon.com. Is it
:: Ken> Learning Perl or Programming Perl that you are referring to?
:: 
:: If you're getting them from Amazon anyway, please go to my page at
:: http://www.stonehenge.com/books/ - so that you can just "one-click" to
:: get there.  Also, I get a bigger kickback that way. :)

Urg. Worse than people putting up stupid ads on their webpages are
the people advertising those ads.

If I were that poor, I'd rather sell my computer than polluting Usenet
begging for click-throughs.

*plonk*


Abigail
-- 
perl -wlpe '}$_=$.;{' file  # Count the number of lines.


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

Date: Mon, 19 Apr 1999 21:08:03 -0300
From: Tong <555034897s@acadiau.ca>
Subject: C directives
Message-Id: <371BC563.684@acadiau.ca>

In perlrun:

> -P 
>      causes your script to be run through the C preprocessor before compilation by Perl. (Because both comments
>      and cpp directives begin with the # character, you should avoid starting comments with any words recognized by
>      the C preprocessor such as ``if'', ``else'', or ``define''.) 

Could you explain it for me a little bit please, 'cause I'm learning
Perl through man pages. 

Does that means that I can use 

#if $var == 3
 ...
#else
#endif

or even "#include <...>" in my code? 

What C preprocessor does it use then? How do i specify it? 

Thanks!

-- 
Anti-Spam: Remove triple 5 to reply


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

Date: Tue, 20 Apr 1999 00:47:18 GMT
From: Z Trexler <ztrexler@heehaw.com>
Subject: CGI/Telnet??
Message-Id: <7fgiqj$d1j$1@nnrp1.dejanews.com>

I own a WebTV, but I am also an intermediate web developer at a university. 
I want to find a way to write a CGI script that allows me to telnet from my
WebTV.	Keep in mind that WebTV has no java capabilities, and obviously no
built-in telnet program.

Apparently someone actually has created one before, at hypermart.com, but it
was removed because of heavy traffic.  I never saw it, and have only heard
about it.

Any input, thoughts, would be helpful.  Thanks,

Trex

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Mon, 19 Apr 1999 23:18:14 -0300
From: Tong <555034897s@acadiau.ca>
Subject: Eliminate to another array
Message-Id: <371BE3E5.5DF6@acadiau.ca>

Hi, gurus:

Suppose  the  array @a0 has two kinds of entries, the ones that begin
with  'aaa' and the ones do not. How I can pick out the array entries
that  begin  with  'aaa' into another array, while left those entries
that  don't begin with 'aaa' in @a0?


I know I can do it in three line of codes:

@a1=grep(/^aaa/, @a0)
@a2=grep(!/^aaa/, @a0)
@a0=@a2;

But can I do it with one function call, say using a map or sth? i.e.

@a1=pick_out_then_remove(/^aaa/, @a0)

Thanks!



-- 
Anti-Spam: Remove triple 5 to reply


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

Date: Mon, 19 Apr 1999 17:16:43 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: FAQ 3.24: How can I get C<#!perl> to work on [MS-DOS,NT,...]?
Message-Id: <MPG.1185674812d2f89f9898e4@nntp.hpl.hp.com>

[Posted and a courtesy copy mailed.]

In article <371bbb7c@cs.colorado.edu> on 19 Apr 1999 17:25:48 -0700, Tom 
Christiansen <perlfaq-suggestions@perl.com> says...
 ...
>     The Win95/NT installation, when using the ActiveState port of Perl,
>     will modify the Registry to associate the `.pl' extension with the
>     perl interpreter. If you install another port (Gurusamy Sarathy's
>     is the recommended Win95/NT port),

These are now one and the same, as you know.

>                                        or (eventually) build your own
>     Win95/NT Perl using a Windows port of gcc (e.g., with cygwin32 or
>     mingw32), then you'll have to modify the Registry yourself. In
>     addition to associating `.pl' with the interpreter, NT people can
>     use: `SET PATHEXT=%PATHEXT%;.PL' to let them run the program
>     `install-linux.pl' merely by typing `install-linux'.

:-)

-- 
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Mon, 19 Apr 1999 23:56:21 GMT
From: raylutz@adaptra.com
Subject: for (my $i;;) doesn't work like I think it should
Message-Id: <7fgfr0$ael$1@nnrp1.dejanews.com>

Hi:
Consider the following code segment:
{
    # pass one
    my $i; my $j = 0;
    for ($i = 0; $i < 8; $i++) {
        print "pass 1: \$i=$i\n";
        $j++;
        }

    print "Pass 1 End: \$j = $j;\n\n";

    # pass two
    my $j = 0;
    for (my $i = 0; $i < 8; $i++) {
        print "pass 2: \$i=$i\n";
        $j++;
        }

    print "Pass 2 End: \$j = $j;\n\n";
}
The only difference between pass one and two is the 'my' in the for().
According to the perl docs I've read, these SHOULD do the same thing.
But they don't. Here is the result:

---------------------
pass 1: $i=0
pass 1: $i=1
pass 1: $i=2
pass 1: $i=3
pass 1: $i=4
pass 1: $i=5
pass 1: $i=6
pass 1: $i=7
Pass 1 End: $j = 8;

Pass 2 End: $j = 0;
---------------------
Note that pass 2 is skipped completely. Why?

This doesn't jive with the perl man docs, which contains segments like this:

       Here's how a C programmer might code up a particular
       algorithm in Perl:

           for (my $i = 0; $i < @ary1; $i++) {
               for (my $j = 0; $j < @ary2; $j++) {
                   if ($ary1[$i] > $ary2[$j]) {
                       last; # can't go to outer :-(
                   }
                   $ary1[$i] += $ary2[$j];
               }
               # this is where that last takes me
           }

       Whereas here's how a Perl programmer more comfortable with
       the idiom might do it:

           OUTER: foreach my $wid (@ary1) {
           INNER:   foreach my $jet (@ary2) {
                       next OUTER if $wid > $jet;
                       $wid += $jet;
                    }
                 }

This won't work for me at all since 'my' doesn't act the way I think this
implies.

-Raymond Lutz

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: 20 Apr 1999 00:12:41 GMT
From: ada@fc.hp.com (Andrew Allen)
Subject: Re: Interpolating Variables for 'use'
Message-Id: <7fggpp$mjc$1@fcnews.fc.hp.com>

M.J.T. Guy (mjtg@cus.cam.ac.uk) wrote:
: In article <7fg7ch$juu$1@fcnews.fc.hp.com>, Andrew Allen <ada@fc.hp.com> wrote:
: >This works:
: >
: >BEGIN {$module="CGI"; eval "use $module";}
: >
: >but there's a nagging voice in my head saying "you don't _really_ want
: >to do that, do you?"

: It's good there are voices in your head.   You should always have
: nagging voices whenever you use   eval STRING.     There's almost always
: a better way to do it.   In this particular case, learn to replace the
: 'use' by it's equivalent 'BEGIN { require ... }'.    So:

:  BEGIN {$module="CGI"; require $module; $module->import }

: Rats!   That doesn't work.  You have to write

:  BEGIN {$module="CGI"; require "$module.pm"; $module->import }

Except that your method doesn't work for, say, $module="CGI::Carp",
since "require STRING" doesn't substitute / for :: like "use Module"
does.  Double rats!

(The same nagging voice was telling me that 'use MODULE', despite the
insistence of perlfunc, isn't _really_ identical to the require/import
sequence).

: Exercise for the reader: why did the first try say

: Unrecognized character \002 at  ...

Easy question if you give the "rest of the story"

 ... /opt/perl5/lib/5.00502/CGI line 1.

It's probably our failure to read the CGI directory as a file?

Andrew


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

Date: Mon, 19 Apr 1999 20:05:05 +0100
From: Kubla Khan <kubla_khan@rocketmail.com>
Subject: Re: Interpolating Variables for 'use'
Message-Id: <371B7E60.4B5B8145@rocketmail.com>

Since the variable that holds the module name is assigned after the BEGIN block,
assigning there won't work.  If I try:

 ...
$module = "CGI::Carp";
use $module;
 ...

I get a syntax error in the 'use' statement at the '$'.

I don't want to use 'require' because that will execute my code, right?  I only
want to execute the subs in the module that are relevent to the specific context
in which the object was instantiated.

What I am trying to do is 'use' a module that I wrote, instantiate a new instance
of it using its' 'new' constructor, and then execute some (not all) of the
methods in the module by specific calls.  I don't know what the module name is
until portions of the program have executed.
Is there a way to instantiate new module objects without using the 'use' method
first?
Or, is there a way to make the 'use' statement interpolate the variable as the
module name string that it is?

Thanks again.
---
I am so honored to have received a response from Tom Christiansen!


Tom Christiansen wrote:

>  [courtesy cc of this posting sent to cited author via email]
>
> In comp.lang.perl.misc,
>     mjtg@cus.cam.ac.uk (M.J.T. Guy) writes:
> :Rats!   That doesn't work.  You have to write
> : BEGIN {$module="CGI"; require "$module.pm"; $module->import }
>
> That won't work either.  Try $module = "CGI::Carp".
>
> --tom
> --
>     "Perl5, surprisingly, makes it very easy to do OO programming.  I suspect
>     that it does this much better than Larry ever intended."
>         --Dean Roehrich in <1994Oct5.140720.1511@driftwood.cray.com>



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

Date: Mon, 19 Apr 1999 21:49:09 -0500
From: Kevin Slanicky <slanicky@students.uiuc.edu>
Subject: Making grep insensitive
Message-Id: <Pine.SOL.3.96.990419214801.15929A-100000@ux13.cso.uiuc.edu>

How can I make this line case-insensitive?  I've tried many different
combinations of -i and i and none will compile (server error)  Any
suggestions?

@results = grep (/$multiple/, @results);




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

Date: Tue, 20 Apr 1999 00:04:36 GMT
From: J. Joy <j_joy@my-dejanews.com>
Subject: obtaining user's PATH statement
Message-Id: <7fggae$asb$1@nnrp1.dejanews.com>




I am trying to write a checker which will eval a given Unix user's environment
and return various problems with it.  To that end I would like to be able to
obtain the user's path (PATH) as it would be if they logged in so I could see
if has a "." in it, or what all they have included, that sort of thing.

If it helps, assume the script is run as root.

IS there a way to do this?  I was trying "su user -c echo $PATH" which
really has nothing to do with Perl, but I feel as I am missing something
obvious here.

So I apologize for a Unix problem, but I'm hoping it is easy to do in Perl.

thanks,
 jen

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: 20 Apr 1999 03:40:57 GMT
From: krusty276@aol.com (Krusty276)
Subject: Perl 'split' function in C??
Message-Id: <19990419234057.17226.00002845@ng110.aol.com>

Does anyone have one, or know of a site that has the split funtion of Perl
converted to C?   Sorry I'm just lazy, and wanna save sometime before I start
working on this?

Thanks


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

Date: Mon, 19 Apr 1999 19:20:56 -0600
From: Ron Reidy <rereidy@uswest.net>
Subject: Perl cookbook ...
Message-Id: <371BD678.1DC4D87D@uswest.net>

This is a multi-part message in MIME format.
--------------ECF4A8264E6D7EC05A84F7D8
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Hi all,

A co-worker of mine was writing a SIMPLE perl program to send e-mail to
a group of users when a certain event has cmpleted processing on our
server.  He used an example right from the cookbook, but it didn't work.

The cookbook example is locate on page 651:

open(SENDMAIL, "|/usr/lib/sendmail -oi -t -odq")
    or die "Can't fork for sendmaile: $!\n";
 ...
 ...
 ...


We could not force the die statement to fail.  Is it me/him, or is there
something missing here.

I would appreciate hearing from anyone with constructive suggestions or
help.

Thanks

rr

--------------ECF4A8264E6D7EC05A84F7D8
Content-Type: text/x-vcard; charset=us-ascii;
 name="rereidy.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: Card for Ron Reidy
Content-Disposition: attachment;
 filename="rereidy.vcf"

begin:vcard 
n:Reidy;Ron
x-mozilla-html:FALSE
org:Reidy Consulting, L.L.C.
version:2.1
email;internet:rereidy@uswest.net
title:Owner
x-mozilla-cpt:;0
fn:Ron Reidy
end:vcard

--------------ECF4A8264E6D7EC05A84F7D8--



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

Date: Tue, 20 Apr 1999 03:11:30 GMT
From: "Jim Durkin" <jdurkin@gw.total-web.net>
Subject: Perl, VB, or Java???
Message-Id: <01be8ab1$8ac45640$4d96bad1@jdurkin>

Hello,

I am trying to decide if I should use Perl or Java to perform the following
task.  I need to constantly
monitor the output of call records being generated by a switch. 
These records are being spooled to a network management station (NT
Server with IIS).  Multiple files will be created.  These records are
delimited by
commas and contain data that determine the performance and error status (if
any) of voice calls.  I need to look at certain fields of each record
and determine if an event needs to be generated to a my network management
software (NNM).  In addition, I
plan to massage the data and make it available on the Internet.  I have a
couple of questions:    

1.  What language do you recommend to perform this task?  (Perl for NT,
Java, or VB?)

2.  Should I feed the records into a database, such as an SQL server? 
Then, utilize SQL to access the pertinent data?
 
Thanks for any advice,

Jim Durkin



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

Date: Tue, 20 Apr 1999 03:49:26 GMT
From: clintp@geeksalad.org (Clinton Pierce)
Subject: Re: Top 10 newbie errors?
Message-Id: <371bf46a.3254335@news.roalok1.mi.home.com>

On Mon, 19 Apr 1999 14:19:42 -0700, Jerome O'Neil
<jeromeo@atrieva.com> wrote:
>I think strict should be used by newbies because it forces them to
>understand scoping and variable life, both of which are important for
>moving beyond newbie-land.  As a side effect, it also encourages good
>blocking and style.  It's a good habit, and it's best to start those
>early.  

"...moving beyond newbie-land..."  But that's not what was asked.
Telling new programmers and new Perl users, as a blanket
recommendation, to "use strict" can have the effect of dampening their
enthusiasm for the language, and for programming in general.

>Well you're no fun... ;->

No, but this thread is quickly filling with wet blankets.  :-)

Believe me, I'm the last person to spoil a new programmers fun.
Agreed: "use strict" should be in a programmer's arsenal of debugging
tools, and coding a project of any size without it is lunacy.  

But using a B&D language can spoil the wonder in simply pasting a
little bit of code from here-and-there and making the computer do what
you want.  Sometimes it's best to ignore the man behind the curtain.
New programmers have to worry about semicolons, $@&%, and whether
their brackets match up.  Variable scope?  Pttth.  

>There is very little difference between:
>my($foo) = q{bar};
>and 
>$foo = q{bar};
>Easily understood by infants and doktors alike!

No.  Your infants seem to be in 4th-5th grade.  Real Programming
Infants prefer:

	$foo="bar";

The quotes look "familar", and the variable just "pops" into
existance.  The tough exercise is remembering the "$" on the "foo".

Scope is a big concept for the first few programs.  Do you want them
blindly declaring all of their variables with my()?  That's what
you'll wind up with.  Honestly, how many here can remember new Perl 4
programmers declaring everything with local()...and still doing it
after Perl 5 came around?  Show of hands?  There's a lot of them
blindly repeating something they don't understand.

I think promoting supersticious programming like this is a Bad Thing.
Let them have "use strict", when they need it.

-- 
"If you rush a Miracle Man, you get rotten miracles"
                     --Miracle Max, The Princess Bride
http://www.geeksalad.org


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

Date: Tue, 20 Apr 1999 03:58:19 GMT
From: clintp@geeksalad.org (Clinton Pierce)
Subject: Re: Top 10 newbie errors?
Message-Id: <371dfaaf.4859277@news.roalok1.mi.home.com>

On Mon, 19 Apr 1999 13:53:59 -0700, in comp.lang.perl.misc you wrote:
>If and only if the two-year-old can correctly communicate its intentions 
>*to a compiler*, not to a tolerant human with intuitive pattern-
>recognition skills.

Perl's pattern recognition skills are quite remarkable.  You should
try some Perl Haiku sometime.  :-)

>I (respectfully) disagree entirely with what you say.  The effective 
>communication rate with 'use strict;' must be immensely higher *for a 
>beginner* than without it.
>
>Consider 'use strict;' as training wheels.  Experts might get away 
>without them; beginners can't.  The size of the program, like the 
>distance the bicycle travels, is irrelevant.

-w is training wheels.  Use strict is a "style committee" making the
user get his form perfect before he's allowed to pedal down the
driveway.  New programmers don't need to have the fine points of a
language (any language) drummed into them to be effective.  They won't
understand them, and will repeat them blindly.  This isn't learning to
code, it's cargo-cult programming.

There's a time and place for it, I just don't think it's at the
beginning.


-- 
"If you rush a Miracle Man, you get rotten miracles"
                     --Miracle Max, The Princess Bride
http://www.geeksalad.org


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

Date: Mon, 19 Apr 1999 19:53:28 -0500
From: "Brad Hilton" <bhilton@kc.net>
Subject: Re: VB and Perl
Message-Id: <X9QS2.123$nH4.1587@newsfeed.slurp.net>

First thing's first...I apoligize for posting repeated times.  It was an
accident...Yes, I am using MS crap to post this.

After I saw what I did I expected to be flamed by a whole bunch of people.

I was suprised though, when the only one who did was Tom Christiansen who I
thought that being as high profile a person as he is, wouldn't go around
trying to embarass people.

Hey Tom, It was an honest mistake...lighten up.

For the more patient people out there who took the time to answer my
question...thank you, I appreciate it.

---

Yes, I agree I would like to scrap VB entirely, however, that is what is
provided for me to use at work and that is what I am payed to do...but I am
looking into integrating Perl into it so that maybe I can slowly change
everything over or at least do a portion of my work in a competent language.

Anybody know where I can get a better newsreader for Windoze?
Brad Hilton wrote in message <51xS2.3106$R93.33003@newsfeed.slurp.net>...
>How can I integrate Perl into VB?  Is it possible to program entirely in
>Perl but use VB for screens?  Where can I go for information on this?
>
>Thanks,
>
>Brad Hilton
>bhilton@kc.net
>
>




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

Date: Mon, 19 Apr 1999 22:12:16 -0400
From: "Matthew O. Persico" <mpersico@erols.com>
Subject: Wow, thought he'd be much older...
Message-Id: <371BE280.DBD52115@erols.com>

Larry, that is. Somehow, I pictured a graying professorial look right
down to patches on the elbows. The cover of Linux Journal shows me
differently.

My $0.02
-- 
Matthew O. Persico
http://www.erols.com/mpersico
http://www.digistar.com/bzip2


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

Date: 20 Apr 1999 02:37:41 GMT
From: damian@cs.monash.edu.au (Damian Conway)
Subject: Re: Wow, thought he'd be much older...
Message-Id: <7fgp9l$pll$1@towncrier.cc.monash.edu.au>

"Matthew O. Persico" <mpersico@erols.com> writes:

>Larry, that is. Somehow, I pictured a graying professorial look right
>down to patches on the elbows. The cover of Linux Journal shows me
>differently.

Ah, but you should see the self-portrait in his study!

Damian


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

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


Administrivia:

Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing. 

]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body.  Majordomo will then send you instructions on how to confirm your
]subscription.  This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.

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.misc (and this Digest), send your
article to perl-users@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.

The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.

The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.

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 V8 Issue 5423
**************************************

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