[15558] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2971 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun May 7 09:05:29 2000

Date: Sun, 7 May 2000 06: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)
Message-Id: <957704707-v9-i2971@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Sun, 7 May 2000     Volume: 9 Number: 2971

Today's topics:
        [Perl] How to find the Perl FAQ <rootbeer&pfaq*finding*@redcat.com>
    Re: Clear and then Reuse a package name space <qchen@snet.net>
    Re: Clear and then Reuse a package name space richard_chen@my-deja.com
    Re: converting input to <p></p> pairs via perl (David Efflandt)
    Re: Cookie & redirect <nospam@devnull.com>
    Re: How do I get the subroutine name of a coderef? <Office@AmethystInf.com>
    Re: How single-line switch (/s) works in regexps? (Bart Lateur)
    Re: How to print '%' character with printf ? (Villy Kruse)
    Re: how to rx and tx thru a remote socket (David Efflandt)
    Re: logon script NT <carvdawg@patriot.net>
        PerlDoc (whatever) bug in win32 (Steve A. Taylor)
    Re: Quality of perl implementations <htp@mac.com>
    Re: Question on references... <propart@mediaone.net>
    Re: Regexp char class: mixing ranges and negation? (Bart Lateur)
    Re: Tanspose rows to columns (Bart Lateur)
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Sun, 07 May 2000 10:22:38 GMT
From: Tom Phoenix <rootbeer&pfaq*finding*@redcat.com>
Subject: [Perl] How to find the Perl FAQ
Message-Id: <pfaqmessage957695041.29787@news.teleport.com>

Archive-name: perl-faq/finding-perl-faq
Posting-Frequency: weekly
Last-modified: 29 Apr 2000

[ That "Last-modified:" date above refers to this document, not to the
Perl FAQ itself! The last _major_ update of the Perl FAQ was in Summer
of 1998; of course, ongoing updates are made as needed. ]

For most people, this URL should be all you need in order to find Perl's
Frequently Asked Questions (and answers).

    http://www.cpan.org/doc/FAQs/

Please look over (but never overlook!) the FAQ and related docs before
posting anything to the comp.lang.perl.* family of newsgroups.

For an alternative way to get answers, check out the Perlfaq website.

    http://www.perlfaq.com/

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # 

Beginning with Perl version 5.004, the Perl distribution itself includes
the Perl FAQ. If everything is pro-Perl-y installed on your system, the
FAQ will be stored alongside the rest of Perl's documentation, and one
of these commands (or your local equivalents) should let you read the FAQ.

    perldoc perlfaq
    man perlfaq

If a recent version of Perl is not properly installed on your system,
you should ask your system administrator or local expert to help. If you
find that a recent Perl distribution is lacking the FAQ or other important
documentation, be sure to complain to that distribution's author.

If you have a web connection, the first and foremost source for all things
Perl, including the FAQ, is the Comprehensive Perl Archive Network (CPAN).
CPAN also includes the Perl source code, pre-compiled binaries for many
platforms, and a large collection of freely usable modules, among its
560_986_526 bytes (give or take a little) of super-cool (give or take
a little) Perl resources.

    http://www.cpan.org/
    http://www.perl.com/CPAN/
    http://www.cpan.org/doc/FAQs/FAQ/html/
    http://www.perl.com/CPAN/doc/FAQs/FAQ/html/

You may wish or need to access CPAN via anonymous FTP. (Within CPAN,
you will find the FAQ in the /doc/FAQs/FAQ directory. If none of these
selected FTP sites is especially good for you, a full list of CPAN sites
is in the SITES file within CPAN.)

    California     ftp://ftp.cdrom.com/pub/perl/CPAN/
    Texas          ftp://ftp.metronet.com/pub/perl/
    South Africa   ftp://ftp.is.co.za/programming/perl/CPAN/
    Japan          ftp://ftp.dti.ad.jp/pub/lang/CPAN/
    Australia      ftp://cpan.topend.com.au/pub/CPAN/
    Netherlands    ftp://ftp.cs.ruu.nl/pub/PERL/CPAN/
    Switzerland    ftp://sunsite.cnlab-switch.ch/mirror/CPAN/
    Chile          ftp://ftp.ing.puc.cl/pub/unix/perl/CPAN/

If you have no connection to the Internet at all (so sad!) you may wish
to purchase one of the commercial Perl distributions on CD-Rom or other
media. Your local bookstore should be able to help you to find one.

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # 

