[24426] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 6612 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed May 26 21:05:58 2004

Date: Wed, 26 May 2004 18:05:07 -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           Wed, 26 May 2004     Volume: 10 Number: 6612

Today's topics:
    Re: Am I a programmer or a scripter? <mike@mysurname.co.uk>
        backtick redirection question <cbohn@nospamming.rrinc.me.com>
    Re: create directory ... (krakle)
    Re: From one-liner to script: -i option? <bik.mido@tiscalinet.it>
        How to Pattern match the keys in a hash <ashutosh.jog@pdf.com>
    Re: How to Pattern match the keys in a hash <ashutosh.jog@pdf.com>
    Re: How to Pattern match the keys in a hash <postmaster@castleamber.com>
    Re: How to Pattern match the keys in a hash <1usa@llenroc.ude>
    Re: How to Pattern match the keys in a hash <jtc@shell.dimensional.com>
    Re: How to test @INC as seen by CGI script? <Joe.Smith@inwap.com>
    Re: Password scheme/Persistent session... <uri@stemsystems.com>
    Re: Perl vs PHP <bart.lateur@pandora.be>
        POK Flag Weirdness wth binary files (Wayne Myers)
    Re: Problem installing modules <tpsX@vr-web.de>
    Re: scoping problem <emschwar@pobox.com>
    Re: SQL::Abstract - generating q(like "%?%")? <gnari@simnet.is>
    Re: SQL::Abstract - generating q(like "%?%")? <dwall@fastmail.fm>
    Re: SQL::Abstract - generating q(like "%?%")? <uri@stemsystems.com>
    Re: Stat() function fails? <http://joecosby.com/code/mail.pl>
    Re: String search/match question (Kevin Potter)
    Re: String search/match question <ebohlman@omsdev.com>
    Re: Take three form variables and write to an "settings <emschwar@pobox.com>
        Templating system needs help <tore@aursand.no>
    Re: Templating system needs help <tore@aursand.no>
    Re: Templating system needs help <noreply@gunnar.cc>
    Re: Templating system needs help <ebohlman@omsdev.com>
    Re: Templating system needs help <tore@aursand.no>
    Re: Templating system needs help <noreply@gunnar.cc>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Thu, 27 May 2004 00:43:46 +0100
From: mike blamires <mike@mysurname.co.uk>
Subject: Re: Am I a programmer or a scripter?
Message-Id: <pan.2004.05.26.23.43.45.586892@mysurname.co.uk>

On Tue, 25 May 2004 12:09:20 +0000, Mothra scribbled furiously:

> Semantic question here:  what's the difference between a script and a 
> program?  At what stage can you call your Perl script a program for 
> example?  And at what stage can you call yourself a Perl programmer?
> 
> I encounter some snobbery from time to time with programmers telling me 
> that what I'm doing is "just scripting", whereas the stuff they write 
> (in Java, ColdFusion, C++ etc) is "real programming".
> 
> Well yes, I'm a lowly Sys Admin, and I've only been using Perl for about 
> 3 years, but I've written some big and complex "scripts" in Perl to 
> solve Sys Admin-type problems.
> 
> So is there a real difference, or is it just semantic snobbery?

Definitely semantic snobbery! Its all computer code at the end of the day,
whether you define it as a script and get it interpreted at runtime or
compile it into a program (if you wish to use such definitions). Perl does
have an image problem, mainly because it can look so messy at times and
there are a few dodgy looking solutions (probably mine ;) out there but
good Perl is almost art and does a stonking job, and there is plenty of
this around.

There are many many Perl programs/scripts out there that are way more
complicated than many 'programmers' works in Java, C/C++ etc...

</2p>
Mike 
http://www.blamires.co.uk/





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

Date: Wed, 26 May 2004 14:41:41 -0400
From: Chris Bohn <cbohn@nospamming.rrinc.me.com>
Subject: backtick redirection question
Message-Id: <c92oak$9j4$1@solaris.cc.vt.edu>

Using an extremely old version of perl:

-------------------
This is perl, version 5.003_07

Copyright 1987-1996, Larry Wall

         + suidperl security patch
         Win32 port Copyright (c) 1995-1996 Microsoft Corporation.
                 All rights reserved.
         Developed by ActiveWare Internet Corp., http://www.ActiveWare.com

Perl for Win32 Build 316 - Built 09:44:44 Mar 13 1998
-------------------

The following command would work:

cvs  -l  commit -m"package imports updated:
  softcon/rribase_dll (beta_102) -> (release_124)
" vers.dat 2>&1

executed via something like

$basic = qq#commit -m"package imports updated:\n @updatedPackages" vers.dat#;
$flags = " -l ";
$cmd = "cvs $flags $basic 2>&1";
@return = `$cmd`;

The @updatedPackages really isn't relevant; it can be replaced with static text,
and the problem still exists.

Under a current version of perl:

-------------------
This is perl, v5.8.2 built for MSWin32-x86-multi-thread
(with 25 registered patches, see perl -V for more detail)

Copyright 1987-2003, Larry Wall

Binary build 808 provided by ActiveState Corp. http://www.ActiveState.com
ActiveState is a division of Sophos.
Built Dec  9 2003 10:19:40
-------------------

