[19090] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1285 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jul 11 14:05:41 2001

Date: Wed, 11 Jul 2001 11:05:17 -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: <994874717-v10-i1285@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Wed, 11 Jul 2001     Volume: 10 Number: 1285

Today's topics:
    Re: "Make" executable? (Garry)
    Re: "Make" executable? <randy@theoryx5.uwinnipeg.ca>
        Accessing a Variable whose Name is in a String <sneswhiz@home.com>
    Re: Accessing a Variable whose Name is in a String <laszlo.gerencser@portologic.com>
    Re: Accessing a Variable whose Name is in a String <cpryce@pryce.net>
    Re: Accessing a Variable whose Name is in a String (Tad McClellan)
    Re: Accessing a Variable whose Name is in a String <mjcarman@home.com>
    Re: Accessing a Variable whose Name is in a String (Tad McClellan)
        Active State <Stewy@Chartermi.net>
    Re: Active State (E.Chang)
    Re: Creating an HTML Template <ak@dasburo.de>
    Re: Data structures question. (Garry)
    Re: Data structures question. <mjcarman@home.com>
        DBase type for Banner Exchange script <giddeyup@derby.com>
    Re: environment variable in cgi <tony_curtis32@yahoo.com>
    Re: environment variable in cgi <hermann@holzerath.de>
        FAQ : How can I open a pipe both to and from a command? <perrot@NOSPAM.fluxus.net>
    Re: FAQ : How can I open a pipe both to and from a comm (Anno Siegel)
    Re: my $ref; vs. my $ref = {}; <goldbb2@earthlink.net>
        passing quotes to the command line (Alan)
        Perl script calling VisualBasic program on Win 2000 sys zszabo@prometheus.rad.jhu.edu
    Re: problems with Apache and DBI (Oracle) (Bob Showalter)
        Read/not read info from POP3 server (=?ISO-8859-1?Q?Morten_Tanger=E5s?=)
    Re: Reading file backwards <cpryce@pryce.net>
        Removing text in a file (Casey Chambliss)
    Re: Removing text in a file <laszlo.gerencser@portologic.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 11 Jul 2001 06:25:54 -0700
From: garry_short@hotmail.com (Garry)
Subject: Re: "Make" executable?
Message-Id: <bdcefd33.0107110525.150f8bb3@posting.google.com>

Florian Albrecht <Florian.Albrecht@alcatel.de> wrote in message news:<3B4C28BD.7E985594@alcatel.de>...
> Hey Gary!
> 
< SNIP >
> I suppose you want to "make" some modules or something! The problem you
> have is that ActiveState Perl is compiled with MSVC++ 6 and all modules
> (or whatever) have also to be compiled with VC++ 6.
> Now you got several possibilities:
> 1. You get MSVC++ 6 which includes nmake! or
> 2. You get the source of perl and make it with an other make, e.g.
> cygwin! or
> 3. You change your OS and don't have to use the MS Compiler.
> 
> Good Luck!
> 
> ;-) Flo

Cheers, Flo, that's actually very useful - I provide ClearCase support
for a team of about 50 developers, so I can grab a copy of the "nmake"
exe from their MSDN subscription! :-)

Many thanks,

Garry


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

Date: 11 Jul 2001 13:50:55 GMT
From: Randy Kobes <randy@theoryx5.uwinnipeg.ca>
Subject: Re: "Make" executable?
Message-Id: <9ihljv$is7$1@canopus.cc.umanitoba.ca>

In comp.lang.perl.misc, Florian Albrecht <Florian.Albrecht@alcatel.de> wrote:

>> Could anyone tell me where I can download a perl-compatible "make"
>> executable from? I'm running ActiveState Perl 5.6.0, build 618, and a
>> search of the system doesn't find a "make" command (or nmake, or
>> omake, or any executable with make in it)!

> I suppose you want to "make" some modules or something! The problem you
> have is that ActiveState Perl is compiled with MSVC++ 6 and all modules
> (or whatever) have also to be compiled with VC++ 6.
> Now you got several possibilities:
> 1. You get MSVC++ 6 which includes nmake! or
> 2. You get the source of perl and make it with an other make, e.g.
> cygwin! or
> 3. You change your OS and don't have to use the MS Compiler.

