[19964] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2159 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Nov 19 21:05:31 2001

Date: Mon, 19 Nov 2001 18:05:07 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <1006221906-v10-i2159@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Mon, 19 Nov 2001     Volume: 10 Number: 2159

Today's topics:
    Re: a good perl editor - know one?? <MichaelRunningWolf@att.net>
        Anyone Read  "Programming the Perl DBI" lately? <aliciausausa@yahoo.com>
    Re: Anyone Read  "Programming the Perl DBI" lately? <jeff@vpservices.com>
    Re: CGI links with a single argument <goldbb2@earthlink.net>
    Re: Fast Portable Logical Shift Right in Perl ? <MichaelRunningWolf@att.net>
        How can i load my config setting from a file ? <robert_loui@yahoo.com>
        Installation error - perl 5.6.1 - Carp.pm <tregan@monger.net>
        Optimizing my Sub Coding <whataman@home.com>
    Re: Picture aspect ratio (Randal L. Schwartz)
    Re: Proc::Daemon-question <vze33mmh@verizon.net>
    Re: Sourcing with a twist of Parsing ? <goldbb2@earthlink.net>
        Traversing directories <rafalk@home.com>
    Re: Traversing directories (Tad McClellan)
    Re: Traversing directories <vze33mmh@verizon.net>
    Re: win32::netadmin problem <kgouldsk@altavista.com>
        { in s///; ? <henders@math.rice.edu>
    Re: { in s///; ? <mbudash@sonic.net>
    Re: { in s///; ? <vze33mmh@verizon.net>
    Re: { in s///; ? (Tad McClellan)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Tue, 20 Nov 2001 01:13:58 GMT
From: Michael Scott Running Wolf <MichaelRunningWolf@att.net>
Subject: Re: a good perl editor - know one??
Message-Id: <wk3d3a1bxk.fsf@att.net>

Paul Spitalny <pauls@cascadelinear.com> writes:

> Hi,
> Anyone know of a text editor (For a windows platform) specifically
> targeted to PERL that has features like color coding of key works and
> other nice development aids?

gnu emacs.  It's the only answer to your editing needs.  I've used it
and loved it for over a decade now.  It's got a great cperl-mode.  And
it's got lots of room to grow.  I'm always (pleasantly) surprised when
I need it to grow with me, and it does.  I can't say that about much
else in this world.

Go to emacs as soon as you can.  As you need more, it will be there.
You will always be glad that you made the initial effort to learn it.

Start with the FAQ, then chase the link to distributions.

http://www.gnu.org/software/emacs/windows/ntemacs.html 

I just got the latest (21.1) version the other day.  It jumped right
out of the box onto my laptop.  Glory, glory!  Took 2 commands to do
it.

Enjoy.

          P.S.  Did I mention that it has a great perl mode?

-- 
Michael Running Wolf

  MichaelRunningWolf@att.net  --  All mammals learn by playing.	


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

Date: Mon, 19 Nov 2001 20:26:43 -0500
From: "Alicia Hirsch" <aliciausausa@yahoo.com>
Subject: Anyone Read  "Programming the Perl DBI" lately?
Message-Id: <9tcann$ff8$1@slb7.atl.mindspring.net>

I am new to Perl and just installed ActiveState and the DBI module. I am
eager to learn SQL and relational databases. Perhaps I have bought the wrong
book.

The book explained quite well in theory but does not really present much
practical codes and examples. Consequently, I hope someone here might have
read the book and would kindly show me how DBI support multiple tables in a
single SQL statement as shown on page 66 below?

SELECT mega.name, mega.description, st.site_type, med.url, med.description

FROM mega, med, st

WHERE mega.id = med.megaliths_id
AND mega.site_type_id = st.id

I created 3 flat-file databases (mega, med, st), which fields are separated
from one another by space in my hard drive. How should I "DBI->connect" the
files? I want to practice learning the SQL statements above, could someone
kindly help this newbie? Thanks in advance for your time.




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

Date: Mon, 19 Nov 2001 17:19:47 -0800
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: Anyone Read  "Programming the Perl DBI" lately?
Message-Id: <3BF9AFB3.CAB09DD5@vpservices.com>

Alicia Hirsch wrote:
> 
> kindly show me how DBI support multiple tables in a
> single SQL statement
> ...
> I created 3 flat-file databases

You can't currently do joins (which is what that is called) with
flat-files.  In about two weeks you will be able to when I release the
new SQL::Statement module that supports joins with flat files.  If you
can't wait until then, email me and I'll send you an advance copy.

-- 
Jeff



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

Date: Mon, 19 Nov 2001 19:35:23 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: CGI links with a single argument
Message-Id: <3BF9A54B.897893A9@earthlink.net>

Steven wrote:
> 
> I was wondering if there is a way to use a link with a single argument
> like
> 
> <a href="http://www.anywhere.com/cgi-bin/some.cgi?argument">xxx</a>
> 
> without using CGI.pm.
> 
> I have got this working got this working using CGI.pm using
> ('keywords')

If the text after the ? does not contain an equal sign, then it is
assumed to be an ISINDEX query, rather than a CGI query.

[remember that CGI means common gateway interface -- isindex is a
different interface]

Instead of putting the query in QUERY_STRING in the environment, it
instead puts it in the first commandline argument, which is $ARGV[0] in
perl.

> but I can't find a good way to build tables dynamically
> with CGI.pm, which is what I need to do with my script.

CGI.pm is an ok general purpose thing for writing cgi programs, but
because it tries to be all things for all people, it can't really be
said to be the best there is at everything.  You *can* generate tables
dynamically with it, but it might not be the best choice.

Here's an example of creating a table with CGI.pm, assuming $sth is a
DBI statement handle which has been prepared and executed.

use CGI qw(*table);
print begin_table;
print Tr th $sth->{NAME};
print Tr td $row while( my $row = $sth->fetchrow_arrayref );
print end_table;

If you don't import "*table" from CGI, then you will only have available
to you the table() method, which creates the start of the table
concatenated whatever it's arguments are, then the end of the table,
which makes it awkward to create the table contents with seperate
statements.  Eg, to do something like the above code, with table()
instead of begin_table() and end_table(), it would look like this:

use CGI;
print table Tr [
    th($sth->{NAME}),
    map td $_, @{$sth->fetchall_arrayref}
];


There are a number of dynamic html generation modules which would
probably be better for your purposes [whatever they are] than CGI.pm.

You might even prefer to print out html directly.

Search on CPAN to find out what suits your needs best.

> The single argument would point to a file, my script would open that
> file and build a table out of what it data it finds there.

What do you do if they enter /etc/passwd as the file?

Might I suggest that you be very very careful about what files you allow
the user to see?

-- 
Klein bottle for rent - inquire within.


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

Date: Tue, 20 Nov 2001 01:51:40 GMT
From: Michael Scott Running Wolf <MichaelRunningWolf@att.net>
Subject: Re: Fast Portable Logical Shift Right in Perl ?
Message-Id: <wky9l2yzte.fsf@att.net>

"Mark Shelor" <shelorm@earthlink.net> writes:

>     $x = ($x >> 1) & 0x7fffffff if ($n--);

> isn't portable since it assumes a 32-bit integer. 

Instead of assuming 32 bits, use the complement operator to derive the
pattern you want.  Something like this could work independent of how
many bits there are:

    ~-1

If this doesn't work (and I'm rusty on my 1's complement and
signed-integer bit patterns), I know how to get the one that does.
The following snippet will get the number to use (if -1 isn't the
right one).  It assumes 32-bits, but then gives you the number that
you can hard-code in the future.  It will then work on N-bit systems.

$num_to_complement = ~0x7fff_ffff;

Then you can write:

    $x = ($x >> 1) & ~$num_to_complement if ($n--);


-- 
Michael Running Wolf

  MichaelRunningWolf@att.net  --  All mammals learn by playing.	


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

Date: Mon, 19 Nov 2001 16:55:44 +0100
From: "Robert" <robert_loui@yahoo.com>
Subject: How can i load my config setting from a file ?
Message-Id: <9tb8pf$ok5$1@newstoo.ericsson.se>

Hi all

I have a program calling many files, and depended on some files located on
different directories.  So at the beginig of my program i have some
configuration setting like :

my $MyFiles =$ENV{HOME}."/MyDir";
my @search_path =("/opt/etc", $ENV{HOME}, '.');
push @INC, "$ENV{HOME}/WORK/DATA";

I want to put all these declarations in a separate file and load it when I
am starting my program. But I don't know how can I load these configuration
file. For example how can load these configuration if they were declared in
a file called "myconfig.cfg".

Thanks allot Robert







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

Date: Mon, 19 Nov 2001 19:55:54 -0500
From: tom regan <tregan@monger.net>
Subject: Installation error - perl 5.6.1 - Carp.pm
Message-Id: <3BF9AA1A.709E796D@monger.net>

I'm getting an error when I try to "make install" during a perl
installation on a Linux box.

I'm using the Mandrake distribution, with a 2.2.15 kernel.  I am
installing the 5.6.1 source code from perl.com.  After reading the
INSTALL and README files, and following their instructions, I got the
following error in the STDOUT when running "make install."  This error
occurs after the installation of the perl scripts (e.g. a2p, s2p,
etc...)  The line on STDOUT immediately before the error is "./perl
installman".

The error message is
"Can't locate Carp/Heavy.pm in @INC (@INC contains: lib) at lib/Carp.pm
line 109."
make[1] : *** [install.man] Error 2
make: *** [install] Error 2

Line 109 from Carp.pm is
"{ local $@ ; require Carp::Heavy ; } # XXX fix require to not clear
$@?"

I put the source code into the directory "/usr/src/perl-5.6.1" and ran
all the config and make commands from that directory.  Lib is a
subdirectory of perl-5.6.1.  The files lib/Carp.pm, and
lib/Carp/Heavy.pm both exist and are readably by root.  I performed the
install as root.

I'm clueless when it comes to make.  I know my way around Unix and
Linux, but I've never compile software before.  So I'm not sure if this
is a problem with the make command or the Carp.pm file.

I'm not familiar with Carp::, but it appears to be a routine that helps
with debugging run-time errors.  I don't know if it's being loaded "in
case" or if an error has occurred.  In the latter case, the the cause of
the problem is not in Case::, although I'd still need to fix it or not
use it.

If the problem is based in the Carp.pm code, can I (and should I) have
make skip this module?  How?

Any help (including pointers to other sites) will be appreciated.

-------------->tom





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

Date: Tue, 20 Nov 2001 00:32:34 GMT
From: "What A Man !" <whataman@home.com>
Subject: Optimizing my Sub Coding
Message-Id: <3BF9A4BD.335EC733@home.com>

After reviewing an old thread from Google, I modified my code below to a
combination of what I deciphered from 2 different posters here.
The below coding doesn't give any errors, but I have a feeling the code
below still needs work; or can be done better. I'd also like to umask
all the files and directories under $tmpdir to 0027; but am not quite
sure where to put that. Any suggestions on this mess below are
appreciated.

### fix files and directories under $tmpdir 
find \&fix_tempfiles, $tmpdir;

   sub fix_tempfiles {
   my $file = $_; 

   ### now do the work
   &del_htaccess($file);
   &bad_chars($file);
   &fix_exes($file);
   &fix_perms($file);
   &chg_space;
   &chg_slash;
}


        ### Delete any file with .htaccess or .htpasswd name
        sub del_htaccess {
        my ($file) = @_;
        my $newname = $file;
        return unless $newname =~ m/^(\.htaccess|\.htpasswd)$/i;
        unlink($newname) or die "Could Not Unlink $newname $!\n"; 
        }

        # Change "bad" characters found in file or directory name
        sub bad_chars { 
        my $new = $_;
        return unless $new =~ s/[^\w.-]//g;   
        if ( -e $new ) { return; }
        else {
        rename $_, $new or print "Could not delete chars from '$_':
$!\n";
          }
        }
        
       ### Change all .exe files to .exe.txt
       sub fix_exes {
       my $file = @_;
       if ($file =~ /\.exe$/) { $_ =~ s/\.exe$/.exe.txt/ig;
          }
       }

       ### Change all file permissions to 644 for files
       ### and change all directories dirs to 755
       sub fix_perms {
       my ($file) = @_;
       if (-f $file ) { 
         chmod 0644, $file
              or die "couldnt chmod $file to 0644: $!\n"
       } 
       else { chmod 0775, $file
              or die "Couldnt chmod $file directory to 0775: $!\n";
          }
        }

       ### Change all spaces to underlines in files and directories
       sub chg_space {
       my ($file) = @_;
       my $new = ( $_ =~ s/ /\_/ );
       rename $_, $new or print "Could not change spaces 
            to underlines: $!\n";
        }
 
       ### Change all %20 to slashes
       sub slash {
       my ($file) = @_;
       my $new = ( $_ =~ s/\%20/\// );
       rename $_, $new or print "Could not change %20 to slash: $!\n";
        }
         

Regards,
Dennis


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

Date: 19 Nov 2001 16:55:10 -0800
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Picture aspect ratio
Message-Id: <m1ofly5ki9.fsf@halfdome.holdit.com>

>>>>> "Emil" == Emil Horowitz <mail@nexo.de> writes:

Emil> Hi,
Emil> hopelfully I will be able to describe my problem in a comprehensible way:

Emil> My task is to generate small thumbnails of pictures uploaded by the users
Emil> and fit them into a dynamically generated HTML page. The picture formates
Emil> are not fixed, and therefore I do not know the aspect ratio. To generate
Emil> undistorted thumbnails, I would have to find out the height and width of the
Emil> original picture. Is there a way to achieve this with Perl?


This message was multi-posted to alt.perl as well.

Please don't multi-post.  Use cross-posting if you must.
Otherwise, redundant answers waste the answerer's time.

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!


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

Date: Tue, 20 Nov 2001 00:14:42 GMT
From: sysop <vze33mmh@verizon.net>
Subject: Re: Proc::Daemon-question
Message-Id: <pan.2001.11.19.19.17.33.642088.1336@verizon.net>

On Mon, 19 Nov 2001 09:35:03 -0500, felix wrote:

> what is the easiest way to get the pid of my child process? I use a
> simple script running as daemon with Proc::Daemon like
> 
> #!/usr/bin/perl
> use Proc::Daemon;
> Proc::Daemon::Init;
> $file = '/tmp/dummy.log';
> while (1){
>   $num++;
>   sleep 1;
>   open (FILE, ">>$file");
>     print FILE $num, \n";
>   close;
> }

Your pid is $$ in perl.  Try:
#!/usr/bin/perl
use Proc::Daemon;
use Sys::Syslog;
Proc::Daemon::Init;
$file = '/tmp/dummy.log';
open(PID, ">/var/run/daemonname.pid") or &handle_it($!); 
print PID $$;
close PID;
while (1){
  $num++;
  sleep 1;
  open (FILE, ">>$file");
    print FILE $num, "\n";
  close;
}
#We can't just die with an error message, noone will be able to see it.
sub handle_it {
	my $msg = shift;
	openlog("daemonname", "pid", "local1"); 
	syslog("error", "Can't open PID	file.  Reason:$msg\n\n"); 
	closelog;
	die;
}


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

Date: Mon, 19 Nov 2001 18:53:58 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Sourcing with a twist of Parsing ?
Message-Id: <3BF99B96.62CBFA14@earthlink.net>

Tad McClellan wrote:
> 
> Benjamin Goldberg <goldbb2@earthlink.net> wrote:
> 
> >my %acceptable_imports = list of things it's ok to get from the
> >script.
>     ^
>     ^
>     ^ I'm sure Benjamin meant @acceptable_imports there instead.

Yup, that was a typo.

> >my %acceptable_imports = map { $_ => 1 } @acceptable_imports;

-- 
Klein bottle for rent - inquire within.


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

Date: Tue, 20 Nov 2001 00:10:31 GMT
From: Rafal Konopka <rafalk@home.com>
Subject: Traversing directories
Message-Id: <3BF9A1F6.4A9AD309@home.com>

I need a listing of all the *.htm files in an given directory and all
its subdirectories.  I tried using the example in the Camel book on p.
56 but it only reports the first two levels and only on the first
subfolder it encounters.

My OS is WINNT4.  Any pointers would be greatly appreciated.

Rafal
-- 
=================
Rafal S. Konopka
<rafalk@home.com>
=================


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

Date: Tue, 20 Nov 2001 00:35:44 GMT
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Traversing directories
Message-Id: <slrn9vj6l0.hm5.tadmc@tadmc26.august.net>

Rafal Konopka <rafalk@home.com> wrote:
>I need a listing of all the *.htm files in an given directory and all
>its subdirectories.  


   use File::Find;


>I tried using the example in the Camel book on p.
>56 but it only reports the first two levels and only on the first
>subfolder it encounters.


Huh? There is no code at all on p56 of the Camel book. There is
some code on p56 in the older second edition of the Camel, but
it does not do directory searching. I do not have a 1st edition
ready to hand. What edition of the Camel are you referring to?

Why not just show us the code that you used?

(then throw it away and use File::Find instead :-)


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


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

Date: Tue, 20 Nov 2001 02:00:00 GMT
From: sysop <vze33mmh@verizon.net>
Subject: Re: Traversing directories
Message-Id: <pan.2001.11.19.21.07.34.796443.1336@verizon.net>

On Mon, 19 Nov 2001 19:10:31 -0500, Rafal Konopka wrote:

> I need a listing of all the *.htm files in an given directory and all
> its subdirectories.  I tried using the example in the Camel book on p.
> 56 but it only reports the first two levels and only on the first
> subfolder it encounters.


This script will do what you want.  I use unix, so I made the assumption
(which could be wrong) that the correct way to refer to a path is with
"\\", not "/" (eg, "./usr/bin/perl" in unix is written in perl as
".\\usr\\bin\\perl".  If I'm wrong you need to replace my \\ with the
proper delimiter before this script would work.
$|=1;

$dir = ".";
&recursive_directory_traversal($dir);
print "\n";

sub recursive_directory_traversal {
   my $parent = shift;
   my (@children, @trim, $offset);
   $offset = 0;

   opendir(PARENT, $parent) or die "Can't open $parent\nReason:$!\n\n";
   @children = grep(!/^[\.]{1,2}$/, readdir PARENT);

   foreach my $index (0..$#children){
      if (-d "$parent\\".$children[$index]){
	recursive_directory_traversal("$parent\\".$children[$index]);
	push(@trim, $index);
      }
   }
   foreach my $index (@trim){
      splice(@children, $index - $offset++, 1);
   }
   print "$parent :\n" . join("\n", @children) . "\n";
}

 
> My OS is WINNT4.  Any pointers would be greatly appreciated.

That's a shame because if you were using unix you'd just: 
find /path/to/html/files/top/directory -name \*.htm -print


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

Date: Tue, 20 Nov 2001 01:55:27 GMT
From: "Kevin Gould" <kgouldsk@altavista.com>
Subject: Re: win32::netadmin problem
Message-Id: <jKiK7.1182728$si5.45367123@typhoon.kc.rr.com>

Try Win32::NetAdmin::UserSetAttributes or Win32::Lanman:NetUserSetInfo


"Mr. Chow Wing Siu" <wschow@Comp.HKBU.Edu.HK> wrote in message
news:9t4g2k$le0$1@net44p.hkbu.edu.hk...
> Hi,
>
> I would like to know if win32::* in latest activeperl can help
> to change the home dir (connect drive to H:), Full name of user,
> or more options.
>
> Thanks.
>
> --
> Johnson Chow




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

Date: 19 Nov 2001 17:25:10 -0600
From: Dale Henderson <henders@math.rice.edu>
Subject: { in s///; ?
Message-Id: <qkkpu6efind.fsf@math.rice.edu>


I was trying to quote '{' and '}' and ran across this compile error

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

s/{/@{/g;
s/}/@}/g;


perl buggy.pl gives:
Missing right curly or square bracket at buggy.pl line 8, within
string
syntax error at buggy.pl line 8, at EOF
Execution of buggy.pl aborted due to compilation errors.


but if I change the code to 

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

my ($openbrace,$closebrace,$openrepl,$closerepl)=( '{','}','@{','@}');

s/$openbrace/$openrepl/g;
s/$closebrace/$closerepl/g;             

it works fine.

I thought that the s///; construct quoted its arguments and the {
should have no effect.


oh before I forget

perl -v

This is perl, v5.6.1 built for i386-linux

Thanks for any explainations.



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

Date: Mon, 19 Nov 2001 23:43:56 GMT
From: Michael Budash <mbudash@sonic.net>
Subject: Re: { in s///; ?
Message-Id: <mbudash-AB8829.15435619112001@news.sonic.net>

In article <qkkpu6efind.fsf@math.rice.edu>, Dale Henderson 
<henders@math.rice.edu> wrote:

> I was trying to quote '{' and '}' and ran across this compile error
> 
> buggy.pl:
> #!/usr/bin/perl -w
> use strict;
> 
> s/{/@{/g;
> s/}/@}/g;
> 
> 
> perl buggy.pl gives:
> Missing right curly or square bracket at buggy.pl line 8, within
> string
> syntax error at buggy.pl line 8, at EOF
> Execution of buggy.pl aborted due to compilation errors.
> 
> but if I change the code to 
> 
> works.pl:
> #!/usr/bin/perl -w
> use strict;
> 
> my ($openbrace,$closebrace,$openrepl,$closerepl)=( '{','}','@{','@}');
> 
> s/$openbrace/$openrepl/g;
> s/$closebrace/$closerepl/g;             
> 
> it works fine.
> 
> I thought that the s///; construct quoted its arguments and the {
> should have no effect.
> 
> oh before I forget
> 
> perl -v
> 
> This is perl, v5.6.1 built for i386-linux

it's the unescaped @ in the first replacement expression... use this:

s/{/\@{/g;

hth-
-- 
Michael Budash ~~~~~~~~~~ mbudash@sonic.net


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

Date: Mon, 19 Nov 2001 23:48:22 GMT
From: sysop <vze33mmh@verizon.net>
Subject: Re: { in s///; ?
Message-Id: <pan.2001.11.19.19.00.59.395770.1336@verizon.net>

On Mon, 19 Nov 2001 18:25:10 -0500, Dale Henderson wrote:


> I was trying to quote '{' and '}' and ran across this compile error
> 
> buggy.pl:
> #!/usr/bin/perl -w
> use strict;
> 
> s/{/@{/g;
> s/}/@}/g;

All's well, except that braces (these two: { }) have special meaning in 
a regular expression.  Try:
s/\{/@\{/g;
s/\{/@\}/g;
Or combine them:
s/([{}])/($1eq'{')?'@{':'@}'/gex;


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

Date: Tue, 20 Nov 2001 00:23:50 GMT
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: { in s///; ?
Message-Id: <slrn9vj5rt.hjq.tadmc@tadmc26.august.net>

sysop <vze33mmh@verizon.net> wrote:
>On Mon, 19 Nov 2001 18:25:10 -0500, Dale Henderson wrote:
>
>> I was trying to quote '{' and '}' and ran across this compile error

>> s/{/@{/g;
>> s/}/@}/g;
>
>All's well, except that braces (these two: { }) have special meaning in 
>a regular expression.  Try:


It is not the regex that is the problem, it is the replacement string.


>s/([{}])/($1eq'{')?'@{':'@}'/gex;


You shouldn't include useless options such as 'x' is there.

You don't need the if/else either:

   s/([{}])/\@$1/g;


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


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

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


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