the same perl code doesn't work.  Instead of executing

cvs  -l  commit -m"package imports updated:
  softcon/rribase_dll (beta_102) -> (release_124)
" vers.dat 2>&1

as it did with the old perl version, it executes the equivalent of

cvs  -l  commit -m"package imports updated:

It basically stops at the \n character.  This results in a different command 
running (instead of running just on one file, vers.dat, it recurses through all 
directories).

The problem is the
2>&1
piece to redirect stderr to stdout.  If I take just that piece of the command 
off, the correct and complete command is executed.  I can also remove the \n, 
and everything works, but I want the newline.  I want to be able to redirect 
stderr to stdout so that I can capture the output from cvs.  I realize I could 
capture them separately, but I want to capture it as I would have seen it on the 
screen (so output from stderr intermixed with output from stdout), so I think I 
need to do the redirection this way.  I don't know why this won't work with the 
current perl.  Any help or suggestions would be appreciated.

thanks
Chris


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

Date: 26 May 2004 13:44:51 -0700
From: krakle@visto.com (krakle)
Subject: Re: create directory ...
Message-Id: <237aaff8.0405261244.143de4a2@posting.google.com>

Jim Cochrane <jtc@shell.dimensional.com> wrote in message news:<slrncb9adh.8oh.jtc@shell.dimensional.com>...
> In article <slrncb8f26.mhn.mgjv@verbruggen.comdyn.com.au>, Martien Verbruggen wrote:
> > On 25 May 2004 18:15:48 -0600,
> > 	Jim Cochrane <jtc@shell.dimensional.com> wrote:
> >> In article <40b3c041$1@news.wineasy.se>, Rickard wrote:
>  
> >>> Are there any other command to use to create an directory?
> > 
> > [snippage]
> > 
> >> Creating directories is also quite easy - e.g., system("mkdir $dir"), or
> >> find the right module.
> > 
> > What's wrong with the builtin function mkdir?
> 
> Nothing.  I'm still working on mastering Perl and that one wasn't in my
> "database" yet. :-)

Well it's a simple command much like the one you were using..


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

Date: Wed, 26 May 2004 23:50:48 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: From one-liner to script: -i option?
Message-Id: <ki19b09f0vfp4dlqtl8voccbj76emnmc6k@4ax.com>

On Wed, 26 May 2004 10:25:46 +0000 (UTC), kj <socyl@987jk.com> wrote:

>>> I want to turn this "one-liner" (broken up for clarity)
>>> 
>>>   perl -i.bak -pe '                                   \
[snip]
>>        ($^I = shift) =~ s/^-i//;
[snip]
>Thanks!  That's just what I needed.

As a side note you may have found about $^I yourself with something
like

  perl -MO=Deparse -i.bak -pe ""


Michele
-- 
you'll see that it shouldn't be so. AND, the writting as usuall is
fantastic incompetent. To illustrate, i quote:
- Xah Lee trolling on clpmisc,
  "perl bug File::Basename and Perl's nature"


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

Date: Wed, 26 May 2004 16:57:27 -0700
From: Ash <ashutosh.jog@pdf.com>
Subject: How to Pattern match the keys in a hash
Message-Id: <10babmnof0q6mb4@corp.supernews.com>

Hi....

I have a hash which has machinename (as the key) and username (as the 
value). I want to do a pattern match on the machinenames (i.e. keys) in 
the hash to satisfy a certain naming convention.

How can I do a pattern match my hash keys (i.e. machinenames)and then 
print the key and value pair of newly patched machinenames and usernames 
to a file.

Any help is appreciated.

Thanks.



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

Date: Wed, 26 May 2004 17:01:57 -0700
From: Ash <ashutosh.jog@pdf.com>
Subject: Re: How to Pattern match the keys in a hash
Message-Id: <10babv5lp5ptn46@corp.supernews.com>

Many Typos there....

Here is what I meant:
I have a hash which has machinename (as the key) and username (as the
value). I want to do a pattern match on the machinenames (i.e. keys) in
the hash to satisfy a certain naming convention.

How can I do a pattern match on my hash keys (i.e. machinenames)and then
print the key and value pair of newly matched machinenames and usernames
to a file.

Any help is appreciated.

Thanks.


Ash wrote:

> Hi....
> 
> I have a hash which has machinename (as the key) and username (as the 
> value). I want to do a pattern match on the machinenames (i.e. keys) in 
> the hash to satisfy a certain naming convention.
> 
> How can I do a pattern match my hash keys (i.e. machinenames)and then 
> print the key and value pair of newly patched machinenames and usernames 
> to a file.
> 
> Any help is appreciated.
> 
> Thanks.
> 



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

Date: Wed, 26 May 2004 19:22:26 -0500
From: John Bokma <postmaster@castleamber.com>
Subject: Re: How to Pattern match the keys in a hash
Message-Id: <40b534c4$0$212$58c7af7e@news.kabelfoon.nl>

Ash wrote:

> Many Typos there....
> 
> Here is what I meant:
> I have a hash which has machinename (as the key) and username (as the
> value). I want to do a pattern match on the machinenames (i.e. keys) in
> the hash to satisfy a certain naming convention.
> 
> How can I do a pattern match on my hash keys (i.e. machinenames)and then
> print the key and value pair of newly matched machinenames and usernames
> to a file.
> 
> Any help is appreciated.
> 
> Thanks.
> 
> 
> Ash wrote:
> 
>> Hi....
>>
>> I have a hash which has machinename (as the key) and username (as the 
>> value). I want to do a pattern match on the machinenames (i.e. keys) 
>> in the hash to satisfy a certain naming convention.
>>
>> How can I do a pattern match my hash keys (i.e. machinenames)and then 
>> print the key and value pair of newly patched machinenames and 
>> usernames to a file.

use strict;
use warnings;

:
:

open my $fh, ">", $filename or
     die "Can't open '$filename' for writing: $!";

for my $key (keys %hash) {

	next unless $key =~ /insert a regexp here/;

	(print $fh "$key - $hash{$key}\n") or
		die "Can't write to '$filename': $!";
}
close $fh or die "Can't close '$filename' after writing: $!";

not tested, etc.

-- 
John                               MexIT: http://johnbokma.com/mexit/
                            personal page:       http://johnbokma.com/
    Experienced Perl programmer available:     http://castleamber.com/


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

Date: 27 May 2004 00:28:38 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude>
Subject: Re: How to Pattern match the keys in a hash
Message-Id: <Xns94F5D04E9EF45asu1cornelledu@132.236.56.8>

Ash <ashutosh.jog@pdf.com> wrote in
news:10babv5lp5ptn46@corp.supernews.com: 

> Many Typos there....
> 
> Here is what I meant:
> I have a hash which has machinename (as the key) and username (as the
> value). I want to do a pattern match on the machinenames (i.e. keys)
> in the hash to satisfy a certain naming convention.
> 
> How can I do a pattern match on my hash keys (i.e. machinenames)and
> then print the key and value pair of newly matched machinenames and
> usernames to a file.

perldoc -f grep
perldoc -f keys

#! perl

use strict;
use warnings;

my %hash = (
    'www.nytimes.com' => 'al',
    'www.cornell.edu' => 'bob',
    'www,vim.org'     => 'carl',
    'www.perl.com'    => 'dan',
    'www.nasa.gov'    => 'erik',
    'ftp.nasa.gov'    => 'ferdinand',
);

use Data::Dumper;
print Dumper { map { $_ => $hash{$_} } grep { /\.com$/ } keys %hash  };

-- 
A. Sinan Unur
1usa@llenroc.ude (reverse each component for email address)


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

Date: 26 May 2004 18:36:57 -0600
From: Jim Cochrane <jtc@shell.dimensional.com>
Subject: Re: How to Pattern match the keys in a hash
Message-Id: <slrncbae1e.6g9.jtc@shell.dimensional.com>

In article <10babv5lp5ptn46@corp.supernews.com>, Ash wrote:
> Many Typos there....
> 
> Here is what I meant:
> I have a hash which has machinename (as the key) and username (as the
> value). I want to do a pattern match on the machinenames (i.e. keys) in
> the hash to satisfy a certain naming convention.
> 
> How can I do a pattern match on my hash keys (i.e. machinenames)and then
> print the key and value pair of newly matched machinenames and usernames
> to a file.

Here's one way:

#!/usr/bin/perl

use strict;
use warnings;

# garbage test data:
my %h = (
'aardvark' => 1,
'bean' => 1,
'doom' => 1,
'grass' => 1,
'dog' => 1,
'log' => 1,
'cat' => 1,
);

my @matches = grep {
	# dummy example: match double letters or 'og'
	/(\w)\1/ or /og/
} keys %h;

# Now that you've got the matching keys, do something with them.
for my $k (@matches) {
	process($k, $h{$k});
}

sub process {
	my ($key, $value) = @_;
	# Here's where you would write them to a file.
	print "$key: $value\n";
}
> 
> Any help is appreciated.
> 
> Thanks.
> 
> 
> Ash wrote:
> 
>> Hi....
>> 
>> I have a hash which has machinename (as the key) and username (as the 
>> value). I want to do a pattern match on the machinenames (i.e. keys) in 
>> the hash to satisfy a certain naming convention.
>> 
>> How can I do a pattern match my hash keys (i.e. machinenames)and then 
>> print the key and value pair of newly patched machinenames and usernames 
>> to a file.
>> 
>> Any help is appreciated.
>> 
>> Thanks.
>> 
> 


-- 
Jim Cochrane; jtc@dimensional.com
[When responding by email, include the term non-spam in the subject line to
get through my spam filter.]


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

Date: Wed, 26 May 2004 18:09:24 GMT
From: Joe Smith <Joe.Smith@inwap.com>
Subject: Re: How to test @INC as seen by CGI script?
Message-Id: <n35tc.41$eY2.38@attbi_s02>

bill wrote:

> Is there a simple way to test the @INC seen by one's CGI script,

Yes, by writing a small CGI script that outputs the contents of
@INC after sending a "Content-type: text/plain\n" header.

> other than writing a CGI script that serves @INC out on a page,
> and visiting that page with a browser?

