[23012] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5232 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jul 17 14:06:17 2003

Date: Thu, 17 Jul 2003 11:05:16 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Thu, 17 Jul 2003     Volume: 10 Number: 5232

Today's topics:
    Re: Accessing contents of MS Exchange mailbox? (Maynard)
    Re: Accessing contents of MS Exchange mailbox? <anonymous@anon.com>
        better way of building string from hash <mike_solomon@lineone.net>
    Re: better way of building string from hash <skuo@mtwhitney.nsc.com>
    Re: better way of building string from hash <mike_solomon@lineone.net>
    Re: better way of building string from hash <krahnj@acm.org>
    Re: better way of building string from hash <info_ns5@sundialservices.com>
        Building Hash of Arrays from multiple files <g4rry_short@zw4llet.com>
    Re: Building Hash of Arrays from multiple files <jvandervloet@hotmail.com>
    Re: Building Hash of Arrays from multiple files <asu1@c-o-r-n-e-l-l.edu>
    Re: Building Hash of Arrays from multiple files <usenet@dwall.fastmail.fm>
    Re: Building Hash of Arrays from multiple files <g4rry_short@zw4llet.com>
    Re: Configure win98 to work with a cgi written in perl <noreply@gunnar.cc>
        crypt returns same string for different texts <mdudley@execonn.com>
    Re: crypt returns same string for different texts <dbo@xbn.nl>
    Re: Dynamically generating multi-table SQL (Jesse Sheidlower)
    Re: Dynamically generating multi-table SQL <jpagnew@vcu.edu>
    Re: Dynamically generating multi-table SQL (Jesse Sheidlower)
        dynamically substituting variable name (mostart)
    Re: dynamically substituting variable name <abigail@abigail.nl>
    Re: dynamically substituting variable name <jurgenex@hotmail.com>
        Error upon Error... (rab)
    Re: Error upon Error... (rab)
    Re: filehandle to variable problem <mathias@gms.lu>
    Re: macros in perl <abigail@abigail.nl>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 17 Jul 2003 08:48:16 -0700
From: rev_maynard3@hotmail.com (Maynard)
Subject: Re: Accessing contents of MS Exchange mailbox?
Message-Id: <a4847dc.0307170748.465ede8a@posting.google.com>

"anonymous" <anonymous@anon.com> wrote in message news:<vhb9pab0lj1e37@corp.supernews.com>...
> I also use exchange 5.5 and i find that exmerge is a great utility for this.
> Check the microsoft website for the utility make sure you get the one for
> exchange 5.5