Comments and suggestions on the contents of this document
are always welcome. Please send them to the author at
<pfaq&finding*comments*@redcat.com>. Of course, comments on
the docs and FAQs mentioned here should go to their respective
maintainers.

Have fun with Perl!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/


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

Date: Sun, 07 May 2000 07:45:56 -0400
From: Richard Chen <qchen@snet.net>
Subject: Re: Clear and then Reuse a package name space
Message-Id: <39155774.4C9360FF@snet.net>

Enough beating around the bush :-)

I asked a generic question and I wanted a direct answer.

After a little thinking, I have answered my own question.
There is indeed an exceedingly simple way
to clear and reuse a package name space in one perl process.

The scrub_package written by Mark Jason Dominus
almost does it except a fatal flaw which results in the undef
of the source subroutine. A tiny, logically obvious replacement,
does the trick. Instead of the buggy line
	undef &$fullname;
use
	*{$fullname}=sub {};

This fix is obvious because that is the way how a code alias is
generated in the first place. In order to undef this alias,
just let it point to a anonymous subroutine which does nothing!


Tom Phoenix wrote:
> 
> On Wed, 3 May 2000 richard_chen@my-deja.com wrote:
> 
> > How the problem arise is not important.
> > Debating about what should be done in modifying the legacy
> > cgi scripts to make them work under modperl is beside the point.
> 
> Well, if you say it's beside the point, my arguing otherwise would be
> beside the point.
> 
> > Keep in mind that the major reason to use Apache::Registry
> > is to minimize modifications of the cgi scripts. Otherwise,
> > I would start from scratch and write my own perl handlers,
> > bypassing Apache::Registry altogether.
> 
> Okay, but that doesn't mean that every existing CGI script will work under
> Apache::Registry without modification. It seems that ones which assume
> that globals will always be empty upon each new invocation may have
> troubles.
> 
> > I have tried very hard to distill the essence of the problem
> > before I posted it to this discussion group. Let me
> > state it again here:
> >
> > =======================================================
> > Is it possible to clear and then reuse the same package
> > name space in one perl process?
> > =======================================================
> 
> As I said before, and you quoted:
> 
> > > Well, clearing the symbol table _is_ possible.
> 
> ...but I don't think it'll help you here. You don't have to believe me,
> though.  :-)
> 
> > I am very surprised that there is an easy way to make alias in perl
> > but apparently there is no way to clear/remove the alias and then bind
> > the alias to another variable/reference.
> 
> I think that's a different problem. But since I don't claim to completely
> understand that one, I'll leave it alone. :-)
> 
> --
> Tom Phoenix       Perl Training and Hacking       Esperanto
> Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/


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

Date: Sun, 07 May 2000 12:16:15 GMT
From: richard_chen@my-deja.com
Subject: Re: Clear and then Reuse a package name space
Message-Id: <8f3mq9$6l8$1@nnrp1.deja.com>

Enough beating around the bush :-)

I asked a generic question and I wanted a direct answer.

After a little thinking, I have answered my own question.

There is indeed an exceedingly simple way
to clear and reuse a package name space in one perl process.

The scrub_package described in perlfaq7 (written by
Mark-Jason Dominus) almost does it except a fatal flaw
which results in the undef of the source subroutine.
A tiny, logically obvious replacement, does the trick.

Here is the original scrub_package subroutine:

           sub scrub_package {
               no strict 'refs';
               my $pack = shift;
               die "Shouldn't delete main package"
                   if $pack eq "" || $pack eq "main";
               my $stash = *{$pack . '::'}{HASH};
               my $name;
               foreach $name (keys %$stash) {
                   my $fullname = $pack . '::' . $name;
                   # Get rid of everything with that name.
                   undef $$fullname;
                   undef @$fullname;
                   undef %$fullname;
                   undef &$fullname;
                   undef *$fullname;
               }
           }

Instead of the line
        undef &$fullname;
which undef's the source subroutine, one should use
        *{$fullname}=sub {};
This fix is obvious because that is the way how a code alias is
generated in the first place. In order to undef this alias,
just let it point to an anonymous subroutine which does nothing!

This works wonders in my Apache::Registry environment.

Thanks for your attention.

Richard

In article
<Pine.GSO.4.10.10005031254090.13677-100000@user2.teleport.com>,
  Tom Phoenix <rootbeer@redcat.com> wrote:
