[13608] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1018 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Oct 8 01:05:24 1999

Date: Thu, 7 Oct 1999 22: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: <939359107-v9-i1018@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Thu, 7 Oct 1999     Volume: 9 Number: 1018

Today's topics:
    Re: bug or feature? <ltl@rgsun40.viasystems.com>
    Re: bug or feature? <uri@sysarch.com>
        Converting from Decimal to Binary <klrose@julian.uwo.ca>
    Re: Converting from Decimal to Binary <jeffp@crusoe.net>
    Re: Converting from Decimal to Binary (Larry Rosler)
    Re: Das GlasPerlenspiel <neale.morison@fujitsu.com.au>
        DBD:MySQL install problems. <kangas@anlon.com>
    Re: Delete a line in a file <cassell@mail.cor.epa.gov>
    Re: Delete a line in a file <cassell@mail.cor.epa.gov>
    Re: Does anyone know how to do ftp in perl? <yosikim@lgeds.lg.co.kr>
    Re: giving a file a variable name <cassell@mail.cor.epa.gov>
    Re: perldoc -q <cassell@mail.cor.epa.gov>
    Re: perldoc -q <elaine@chaos.wustl.edu>
    Re: perldoc -q <bwilcox@eudoramail.com>
    Re: Please compare and contrast C and Perl. <theglauber@my-deja.com>
        reading binary data files fheitka@attglobal.net 
    Re: reading binary data files (Martien Verbruggen)
        RE: Redirecting with a SSI from perl <webmaster@compre-ya.com>
        Searching an array (David Walford)
    Re: Searching an array <rra@stanford.edu>
    Re: Searching an array (Martien Verbruggen)
        Spreadsheets. <kangas@anlon.com>
    Re: Using a regexp in an index function, can it be done <rick.delaney@home.com>
    Re: Using a regexp in an index function, can it be done <ltl@rgsun40.viasystems.com>
    Re: Wrong?  s/\n\n/#/g; (Tad McClellan)
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: 8 Oct 1999 01:07:11 GMT
From: lt lindley <ltl@rgsun40.viasystems.com>
Subject: Re: bug or feature?
Message-Id: <7tjg3v$9ro$1@rguxd.viasystems.com>

Uri Guttman <uri@sysarch.com> wrote:

:>how was that, lindley?

I think you morphed your club into a scalpel and circumcised
him without anesthesia.  I kept waiting for you to slip and 
emasculate him, but your hand was steady with logic and
good advice, and if there was a sadistic smile anywhere, it
seemed aimed more at the corrupting influence of a lousy
book that had misled poor Ilya.

Of course he is not going to appreciate your restraint.

And at the moment, I don't feel too proud of having goaded
you on in the name of humor.  It really isn't that funny.

I'm feeling guilty for contributing to the noise and so will
now try to shrink back and stick to Perl discussions.

-- 
// Lee.Lindley   /// I used to think that being right was everything.
// @bigfoot.com  ///  Then I matured into the realization that getting
////////////////////   along was more important.  Except on usenet.


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

Date: 07 Oct 1999 22:12:33 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: bug or feature?
Message-Id: <x7puyqob1q.fsf@home.sysarch.com>

>>>>> "ll" == lt lindley <ltl@rgsun40.viasystems.com> writes:

  ll> Of course he is not going to appreciate your restraint.

  ll> And at the moment, I don't feel too proud of having goaded
  ll> you on in the name of humor.  It really isn't that funny.

it's ok. i would have done it anyway given his comment. you just gave me
some more incentive.

  ll> I'm feeling guilty for contributing to the noise and so will
  ll> now try to shrink back and stick to Perl discussions.

it was a perl discussion. he just didn't know it. he sent me an email
about my repressed anger. i don't repress it, i express it (mostly at
bad perl books). :-)

uri

-- 
Uri Guttman  -----------------  SYStems ARCHitecture and Software Engineering
uri@sysarch.com  ---------------------------  Perl, Internet, UNIX Consulting
Have Perl, Will Travel  -----------------------------  http://www.sysarch.com
The Best Search Engine on the Net -------------  http://www.northernlight.com


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