The way to tell what the server is providing to
CGI scripts is to actually run one.
	-Joe


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

Date: Wed, 26 May 2004 23:22:27 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Password scheme/Persistent session...
Message-Id: <x7k6yyixjg.fsf@mail.sysarch.com>

>>>>> "k" == krakle  <krakle@visto.com> writes:

  k> Uri Guttman <uri@stemsystems.com> wrote in message news:<x7isekks2a.fsf@mail.sysarch.com>...

  >> now go away already. you have stuck your nose into other threads

  k> I don't have to go away same as you don't have to read my posts.
  k> And, I reply in other threads simply because this IS Usenet. I
  k> thought replying was allowed? However, I am so wrong. Where are my
  k> morals..  where are they...

you lost them in the same place as your brains. you have no reason to be
helping others given how much you don't understand computers nor
perl. that hasn't stopped others and it won't stop you. but i won't let
you get away with your attitude here. better off if you just left now.

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org


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

Date: Wed, 26 May 2004 18:41:33 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: Perl vs PHP
Message-Id: <j4p9b01budnfnqgjlv66f1rovmuhbin0ms@4ax.com>

Charlton Wilbur wrote:

> There's one enormous namespace with dozens of
>inconsistently-named functions in it

"Dozens"? The last summary I found talked about over 3500 keywords in
PHP!

-- 
	Bart.


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

Date: 26 May 2004 16:42:52 -0700
From: waz@easynet.co.uk (Wayne Myers)
Subject: POK Flag Weirdness wth binary files
Message-Id: <9c68c0b5.0405261542.7511b821@posting.google.com>

Hi,

(Apologies for repost; this was originally sent to comp.lang.perl, which
turns out to be widely considered not to exist, whatever Google thinks)

This week I got bitten by something very strange. I was writing
code that needed to decrypt something encrypted using Rijndael
encryption, but when I read the key in, for some reason, the
Crypt::Rijndael module refused to accept the key as a valid
scalar string.

Digging around in the Crypt::Rijndael code and testing the string
with Devel::Peek revealed that no matter what method I used to
read the key (a stream of random binary digits), the internal POK
flag was not being set. Crypt::Rijndael explicitly tests the POK
flag before accepting a key: this is why that was failing.

However, I am not the first person to come across this problem,
and found an extremely strange workaround here:

http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&th=b088f2ae7045eb62&seekm=3CE
+0C77A.5030404%40hexaflux.com&frame=off

I have written a short script reproducing the problem (under Perl
5.6.1 and Perl 5.8.3) and demonstrating the same workaround, here:

http://www.waz.easynet.co.uk/pok/pok.pl.txt

Is it a bug in Perl, a bug in Crypt::Rijndael, or a bug in my
understanding of how to read in binary files?

I'd be grateful if anyone could help me shed light on the matter

Cheers etc.,

Wayne

--
Wayne Myers
http://www.waz.easynet.co.uk/


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

Date: Thu, 27 May 2004 02:07:39 +0200
From: Thomas Schweikle <tpsX@vr-web.de>
Subject: Re: Problem installing modules
Message-Id: <2hkqv4Fe44e2U1@uni-berlin.de>

Randy Kobes wrote:

> "Thomas Schweikle" <tpsX@vr-web.de> wrote in message
>    news:2h8v2bFa4ccrU1@uni-berlin.de...
>> J. Gleixner wrote:
>> > Can be found at http://theoryx5.uwinnipeg.ca/ppms/AppConfig.ppd
>>
>> OK! Thanks! This worked. But now I am missing four additional packages:
>>
>> CGI --- I need v2.93 the repository only has 2.81
>> Date::Format --- not found
>> Template --- not found
>> Chart::Base --- not found
>>
>> Where can I find them, or, how can I build my own working ppm-module
>> installable via ActivePerl PPM?
> 
> I've made up ppm packages of them, which you can install by adding
>    http://theoryx5.uwinnipeg.ca/cgi-bin/ppmserver?urn:/PPMServer58
> to your repository list within the ppm shell (for ActivePerl 8xx).

This doesn't work. ppm gives some fatal error. It is killed by the 
operating system afterwards. It is not possible to add the repository!