> On Wed, 3 May 2000 richard_chen@my-deja.com wrote:
>
> > How the problem arise is not important.
> > Debating about what should be done in modifying the legacy
> > cgi scripts to make them work under modperl is beside the point.
>
> Well, if you say it's beside the point, my arguing otherwise would be
> beside the point.
>
> > Keep in mind that the major reason to use Apache::Registry
> > is to minimize modifications of the cgi scripts. Otherwise,
> > I would start from scratch and write my own perl handlers,
> > bypassing Apache::Registry altogether.
>
> Okay, but that doesn't mean that every existing CGI script will work
under
> Apache::Registry without modification. It seems that ones which assume
> that globals will always be empty upon each new invocation may have
> troubles.
>
> > I have tried very hard to distill the essence of the problem
> > before I posted it to this discussion group. Let me
> > state it again here:
> >
> > =======================================================
> > Is it possible to clear and then reuse the same package
> > name space in one perl process?
> > =======================================================
>
> As I said before, and you quoted:
>
> > > Well, clearing the symbol table _is_ possible.
>
> ...but I don't think it'll help you here. You don't have to believe
me,
> though.  :-)
>
> > I am very surprised that there is an easy way to make alias in perl
> > but apparently there is no way to clear/remove the alias and then
bind
> > the alias to another variable/reference.
>
> I think that's a different problem. But since I don't claim to
completely
> understand that one, I'll leave it alone. :-)
>
> --
> Tom Phoenix       Perl Training and Hacking       Esperanto
> Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/
>
>


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: 7 May 2000 11:20:27 GMT
From: efflandt@xnet.com (David Efflandt)
Subject: Re: converting input to <p></p> pairs via perl
Message-Id: <slrn8hakcj.ph.efflandt@efflandt.xnet.com>

On 7 May 2000 02:09:15 GMT, The WebDragon <nospam@devnull.com> wrote:
>In article <8f2a7e$cvg$0@216.155.33.54>, The WebDragon 
> | this text will eventually be input from a TEXTAREA field in a 
> | cgi-generated html form, but the perlish problem still remains, hence my 
> | posting it here, rather than over there.
>
>breaking this down into a two-pass procedure, what I can derive that I 
>need to do is this: 
>
>first search for every \n that is not also followed by another \n, and 
>replace it with <br>

How do you know what lines end with?  Even from a Linux Netscape textarea
they end with \r\n.  Not sure about Mac.  It is wise to not assume.

>then for every chunk of data terminated with \n\n, surround the chunk 
>with <p></p> and put the \n\n after the </p>

Newlines are not required (except for easier "view source" reading).

>if the last chunk of data has no \n\n after it, or has a <br> at the end 
>(from the first pass), be sure to also wrap it in a <p></p> pair and 
>REMOVE the terminating <br>, adding back a \n\n after the final </p>
>
>if that looks correct mostly, how would I write sugh beasts using 
>regexps? Anyone? 

#!/usr/bin/perl
$_ = <<EOF;
Paragraph one
second line  

Paragraph two
EOF
# These work with any line ending
s/(\r\n\r\n|\n\n|\r\r)/<\/p><p>/g;
s/(\r\n|\n|\r)/<br>/g;
s/<p>$//;		# strip trailing <p>
s/<br>$/<\/p>/;		# convert trailing <br>
s/(<br>)/$1\n/g;	# optional \n
s/(<\/p>)/$1\n\n/g;	# optional \n\n
print "<p>$_";


>-- 
>send mail to mactech (at) webdragon (dot) net instead of the above address. 

-- 
David Efflandt  efflandt@xnet.com  http://www.de-srv.com/
http://www.autox.chicago.il.us/  http://www.berniesfloral.net/
http://hammer.prohosting.com/~cgi-wiz/  http://cgi-help.virtualave.net/



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

Date: 7 May 2000 10:14:19 GMT
From: The WebDragon <nospam@devnull.com>
Subject: Re: Cookie & redirect
Message-Id: <8f3flr$n22$0@216.155.33.54>

In article <8f3brg$13$1@lure.pipex.net>, "Marko Djukic " 
<mdjukic@dial.pipex.com> wrote:

 | Vlatko,
 |     You appear to be using cgi.pm.....................unfortunately, the
 | header command issues a 'Content-type.....'  directive.  This is not 
 | what
 | you want, as the redirect will not work.................been there done 
 | it.
 | We finally decided not to use cgi.pm and things worked fine.
 | 
 | Regards
 | 
 | Marko Djukic