You only need to get VC++ if you plan on building XS-based
modules. The large majority of modules on CPAN are pure perl, and 
so for these you just need 'nmake' if using ActivePerl. As
another reply noted, Microsoft provides a free 'nmake' package.

best regards,
randy kobes


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

Date: Wed, 11 Jul 2001 10:59:36 -0400
From: Kevin Chen <sneswhiz@home.com>
Subject: Accessing a Variable whose Name is in a String
Message-Id: <3B4C69D8.D2BF44C2@home.com>

Is it possible to access a variable whose name is in another variable?

Suppose $a = "name".  Is it possible to somehow use $a to access $name?

What if $b = "2"?  Can I access $name2 or $name[2] using a combination
of $a and $b?

--
Kevin Chen



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

Date: Wed, 11 Jul 2001 15:05:51 GMT
From: Laszlo Gerencser <laszlo.gerencser@portologic.com>
Subject: Re: Accessing a Variable whose Name is in a String
Message-Id: <3B4C6B8A.B53447F0@portologic.com>

perldoc -f eval

--
Laszlo Gerencser
PortoLogic Ltd.


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

Date: Wed, 11 Jul 2001 10:36:54 -0500
From: cp <cpryce@pryce.net>
Subject: Re: Accessing a Variable whose Name is in a String
Message-Id: <B771DCC6.84E4%cpryce@pryce.net>

in article 3B4C69D8.D2BF44C2@home.com, Kevin Chen at sneswhiz@home.com wrote
on 07/11/2001 9:59 AM:

> Is it possible to access a variable whose name is in another variable?
> 
> Suppose $a = "name".  Is it possible to somehow use $a to access $name?
First, read the doc. Go to a command line where on a machine where Perl is
installed, and type:

perldoc perldata 

Read those docs, and then type:

perldoc perlfaq4

Many questions answered.

Yes, you can access a value the way that you are asking (without resorting
to an eval statement). ${$a} for instance. But if you want to get at a value
using a variable, consider using a hash instead.

%greek = (a=>'alpha',b=>'beta',c=>'gamma');
 print $greek{'a'}; # prints alpha

# or 
 $letter = 'a'; 
 print $greek{$letter}; # prints alpha also!


> 
> What if $b = "2"?  Can I access $name2 or $name[2] using a combination
> of $a and $b?

If you need a string of variables like $a1, $a2, $a3, etc., you probably
want an array 

@name = ('alpha', 'beta','gamma');
 foreach $a (@name) {
    print $a, "\n";
 } 

# prints: 
# alpha 
# beta
# gamma


# You can access the values in @name by index, as in:

 print $name[0]; #prints alpha
 
cp




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

Date: Wed, 11 Jul 2001 11:18:09 -0400
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Accessing a Variable whose Name is in a String
Message-Id: <slrn9korhh.epa.tadmc@tadmc26.august.net>

Kevin Chen <sneswhiz@home.com> wrote:

>Is it possible to access a variable whose name is in another variable?
                            ^^^^^^^^

[ You are expected to check the Perl FAQs *before* posting to the
  Perl newsgroup you know.
]


Yes. But you do not want to do that.

Use a hash element instead of an individually named scalar.

   $hash{name} = 'whatever the value of $name would be';


>Suppose $a = "name".  Is it possible to somehow use $a to access $name?
                                                     ^^ bad choice of name.
                                                     ^^ used by sort()


Yes. But you do not want to do that.

Now (with a hash) you can access it based on $a without 
evil Symbolic References:

   $hash{$a} = ...


>What if $b = "2"?  Can I access $name2 

   $hash{ "$a$b" } = ...

or

   $hash{ $a . $b } = ...


Have you done this:

   perldoc -q variable

yet?


Perl FAQ, part 7:

   "How can I use a variable as a variable name?"

See also:

   http://www.plover.com/~mjd/perl/varvarname.html
   http://www.plover.com/~mjd/perl/varvarname2.html
   http://www.plover.com/~mjd/perl/varvarname3.html


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


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