> After that,
>    ppm> install CGI.pm
>    ppm> install TimeDate
>    ppm> install Template-Toolkit
>    ppm> install Chart
> should install these, as well as their dependencies.
> 
> Alternatively, the PPM-Make distribution on CPAN (and also
> in the above repository) can make and install (via the ppm utility)
> CPAN distributions for which there isn't an available ppm package.
> This requires the 'nmake' utility (installing PPM-Make should offer
> to fetch it for you, if you don't have it), but for some packages
> (eg, GD, which is needed  by Chart) you'll also need a C compiler
> (VC++ 6, if you're using ActivePerl).

-- 
Thomas


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

Date: Wed, 26 May 2004 13:26:28 -0600
From: Eric Schwartz <emschwar@pobox.com>
Subject: Re: scoping problem
Message-Id: <etohdu356sb.fsf@fc.hp.com>

"ZMAN" <vze2mf4r@verizon.net> writes:
> I have a routine to generate an image map that I've written for our HTML
> wrapper that we use here at work.
> I for the life of me have not been able to clear out the array @t_imaprows.

You should define it as closely as possible to the scope in which it
is used, instead of using a global.

> Keeps appending with each pass.
> Any help would be greatle appreciated thanks in advance!

I'm going to comment on a number of other things as well.

> ########################################################
> my (@t_imaprows)=();

Don't define this here.

> %env_imap = (
>               'begin_fn' => ['*SKIP*', 'BeginImap'],
>               'end_fn' => ['*SKIP*', 'EndImap'],
>               'name' => '',
> );

%env_imap is not declared with 'our' or 'my'.  Why not?  Fix this.

> sub mcr_imaprow
> {
>    push(@t_imaprows, {@_});
>    return(undef);
> }

I don't think this is actually needed in this code.  Anyway, it's so
massively trivial, I can't see wasint a sub on it.  Also, your sub
naming style seems inconsistent-- why use lower_case_with_underscores
here and CamelCase later on?  Pick one and stick with it; it's easier
to grasp.

> sub BeginImap
> {
>   my($cmp) = &df::CurrentComponent();

Don't use & for function calls unless you know exactly what it does,
because 99% of the time, you don't want its side-effects.

>   my($tag, $pass, %env) = @_;
>   return(undef) if ($factory::pass_level < 1);

You probably just want 'return if...' here.

>   my($r) = '';

"my $r;" will do the same thing, but I don't mind explicit
initialization very much.

>   my $name  = $env{'name'};
>   $r .= "<map name=\"$name\">\n";


>   my($i);
>   for($i = 0; $i <= $#t_imaprows; $i++ )
>   {
>     my(%t_imaprow) = %{$t_imaprows[$i]};

This whole bit here can be replaced with:

    foreach my $t_imaprow (@t_imaprows) {

and then replace

>     my $coords  = $t_imaprow{'coords'};

with

      my $coords  = $t_imaprow->{'coords'};

C-style loops are generally frowned on in Perl programs, and they tend
to distract me from the purpose of the loop.  Since you're not using
$i anywhere else in the loop, just don't use that style of loop.

>     my $shape  = $t_imaprow{'shape'};
>     my $target  = $t_imaprow{'target'};
>     my($link) = $t_imaprow{'link'};

Fix all these as above.

>     my($l) = &make_link($link);

Don't use & here either.  Also, $l is a terrible name for a variable.
In some fonts, it's hard to tell the difference between $1 and $l.  In
point of fact, below I had to read your code a few times trying to
figure out where you'd used a regex before I realized it was $l, not
$1.  Remember, you write code for programmers, not for compilers.  It
won't run any faster if you call it $html_link instead of $l.

>     my($target_str);

This may be a style thing, but I don't define 'my' variables in a list
unless I'm initializing them with a list.  Also, you initialized $r to
'' above; if you're going to do it anywhere, at least be consistent--
either fix this definiton or the one for $r above.

>    if ($t_imaprow{'target'} eq '')
>    {
>         $target_str = '';
>    } else {
>         $target_str = "target=\"_$setimaprow{'target'}\"";

Use alternate quoting here to save backwhacks:

          $target_str = qq{target="_$setimaprow{'target'}"};

perldoc perlop for "Quote and Quote¡¾like Operators"

>    }
>      $r .= "<AREA coords=\"$coords\" href=$l shape=\"$shape\"
> $target_str>\n";
>    }
>
>   $r .= "</map>\n";
>
>   return($r);
> }

You never say at what point you want @t_imaprows cleared; right before
the return might be a good point; you could just put 

    @t_imaprows = ();

there.

Of course, the Right Answer(tm) in my mind is to pass in t_imaprows as
an arrayref and then clear it between calls to BeginImap.  The problem
is that you define it as a global variable and then don't show how you
use it outside this context, so we can't really tell you where an
appropriate place to clear it is.

If, instead, you define it as a local variable, then you can do
something like:

my @t_imaprows = GetImapRows();
BeginImap($tag, $pass, \%env, \@t_imaprows);
 ...
@t_imaprows = (); # empty the variable
 ...
EndImap()

> sub EndImap
> {
>               return(undef);
> }

I'll just second others' responses that you should just use 'return;'
here.

From what you've shown there doesn't seem to be a problem with just
assigning an empty list to @t_imaprows at any point you decide it
should be 'cleared', so maybe you should try to create a small (10 to
20 lines long) program that exhibits your problem that we can look at.
Posting your whole program is likely to cause brain hemorrages in most
posters here, and I usually find that in the process of trying to
create a small example that reproduces my problem, I can figure it out
on my own.

-=Eric
-- 
Come to think of it, there are already a million monkeys on a million
typewriters, and Usenet is NOTHING like Shakespeare.
		-- Blair Houghton.


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

Date: Wed, 26 May 2004 19:38:09 -0000
From: "gnari" <gnari@simnet.is>
Subject: Re: SQL::Abstract - generating q(like "%?%")?
Message-Id: <c92rjo$vro$1@news.simnet.is>

"David K. Wall" <dwall@fastmail.fm> wrote in message
news:Xns94F584FEF26D5dkwwashere@216.168.3.30...
> I've been playing with SQL::Abstract, but I can't seem to get it to
> generate the SQL I want.  I want the following, with wildcards around
> the placeholder:
>
>      WHERE ( DB_FIELD LIKE "%?%" )
>         OR ( DB_FIELD LIKE "%?%" )
>         OR ( DB_FIELD LIKE "%?%" )
>

I was under the impression thatbthis is illegal
placeholder syntax

have you actually managed to use a SQL statement
using such syntax? I think it would be practical to
verify that befor going any further.

gnari






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

Date: Wed, 26 May 2004 21:32:35 -0000
From: "David K. Wall" <dwall@fastmail.fm>
Subject: Re: SQL::Abstract - generating q(like "%?%")?
Message-Id: <Xns94F5B2745F117dkwwashere@216.168.3.30>

gnari <gnari@simnet.is> wrote:

> "David K. Wall" <dwall@fastmail.fm> wrote in message
> news:Xns94F584FEF26D5dkwwashere@216.168.3.30...
>> I've been playing with SQL::Abstract, but I can't seem to get it
>> to generate the SQL I want.  I want the following, with wildcards
>> around the placeholder:
>>
>>      WHERE ( DB_FIELD LIKE "%?%" )
>>         OR ( DB_FIELD LIKE "%?%" )
>>         OR ( DB_FIELD LIKE "%?%" )
>>
> 
> I was under the impression that this is illegal
> placeholder syntax
> 
> have you actually managed to use a SQL statement
> using such syntax? I think it would be practical to
> verify that before going any further.

Unfortunately I think you're right. Sigh. 

In my defense, I'm rewriting an old program that I first wrote as an 
exercise to learn DBI. It turned out to be useful and is still being 
used 4 years later -- but it's so convoluted that, even though I 
wrote it, it's hard to tell what it's doing, and I made a mistake 
reading it.

I started to post the code that caused my confusion, but it's so ugly 
that I cringe from looking at it. If MJD needs a program for a Red 
Flags article, he could always dissect this one to find various 
stupidities. Oh, the shame. :-)



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

Date: Thu, 27 May 2004 00:20:49 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: SQL::Abstract - generating q(like "%?%")?
Message-Id: <x7hdu2iuu6.fsf@mail.sysarch.com>

>>>>> "g" == gnari  <gnari@simnet.is> writes:

  g> "David K. Wall" <dwall@fastmail.fm> wrote in message
  g> news:Xns94F584FEF26D5dkwwashere@216.168.3.30...
  >> I've been playing with SQL::Abstract, but I can't seem to get it to
  >> generate the SQL I want.  I want the following, with wildcards around
  >> the placeholder:
  >> 
  >> WHERE ( DB_FIELD LIKE "%?%" )
  >> OR ( DB_FIELD LIKE "%?%" )
  >> OR ( DB_FIELD LIKE "%?%" )
  >> 

  g> I was under the impression thatbthis is illegal
  g> placeholder syntax

i think you can just have ? there and put the % wrapper in the data
before you send it to dbi. it really is just a string with %% around it
and it shouldn't be any different than other uses of placeholders. 

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org


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

Date: Wed, 26 May 2004 18:04:20 -0700
From: Joe Cosby <http://joecosby.com/code/mail.pl>
Subject: Re: Stat() function fails?
Message-Id: <0jfab05uf6gi8c8ufr0mp3rppgfrt91sq3@4ax.com>

I'm trying to write a script which converts a directory to html, so I
use

opendir()
readdir()
closedir()

to open a directory, read a list of file names, use the stat()
function on the file name to determine if it is a subdirectory, and
generate HTML links based on that.

I chdir to the directory I'm reading and this is succesful, and the
readdir() is pulling the correct list of file names, but when I try to
stat($filename) it fails.

There's no error message or anything, but when it executes

$st = stat($filename) or die "Can't stat file $filename\n";

it dies.

I am running Windows, I tried this on both a FAT32 directory and an
NTFS directory with the same result.

I tried CD'ing to the target directory before running the script, in
addiition to the chdir within the perl script, but no go.

Does anybody have any idea why this might be failing?

-- 
Joe Cosby
http://joecosby.com/ 
"Turn the pot upside down, the girl will still be like her mother"
- Syrian proverb
 


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

Date: 26 May 2004 14:33:39 -0700
From: krpotter@co.douglas.or.us (Kevin Potter)
Subject: Re: String search/match question
Message-Id: <64f69747.0405261333.56f6465@posting.google.com>

Matija Papec <perl@my-header.org> wrote in message news:<oqpsa0t6pcbrah8iqu2o7m6oh26rs6ido8@4ax.com>...
> X-Ftn-To: Kevin Potter 
> 
> krpotter@co.douglas.or.us (Kevin Potter) wrote:
> >How can I find the POSITION number of the first occurance of the
> >letter "x" that is not enclosed in the bracketed text (the one I want
> >is the one directly before the capital YZ).
> >
> >I've tried numerous versions indexing this and that, comparing this to
> >the positions of the first and successive brackets, but cannot come up
> >with a realiable method.
> >
> >Any thoughts, or pointers would be really appreciated.  Maybe a fancy
> >regex would be able to do this?
> 
> It's not fancy but it should be reliable. :)
> 
> my $s =
> "abcdefg[extra]hijklmn[texas]opqrstuvwxYZabc[tex]defghijklmnopqrstuvwxyz";
> 
> s/(\[.+?\])/' ' x length $1/ge, $_ = index $_,'x' for my $pos = $s;
> print "$pos\n";

Matija's regex works *almost* perfectly for my needs, but I've just
discovered that the data enclosed in the [...] will also contain
unprintable ascii characters [00-FF].  In testing the regex above, it
doesn't seem to work if there is a linefeed (\x0a) contained within
the brackets,,, the regex doesn't seem to see the [...] block
correctly to perform the space substitution for this block of data.

Given example string:

my $s = "abc[extra\xa ]x";

The regex returns 5.  This is the first occurance of X, but I need it
to ignore the characters in the [...], no matter what characters are
contained in there.  Is there a way to have it ignore the \x0a?

Thanks again.


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

Date: 26 May 2004 23:06:30 GMT
From: Eric Bohlman <ebohlman@omsdev.com>
Subject: Re: String search/match question
Message-Id: <Xns94F5B8E40109Aebohlmanomsdevcom@130.133.1.4>

krpotter@co.douglas.or.us (Kevin Potter) wrote in
news:64f69747.0405261333.56f6465@posting.google.com: 

>> s/(\[.+?\])/' ' x length $1/ge, $_ = index $_,'x' for my $pos = $s;
>> print "$pos\n";
> 
> Matija's regex works *almost* perfectly for my needs, but I've just
> discovered that the data enclosed in the [...] will also contain
> unprintable ascii characters [00-FF].  In testing the regex above, it
> doesn't seem to work if there is a linefeed (\x0a) contained within
> the brackets,,, the regex doesn't seem to see the [...] block
> correctly to perform the space substitution for this block of data.

By default, '.' matches any character *except* a newline (represented on 
most systems as \x0a).  perldoc perlre will show you how to override that 
behavior.


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

Date: Wed, 26 May 2004 13:47:58 -0600
From: Eric Schwartz <emschwar@pobox.com>
Subject: Re: Take three form variables and write to an "settings-file"
Message-Id: <etod64r55sh.fsf@fc.hp.com>

Rickard <hanssonrickard@hotmail.com> writes:
> Well actually, i have never done PERL CGI scripting.

The CGI.pm docs are nice, but there is also a nice book on the
subject, "CGI Programming with Perl", that you might find helpful.  

Regardless, I recommend you read through the CGI.pm docs completely
before starting to use it, as there are many code samples that may be
helpful.

> But thanks for the link, i will start reading directly.

No-one has mentioned this yet, but if you will have more than one
person running this CGI program at once (very likely, in a web
environment), and they all modify the same file, then you will want to
lock the file after opening it.  See 'perldoc -f flock' for more
information.  Read that one carefully, as well.

-=Eric
-- 
Come to think of it, there are already a million monkeys on a million
typewriters, and Usenet is NOTHING like Shakespeare.
		-- Blair Houghton.


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

Date: Wed, 26 May 2004 21:39:44 +0200
From: Tore Aursand <tore@aursand.no>
Subject: Templating system needs help
Message-Id: <pan.2004.05.26.19.39.43.234203@aursand.no>

Hi!

I need to develop a templating system.  I _cannot_ use on of the
templating systems found on CPAN as this utility will be used on
"proprietary" (and already existing) template files.  So - please don't
tell me to go to CPAN; I already know of it, and I know the templating
systems found there.  Thanks.

The problem is lists.  And lists in lists (in lists...).  I've decided to
have the data structure for my lists like this:

  $VAR1 = {
      '__ROOT__' => {
          'children' => [
              {
                  'name'     => 'WEEK_LIST',
                  'columns'  => [ 'NR' ],
                  'values'   => [
                      [ '1' ],
                      [ '2' ]
                  ],
                  'children' => [
                      {
                          'name'    => 'DAY_LIST',
                          'columns' => [ 'DAY' ],
                          'values'  => [
                              [ '1' ],
                              [ '2' ],
                              [ '3' ],
                              [ '4' ],
                              [ '5' ],
                              [ '6' ],
                              [ '7' ],
                          ]
                      },
                      {
                          'name'    => 'DAY_LIST',
                          'columns' => [ 'DAY' ],
                          'values'  => [
                              [ '8' ],
                              [ '9' ],
                              [ '10' ],
                              [ '11' ],
                              [ '12' ],
                              [ '13' ],
                              [ '14' ],
                          ]
                      }
                  ]
              }
          ]
      }
  }

This is from Data::Dumper, though I had to reformat it a bit.  I guess you
all get the point.  The template for this data looks like this (shortened):

  <%% WEEK_LIST BEGIN %%>
  <%% NR %%>:<%% DAY_LIST BEGIN %%> <%% DAY %%><%% DAY_LIST END %%>
  <%% WEEK_LIST END %%>

Thus - in the end - the following output should be created:

  1: 1 2 3 4 5 6 7
  2: 8 9 10 11 12 13 14

Now.  I have absolutely _no_ idea on how to create this list (and take
height for the fact that there can be unlimited nested lists).  Anyone
feel like they have the guts to try? :)

Thanks!


-- 
Tore Aursand <tore@aursand.no>
"What we do is never understood, but only praised and blamed."
 (Friedrich Nietzsche)


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

Date: Wed, 26 May 2004 22:01:06 +0200
From: Tore Aursand <tore@aursand.no>
Subject: Re: Templating system needs help
Message-Id: <pan.2004.05.26.20.01.06.21286@aursand.no>

On Wed, 26 May 2004 21:39:44 +0200, Tore Aursand wrote:
> [...]
> Now.  I have absolutely _no_ idea on how to create this list (and take
> height for the fact that there can be unlimited nested lists).  Anyone
> feel like they have the guts to try? :)

I could of course post some of the ideas I've been playing with.  The
module is OO, and everything gets "wrapped up" when 'build_template' is
called;

  sub build_template {
      my $self = shift;

      # Lists
      $self->_generate_lists();

      # Replacements
      while ( my ($key, $value) = each %{$self->{'_replace'}} ) {
          # ...
      }

      # Substitutions
      while ( my ($key, $value) = each %{$self->{'_subst'}} ) {
          # ...
      }
  }

  sub _generate_lists {
      my $self     = shift;
      my $node     = shift || $self->{'_lists'}->{'__ROOT__'};
      my $template = shift || $self->{'_template'};

      # Now what? :)
  }



-- 
Tore Aursand <tore@aursand.no>
"First get your facts; then you can distort them at your leisure."
 (Mark Twain)


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

Date: Wed, 26 May 2004 23:17:29 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Templating system needs help
Message-Id: <2hkfveFdnm6jU1@uni-berlin.de>

Tore Aursand wrote:
> I need to develop a templating system.  I _cannot_ use on of the 
> templating systems found on CPAN as this utility will be used on 
> "proprietary" (and already existing) template files.  So - please
> don't tell me to go to CPAN; I already know of it, and I know the
> templating systems found there.  Thanks.

Err.. Go to CPAN. :)