Date: Fri, 08 Oct 1999 03:44:13 GMT
From: Kenneth Rose <klrose@julian.uwo.ca>
Subject: Converting from Decimal to Binary
Message-Id: <37FD687A.446CD000@julian.uwo.ca>

Hi all,

Have the following question.  Suppose I have a number in decimal (let's
say I have 112).  How, in Perl, can I quickly change this to its binary
notation (in this case, 1110000)?

I read the FAQs and saw the code for:

$binary_string = join('', unpack('B*', "\x29"));

in perlfaq4.  But \x29 is a hex value.  I want to convert from decimal. 
Any help is appreciated.

/<en


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

Date: Fri, 8 Oct 1999 00:25:44 -0400
From: Jeff Pinyan <jeffp@crusoe.net>
Subject: Re: Converting from Decimal to Binary
Message-Id: <Pine.GSO.4.10.9910080023460.14462-100000@crusoe.crusoe.net>

[posted & mailed]

On Oct 8, Kenneth Rose blah blah blah:

> I read the FAQs and saw the code for:
> $binary_string = join('', unpack('B*', "\x29"));
> in perlfaq4.  But \x29 is a hex value.  I want to convert from decimal. 

GAH!  That hurts my brain.

You DO realize that \x29 is the hexadecimal representation for a decimal
number, right?  It's not a special data type in Perl.  And to avoid the
quotes, use 0x29 notation (leading 0x or 0X means hex, leading 0 means
octal).  Numbers generally shouldn't have quotes around them.

Anyway, did you TRY using a decimal number in the hexadecimal number's
place?  No, methinks.

-- 
jeff pinyan    japhy@pobox.com
perl stuff     japhy+perl@pobox.com
CPAN ID: PINYAN            http://www.perl.com/CPAN/authors/id/P/PI/PINYAN



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

Date: Thu, 7 Oct 1999 21:37:56 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Converting from Decimal to Binary
Message-Id: <MPG.126714fbf3c0e16698a05a@nntp.hpl.hp.com>

In article <37FD687A.446CD000@julian.uwo.ca> on Fri, 08 Oct 1999 
03:44:13 GMT, Kenneth Rose <klrose@julian.uwo.ca> says...
> Have the following question.  Suppose I have a number in decimal (let's
> say I have 112).  How, in Perl, can I quickly change this to its binary
> notation (in this case, 1110000)?

print unpack 'B*' => pack 'C' => $number;

That produces 8 bits.  To get 16 bits, use 'n'; 32 bits 'N'.

pack/unpack has a little language of its own.  Perl 5.6 will have 
s?printf '%b', which will be part of another little language, which is 
much more familiar though.

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Fri, 8 Oct 1999 12:28:40 +1000
From: "Neale Morison" <neale.morison@fujitsu.com.au>
Subject: Re: Das GlasPerlenspiel
Message-Id: <7tjkns$31b@newshost.fujitsu.com.au>

David Cassell wrote in message <37FD1146.E88C6CF4@mail.cor.epa.gov>...
>Fujitsu Australia Limited wrote:
>I've read Hesse.  But not for a few years.  Still, I was making
>a joke in return, since your intent was obvious.  And you must
>not know enogh about MST3K and the rec.arts.tv.mst3k.misc
>newsgroup if you think Hesse would be off-topic for either.
>Considering that MST3K has made refs to Melville, Pynchon, and
>James Joyce [to name a few that I happen to know of], Hesse
>is definitely in their purview.

You've got me bang to rights, officer. I was not familiar with the MST3K
group. I naturally assumed I was getting another "You're off topic, crawl
back under your rock" message.
I've had a look at rec.arts.tv.mst3k.misc on deja.com and I'm still somewhat
in the dark. The light's better over here.

Neale Morison




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

Date: Thu, 07 Oct 1999 21:36:38 -0500
From: Kangas <kangas@anlon.com>
Subject: DBD:MySQL install problems.
Message-Id: <37FD58B6.B1754DA1@anlon.com>