Date: Wed, 11 Jul 2001 11:15:41 -0500
From: Michael Carman <mjcarman@home.com>
Subject: Re: Accessing a Variable whose Name is in a String
Message-Id: <3B4C7BAD.3532F39A@home.com>

Kevin Chen wrote:
> 
> Is it possible to access a variable whose name is in another variable?

Sometimes, via soft references, but it's almost always a bad idea.
 
> Suppose $a = "name".  Is it possible to somehow use $a to access
> $name?

Yes, provided that strict refs have been disabled and that $name is a
global variable.

$name = 'Bob';
$a = 'name';
print ${$a};

You cannot use soft references to access lexical variables.

What you should do is use hard refereces:

my $name = 'Bob';
my $a = \$name;
print ${$a};

> What if $b = "2"?  Can I access $name2 or $name[2] using a
> combination of $a and $b?

Doing this the Right Way (tm):

my @name = qw/Bob Tim George Fred/;
my $a = \@name;
my $b = 2;
print $a->[$b]; # prints "George"

There is no good way to access $name2 using (both) $a and $b, but if
you're naming variables $name1, $name2, etc., you should be using an
array anyway.

For more information on references, see the perlref manpage. (perldoc
perlref).

-mjc


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

Date: Wed, 11 Jul 2001 12:25:38 -0400
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Accessing a Variable whose Name is in a String
Message-Id: <slrn9kovg2.g1a.tadmc@tadmc26.august.net>

Michael Carman <mjcarman@home.com> wrote:
>Kevin Chen wrote:
>> 
>> Is it possible to access a variable whose name is in another variable?


>> What if $b = "2"?  Can I access $name2 or $name[2] using a
>> combination of $a and $b?
>
>Doing this the Right Way (tm):

[snip]

>There is no good way to access $name2 using (both) $a and $b, 
             ^^^^

There is _a_ way though:

   $name2 = 'Bob';
   $a = 'name';
   $b = 2;
   print ${$a . $b};   # or ${"$a$b"}

But that is not a "good way" 'cause it uses symrefs.


>but if
>you're naming variables $name1, $name2, etc., you should be using an
>array anyway.


Right.


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


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

Date: Wed, 11 Jul 2001 10:29:52 -0500
From: "Adam Stewart" <Stewy@Chartermi.net>
Subject: Active State
Message-Id: <tkoose7di0467d@corp.supernews.com>

For a while now I have been interested in learning perl. So I recently
installed Active State Perl on my computer. My operating system is Windows
98, just so you know. First thing is it says to run there example program to
make sure it is working correctly. Now the problem is where do I run this
program from? It says to type <perl example.pl> at the command line, but it
doesnt say where this command line is, and i've looked all over with out
success.

Does anyone understand what I am saying? Your help is appreciated. Actualy I
would prefer for you to email me than to respond here as I may not get back
here for a few days.

Thank you,
Stewyyyyyyyy




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

Date: Wed, 11 Jul 2001 15:24:07 GMT
From: echang@netstorm.net (E.Chang)
Subject: Re: Active State
Message-Id: <Xns90DB7497775DEechangnetstormnet@207.106.92.86>

[posted and mailed]

"Adam Stewart" <Stewy@Chartermi.net> wrote in
<tkoose7di0467d@corp.supernews.com>: 

> For a while now I have been interested in learning perl. So I
> recently installed Active State Perl on my computer. My operating
> system is Windows 98, just so you know. First thing is it says to
> run there example program to make sure it is working correctly. Now
> the problem is where do I run this program from? It says to type
> <perl example.pl> at the command line, but it doesnt say where this
> command line is, and i've looked all over with out success.

The command line is an interface to DOS.  You can find it on your 
startmenu with the name "MS-DOS Prompt"  Look under Programs or 
Accessories.  You can also being up the DOS command prompt by selecting 
Run... from the startmenu and entering "command.com". 

Next, change to the directory where the script is located.  Use the 
command "cd to change directories'.  For example, enter "cd \perl\eg" 
if that's where your Perl examples are.  Then enter "perl example.pl".  
You can use the DOS command "dir" to see a listing of the files in the 
directory.

-- 
EBC


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