Be sure to report this to the Author of CGI.pm so that if neccessary, he 
can correct the behaviour of it.. also be certain that you were using 
the latest 2.66 version of CGI.pm.. there's been numerous fixes and 
updates. 


 | Vlatko Primorac wrote in message ...
 | >
 | >> I'd like to send a cookie and then redirect, but it doesn't work at 
 | >> all.
 | >> Here is my portion of code:
 | >>
 | >> my
 | >>
 | $cookie=$q->cookie(-name=>'moonkey_exchange',-value=>'Hi',-expires=>'+37y
 | ');
 | >>
 | >> print $q->header(-cookie=>$cookie);
 | >>
 | >> #print CGI->redirect(-uri=>$url,-nph=>1);
 | >
 | >You should not mix normal header generation with CGI->redirect. You 
 | >will
 | >only end up with double header sent, or something even worse. If you
 | >decided to use CGI->redirect call, it will create html headers for you. 
 | >If
 | >you want to set a cookie, you should add it to the CGI module generated
 | >header, not send a partial header with the cookie, then send the 
 | >complete
 | >one from CGI module without a cookie. perldoc on CGI will tell you not 
 | >to
 | >send your own headers if you're using the CGI->redirect.
 | >
 | >To add a cookie to CGI->redirect generate header, here's a code example
 | >from http://developer.irt.org/. I hope it works for you, I've never 
 | >tried
 | >it myself. Beware, some browsers might not be entirely happy accepting
 | >the cookie within the 30x server response, so I would recommend testing
 | >the code behavior on all versions of browsers you claim to support.
 | >
 | >Good luck, and please let me know if it worked for you.
 | >
 | >Vlatko
 | >
 | >
 | >use CGI qw(:cgi);
 | >
 | >my $q = CGI->new();
 | >my $cookie = $q->cookie(
 | >                         -name    => 'yummy_cookie',
 | >                         -value   => 'chocolate chip',
 | >                         -domain  => '.irt.org',
 | >                         -expires => '+10d',
 | >                         -path    => '/'
 | >                        );
 | >print $q->redirect(
 | >                    -url    => 'http://www.irt.org/index.htm',
 | >                    -cookie => $cookie
 | >                   );
 | >
 | 
 |

-- 
send mail to mactech (at) webdragon (dot) net instead of the above address. 
this is to prevent spamming. e-mail reply-to's have been altered 
to prevent scan software from extracting my address for the purpose 
of spamming me, which I hate with a passion bordering on obsession.  


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

Date: Sun, 7 May 2000 13:45:06 +0200
From: "Victor Kroese" <Office@AmethystInf.com>
Subject: Re: How do I get the subroutine name of a coderef?
Message-Id: <BIcR4.1663$bO4.28761@news1.online.no>

Hello Steve,

I am just starting with Perl so I don't consider myself an expert yet, but
maybe you can ask the sub for it's name, like:

use strict;

sub hello {
     #If someone is asking my name give it
     #In this case it will return main::hello
     return (caller(0))[3] if (uc(@_[0]) eq "WHOAMI");

     # now start for real.
     print "Hello ", join(", ",@_), "\n";
}

my $href=\&hello;

print &$href("WhoAmI"), "\n";
&$href("world");

Hope it helps, I don't know how to get the name directly from the address.

Good luck,

Victor Kroese
Victor.Kroese@AmethystInf.com

"Steve Leibel" <stevel@coastside.net> wrote in message
news:<stevel-0705000021250001@192.168.100.2>...
>
> Suppose I have a coderef:
>
> $fooref = \&foo;
>
> Later in the program for debugging purposes I would like to recover the
> name of the referenced subroutine from the coderef.  In other words given
> $fooref, how do I get "foo"?
>
> Needless to say simply dereferencing, as in
>
> $name = &$fooref;  # doesn't work
>
>  doesn't give me back the name, it calls the subroutine.
>
> Thanks,
>
> Steve L
> stevel@coastside.net




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

Date: Sun, 07 May 2000 11:44:38 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: How single-line switch (/s) works in regexps?
Message-Id: <39155628.595826@news.skynet.be>

Jonathan Stowe wrote:

>I dont believe I have ever heard any call for
>people to write 'pseudo-code following Perl syntax.'

Only if people are talking about a feature that Perl is (currently)
missing, and which they would like to see. The pseudo-code then is
simply an example of what they would like how the syntax would look
like.

This particular case here, was an example of this. Of course it won't
compile! But how else would you discuss an desired feature?

-- 
	Bart.


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

Date: 7 May 2000 12:20:53 GMT
From: vek@pharmnl.ohout.pharmapartners.nl (Villy Kruse)
Subject: Re: How to print '%' character with printf ?
Message-Id: <slrn8hanpd.411.vek@pharmnl.ohout.pharmapartners.nl>

On 6 May 2000 15:00:25 GMT, msouth@fulcrum.org <msouth@fulcrum.org> wrote:

>
>>    %%   a percent sign 
>
>Okay, to make this post slightly useful I'll note that putting 
>two special characters together is a common idiom for quoting
>a single one of those characters (for example, to put single
>quote marks into a text field in MySQL).  Just for future 
>reference next time you're shooting in the dark.
>



perldoc -f sprintf

How you should have known that I don't know as you don't get a cross
reference from perldoc -f printf


=item printf FILEHANDLE FORMAT, LIST

=item printf FORMAT, LIST

Equivalent to C<print FILEHANDLE sprintf(FORMAT, LIST)>.  The first argument
                                 ^^^^^^^^^^^     Unless this is the
cross reference.




Villy


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

Date: 7 May 2000 11:33:40 GMT
From: efflandt@xnet.com (David Efflandt)
Subject: Re: how to rx and tx thru a remote socket
Message-Id: <slrn8hal5d.ph.efflandt@efflandt.xnet.com>

On Sun, 07 May 2000 02:25:54 GMT, k_ahg@my-deja.com <k_ahg@my-deja.com> wrote:
>hi,
>
>   I'm currently using perl version : 5.004_04 in Unix to write a
>program to receive and send files thru a socket. But I'm not so sure how
>to send and receive my data. Can any one help me on this?
> Below is part of the program:

If you want to transfer files, use the Net::FTP module (in the libnet
module package).  If you do want to telnet, use Net::Telnet (a separate
module).

Your example was attempting to use IO::Socket for telnet, but I do not
think that would work as you wrote it since telnet sends and receives on
separate ports.

-- 
David Efflandt  efflandt@xnet.com  http://www.de-srv.com/
http://www.autox.chicago.il.us/  http://www.berniesfloral.net/
http://hammer.prohosting.com/~cgi-wiz/  http://cgi-help.virtualave.net/



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

Date: Sun, 07 May 2000 06:38:37 -0400
From: H C <carvdawg@patriot.net>
Subject: Re: logon script NT
Message-Id: <391547AD.7B8FD0E2@patriot.net>

Your answer, with examples, is located at Dave Roth's web
site...http://www.roth.net

Take a look at Dave's LISA-NT '99 paper...in it, he presents an SMS-like
funcationality
done completely in Perl.  He shows how to execute Perl scripts on hosts that do
not have
Perl installed by installing Perl on a shared drive.

steve pelts wrote:

> I am creating a logon script and one of the things I need to do is know if
> the user is a member of a local group on a member server.  I can do this in
> PERL.
> what do I need to do to run a perl script on a win95/NT client at logon.  I
> know the PERL script will be in the netlogon directory.  I don't want to
> have to load perl on each machine.  what needs to happen for the client to
> be able to run PERL
> thanks
> spelts@lucent.com



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

Date: Sun, 07 May 2000 12:25:04 GMT
From: an400@freenet.carleton.ca (Steve A. Taylor)
Subject: PerlDoc (whatever) bug in win32
Message-Id: <3914c3d4.52608026@news.ncf.carleton.ca>

What is causing this bug? All the recommendations to perldoc this or
that on Win95b, perl 5.005_03 build 519, get an error message:

C:\BATCH>perldoc Net::FTP

Can't call method "getline" on unblessed reference at
D:/perl/site/lib/Pod/Input Objects.pm line 149.



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

Date: Sun, 07 May 2000 21:50:12 +0930
From: Henry <htp@mac.com>
Subject: Re: Quality of perl implementations
Message-Id: <htp-EC2F8F.21501207052000@news.metropolis.net.au>

In article <MPG.137e5a5744f6439f98aa17@nntp.hpl.hp.com>, Larry Rosler 
<lr@hpl.hp.com> wrote:

> I am troubled by your philosophy of abstention from directing the 
> attention of Perl implementors toward reliability as opposed to new 
> features.  
 ...
> I said nothing about performance.  I would rather have a Swiss-army 
> knife with fewer blades, if they could be relied on not to break and 
> lacerate my fingers.


In article <8f2ggs$sh8$1@orpheus.gellyfish.com>, Jonathan Stowe 
<gellyfish@gellyfish.com> wrote:

> I think you missed Larry's point which was that instead of striving to
> add new and ever more exotic features to Perl we should direct our
> attentions to improving the quality of the implementation,  not so that
> people might make avionics programs with it, but so that it can be
> objectively said to be correct.  At least I think thats what he meant :)