I am an NT guy who is converting to Linux. I need to get Perl to connect
to my MySQL database. This is what has been happening while I have been
trying to make this happen.

I installed the MySQL server and client using the RPM's.  I got the DBI
installed but when it comes to the mSQL/MySQL module installation it is
asking me for the location of the MySQL.h file. I grabed it from the
tar.gz file. I created the 'include' directory and stuck it in there.
The next question asks for the libmysqlclient.a or libmysqlclient.so
file and these are not in the installation directory or in the
MySQL.src.rpm file that I downloaded.

I tried to run the install for the mysql.src.rpm but nothing happened. I
was hoping that it would install the source files. I managed to grab and
gunzip the src.tar.gz file and copied the source into my install
directory but this accomplished nothing but filing up my drive and
getting the mysql.h file for me. I still need the libmysqlclient.so file
and any others I will need after I get past this point of the mSQL/MySQL
installation sticking point.

1.) Where do I find the libmysqlclient.so file?
2.) Is it o.k. to just grab the file it is looking for and put it into
the directory it is looking for it in?
3.) Is there another module I can use the connect to MySQL?


Thanks
--
Michael Kangas
kangas@anlon.com






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

Date: Thu, 07 Oct 1999 17:28:13 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Delete a line in a file
Message-Id: <37FD3A9D.7F546802@mail.cor.epa.gov>

Ilya wrote:
[snip]
> It is a  fallacy that the FAQ  can satisfy the needs of  everyone.

It isn't claimed to be so.

>  That's why
> newsgrops  exist to complement  it.

No, newsgroups exist for other reasons.  Some have FAQ so visitors
will *not* ask those questions.

>  FAQ  are good,  but sometimes  users have
> unique  variations  of  the  same   problem  that  requires  a  less  standard
> response.

Agreed.  Those people say "I tried FAQ 4.21 and it didn't work for
me.  Here's my code and here's what I needed it to do..."  And
those people get help here.  We *like* people who read the FAQ
and try to write code to help themselves.  But the whole purpose
of the FAQ is so that the basic questions do *not* have to be asked
here again and again and again.

> Just because there is a FAQ entry, does not mean the question should
> not be asked/answered here. So... Asking FAQ questions is not a waste of time,
> personally I want to see these kinds  of questions. What's a waste of time and
> noise is people saying "Oh! It is in the FAQ! Go read it! Don't ask here".

Asking FAQ questions is not only a waste of time, it violates Larry
Wall's definition of 'Laziness' [see the glossary of the camel book
for details].  Why would you want to see FAQ over and over, when you
can just read through the FAQ yourself and learn what topics are
already covered?  And why would you enjoy seeing people posting bad
code as answers instead of reffing the FAQ [where good code sits
waiting for you], so that others then have to correct the errors?

> As to the question,  there are many many ways of doing  that. Could you give a
> more  detailed example  of what  you  are trying  to accomplish?   If you  are
> interfacing with the system file, I would use "grep -v". If you have your data
> in an array, I would use regular expressions and pattern matching.

If you shell out to use 'grep -v' you're probably not interested
in using the Perl tools which permit you to do things more
efficiently.  I use grep now and then, but it's lousy when
you have a long list of words to use as exceptions.  The FAQ
has a good way of dealing with a long list of strings to
test for inclusion or exclusion.
 
> The one book that covers it really well is: _Perl By Example_ by Quigley.  The
> _Perl Cookbook_ is also excellent.  I  somehow have not found much use for the
> Camel book.

You like Quigley and you don't have a use for the Camel?
That's a bad sign, Ilya.  Go to www.perl.com and look at the
book review page.

David
-- 
David Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician


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

Date: Thu, 07 Oct 1999 17:34:45 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Delete a line in a file
Message-Id: <37FD3C25.366B05F8@mail.cor.epa.gov>