Date: Wed, 11 Jul 2001 14:52:45 +0200
From: Alexander Knack <ak@dasburo.de>
Subject: Re: Creating an HTML Template
Message-Id: <3B4C4C1D.F4C1053C@dasburo.de>

Take a look at Text::Tmpl http://www.pootpoot.com/~dlowe/Text-Tmpl/
i have good experiences with this module under unix, and have build
complex web-pages with it.
win32 is still experimental, but we're working on it to get it running

> 
> I'm designing a web site ( http://TeamAngelus.tripod.com ) and I've got
> the layout so the only thing I need to edit for each page is at the very
> bottom of the HTML source code. Basically everything is laid out in
> tables, being a table at the top for the banner, a table at the left for
> the nav, a table at the right for the quicklinks, and the middle table for
> the editable content.
> 
> Eveything but the middle table stays the same until I make an update for
> the left or right tables. And everything is used as the same template for
> each page, meaning when I change something in the left or right tables, I
> have to change it for every single page or I'll have blind links. I need a
> way to be able to change it once, and have it effect every page.
> 
> Any help would be greatly appreciated.
> 
> --
> Posted via CNET Help.com
> http://www.help.com/


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

Date: 11 Jul 2001 07:44:56 -0700
From: garry_short@hotmail.com (Garry)
Subject: Re: Data structures question.
Message-Id: <bdcefd33.0107110644.41e0b03@posting.google.com>

Michael Carman <mjcarman@home.com> wrote in message news:<3B4B28B3.61950B7C@home.com>...
> Garry wrote:
> > 
> 
> Yes, see the perlfaq4 entry "How do I sort an array by (anything)?"
>  

Thanks for that! I've had a read through it, and tried something
similar with strange problems (can't remember what, at the moment). I
think I'll have to have a play for a while to get to grips with it.

> > Assuming that's not possible, has anyone got any suggestions on
> > implementing the following data structure :
> > 
> > array of (unique SRC_IP,
> >   array of (unique SRC_PORT,
> >     array of (unique DEST_IP,
> >       array of (unique DEST_PORT,
> >         array of (unique PROTOCOL,
> >           array of (unique DATE,
> >             array of (unique TIME,
> >               array of (TYPE, CODE)
> >             )
> >           )
> >         )
> >       )
> >     )
> >   )
> > )
> 
> Hrm. I'm not sure I understand. That pseudocode looks like you want a
> eight-dimensional array! (Each SRC_IP would have multiple SRC_PORTs,
> each SRC_PORT multiple DEST_IPs, etc...) I don't think you really want
> that. :)
>
Mmm, possibly - I was thinking more along the lines of a tree
structure, but I understand what you mean :-)
 
> I'd suggest using a LoH (list of hashes). Something like this:
> 
> #!/usr/bin/perl -w
> use strict;
> 
> my @connection;
> 
> while (<DATA>) {
>     next if /^#/;
>     chomp;
>     my ($src_ip, $src_port, $dest_ip, $dest_port) = split;
> 
>     my %link = (
>         SRC_IP    => $src_ip,
>         SRC_PORT  => $src_port,
>         DEST_IP   => $dest_ip,
>         DEST_PORT => $dest_port,
>     );
>     push @connection, \%link;
> }
> 
> foreach my $n (0 .. $#connection) {
>     my $link = $connection[$n];
>     print "$n:\n";
>     foreach my $k (sort keys %$link) {
>         print "\t$k - $link->{$k}\n";
>     }
> }
>     
> __DATA__
> # src_ip  src_port dest_ip  dest_port
> 1.1.1.1   80       2.1.1.1  80
> 1.1.1.2   10       2.1.1.2  34
> 1.1.1.3   40       2.1.1.3  12
> 
> -mjc

Now *that* looks fantastic - thanks! I'd looked at hashes, but
couldn't find any examples that were close enough for me to see how to
apply them. There's enough info here for me to get to grips with it
now.