Yes, it seems I did miss the point.  But now that you gents have put me 
back on track...

The motto of Perl, TMTOWTDI, is what gives Perl its flexibility, and its 
warm fuzzy character.  To improve the quality of the implementation 
would limit, and possibly even decrease, this flexibility.

(I have yet to see a quality contol measure increase the freedom of a 
'worker' to carry out a job in the best way he or she sees fit.  They 
all _limit_ options and variables.)

Why do we need another C, anyway?  Why should we care if Perl can be 
objectively said to be correct or not?  What will this new, objectively 
correct language be called, anyway - 'P'?

Henry.


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

Date: Sun, 07 May 2000 12:03:46 GMT
From: PropART <propart@mediaone.net>
Subject: Re: Question on references...
Message-Id: <39155B72.3CCBBE69@mediaone.net>

>
> # [ ] constructs a whole new array, but doesn't bother to give it a name,
> # and just returns the reference to this new array.
>
> In this case the anonymous array is constructed by taking @foo in list context,
> which just happens to be the list of its elements. But you could also have
> used [ sort @foo ] or [ @foo, "quux", @bar ] or [ 1, 2, 3 ].
>
> See man perlreftut (or perldoc perlreftut) for a great tutorial
> on the subject; and man perllol and perldsc for many examples.
>
>