David Amann wrote:
> 
> Hi Gaetan,
> 
> Gaetan wrote:
> 
> > What can i do to delete just one line in a file.
> 
> What I would do is the following;
> 
>   1. Read in the file to delete the line from line by line
>   2. Write each line to the temp file unless it matches the line to
>      delete
>   3. Rename the temp file to the deleted file.
> 
> Here's a script which does that.
[snip of script]

Ummm, David, is there a reason why you didn't cite the program
from the FAQ which does this in a shorter, cleaner, safer,
better manner?

You checked the return on your open()s and close()s.
That's good.  But you forgot to check the return on your
rename()s.  You need to die if your first rename() fails,
or you eat the new file with the second rename().  That's
an oops.  

And your regex may not do the right thing if someone
specifies a $delete_line like "lots of stars***!"

But you used -w and strict, and did most things right.
Setting a good example there.

David
-- 
David Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician


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

Date: Fri, 08 Oct 1999 09:22:48 +0900
From: Yongsik Kim <yosikim@lgeds.lg.co.kr>
Subject: Re: Does anyone know how to do ftp in perl?
Message-Id: <37FD3958.619DAA16@lgeds.lg.co.kr>



cheis01@yahoo.com wrote:
> 
> Does anyone know how to do ftp in perl?
> 
> You know in a shell script, you could do the following:
>    ftp -n -d << EOF
>    open SERVER
>    user USER\PASSWD
>    put FILE
>    bye
>    EOF
> And then execute the script in shell, so the file is transfered.
> 
> Is there a way to do this in perl?
> 
> Thanks.
> 
> Sent via Deja.com http://www.deja.com/
> Before you buy.

I do ftp with Net::FTP module. check here
http://theory.uwinnipeg.ca/CPAN/data/libnet/Net/FTP.html


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

Date: Thu, 07 Oct 1999 17:39:20 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: giving a file a variable name
Message-Id: <37FD3D38.53983623@mail.cor.epa.gov>

Kevin Monroe wrote:
> 
> Thank you for your assistance.  Your help is greatly appreciated.  As I want to
> learn how to fish for myself instead of being fed, could you elaborate on why

Good.  We like people who want to learn.

> > __    print NEW "$line";
> >                 ^     ^
> >                 |     |
> >
> >               Don't do that.
> 
> this should not be done that way. 

Use this instead:

    print NEW $line;

Putting unneeded quotes around variables can lead to..
umm.. surprises.  Try this and see the difference.

my @array = qw/one two three four/;
print @array;
print "@array";

David
-- 
David Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician


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

Date: Thu, 07 Oct 1999 17:18:59 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: perldoc -q
Message-Id: <37FD3873.68D40A21@mail.cor.epa.gov>

Bob Wilcox wrote:
> 
> When I try something like perldoc -q perldoc -q "delete a line in a file"
> that someone recently suggested, or any perldoc -q command, I get an invalid
> option message.  perldoc tells me the correct option is -f.  Is this an old
> version on our machine maybe?

Well, not a new version.  Anything 5.004_04 or earlier [IIRC]
won't have the -q option in it.  So think of it as a reason
to upgrade.  :-)

David
-- 
David Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician


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

Date: Thu, 07 Oct 1999 22:08:07 -0400
From: Elaine -HFB- Ashton <elaine@chaos.wustl.edu>
Subject: Re: perldoc -q
Message-Id: <37FD51F3.B7FCE7CC@chaos.wustl.edu>

Bob Wilcox wrote:
> 
> When I try something like perldoc -q perldoc -q "delete a line in a file"

try "perldoc perldoc" which should explain how to use perldoc.

Running that precise command emits:

=head1 Found in /usr/local/lib/perl5/5.00503/pod/perlfaq5.pod

=head2 How do I change one line in a file/delete a line in a file/insert
a line in t
he middle of a file/append to the beginning of a file?

Those are operations of a text editor.  Perl is not a text editor.
Perl is a programming language.  You have to decompose the problem into
low-level calls to read, write, open, close, and seek.
[...snip...]

on my system. 

Might you have Perl4 on your system?

e.


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