Oh, one point for clarification ... the line 
    foreach my $n (0 .. $#connection) {
 ... does that work along similar lines as ...
    for ($n = 0; $n <= $#connection; $n++) {
?

Thanks a lot,

Garry


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

Date: Wed, 11 Jul 2001 10:44:31 -0500
From: Michael Carman <mjcarman@home.com>
Subject: Re: Data structures question.
Message-Id: <3B4C745F.5B55851A@home.com>

Garry wrote:
> 
> Michael Carman <mjcarman@home.com> wrote in message > news:<3B4B28B3.61950B7C@home.com>...
> 
> > I'd suggest using a LoH (list of hashes). Something like this:
> >
[snip example]
> 
> Now *that* looks fantastic - thanks! I'd looked at hashes, but
> couldn't find any examples that were close enough for me to see how to
> apply them. There's enough info here for me to get to grips with it
> now.

You're welcome. Perl makes it easy to create complex data structures,
and having your data in the right format makes it much easier to work
with. After a while, you'll find yourself thinking much more about
*what* you want to do, and a lot less time getting bogged down in the
details of *how*.
 
> Oh, one point for clarification ... the line
>     foreach my $n (0 .. $#connection) {
> ... does that work along similar lines as ...
>     for ($n = 0; $n <= $#connection; $n++) {

They're equivilant. The first is easier to write and more Perlish. Using
the second one is like waving a big flag that says "I'm used to
programming in C!" There's nothing wrong with that, per se, but in Perl
it's rarely necessary to know what your loop index is, and as such it's
rarely used (by experienced Perl hackers, anyway). I only used it in my 
example because in this case I wanted to print out the index. Otherwise
I would have written it this way:

foreach my $link (@connection) {
    foreach my $k (sort keys %$link) {
        print "\t$k - $link->{$k}\n";
    }
}

-mjc


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

Date: Wed, 11 Jul 2001 10:41:06 -0700
From: "Mr. Ed" <giddeyup@derby.com>
Subject: DBase type for Banner Exchange script
Message-Id: <tkp3namcllk38d@corp.supernews.com>

I'm creating a banner exchange script  in Perl on Unix that will allow users
to sign up online and do the normal process of entering their info - I'm
wondering about the database, as I am more an ASP programmer- what would be
the best way to go as far as a flat-file database process, or similar one
that would work with a dynamic environment.

Thanks
Mr Ed




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

Date: 11 Jul 2001 09:03:46 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: environment variable in cgi
Message-Id: <871ynn5zr1.fsf@limey.hpcc.uh.edu>


PLEASE STOP TOP-POSTING.

>> On Wed, 11 Jul 2001 09:04:00 +0000,
>> gnari <gnarinn@hotmail.com> said:

>> gnari <gnarinn@hotmail.com> wrote in message
>> news:<994792339.0208406420424581.gnarinn@hotmail.com>...
>> ( please do not top-post.  by top-posting, i mean
>> putting your answer at the top of the article, and then
>> quoting the whole of the article you are answering to
>> after that.
>> 
>> now i will have to rearrange the article to be able to
>> answer, and usually that puts me off enough so that I
>> do not bother )
>> 

> (snipped the rest of the (whole) quoted article after
> top-post)

> I give up on you, sorry.

> gnari

> In article
> <3913d5b4.0107101800.7ddcb864@posting.google.com>, hao
> tran <hao7@yahoo.com> TOP-POSTED AGAIN:
>> Hi, ok forget about HOME.  suppose I have an
>> environment variable that I defined set MYNAME = hao7.
>> I display it by echo $MYNAME and get hao7.  in the
>> script i have: print "$ENV{MYNAME}\n"; I run the script
>> and get hao7 printed out.  but to call this script from
>> the browser, like netscape, the environment variable
>> not displayed.

Why are you continually ignoring Gnari's answers?  Are you
a troll?

The set of environment variables defined through a CGI
call is determined by the particular server and its
configuration.

It doesn't matter what environment variables you happen to
set in your login shell, that has nothing to do with CGI.
CGI programs get launched by the server, not by *you*,
they do not inherit *your* (possibly transient and
changing) environment.

And please stop top-posting.  Cite the parts of the text
you want to reply to, and then append your new text.

hth
t
-- 
Beep beep!  Out of my way, I'm a motorist!


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

Date: Wed, 11 Jul 2001 17:29:31 +0200
From: Hermann Fass <hermann@holzerath.de>
To: hao tran <hao7@yahoo.com>
Subject: Re: environment variable in cgi
Message-Id: <3B4C70DB.55D1D676@holzerath.de>

hao tran wrote:
> 
> Hi,
> ok forget about HOME.  suppose I have an environment variable that I
> defined set MYNAME = hao7.  I display it by echo $MYNAME and get hao7.
> in the script i have: print "$ENV{MYNAME}\n";  I run the script and
> get hao7 printed out.  but to call this script from the browser, like
> netscape, the environment variable not displayed.  Thanks.

I do not believe - as most other posters - that
$HOME is defined FOR THE USER AND SHELL THE WEBSERVER
IS RUNNING IN. (The user might be "nobody".)

Hermann


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

Date: Wed, 11 Jul 2001 17:18:09 +0200
From: "Gildas PERROT" <perrot@NOSPAM.fluxus.net>
Subject: FAQ : How can I open a pipe both to and from a command?
Message-Id: <9ihqrl$kuk$1@wanadoo.fr>

Hi,

I saw the FAQ about that question in
http://www.perldoc.com/perl5.6/pod/perlfaq8.html but I have difficulties to
implement it. Here is the program :

#!/usr/bin/perl

$cmd = "grep test";
$in = "test\nteste\n";

require 'Comm.pl';
&Comm'init();

$ph = open_proc($cmd);
print $ph $in;
while ($out = <$ph>) {
print "OUT : $out\n";
}

The first problem is the warning message I have on Redhat 6.2 :

stty: standard input: Inappropriate ioctl for device

The second one is that I need to be root to launch that program or I have :

could not open slave, /dev/pts258, errno=Permission denied at
/usr/lib/perl5/site_perl/5.005/Comm.pl line 1342.

Any idea about those problems ? Thanks in advance for your help.
Gildas.





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

Date: 11 Jul 2001 17:50:03 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: FAQ : How can I open a pipe both to and from a command?
Message-Id: <9ii3kb$igj$4@mamenchi.zrz.TU-Berlin.DE>

According to Gildas PERROT <perrot@NOSPAM.fluxus.net>:
> Hi,
> 
> I saw the FAQ about that question in
> http://www.perldoc.com/perl5.6/pod/perlfaq8.html but I have difficulties to
> implement it. Here is the program :
> 
> #!/usr/bin/perl
> 
> $cmd = "grep test";
> $in = "test\nteste\n";
> 
> require 'Comm.pl';
> &Comm'init();
> 
> $ph = open_proc($cmd);
> print $ph $in;
> while ($out = <$ph>) {
> print "OUT : $out\n";
> }
 
Yikes!  How did you end up with Perl 4 code starting from the
5.6 faq?  The first thing the faq suggests is IPC::Open2.  Try
that one.

Anno


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

Date: Wed, 11 Jul 2001 13:05:07 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: my $ref; vs. my $ref = {};
Message-Id: <3B4C8743.15171716@earthlink.net>

[Please don't top-post and don't quote signatures unless you're
commenting on them.]

Arvin Portlock wrote:
> Philip Newton <pne-news-20010620@newton.digitalspace.net> wrote in
> message news:pvj1jtc86emusud4er8ov4c7j2proe21gc@4ax.com...
> > On Wed, 20 Jun 2001 09:23:22 -0700, "Arvin Portlock"
> > <temp133@hotmail.com> wrote:
> >
> > > Is there a difference between declaring a hash reference as my
> > > $ref = {}; and as just plain my $ref; ?
> >
> > The first creates an anonymous hash and puts a reference to it into
> > $ref, the second leaves $ref with the undefined value.
> >
> > Note that if you use an undefined value as if it were a hash
> > reference, Perl automagically conjures up an anonymous hash and
> > sticks a reference to it into the variable so that you can reference
> > it. Thus, this:
> >
> >     $ref = undef;
> >     $ref->{'foo'} = 42;
> >
> > works, and $ref contains a hash reference afterwards.
> >
> > > The former has the advantage of being somewhat self-documenting,
> >
> > There is that.
> >
> > > sub make_hash {
> > >    my ($key, $value) = @_;
> > >    my $hashref;
> > >    $hashref->{$key}++ if $value;
> > >    return $hashref;
> > > }
> >
> > This doesn't make a whole lot of sense to me. You return either
> > undef or a reference to a hash with just one key.
> 
> Thanks. It's all so obvious now that you've explained it and
> clears up some fuzziness I've had on the subject. The example
> I included was illustrative rather than practical. But sometimes
> I'll do something very similar so that later I can do things like:
> 
> if ($hashref)
> 
> because if (keys %{$hashref}) is inefficient and 'if exists' only
> works when I know a specific key will always be present if the hash is
> defined. I see now that if I want to perform such a test I should
> avoid declaring the reference as $hashref = {}.

keys %$hashref is not inefficient... when called in a scalar context,
all it should do is reset the iterator and return the number of keys; it
should not actually create a key array.

> My problems in the past with declaring plain 'my $hashref;' were along
> the lines that sometimes such a test would still return true even if
> no keys seemed to have been created. I wondered whether perl would
> sometimes turn $hashref into an actual reference to a hash based on
> code in other areas of the subroutine, i.e., just the fact that the
> subroutine contained $hashref-> *anywhere* would be enough for it to
> do this.

When a scalar will autovivify is a confusing issue.  Perhaps someone
could explain it in some detail?

> Small tests I have performed seem to prove it does not, so
> those anamolous results were most probebly due to other errors in my
> code.

Maybe, maybe not.

-- 
The longer a man is wrong, the surer he is that he's right.


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

Date: 11 Jul 2001 06:14:24 -0700
From: slush@oceanfree.net (Alan)
Subject: passing quotes to the command line
Message-Id: <880a70aa.0107110514.7af2efd3@posting.google.com>

Sorry to bother you all,
I am trying to pass a single quote properly to the command line and it
does not seem to be working. I have tried escaping them and also using
qq etc... i have to interpolate variables inside the quotes so
unfortunatly I cannot use a single quote. Although that does do the
job I need it to do but obviously I cannot use variables in there.

example 
"dsh -w $node \'mount test_cws:/loglooker /mnt ; echo $?\'");
I am trying to get it to pass back the $? from the remote machine.
This command will work from the command line with the quotes set
properly, but not when I pass it from within perl.
If anybody thinks that it could be a problem with the dsh command then
that would also be appreciated.

Thanks All.

Alan


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

Date: Wed, 11 Jul 2001 15:03:04 -0400
From: zszabo@prometheus.rad.jhu.edu
Subject: Perl script calling VisualBasic program on Win 2000 system
Message-Id: <9ii7t8$bpc$1@prometheus.rad.jhu.edu>

This is slightly off-topic, but perhaps somebody can help me with this.

I have written a Visual Basic program that runs Word for Windows and performs
certain tasks. If I run it from the shell, it works correctly - word is
loaded and the tasks within it are performed.
If on the other hand I run it remotely, from within a Perl script, Word
is loaded but invisible and just hangs.

Does anyone have any advice to offer on this? Are there any parameters/
variables I need to set within Perl, so that it can run visual apps within
Win 2k remotely (executed from a web page)? Obviously I am not looking to
display the Word window on the web page; I just need to run it and complete
certain tasks.



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

Date: 11 Jul 2001 06:05:41 -0700
From: yaquib@yahoo.com (Bob Showalter)
Subject: Re: problems with Apache and DBI (Oracle)
Message-Id: <4a71b598.0107110505.3670d01d@posting.google.com>

"Daniel Czajko" <czajko@ocas.on.ca> wrote in message news:<GG9vuC.15D5@alfalfa.utcs.utoronto.ca>...
> I'm trying to run some Perl scripts that connect to an Oracle Database and
> output the information onto an HTML page running on Apache.  I can fetch the
> information from the database via DBI and display it at command line, but I
> don't seem to be able direct the output onto an HTML page.  Does anybody
> know of any issues between Apache and DBI (Oracle)?  I wish I could provide
> some output errors but there are none, the html page just won't appear.

Are you connecting to Oracle successfully? Make sure ORACLE_HOME is
set correctly in the web server's environment.


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

Date: Wed, 11 Jul 2001 18:56:17 +0200
From: morten@tangeraas.com (=?ISO-8859-1?Q?Morten_Tanger=E5s?=)
Subject: Read/not read info from POP3 server
Message-Id: <1ewe929.8bao8n15ropnyN%morten@tangeraas.com>

I'm making an online mailreader, and have some questions:

First of all, is there any sertain way to catch information from a POP3
mailserver if a message is read or not? I know that I could use the
"Status" field in the header, but as far as I know, this is not a
standard field on all POP3 servers, and it will therefor not allways
give the correct information.

I haven't seen som many mail readers that catch this information
correctly, but I have seen some (i.e. IMail Web Messagin v6.0 from
Ipswitch Inc., which is used on several Windows NT mail servers, as a
web interface to the POP3 server) who gets the right information. 

How do they do it? Are there any mail/POP3 commands to use (like uidl
and stuff) to get correct information about this?


I also would like som opinions about two values; timeout and number of
mails per summary page.

The timeout a security value in seconds. If the user is inactiv in more
than x number of secounds (now set to 1000), the user has to enter the
username and password all over to enter the mail account.
This also counts when the user is writing / replying an e-mail, so it
the timeout value shouldn't be to short either. Any thoughts?

The other value is number of mails which by default is to be shown per
summary page. This is by default set to 15 e-mails. But when a user has
logged in, she/he can choose an other value which overrides the default
value. Anyway, any thougts about what the default value should be?

By the way, for those of you who wants to try the beta of the online
e-mail reader, send me an e-mail for more information
(morten@tangeraas.com)!

Thanks!

Morten Tangeraas


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

Date: Wed, 11 Jul 2001 09:28:14 -0500
From: cp <cpryce@pryce.net>
Subject: Re: Reading file backwards
Message-Id: <B771CCAE.841A%cpryce@pryce.net>

in article 1ewb0ve.vv4bhp1wnta9sN%tony@svanstrom.com, Tony L. Svanstrom at
tony@svanstrom.com wrote on 07/09/2001 5:48 PM:

>> I have a file (huge). I want to find  pattern which occurs last. So I guess
>> if I can read the file from the end it will be fine.
>> How to do it?
>> My line lengths are not same
> 
> Search this NG for information regarding that, I think googles NG-stuff
> is up and running...

It is. The address for searching this NG is:

http://groups.google.com/groups?group=comp.lang.perl.misc

cp



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

Date: 11 Jul 2001 09:58:34 -0700
From: cchambli@lycos.com (Casey Chambliss)
Subject: Removing text in a file
Message-Id: <a15e3f18.0107110858.33701c89@posting.google.com>

Ok here's a sample of what I got:

</tr><tr><td>Auburn ,AL</td>
</tr><tr><td>Buffalo ,NY</td>
</tr><tr><td>Cheyenne ,WY</td>
</tr><tr><td>Columbia ,SC</td>

This is in a file called copied.txt with a file handle OUTFILE.

I want to remove the tags.  What would be the best way to do this?

Also, I know I'm going to need to do this in a loop.  How do I stop
the loop when I get to the end of the text file?  What is the syntax?


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

Date: Wed, 11 Jul 2001 17:26:06 GMT
From: Laszlo Gerencser <laszlo.gerencser@portologic.com>
Subject: Re: Removing text in a file
Message-Id: <3B4C8C63.1FB19A03@portologic.com>

Casey Chambliss wrote:
> 
> Ok here's a sample of what I got:
> 
> </tr><tr><td>Auburn ,AL</td>
> </tr><tr><td>Buffalo ,NY</td>
> </tr><tr><td>Cheyenne ,WY</td>
> </tr><tr><td>Columbia ,SC</td>
> 
> This is in a file called copied.txt with a file handle OUTFILE.
> 
> I want to remove the tags.  What would be the best way to do this?
Use a HTML parser module (see on CPAN).
Or (if you don't afraid about < and > in text or in an attribute - which
is invalid HTML anyway) do it with a regexp.

> Also, I know I'm going to need to do this in a loop.  How do I stop
> the loop when I get to the end of the text file?  What is the syntax?
perldoc perlsyn
And look at the Loop Control section.

--
Laszlo Gerencser
PortoLogic Ltd.


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

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


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