Actually, I'm not sure I understand why you can't. Most modules there
are provided under the artistic license, which I thought does not
prevent you from using the modules with propriety code.

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



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

Date: 26 May 2004 22:58:42 GMT
From: Eric Bohlman <ebohlman@omsdev.com>
Subject: Re: Templating system needs help
Message-Id: <Xns94F5B791B15D4ebohlmanomsdevcom@130.133.1.4>

Gunnar Hjalmarsson <noreply@gunnar.cc> wrote in news:2hkfveFdnm6jU1@uni-
berlin.de:

> Tore Aursand wrote:
>> I need to develop a templating system.  I _cannot_ use on of the 
>> templating systems found on CPAN as this utility will be used on 
>> "proprietary" (and already existing) template files.  So - please
>> don't tell me to go to CPAN; I already know of it, and I know the
>> templating systems found there.  Thanks.
> 
> Err.. Go to CPAN. :)
> 
> Actually, I'm not sure I understand why you can't. Most modules there
> are provided under the artistic license, which I thought does not
> prevent you from using the modules with propriety code.

I think he was trying to say that the template files already exist, and 
were written in a novel template language.  Unless I'm badly mistaken, each 
of the several million (OK, I exaggerate) templating modules available on 
CPAN has its own template language, and none of them will be compatible 
with the one used by Tore's files.



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