Thanks for the reply, but I want a script I can run in the background
(doesn't have to run as an interactive app) and has some flexible
regular expression support.  If I were to use this, I'd be forced to
run it manually and well, that seems to defeat the purpose.

I was looking at Win32::LDAP which seems like the light at the end of
the tunnel, but I'm having trouble (naturally) finding any examples of
how to go about my stated goal.  Is this a realistic way to go?  Is
there a way to do what I'm asking via Perl?

Thanks again.


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

Date: Thu, 17 Jul 2003 10:15:17 -0700
From: "anonymous" <anonymous@anon.com>
Subject: Re: Accessing contents of MS Exchange mailbox?
Message-Id: <vhdmddfdac0f6b@corp.supernews.com>

actually you can run exmerge unattended as a scheduled task but good luck
with your script.

"Maynard" <rev_maynard3@hotmail.com> wrote in message
news:a4847dc.0307170748.465ede8a@posting.google.com...
> "anonymous" <anonymous@anon.com> wrote in message
news:<vhb9pab0lj1e37@corp.supernews.com>...
> > I also use exchange 5.5 and i find that exmerge is a great utility for
this.
> > Check the microsoft website for the utility make sure you get the one
for
> > exchange 5.5
>
> Thanks for the reply, but I want a script I can run in the background
> (doesn't have to run as an interactive app) and has some flexible
> regular expression support.  If I were to use this, I'd be forced to
> run it manually and well, that seems to defeat the purpose.
>
> I was looking at Win32::LDAP which seems like the light at the end of
> the tunnel, but I'm having trouble (naturally) finding any examples of
> how to go about my stated goal.  Is this a realistic way to go?  Is
> there a way to do what I'm asking via Perl?
>
> Thanks again.




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

Date: Thu, 17 Jul 2003 17:43:44 +0100
From: mike solomon <mike_solomon@lineone.net>
Subject: better way of building string from hash
Message-Id: <3F16D240.9020208@lineone.net>

I have written the following code to create a variable in the format of 
'code' , 'value' , 'description'

I know i could have just said:

  my $arrField = "'code' , 'value' , 'description'";

but i think it is neater to put the code pairs into a hash

What I want to know if if there is a better way of doing this, as the 
way I have come up with is a bit messy



	my %required = (
		code => "Code is required",
		value => "Value is required",
		description => "Description is required",
		);

	my @arrField ;
	my @arrMess;

	for my $key (keys %required) {
		push @arrMess , qq {'$required{$key}'};
		push @arrField, qq {'$key'};
		}

	my $arrMess = join "," , @arrMess;
	my $arrField = join "," , @arrField;



Regards

Mike Solomon



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

Date: Thu, 17 Jul 2003 10:18:37 -0700
From: Steven Kuo <skuo@mtwhitney.nsc.com>
Subject: Re: better way of building string from hash
Message-Id: <Pine.GSO.4.21.0307171014090.1335-100000@mtwhitney.nsc.com>

On Thu, 17 Jul 2003, mike solomon wrote:

(snipped) 
> What I want to know if if there is a better way of doing this, as the 
> way I have come up with is a bit messy
> 
> 
> 
> 	my %required = (
> 		code => "Code is required",
> 		value => "Value is required",
> 		description => "Description is required",
> 		);
> 
> 	my @arrField ;
> 	my @arrMess;
> 
> 	for my $key (keys %required) {
> 		push @arrMess , qq {'$required{$key}'};
> 		push @arrField, qq {'$key'};
> 		}
> 
> 	my $arrMess = join "," , @arrMess;
> 	my $arrField = join "," , @arrField;
> 
> 
> 
> Regards
> 
> Mike Solomon
> 



This is more legible to me:

my $string_from_keys   = join ', ' => map qq{'$_'} => keys %required;
my $string_from_values = join ', ' => map qq{'$_'} => values %required;

-- 
Hope this helps,
Steven



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

Date: Thu, 17 Jul 2003 18:25:45 +0100
From: mike solomon <mike_solomon@lineone.net>
Subject: Re: better way of building string from hash
Message-Id: <3F16DC19.3090204@lineone.net>



Steven Kuo wrote:
> On Thu, 17 Jul 2003, mike solomon wrote:
> 
> (snipped) 
> 
>>What I want to know if if there is a better way of doing this, as the 
>>way I have come up with is a bit messy
>>
>>
>>
>>	my %required = (
>>		code => "Code is required",
>>		value => "Value is required",
>>		description => "Description is required",
>>		);
>>
>>	my @arrField ;
>>	my @arrMess;
>>
>>	for my $key (keys %required) {
>>		push @arrMess , qq {'$required{$key}'};
>>		push @arrField, qq {'$key'};
>>		}
>>
>>	my $arrMess = join "," , @arrMess;
>>	my $arrField = join "," , @arrField;
>>
>>
>>
>>Regards
>>
>>Mike Solomon
>>
> 
> 
> 
> 
> This is more legible to me:
> 
> my $string_from_keys   = join ', ' => map qq{'$_'} => keys %required;
> my $string_from_values = join ', ' => map qq{'$_'} => values %required;
> 

Steven

Thats great, much neater

Thanks

I have a blind spot about using map
I must learn more about it






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

Date: Thu, 17 Jul 2003 17:54:19 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: better way of building string from hash
Message-Id: <3F16E305.34E4DF8F@acm.org>

mike solomon wrote:
> 
> I have written the following code to create a variable in the format of
> 'code' , 'value' , 'description'
> 
> I know i could have just said:
> 
>   my $arrField = "'code' , 'value' , 'description'";
> 
> but i think it is neater to put the code pairs into a hash
> 
> What I want to know if if there is a better way of doing this, as the
> way I have come up with is a bit messy
> 
> my %required = (
>         code => "Code is required",
>         value => "Value is required",
>         description => "Description is required",
>         );
> 
> my @arrField ;
> my @arrMess;
> 
> for my $key (keys %required) {
>         push @arrMess , qq {'$required{$key}'};
>         push @arrField, qq {'$key'};
>         }
> 
> my $arrMess = join "," , @arrMess;
> my $arrField = join "," , @arrField;

You could do it like this:

my $arrMess  = join ',', map "'$_'", values %required;
my $arrField = join ',', map "'$_'", keys   %required;



John
-- 
use Perl;
program
fulfillment


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

Date: Thu, 17 Jul 2003 11:02:29 -0700
From: Sundial Services <info_ns5@sundialservices.com>
Subject: Re: better way of building string from hash
Message-Id: <3f16e4a9@shknews01>

John W. Krahn wrote:

> mike solomon wrote:
>> 
>> I have written the following code to create a variable in the format of
>> 'code' , 'value' , 'description'
>> 
>> I know i could have just said:
>> 
>>   my $arrField = "'code' , 'value' , 'description'";
>> 
>> but i think it is neater to put the code pairs into a hash
>> 
>> What I want to know if if there is a better way of doing this, as the
>> way I have come up with is a bit messy
>> 
>> my %required = (
>>         code => "Code is required",
>>         value => "Value is required",
>>         description => "Description is required",
>>         );
>> 
>> my @arrField ;
>> my @arrMess;
>> 
>> for my $key (keys %required) {
>>         push @arrMess , qq {'$required{$key}'};
>>         push @arrField, qq {'$key'};
>>         }
>> 
>> my $arrMess = join "," , @arrMess;
>> my $arrField = join "," , @arrField;
> 
> You could do it like this:
> 
> my $arrMess  = join ',', map "'$_'", values %required;
> my $arrField = join ',', map "'$_'", keys   %required;
> 

Just remember though ... "it has to be clear."  Abundantly clear.  And it 
has to be resistant to side-effects, caused by an unrelated change made to 
the software at some future time.  (A change, that is, that you intended to 
be "unrelated," but because of the original design, "suh-prize!")

Perl teeters on being a "write-only language."  Keep your code simple and 
direct, and extremely well-documented AS you write it.




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

Date: Thu, 17 Jul 2003 14:28:55 +0000
From: Garry Short <g4rry_short@zw4llet.com>
Subject: Building Hash of Arrays from multiple files
Message-Id: <bf68hs$qjs$1$8300dec7@news.demon.co.uk>

Hi all,

I'm having a little trouble coming up with a working solution for this hash
of arrays.

I've got a list of property files that I'm trying to display in a table
(this is actually part of a CGI script, but that's not really relevant).

These properties have a series of key=value pairs. However, each file may
only have a selection of the pairs, and it's unlikely that any file will
have all of the keys.

This is easy enough when a key exists in every file, BUT ...

1. How do I add a new key that hasn't existed in previous files, and add
data to show that it doesn't exist in the previous files?

2. How do I mark that the key from a previous file doesn't exist in this
one?

This is a rough sketch of what I've got so far:

#!/usr/bin/perl -w

my %HoA;
my @filelist;
my $master_file = "master.list";

open MASTER, $master_file or die "Can't open $master_file: $!\n";
my @master_list = <FILE>;
close FILE;
my $fc = 0;     # file counter
foreach my $file (@master_list) {
  open FILE, $file or die "Can't open $file: $!\n";
  $fc++;
  while (<FILE>) {
    my ($key, $value) = split /=/;
    if ($HoA{$key}) {   # if this key already exists
      push ($HoA{$key}, [ $value ]);
    } else {            # This is a new key
      # I can do this ...
      for (my $counter = 0; $counter < $fc; $counter++) {
        push ($HoA{$key}, [ "" ]);
      }
      push ($HoA{$key}, [ $value ]);
      # Would this work as I expect it to??
    }
  }
}
foreach $key (keys %HoA) {
  my @list = $HoA{$key};
  foreach my $elem (@list) {
    print "$elem\t";
  }
  print "\n";
}

I've not really done much with hashes before, and this is a fairly
complicated one (for me, at least :-)

Is this likely to print the table as I expect it? 
Is there a better way of adding in new keys half way through (as suggested
in the ELSE loop).
Anyone got any ideas on how to indicate that the current file does NOT
contain a key?

TIA,

Garry




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

Date: Thu, 17 Jul 2003 14:09:19 GMT
From: "joeri" <jvandervloet@hotmail.com>
Subject: Re: Building Hash of Arrays from multiple files
Message-Id: <j6yRa.15906$F92.1952@afrodite.telenet-ops.be>

"Garry Short" <g4rry_short@zw4llet.com> wrote in message
news:bf68hs$qjs$1$8300dec7@news.demon.co.uk...
> my %HoA;
> my @filelist;
> my $master_file = "master.list";
>
> open MASTER, $master_file or die "Can't open $master_file: $!\n";
> my @master_list = <FILE>;
> close FILE;
> my $fc = 0;     # file counter
> foreach my $file (@master_list) {
>   open FILE, $file or die "Can't open $file: $!\n";
>   $fc++;
>   while (<FILE>) {
>     my ($key, $value) = split /=/;
>     if ($HoA{$key}) {   # if this key already exists
>       push ($HoA{$key}, [ $value ]);
>     } else {            # This is a new key
>       # I can do this ...
>       for (my $counter = 0; $counter < $fc; $counter++) {
>         push ($HoA{$key}, [ "" ]);
>       }
>       push ($HoA{$key}, [ $value ]);
>       # Would this work as I expect it to??
>     }
>   }
> }
> foreach $key (keys %HoA) {
>   my @list = $HoA{$key};
>   foreach my $elem (@list) {
>     print "$elem\t";
>   }
>   print "\n";
> }

you must "push" onto an array, so you have to make the value of your hash
into an array. Try this instead:

push(@{$HoA{$key}}, $value);

You can still check the existence of the $key in the hash with

if exists $HoA{$key}


J





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

Date: 17 Jul 2003 14:33:59 GMT
From: "A. Sinan Unur" <asu1@c-o-r-n-e-l-l.edu>
Subject: Re: Building Hash of Arrays from multiple files
Message-Id: <Xns93BB6B7C814B8asu1cornelledu@132.236.56.8>

Garry Short <g4rry_short@zw4llet.com> wrote in
news:bf68hs$qjs$1$8300dec7@news.demon.co.uk: 

> Hi all,
> 
> I'm having a little trouble coming up with a working solution for this
> hash of arrays.
 ...

> These properties have a series of key=value pairs. However, each file
> may only have a selection of the pairs, and it's unlikely that any
> file will have all of the keys.

Would Config::Properties 

http://search.cpan.org/author/SALVA/Config-Properties-0.51/

help?

Sinan.

-- 
A. Sinan Unur
asu1@c-o-r-n-e-l-l.edu
Remove dashes for address
Spam bait: mailto:uce@ftc.gov


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

Date: Thu, 17 Jul 2003 15:31:52 -0000
From: "David K. Wall" <usenet@dwall.fastmail.fm>
Subject: Re: Building Hash of Arrays from multiple files
Message-Id: <Xns93BB754CCD687dkwwashere@216.168.3.30>

Garry Short <g4rry_short@zw4llet.com> wrote:

> I'm having a little trouble coming up with a working solution for
> this hash of arrays.
> 
> I've got a list of property files that I'm trying to display in a
> table (this is actually part of a CGI script, but that's not
> really relevant). 
> 
> These properties have a series of key=value pairs. However, each
> file may only have a selection of the pairs, and it's unlikely
> that any file will have all of the keys.
> 
> This is easy enough when a key exists in every file, BUT ...
> 
> 1. How do I add a new key that hasn't existed in previous files,
> and add data to show that it doesn't exist in the previous files?
> 
> 2. How do I mark that the key from a previous file doesn't exist
> in this one?

I don't think a hash of arrays is the best way to approach this if 
your desired output is a table where the rows are keys and the 
columns are filenames. I'd use a hash of hashes, something like 
$HoH{$key}{$file} = $value, so you don't have to keep track of empty 
entries in an array.  Once everything is stored in the hash of hashes 
you can print it any way you please.

For example:

    use strict;
    use warnings;
    
    my %HoH;
    my $master_file = "master.list";
    
    open MASTER, $master_file or die "Can't open $master_file: $!\n";
    chomp(my @master_list = <MASTER>);
    close MASTER;
    foreach my $file (@master_list) {
        open FILE, $file or die "Can't open $file: $!\n";
        while (<FILE>) {
            chomp;
            my ($key, $value) = split /=/;
            $HoH{$key}{$file} = $value;
        }
        close FILE;
    }
    foreach my $key (sort keys %HoH) {
        print "$key: ";   # maybe <tr> here in your CGI program? :-)
        foreach my $file (@master_list) {
            print defined $HoH{$key}{$file} ? 
    	    	    	$HoH{$key}{$file} : 
    	    	    	'n/a';
            print "\t\t";
        }
        print "\n";
    }

Hope this helps.  


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

Date: Thu, 17 Jul 2003 16:55:20 +0000
From: Garry Short <g4rry_short@zw4llet.com>
Subject: Re: Building Hash of Arrays from multiple files
Message-Id: <bf6h2j$81j$1$8300dec7@news.demon.co.uk>

David K. Wall wrote:

> 
> I don't think a hash of arrays is the best way to approach this if
> your desired output is a table where the rows are keys and the
> columns are filenames. I'd use a hash of hashes, something like
> $HoH{$key}{$file} = $value, so you don't have to keep track of empty
> entries in an array.  Once everything is stored in the hash of hashes
> you can print it any way you please.
> 
> For example:
> 
>     use strict;
>     use warnings;
>     
>     my %HoH;
>     my $master_file = "master.list";
>     
>     open MASTER, $master_file or die "Can't open $master_file: $!\n";
>     chomp(my @master_list = <MASTER>);
>     close MASTER;
>     foreach my $file (@master_list) {
>         open FILE, $file or die "Can't open $file: $!\n";
>         while (<FILE>) {
>             chomp;
>             my ($key, $value) = split /=/;
>             $HoH{$key}{$file} = $value;
>         }
>         close FILE;
>     }
>     foreach my $key (sort keys %HoH) {
>         print "$key: ";   # maybe <tr> here in your CGI program? :-)
>         foreach my $file (@master_list) {
>             print defined $HoH{$key}{$file} ?
>     $HoH{$key}{$file} :
>     'n/a';
>             print "\t\t";
>         }
>         print "\n";
>     }
> 
> Hope this helps.

Hi David,

Mmm, I wondered about HoH, but couldn't quite get my head round how it'd
work - this shows it nicely thanks! 

Cheers,

Garry




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

Date: Thu, 17 Jul 2003 14:17:31 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Configure win98 to work with a cgi written in perl
Message-Id: <bf646r$bkdo2$1@ID-184292.news.uni-berlin.de>

iris wrote:
> How do i configure win 98 to work with cgi?

You install a web server, too. Easiest way to get it working: 
http://www.indigostar.com/indigoperl.htm

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl



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

Date: Thu, 17 Jul 2003 11:17:00 -0400
From: Marshall Dudley <mdudley@execonn.com>
Subject: crypt returns same string for different texts
Message-Id: <3F16BDEC.EEBF8D01@execonn.com>

I am having a problem where crypt is returning exactly the same
encrypted string for multiple input texts.  Does anyone know how to fix
this?

Example:

$password1 = crypt "1058455513","SK";
$password2 = crypt "1058455539","SK";
$password3 = crypt "1058455589","SK";
$password4 = crypt "1058455500","SK";
print "passwords = $password1, $password2, $password3, $password4\n";

Result:

perl testcrypt.pl
passwords = SKQ6.yqTB9svk, SKQ6.yqTB9svk, SKQ6.yqTB9svk, SKQ6.yqTB9svk

This is totally messing up a password lookup, it is finding the wrong
people!

Thanks,

Marshall



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

Date: Thu, 17 Jul 2003 18:01:34 +0200
From: David Bouman <dbo@xbn.nl>
Subject: Re: crypt returns same string for different texts
Message-Id: <3F16C85E.97D98F20@xbn.nl>

Marshall Dudley wrote:

> I am having a problem where crypt is returning exactly the same
> encrypted string for multiple input texts.  Does anyone know how to 
> fix this?
> 
> Example:
> 
> $password1 = crypt "1058455513","SK";
> $password2 = crypt "1058455539","SK";
> $password3 = crypt "1058455589","SK";
> $password4 = crypt "1058455500","SK";
> print "passwords = $password1, $password2, $password3, $password4\n";
> 
> Result:
> 
> perl testcrypt.pl
> passwords = SKQ6.yqTB9svk, SKQ6.yqTB9svk, SKQ6.yqTB9svk, SKQ6.yqTB9svk

While it's perfectly legal for crypt to produce the same result for
differing inputs, your crypt might actually encrypt just the first 8
characters here

--
D.


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

Date: 17 Jul 2003 10:49:47 -0400
From: jester@panix.com (Jesse Sheidlower)
Subject: Re: Dynamically generating multi-table SQL
Message-Id: <bf6d2b$qer$1@panix2.panix.com>

In article <1bff1830.0307082155.13a4950b@posting.google.com>,
Bryan Castillo <rook_5150@yahoo.com> wrote:
>jester@panix.com (Jesse Sheidlower) wrote in message news:<bed7hg$mqr$1@panix2.panix.com>...
>> I'm trying to automatically generate multi-table SQL
>> statements from a Web environment, and am having a lot of
>> difficulty doing it in a way that doesn't feel kludgy to
>> me. I've looked at various sites and books, but they tend to
>> focus on situations where multi-table joins are fixed--you
>> want the same results every time, so form of the query never
>> changes.
>> 
>
>Are you familiar with OO perl? [...]

Thanks to all who replied, and sorry for taking so long to follow
up myself.

In fact, I'm just starting to program in OO Perl myself, and had
been trying to figure out how to do this in an OO way.

After doing a whole bunch of work, which was going fairly well,
I then ran into yesterday's article on perl.com about doing
this very simply using Template Toolkit and Class::DBI. Grr. 
I'm still not sure that this is necessarily better than rolling
my own--if it takes just as much effort to learn two different
new abstraction layers, where's the benefit?--but I'm considering
something like this, or with Alzabo or something.

Thanks again for the thoughts. Am still working away.

Best,

Jesse Sheidlower


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

Date: Thu, 17 Jul 2003 11:43:59 -0400
From: Jim Agnew - VCU/MCV Neurosurgery <jpagnew@vcu.edu>
Subject: Re: Dynamically generating multi-table SQL
Message-Id: <3F16C43F.AE39A9A4@vcu.edu>

Jesse Sheidlower wrote:
> 
> In article <1bff1830.0307082155.13a4950b@posting.google.com>,
> Bryan Castillo <rook_5150@yahoo.com> wrote:
> >jester@panix.com (Jesse Sheidlower) wrote in message news:<bed7hg$mqr$1@panix2.panix.com>...
> >> I'm trying to automatically generate multi-table SQL
> >> statements from a Web environment, and am having a lot of
> >> difficulty doing it in a way that doesn't feel kludgy to
> >> me. I've looked at various sites and books, but they tend to
> >> focus on situations where multi-table joins are fixed--you
> >> want the same results every time, so form of the query never
> >> changes.
> >>
> >
> >Are you familiar with OO perl? [...]
> 
> Thanks to all who replied, and sorry for taking so long to follow
> up myself.
> 
> In fact, I'm just starting to program in OO Perl myself, and had
> been trying to figure out how to do this in an OO way.
> 
> After doing a whole bunch of work, which was going fairly well,
> I then ran into yesterday's article on perl.com about doing
> this very simply using Template Toolkit and Class::DBI. Grr.
> I'm still not sure that this is necessarily better than rolling
> my own--if it takes just as much effort to learn two different
> new abstraction layers, where's the benefit?--but I'm considering
> something like this, or with Alzabo or something.
> 
> Thanks again for the thoughts. Am still working away.
> 
> Best,
> 
> Jesse Sheidlower

That is a very valid question, if it's a one-shot deal, and learning new
is slower than doing old, ???


-- 
"4,000 years ago I made a mistake."  Elrond Half-Elven, in "Fellowship
of the Ring"

"I try not to be right any more than necessary". -- Larry Wall, author
of the Perl Language


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

Date: 17 Jul 2003 12:08:39 -0400
From: jester@panix.com (Jesse Sheidlower)
Subject: Re: Dynamically generating multi-table SQL
Message-Id: <bf6hm7$b19$1@panix2.panix.com>

In article <3F16C43F.AE39A9A4@vcu.edu>,
Jim Agnew - VCU/MCV Neurosurgery  <jpagnew@vcu.edu> wrote:
>Jesse Sheidlower wrote:
>> After doing a whole bunch of work, which was going fairly well,
>> I then ran into yesterday's article on perl.com about doing
>> this very simply using Template Toolkit and Class::DBI. Grr.
>> I'm still not sure that this is necessarily better than rolling
>> my own--if it takes just as much effort to learn two different
>> new abstraction layers, where's the benefit?--but I'm considering
>> something like this, or with Alzabo or something.

[...]

>That is a very valid question, if it's a one-shot deal, and learning new
>is slower than doing old, ???

But of course it isn't that simple. It's not a one-shot deal,
in that I do expect to be doing other database programming for
the Web, but it's the usefulness of any particular other layer
that's a problem.  That is, and leaving aside the issue of how
much I'd learn by rolling my own, the main issue would seem to
be putting the effort into learning Class::DBI, or Alzabo, or
Tangram, or DBIx::RecordSet, or..., and then six months from 
now everyone has abandoned whatever I just chose, and I'm stuck
with code in a system no one uses any more.

Anyway I realize this is hardly a new concern, and I'm just
nattering in a way that's probably not appropriate, so I'll
stop.

Jesse Sheidlower



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

Date: 17 Jul 2003 03:56:39 -0700
From: mostart@yahoo.com (mostart)
Subject: dynamically substituting variable name
Message-Id: <e5304693.0307170256.6096b81b@posting.google.com>

hi,

I want to dynamically substitute a variables name.
I know this from PHP where you can have somthing like
${$foo}

how can I do this in perl ??

thanks
mostart


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

Date: 17 Jul 2003 11:23:15 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: dynamically substituting variable name
Message-Id: <slrnbhd1p3.53v.abigail@alexandra.abigail.nl>

mostart (mostart@yahoo.com) wrote on MMMDCVII September MCMXCIII in
<URL:news:e5304693.0307170256.6096b81b@posting.google.com>:
##  hi,
##  
##  I want to dynamically substitute a variables name.
##  I know this from PHP where you can have somthing like
##  ${$foo}
##  
##  how can I do this in perl ??


You'd use ${$foo} or $$foo.

But are you sure you want this? It could easily lead to hard
to find bugs. Wouldn't a hash do?


Abigail
-- 
               split // => '"';
${"@_"} = "/"; split // => eval join "+" => 1 .. 7;
*{"@_"} = sub {foreach (sort keys %_)  {print "$_ $_{$_} "}};
%{"@_"} = %_ = (Just => another => Perl => Hacker); &{%{%_}};


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

Date: Thu, 17 Jul 2003 13:08:04 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: dynamically substituting variable name
Message-Id: <UcxRa.18803$kI5.8198@nwrddc02.gnilink.net>

mostart wrote:
> I want to dynamically substitute a variables name.
> I know this from PHP where you can have somthing like
> ${$foo}
>
> how can I do this in perl ??

You may want to check The Fine Manual about why it's a bad idea to use
symbolic references and what better options are available: perldoc -q
'variable name'

 How can I use a variable as a variable name?
           Beginners often think they want to have a variable contain the
           name of a variable.
             [...]
           This works *sometimes*, but it is a very bad idea for two
           reasons. [...]

jue




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

Date: 17 Jul 2003 07:29:45 -0700
From: unix@att.com (rab)
Subject: Error upon Error...
Message-Id: <9bb5fc.0307170629.189b2260@posting.google.com>

anyone seen this error before: 

> Can't load '/usr/local/lib/perl5/5.8.0/PA-RISC2.0/auto/DB_File/DB_File.sl' for module DB_File: No such file or directory at /usr/local/lib/perl5/5.8.0/PA-RISC2.0/XSLoader.pm line 83.
>  at /usr/local/lib/perl5/5.8.0/PA-RISC2.0/DB_File.pm line 236


I'm just trying to run this script:

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

print "Hello World!\n"


all three of the files exist on the system....why is it saying this.  
(there are a few scripts that I have that want to use DB_File and they
all say this.... that's why I just use this simple script above for
error diagnosis)

rab


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

Date: 17 Jul 2003 10:34:27 -0700
From: unix@att.com (rab)
Subject: Re: Error upon Error...
Message-Id: <9bb5fc.0307170934.23230501@posting.google.com>

> >>>>> "rab" == rab  <unix@att.com> writes:
> 
>     rab> anyone seen this error before: 
> This does look puzzling.  If the files truly exist, could there be a
> permission issue with DB_File.sl?  It could be the result of a bad
> install, so you might try re-installing the DB_File modules.
> 
> Good luck to you,
> 
> --Ethan Brown
> --Keyboards: "The Fabulous Pelicans" (www.pelicans.com)
> --In a band?  Use http://www.WheresTheGig.com for free.
> 
> 

Ethan....Thanks for the response.  Checked the permissions...but they
were all fine.

I'm afraid that reinstalling is even more difficult.   I wouldn't even
know where to begin trying to get rid of all the complaints from gcc.

I got this copy of Perl from a port to HPUX site.

thanks though.


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

Date: Thu, 17 Jul 2003 14:01:00 +0200
From: mathias <mathias@gms.lu>
Subject: Re: filehandle to variable problem
Message-Id: <3f168ffc$1@news>

Jay Tilton wrote:
> mathias <mathias@gms.lu> wrote:
> 
> : Greg Bacon wrote:
> : 
> : > : like *main::FH or main::STDOUT or GLOB(0x80f60ac)
> : > 
> : > It's a filehandle.  Why do you care what it looks like when you print
> : > its internal representation?  What did you expect to happen?
> : > 
> : > Greg
> 
> : well i was waiting for bla instead of any of the strings i had.
> : can you give me a way then to get "bla" from this filehandle ?
> 
> Your code is short enough that including it in the article is
> preferable to making readers go out to the web to see it.
> 
> [grabbed from http://www.tiasarea.org/perl.html]
>     #!/usr/bin/perl -w
>     use strict;
> 
>     sub runme {
>     my $fh=shift;
>     print $fh "bla\n"; }
> 
>     my $var;
>     open FH, '>', \$var;
>     runme(\*FH);
>     $var = *FH;
>     close FH;
> 
>     print "var: \n";
>     print ">".$var."<\n";
> 
>     the output from this script is: 
>     var: 
>     >*main::FH< 
> 
> In Perl 5.8.0, "open FH, '>', \$var" will cause stuff printed to FH to
> go into $var.  Cut out the "$var = *FH;" line and look in $var for
> your 'bla'.
> 
> In an older Perl, that form of open() does not have the same behavior.
> It just ends up stringifying the scalar reference, creating a file
> named like "SCALAR(0x1a653b4)".
> 
thank you for the help
i finally solved it out

Mathias



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

Date: 17 Jul 2003 10:37:24 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: macros in perl
Message-Id: <slrnbhcv33.53v.abigail@alexandra.abigail.nl>

Eric J. Roode (REMOVEsdnCAPS@comcast.net) wrote on MMMDCVII September
MCMXCIII in <URL:news:Xns93BB3C48D4FCDsdn.comcast@206.127.4.25>:
^^  -----BEGIN xxx SIGNED MESSAGE-----
^^  Hash: SHA1
^^  
^^  marc0 <marc0@autistici.org> wrote in news:87n0fek5p7.fsf@autistici.org:
^^  
^^ > I desire them because I desire to modify the syntax where IMHO makes
^^ > sense, for example something like:
^^ > 
^^ > #include <stdio.h>
^^ > 
^^ > #define loop(n) for (i = 0; i < n; i++)
^^ > 
^^ > int main ()
^^ > {
^^ >   unsigned int i;
^^ > 
^^ >   loop (10)
^^ >     do_something ();
^^ > 
^^ >   return 0;
^^ > }
^^ > 
^^ > In the Perl script I'm working on I would use it to write something
^^ > like
^^ > 
^^ > #define walk_file(FILE) for ($walk_file_line = <FILE>)
^^ > 
^^ > walk_file (FILE) {
^^ > ...
^^ > }
^^ > 
^^ > and alike.
^^ > 
^^ > That's not necessary but IMHO it helps to make the code more clear.
^^ > 
^^ > Another way to do it would be to use the C preprocessor or M4 (likely
^^ > better) on the file but this adds complexity.
^^  
^^  IMNSHO, learn the goddamn language and use it.  I once worked in a 
^^  department where some long-gone moron had written macros for making C 
^^  look like Pascal:
^^  
^^      #define begin {
^^      #define end   }
^^      #define or    ||
^^      #define not   !
^^  
^^  And so on.  And then these macros were used -- inconsistently -- 
^^  throughout much of the codebase.  Far from making the code more clear, it 
^^  obfuscated the hell out of everything.


And a single observation makes you conclude that macros can't
make the source clearer?

Do you also think that 'Switch.pm' shouldn't be included in the
main distribution? After all, that makes use of a source filter,
which is a source preprocessor just like cpp or m4.

What about modules in general? Should people stop using Socket,
and just learn the goddamn language and use socket() and
bind (), they way some god intended?


Abigail
-- 
perl -le 's[$,][join$,,(split$,,($!=85))[(q[0006143730380126152532042307].
          q[41342211132019313505])=~m[..]g]]e and y[yIbp][HJkP] and print'


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

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


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