Date: Thu, 7 Oct 1999 22:54:40 -0400
From: "Bob Wilcox" <bwilcox@eudoramail.com>
Subject: Re: perldoc -q
Message-Id: <939351457.281887@news.tir.com>

>Well, not a new version.  Anything 5.004_04 or earlier [IIRC]
>won't have the -q option in it.  So think of it as a reason
>to upgrade.  :-)


Thanks...appears we do have 5.004_4.  Have to talk to the system guys.





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

Date: Fri, 08 Oct 1999 01:06:27 GMT
From: The Glauber <theglauber@my-deja.com>
Subject: Re: Please compare and contrast C and Perl.
Message-Id: <7tjg2a$kmo$1@nnrp1.deja.com>

In article <37f04e55.0@news.pacifier.com>,
  Neil <neil@pacifier.com> wrote:
> Please compare and contrast the two languages.
>
> I am aware that Larry Wall wrote Perl in C.
>

One day if i have the time i'll write C in Perl.

--
Glauber Ribeiro
theglauber@my-deja.com
"Opinions stated are my own and not representative of Experian"


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


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

Date: 8 Oct 1999 00:31:20 GMT
From: fheitka@attglobal.net 
Subject: reading binary data files
Message-Id: <37fd3b58_2@news1.prserv.net>
Keywords: binary,data,Perl,reading 


I'm trying to read a binary file using Perl.
I've check through a lot of the online docs
and a few books and I can't seem to get it to
work.  Here is an example:
Suppose I have a C program that writes out a
binary file using fwrite.  In the files is 
date from the structure.

struct mystruct {
  int num;
  double date[100];
  char *dname="9/04/99 data"
};

How would I read the data?  I've tried using
the seek, read, and unpack commands and all I
seem to read is garbage.  Should Perl be able
to do this?  I've seen lots of examples where
Perl is evidently used to read text files.

-- 
Fred


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

Date: Fri, 08 Oct 1999 00:55:42 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: reading binary data files
Message-Id: <iibL3.64$u83.4613@nsw.nnrp.telstra.net>

On 8 Oct 1999 00:31:20 GMT,
	fheitka@attglobal.net <fheitka@attglobal.net> wrote:

> Suppose I have a C program that writes out a
> binary file using fwrite.  In the files is 
> date from the structure.
> 
> struct mystruct {
>   int num;
>   double date[100];
>   char *dname="9/04/99 data"
> };
> 
> How would I read the data?  I've tried using

You could consider reading the responses to the question that was sent
here on 07 Oct, one day before you posted this. You should also
complain to the poster of the other article, because he is using
_exactly_ the same address as you are. In fact, he also had a question
about a struct which looked _very very much_ like yours. Maybe he'll
sue you for plagiarism.

I'm pretty sure that you can't be the same person posting the same
question twice, because no one would do that. People first read the
responses to their original post.

There was one answer to that other article (posted by someone who is
using the same name as I am, but a different address, and therefore
definitely cannot be the same person) which was quite elaborate in
answering, and showing you how to do this. And even demonstrating how
to do it. 

If that isn't sufficient for your needs, you should complain in a
followup post to that one. If that doesn't help, you should take this
to the international courts of law and demand that you get your
rights!

Martien

PS. I wonder why I spent all that time answering your question the
first time around.

PPS. I wonder why I spent all this time typing this nonsense the
second time around

PPPS. Yes, I know there are delays in distributions of articles. I
don't care. You should know that too. You should also realise that you
can't expect an instantaneous response to anything you post.
-- 
Martien Verbruggen                  | 
Interactive Media Division          | That's funny, that plane's dustin'
Commercial Dynamics Pty. Ltd.       | crops where there ain't no crops.
NSW, Australia                      | 


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

Date: Wed, 6 Oct 1999 17:01:00 -0300
From: "Webmaster" <webmaster@compre-ya.com>
Subject: RE: Redirecting with a SSI from perl
Message-Id: <7tfkn9$a1a$1@vnews.prima.com.ar>

All the script must send to the browser after checking the IP is

print "Content-type: text/html\n";
print "Window-target: newwindow\n";
print "Location: name.html\n\n";