Date: Thu, 27 May 2004 01:19:06 +0200
From: Tore Aursand <tore@aursand.no>
Subject: Re: Templating system needs help
Message-Id: <pan.2004.05.26.23.14.44.288684@aursand.no>

On Wed, 26 May 2004 22:58:42 +0000, Eric Bohlman wrote:
>> Actually, I'm not sure I understand why you can't. Most modules there
>> are provided under the artistic license, which I thought does not
>> prevent you from using the modules with propriety code.

> I think he was trying to say that the template files already exist, and
> were written in a novel template language.

That's correct.  I can't use any of them - AFAIK.  And - still AFAIK -
none of them handles lists (in lists) the way I'm looking for, so I can't
"borrow" some of the existing modules' code, either.


-- 
Tore Aursand <tore@aursand.no>
"I know not with what weapons World War 3 will be fought, but World War
 4 will be fought with sticks and stones." (Albert Einstein)


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

Date: Thu, 27 May 2004 01:45:05 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Templating system needs help
Message-Id: <2hkokaFdpl8hU1@uni-berlin.de>

Tore Aursand wrote:
> On Wed, 26 May 2004 22:58:42 +0000, Eric Bohlman wrote:
>> I think he was trying to say that the template files already
>> exist, and were written in a novel template language.
> 
> That's correct.  I can't use any of them - AFAIK.  And - still
> AFAIK - none of them handles lists (in lists) the way I'm looking
> for, so I can't "borrow" some of the existing modules' code,
> either.

Okay. Your mentioning of the word "proprietary" gave the impression
that you preclude the use of CPAN for licensing reasons, and I just
wanted to say that that's not necessary - AFAIK. ;-)

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



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

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.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

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


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