Ok, I think I've got it. When you pass a ref to an array you've basically just
created another name for the array, but when you pass an anonymous ref to the array
you've passed it by value.

I'll check out the tutorials... As to my original non-question, I guess the
non-answer is the syntax is the syntax.

Thanx,

-- Wm. C.







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

Date: Sun, 07 May 2000 11:52:26 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Regexp char class: mixing ranges and negation?
Message-Id: <39175837.1123106@news.skynet.be>

Tim Richardson wrote:

>I'm lazy. I want a regular expression that will match all visible
>characters (7-bit will do) except , and /
>
>I don't think there is any notation that lets me specify such a
>character class easily, so I am stuck with making ranges that exclude
>the characters I don't want.

How about lookahead:

	(?=[\000-\177])[^\/,]

(untested)

I don't think it's nearly as fast as a simple chartacter class, though.

-- 
	Bart.


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

Date: Sun, 07 May 2000 12:44:25 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Tanspose rows to columns
Message-Id: <39186082.3246616@news.skynet.be>

jimbob4334@my-deja.com wrote:

>I have been trying to convert this:
>
>4|3|7|0|2|0|2|0|2|1|1|0|2|3|0|0|0|0|0|0|0|0|0|0|1.1|
>6|2|3|4|6|3|6|8|6|1|2|5|3|7|2|0|0|0|0|0|0|0|0|0|1.2|
>0|0|0|0|0|0|0|0|0|0|0|0|0|5|3|0|0|0|0|0|0|0|0|0|1.3|
>
>into this:
>
><PRO>
>1.1
>1.2
>1.3
></PRO>
><DATA>
>4	6	0
>3	2	0
>7	3	0
 ...
></DATA>

my($columns, @row, @header) = 0;
while(<DATA>) {
	chomp;
	my @data =  split /\|/;
	push @row, \@data;
	push @header, pop @data;
	$columns = @data if @data > $columns;
}

local ($\,$,) = ("\n","\n");
print '<PRO>', @header, '</PRO>', '<DATA>';
$, = "\t";
for my $i (0 .. $columns-1) {
	print map { $_->[$i] } @row;
}
print '</DATA>'
__DATA__
4|3|7|0|2|0|2|0|2|1|1|0|2|3|0|0|0|0|0|0|0|0|0|0|1.1|
6|2|3|4|6|3|6|8|6|1|2|5|3|7|2|0|0|0|0|0|0|0|0|0|1.2|
0|0|0|0|0|0|0|0|0|0|0|0|0|5|3|0|0|0|0|0|0|0|0|0|1.3|


But where is the challenge in that!

So I've been thinking about a single function that indeed transposes an
array of arrays.

So, assuming that @row and $columns are filled as with the above
function:

@transposed = map { my $i = $_; [ map { $_->[$i] } @row ] } 
  0 .. $columns-1;

{ 
    #check:
    local($", $\) = "\t"; 
    print "@$_\n" foreach @transposed;
}

-- 
	Bart.


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

Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

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 V9 Issue 2971
**************************************


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