or

 open(FILE, "name.html");
 while(<FILE>)
 {
    print;
}

The fisrt one will work with SSI directives too and pulling out a new
browser window.

Bye

--
Gastón Gorosterrazú
webmaster@compre-ya.com
http://www.compre-ya.com

<jnoviell@my-deja.com> escribió en el mensaje de noticias
7tdfa1$ao2$1@nnrp1.deja.com...
> Greetings All,
>
>
> I'm using a SSI directive in my html page the executes a script (perl)
> and redirect a user if he/she had never login before.
>
>
> In the script I verify the users IP address, and if it's not part of my
> lists, I want him redirected to a sign in page (another html document),
> else let him/her through.
>
>
> The problem is I can't seem to redirect it to the sign in page, it
> somehow goes into a loop.
>
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.




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

Date: 8 Oct 1999 02:18:09 GMT
From: davewal@echo.corp.sgi.com (David Walford)
Subject: Searching an array
Message-Id: <7tjk91$gel$1@murrow.corp.sgi.com>

This there a fast way to search through the elements of an array
and return the number of matches found without doing a 
for loop.

Better way than this:

for (@array) {
   count++ if ($_ eq $test_var);
}

What would it be?

Thanks
David


-- 
--------------------------------------------------------------
 David M. Walford           | email: davewal@corp.sgi.com
 RealityCenter Tech. Engr.  | m/s: 06U-122 
 Silicon Graphics, Inc.     | voice: 650-933-6451 
 Corporate Briefing Center  | fax: 650-932-6451 


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

Date: 07 Oct 1999 19:24:38 -0700
From: Russ Allbery <rra@stanford.edu>
Subject: Re: Searching an array
Message-Id: <yl1zb637yx.fsf@windlord.stanford.edu>

David Walford <davewal@echo.corp.sgi.com> writes:

> Better way than this:

> for (@array) {
>    count++ if ($_ eq $test_var);
> }

> What would it be?

$count = grep { $_ eq $test_var } @array;

-- 
#!/usr/bin/perl -- Russ Allbery, Just Another Perl Hacker
$^=q;@!>~|{>krw>yn{u<$$<[~||<Juukn{=,<S~|}<Jwx}qn{<Yn{u<Qjltn{ > 0gFzD gD,
 00Fz, 0,,( 0hF 0g)F/=, 0> "L$/GEIFewe{,$/ 0C$~> "@=,m,|,(e 0.), 01,pnn,y{
rw} >;,$0=q,$,,($_=$^)=~y,$/ C-~><@=\n\r,-~$:-u/ #y,d,s,(\$.),$1,gee,print


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

Date: Fri, 08 Oct 1999 02:33:09 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Searching an array
Message-Id: <FJcL3.83$u83.5851@nsw.nnrp.telstra.net>

On 8 Oct 1999 02:18:09 GMT,
	David Walford <davewal@echo.corp.sgi.com> wrote:
> This there a fast way to search through the elements of an array
> and return the number of matches found without doing a 
> for loop.

Note that there is no way without doing a loop. You might not see the loop
in the code, but it's being done anway :)

# perldoc -f grep

Martien
-- 
Martien Verbruggen                  | 
Interactive Media Division          | Begin at the beginning and go on till
Commercial Dynamics Pty. Ltd.       | you come to the end; then stop.
NSW, Australia                      | 


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

Date: Thu, 07 Oct 1999 22:35:24 -0500
From: Kangas <kangas@anlon.com>
Subject: Spreadsheets.
Message-Id: <37FD667C.BBBF312F@anlon.com>

Other than Excel what spreadsheets can perl connect with??

--
Michael Kangas
kangas@anlon.com




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

Date: Fri, 08 Oct 1999 00:43:36 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: Using a regexp in an index function, can it be done?
Message-Id: <37FD3E41.6A05DD1F@home.com>

Larry Rosler wrote:
> 
> W. Arthur <jwarthur@prokofiev.fccc.edu> says...
> > I need to know the position that a particular regular expression first
> > occurs in a line of characters.
> 
> /$pattern/g; # Add 'o' modifier if $pattern never changes
> 
> print pos() - length $pattern, "\n";

> Obviously, the pattern must match a fixed number of characters (i.e., 
> no * ? + {,} quantifiers).

And if it needs those quantifiers you can so something like

    /($pattern)/g; # Add 'o' modifier if $pattern never changes

    print pos() - length $1, "\n";

-- 
Rick Delaney
rick.delaney@home.com


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

Date: 8 Oct 1999 01:44:47 GMT
From: lt lindley <ltl@rgsun40.viasystems.com>
Subject: Re: Using a regexp in an index function, can it be done?
Message-Id: <7tjiaf$ah1$1@rguxd.viasystems.com>

Larry Rosler <lr@hpl.hp.com> wrote:
:>In article <Pine.SGI.4.10.9910071756520.262457-
:>100000@prokofiev.fccc.edu> on Thu, 7 Oct 1999 18:07:54 -0400, Jonathan 
:>W. Arthur <jwarthur@prokofiev.fccc.edu> says...
:>> I need to know the position that a particular regular expression first
:>> occurs in a line of characters. 

:>...

:>> ... Is there a way I can work out where in $_ the regular expression first
:>> matches?

:>#!/usr/local/bin/perl -w
:>use strict;
:>$_ = 'xyzxyzxyz';
:>my $pattern = 'zxy';
:>/$pattern/g; # Add 'o' modifier if $pattern never changes
:>print pos() - length $pattern, "\n";
:>__END__
:>Output:
:>2

:>Obviously, the pattern must match a fixed number of characters (i.e., no 
:>* ? + {,} quantifiers).

Nice.  

Consider that you can find the length of what matched
too and so the fixed length pattern requirement could be eliminated.

$_ = 'xyzxyzxyz';
my $pattern = qr{((?:zxy)+)};
if (/$pattern/g) {
	print pos() - length $1, "\n";
}
__END__
2

Although "perldoc -f pos" says so, it is probably worth stressing
that the m//g global modifier is required even though you are only
matching the pattern once in this scalar context.  I remember that it
is a distinction that was not obvious to me when I first saw pos().

-- 
// Lee.Lindley   /// I used to think that being right was everything.
// @bigfoot.com  ///  Then I matured into the realization that getting
////////////////////   along was more important.  Except on usenet.


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

Date: Thu, 7 Oct 1999 15:18:08 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Wrong?  s/\n\n/#/g;
Message-Id: <glrit7.a5m.ln@magna.metronet.com>

Myriad (myriad@erols.com) wrote:

: perl -pe s/\n\n/#/g; somedoc.txt
          ^^         ^^

: Can someone tell me why this won't work


   Because semi-colon is special to the shell, and you didn't
   quote it maybe?

   So it just sits there, waiting for you to type something on STDIN.

   
   Please don't try and rekey code, use cut/paste instead,
   else you will get a bunch of help with your typo that is
   in your post but is not in your code...




:  to remove replace double hard
                            ^^^^
: returns in a text file?  Can't figure it out.   
  ^^^^^^


   Because "-p" reads *one line* at a time.

   You cannot have a successful *multi*-line pattern match against
   a *single*-line string.


   [ I dunno what you mean when you say "hard return". ASCII does
     not have any characters with that name. Are you perhaps using
     some other character set?

     I assume not. I further assume that you really meant "line feed"
     (ASCII 10 decimal, aka "newline") rather than "hard return"
   ]


: Thought maybe it was because
: \n needed to be used in conjunction with \r, but that didn't work either.


   That is the first mention of Carriage Return. I dunno why
   you mention that character either.

   shrug...



   If the file is not too large, you can slurp the entire thing
   into memory, do the substitution, and print it out:

      perl -007pe 's/\n\n/#/g' data       # same as setting $/=undef;

   Or, you might try "para mode" to use less memory:

      perl -000pe 's/\n\n/#/' data        # same as setting $/='';



--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

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


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