[6660] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 285 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Apr 12 00:08:40 1997

Date: Fri, 11 Apr 97 21:00:39 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Fri, 11 Apr 1997     Volume: 8 Number: 285

Today's topics:
     "system" on NT <jbecker@syssol.com>
     "system" on NT <jbecker@syssol.com>
     Re: @array as input symbol in <@array> <tchrist@mox.perl.com>
     Re: @array as input symbol in <@array> <ajs@ajs.com>
     Re: Easy Perl Cookie Question. (Geoffrey Hebert)
     Re: frameset (Geoffrey Hebert)
     HELP PERL AND CGI ?? <goce@dcc.net.au>
     Re: HTML document title (Geoffrey Hebert)
     Re: If Else construct? <ajs@ajs.com>
     Re: Is there a length limitation on CGI Posts (STDIN)? (Geoffrey Hebert)
     Mail header rewriting (Dave Schenet)
     Re: parsing a line w/ quoted strings (newbie) (David Alan Black)
     Re: Perl basics (Laurel Shimer)
     Re: Perl for AS/400? (Clay Irving)
     Perl2awk or Perl2sed translators <hxk1076@cacs.usl.edu>
     Re: put data from web in a file (Geoffrey Hebert)
     Re: Reply to Ousterhout's reply (was Re: Ousterhout and (Charles Lin)
     Re: Reply to Ousterhout's reply (was Re: Ousterhout and <graham.matthews@maths.anu.edu.au>
     Re: Splitting Hairs, or strings, rather (Laurel Shimer)
     Transliterate from a pattern? (Jeff Vannest)
     Re: Unix and ease of use  (WAS: Who makes more ...) (Tom Wheeley)
     Re: Unix and ease of use  (WAS: Who makes more ...) (Tom Wheeley)
     Re: why can't arg 1 to shift be split? <merlyn@stonehenge.com>
     Win32 extension proposal <rothd@roth.netX>
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Fri, 11 Apr 1997 22:21:10 -0400
From: Jim Becker <jbecker@syssol.com>
Subject: "system" on NT
Message-Id: <334EF196.6ED5@syssol.com>

Hi all,

I'm new to Perl, so pardon me if the answer should be obvious...

Here's an excerpt of a Perl script:

$command = "c:\\apps\\blat\\blat $tempfile ";
$command .= "-t webmaster\@syssol.com ";
$command .= '-s "Request for Info" ';
$command .= "-i $input{'email'}" if $input{'email'};
print "<p>Command:<br>$command";
system("$command");

If I omit or comment out the system line, the script displays the
expected followup page, and the command it echoes works just right 
when issued at a command prompt.

If I include the system line, Netscape prompts me to save a file 
(by default, it gives me the script name). The file it's prompting me 
to save is the html generated by the script (that is, the stuff that's
supposed to go to STDOUT, I believe).

I'm running IIS 3.0, NT 4.0 sp2, Perl 5, and Blat 1.5. My browser
is Netscape 3.01 under Windows 95.

TIA for any assistance,

Jim Becker (jbecker@syssol.com)
System Solutions Incorporated (http://www.syssol.com)
ESILUG Chair (http://www.decus.org/decus/lugs/esilug)


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

Date: Fri, 11 Apr 1997 22:23:38 -0400
From: Jim Becker <jbecker@syssol.com>
Subject: "system" on NT
Message-Id: <334EF22A.66EA@syssol.com>

Hi all,

I'm new to Perl, so pardon me if the answer should be obvious...

Here's an excerpt of a Perl script:

$command = "c:\\apps\\blat\\blat $tempfile ";
$command .= "-t webmaster\@syssol.com ";
$command .= '-s "Request for Info" ';
$command .= "-i $input{'email'}" if $input{'email'};
print "<p>Command:<br>$command";
system("$command");

If I omit or comment out the system line, the script displays the
expected followup page, and the command it echoes works just right 
when issued at a command prompt.

If I include the system line, Netscape prompts me to save a file 
(with the script name as the default name). The file it's prompting 
me to save is the html generated by the script (that is, the stuff 
that should be going to STDOUT, if I understand correctly).

I'm running IIS 3.0, NT 4.0 sp2, Perl 5, and Blat 1.5. My browser
is Netscape 3.01 under Windows 95.

TIA,

Jim Becker (jbecker@syssol.com)
System Solutions Incorporated (http://www.syssol.com)
ESILUG Chair (http://www.decus.org/decus/lugs/esilug)


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

Date: 12 Apr 1997 02:36:33 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: @array as input symbol in <@array>
Message-Id: <5imsfh$i1b$1@csnews.cs.colorado.edu>

 [courtesy cc of this posting sent to cited author via email]

In comp.lang.perl.misc, autopen@quake.net (Laurel Shimer) writes:
:Well I'm fully willing to be one of those 'clueless idiots' you refer to
:in your next message, but I can't find any reference in my Camel book
:index to  (<*.c>) . What is that? Can you give me something to look up? I
:looked all through the  parenthesis section....

It's in there.

A "<" is not a "(" character.  If you look up "<", you'll find that on
page 623 there's a pretty sturdy index entry for this.  It includes a
mention of "file name globbing operator" on pp 55-57.

--tom
-- 
	Tom Christiansen	tchrist@jhereg.perl.com

Down that path lies madness.  On the other hand, the road to hell is
paved with melting snowballs. --Larry Wall in <1992Jul2.222039.26476@netlabs.com>


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

Date: Fri, 11 Apr 1997 23:51:03 -0400
From: Aaron Sherman <ajs@ajs.com>
Subject: Re: @array as input symbol in <@array>
Message-Id: <334F06A7.5E97@ajs.com>

Laurel Shimer wrote:
> 
> Well I'm fully willing to be one of those 'clueless idiots' you refer to
> in your next message, but I can't find any reference in my Camel book
> index to  (<*.c>) . What is that? Can you give me something to look up? I
> looked all through the  parenthesis section....
> 
> Laurel
> ---------
> 
> In article <5i5tg7$81t@picasso.op.net>, mjd@plover.com (Mark-Jason
> Dominus) wrote:
> 
> > Someone recently sent me a code sample that included
> >
> >         while (<@array>) {
> >           print $_, "\n";
> >         }
> >
> > and when I saw it, I said, ``Well, no wonder your program doesn't
> > work; you can't treat an array like a filehandle.''  But then I tried
> > it and it *did* work.
> >
> > So I wondered how I could have missed this feature in my extensive and
> > dilligent perusal of the manual, and I went back to chack, and I
> > couldn't find it in the manual this time either.  I have the manual
> > that came with 5.003_22, and the blue camel book, and I couldn't find
> > it in either place.
> >
> > Yes, I know about while (<*.c>) ..., but this isn't like that either.
> > It's something else.
> >
> > What I want to know is: *Is* this in the manual?  If so, where is 

Look under "glob" in perlfunc, or <> under perlop. It's there.

			-AJS

-- 
Aaron Sherman			"We are, all of us, living in the shadow of
Safety Net Solutions		 Manhatten." -The Watchmen
Email: ajs@ajs.com
WWW: http://ajs.com/~ajs/


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

Date: Sat, 12 Apr 1997 01:45:31 GMT
From: soccer@microserve.net (Geoffrey Hebert)
Subject: Re: Easy Perl Cookie Question.
Message-Id: <5imog5$98d$1@news3.microserve.net>

Yes you are lost.  

Forget the terminology server side includes, that is not a perl term.

Here is come code I use to set a cookie and then go to another
location.

You should read about how to do this.  There are several book on perl
and the web.  Besure you find one that has web examples.

sub setcookie {
    $now=time();
    $now=$now+(3600*24)*120;  # 1 hr * 24 * 120 = 120 days in future
    $time=gmtime($now);
    ($wday, $mon, $mday, $t_of_day, $year)= split/ /, $time;
    $newtime="$wday, $mday-$mon-$year $t_of_day GMT";
    $name=uc($p_subject);
    print "Set-Cookie: preview=binder; expires=$newtime;\n";
    print "Location: http://www.my.new.loaction.html\n\n";
    exit;
    return;
}


dico@peionline.com (Dico Reyers) wrote:

>Hello there...

>My problem:

>I have a web page and I want it to send the visitor a cookie when they
>arrive.  

>The way that I want to do this is in a server side includes call.  So
>when the person comes to the page, the page executes a SSI call that
>sends the cookie to the client.  How do I do this?

>#!/usr/local/bin/perl

>print "Content-type: text/html\n\n";

>Now what do I print to the browser?  (say for example that I only want
>to print the NAME=VALUE item, calling it customer=myself .)


>and after all that is said and done, how do I read this cookie, using
>much the same (server side includes) method.  And simply outputting
>the cookie to the screen? 

>I have looked around the internet for such information but I keep
>finding stuff that uses librarys, I want to have everything hard coded
>into my perl script.

>Any help would be appreciated.

>Thanks in advance,

>~Dico Reyers

>dico@peionline.com

Check out the Perl site!

http://www.microserve.net/~soccer/xref

use password perlmisc

Geat tool for Developers>



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

Date: Sat, 12 Apr 1997 02:30:22 GMT
From: soccer@microserve.net (Geoffrey Hebert)
Subject: Re: frameset
Message-Id: <5imr47$9jv$2@news3.microserve.net>

You are right.  This seems to be a browser function.  I use frames a
lot and have found I had to develop lots of work-arounds.
See site below for my solution to problem. follow the perl cross
reference path and remember to use perlmisc for password.



"David Baker" <dbaker@dkburnap.com> wrote:

>I need to bust out of a frameset when specific criteria is achieved.  How
>does the syntax look in the location: command?

>print "Location:../sreg/login.htm target='_top'\n\n";

>This isn't working...

>Thanks,

>David

Check out the Perl site!

http://www.microserve.net/~soccer/

use password perlmisc

Geat tool for Developers>



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

Date: Sat, 12 Apr 1997 11:24:46 +1000
From: Goce Dimitroski <goce@dcc.net.au>
Subject: HELP PERL AND CGI ??
Message-Id: <334EE45E.6BD2@dcc.net.au>


hi i am having a problem with my cgi script (written in perl ). I am
writting a network managenment software that will enable nt admin to be
able to backup and restores files from the host pc via the internet.

I am using forms.
I send the following to the perl script :-
the bk directory 
the bk method (via radio buttons tar ...)
the output bk file 

OK. how then can i join them all together so that it is one scentance
and will work

e.g. tar -cvf outputfile bk_directory 

please HELP


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

Date: Sat, 12 Apr 1997 02:39:53 GMT
From: soccer@microserve.net (Geoffrey Hebert)
Subject: Re: HTML document title
Message-Id: <5imrm1$9jv$4@news3.microserve.net>

I do not think we understand the question.

An html document can be read by perl script.
perl script can look for <title> in the beginning
and capture the data.

I think a better group is comp.infosystems.www.authoring.cgi

"David Baker" <dbaker@dkburnap.com> wrote:

>What is the best way to get this inf. from Perl?

>Thanks,

>David

Check out the Perl site!

http://www.microserve.net/~soccer/

use password perlmisc

Geat tool for Developers>



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

Date: Fri, 11 Apr 1997 23:49:35 -0400
From: Aaron Sherman <ajs@ajs.com>
Subject: Re: If Else construct?
Message-Id: <334F064F.516C@ajs.com>

Laurel Shimer wrote:
> 

> > I usually avoid religious discussions, but I have to do a little
> > proselytizing here.  || can be a bit cryptic to the uninitiate, and has
> > precedence problems besides. But in perl5 you can write
> >
> >   $arg eq "-n" or $arg = "-n"

Um, what about

	$arg = '-n' unless $arg eq '-n';

or

	$arg = '-n';  # ;-)

Sure, when the logic is simple this is fine. Now, do:

	if ($x == 7 && $n == 8) {
		if ($y == 4) {
			$z = 100;
		} elsif ($y == 80) {
			$z = 200;
		} elsif ($a < 10) {
			$z = 400;
		}
	} else {
		$y = $a - 200;
		$z = 20;
	}

Let's see, that's:

	(($x == 7 and $n == 8) &&
		(($y == 4 and $z = 100) ||
		 ($y == 80 and $z = 200) ||
		 ($a < 10 and $z = 400))) ||
	 ($y = $a - 200 and $z = 20)   		;# Not lisp, really

I think I'd rather match up if/elsif/elses than the parens. Also,
remember that this is all one statement, which makes debugging...
interesting.

			-AJS

-- 
Aaron Sherman			"We are, all of us, living in the shadow of
Safety Net Solutions		 Manhatten." -The Watchmen
Email: ajs@ajs.com
WWW: http://ajs.com/~ajs/


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

Date: Sat, 12 Apr 1997 02:35:27 GMT
From: soccer@microserve.net (Geoffrey Hebert)
Subject: Re: Is there a length limitation on CGI Posts (STDIN)?
Message-Id: <5imrdo$9jv$3@news3.microserve.net>

Look for another problem.  It is not a 2k limit problem.
At least I do not think it is.

Break the problem down to little steps.
break cgi into two scripts
One to send the form.  Have the form point to the second.
At first code a different second piece that just returns html
hello, I made it this far message.

pbaker@nwcs.net (Peter Baker) wrote:

>I have UnixWare 2.1 running Apache 1.2b7.  

>On this I am running a script that when sent post the complete form consist of about 2k worth 
>of data.

>The script is handled via perl 5.002 and CGI.pm.  When it runs on the command line and CGI.pm 
>is piped the form results all is ok.  Now when I run this off the server, the perl script 
>dumps core and there is no error in the logs.

>I am wondering if this is a problem with CGI.pm, STDIN or what?!

>Any ideas out there?

>-Peter

Check out the Perl site!

http://www.microserve.net/~soccer/

use password perlmisc

Geat tool for Developers>



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

Date: 12 Apr 1997 01:25:58 GMT
From: shodan@shodan.erols.com (Dave Schenet)
Subject: Mail header rewriting
Message-Id: <5imob6$6n3@boursy.news.erols.com>


I have a quick question.. I've written some scripts to automate some of
the more mundane tasks of registering IP addresses through a web page.
(Oooh. Spiffy.) heh. Anyway, the script takes input from a form, and mails
it off to the InterNIC. My problem is, the responses from NIC still need
to be read by a human, and the mail is being sent from the httpd process's
ID (i.e. nobody). What I need to do is somehow rewrite the From: line on
the mail so it points back to a designated address at my domain. I've
essentially been piping the completed form into /bin/mail... What I'm
thinking of doing is opening a telnet session to my own port 25 and issue
SMTP commands to send the email, since I can make up my own From: line
that way. 

I've almost gotten the script to work that way, it connects to the port
and immediatly disconnects (Sorry I can't post any code snippets; they're
on another machine right now).

Anyone have any ideas?

--Dave


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

Date: 12 Apr 1997 01:47:44 GMT
From: dblack@icarus.shu.edu (David Alan Black)
Subject: Re: parsing a line w/ quoted strings (newbie)
Message-Id: <5impk0$g7c@pirate.shu.edu>

Hello -

systech@polarnet.com (Ken Irving) writes:

>I'd like to parse an input line 
>	tag1=value1 tag2="a quoted string" tag3=value3

>into the hash
>	tag1 => value1 
>	tag2 => a quoted string 
>	tag3 => value3

>One way would be to replace whitespace between quotes with a special 
>value, delete the quotes, split on whitespace, then split on "=", 
>and finally restore the special value to whitespace. Is there an 
>easier way? Thanks.

No, but there are more compact ways :-)

#!/usr/bin/perl -w

$string = 'tag1=value1 tag2="a quoted string" tag3=value3';

%hash = ($string =~ /(\S+)="?([^"]+)\b"?(?:\s+|$)/g);


Commented version:

%hash = ($string =~ /
                (\S+)=      # non-space chars followed by =
                "?          # zero or one quotes
                ([^"]+)     # non-quote characters
                \b          # anchored on word boundary
                "?          # zero or one quotes
                (?:\s+|$)   # whitespace or end-of-string (don't return
                            #  as a submatch)
        /gx);



David Black
dblack@icarus.shu.edu


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

Date: Fri, 11 Apr 1997 17:47:11 -0700
From: autopen@quake.net (Laurel Shimer)
Subject: Re: Perl basics
Message-Id: <autopen-1104971747110001@l82.d22.quake.net>

To run a perl script called 'working', at the shell prompt, type 

perl working

or, if there are 2 versions of perl on the server and yours uses perl5
features, you may need to say

perl5 working

In article <01bc45b7$5e783840$966cafce@cactus>, "Geoff Mottram"
<minaret@sprynet.com> wrote:

> >    I've a perl program and my web serber can run it...I'd like to know if
> I
> > need to compile this program to run it. And if I need, How I do this ?
> 
> Since your web server can run your Perl script, you are all set.
> 
> Geoff Mottram
> minaret@sprynet.com

-- 
        The Reader's Corner: Mystery, Romance, Fantasy 
         http://www.autopen.com/index.shtml 
     Subscribe to our free StoryBytes publication
 New: Fashion Challenges for the Time Traveling Heroine     http://www.autopen.com/romance.well.dressed.shtml


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

Date: 11 Apr 1997 22:43:23 -0400
From: clay@panix.com (Clay Irving)
Subject: Re: Perl for AS/400?
Message-Id: <5imssb$kgc@panix.com>

In <5iljs5$h6b@news.ysu.edu> bob@cis.ysu.edu (Bob Hogue) writes:

>Is Perl availabe for the AS/400 platform?  If so, could someone point me
>to a site where I could find it?  Thanks for any help.

http://www.perl.com/perl/CPAN/ports/as400/

[ mailed and posted ]

-- 
Clay Irving                                        See the happy moron,
clay@panix.com                                     He doesn't give a damn,
http://www.panix.com/~clay                         I wish I were a moron,
                                                   My God! Perhaps I am!


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

Date: Fri, 11 Apr 1997 20:49:58 -0500
From: Harsha Krishnamurthy <hxk1076@cacs.usl.edu>
Subject: Perl2awk or Perl2sed translators
Message-Id: <334EEA46.41C67EA6@cacs.usl.edu>

Hello,

I am aware of the availability of awk2Perl translator. But could
anyone please let me know if there are Perl2awk or Perl2sed translators
available somewhere ? 

Thanks in advance for any information in this regard.

Harsha.K.


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

Date: Sat, 12 Apr 1997 02:12:27 GMT
From: soccer@microserve.net (Geoffrey Hebert)
Subject: Re: put data from web in a file
Message-Id: <5imq2k$9jv$1@news3.microserve.net>

Some questions, some answers, just enough to keep you looking.

check your file permissions.

Can you try this on the command line?  Does it work?

other problems see below

Bochenek Christophe <bchrist@cme.nist.gov> wrote:

>Hi,

>I have managed to make:
>- One CGI program which reads 2 numbers from an entry box (HTML program)
>on netscape, and prints the data.
>- one CGI program which opens a file and write a message in this file.

>Now I would like to read the 2 numbers on netscape, and write them in
>a file. But, when I push on validate, a message appears:"document 
>contains no data". My program:

>#! /usr/local/bin/perl
>print "Content-type: text/html\n\n";

>$donnee=<stdin>;
I do not know what this does (I am just a little more than a newbie
not much) in a web invironment.
Are you using get or post?


>open(FILEHANDLE,">filea");
   add   or (check to see that it opened, most likely did not)

>print FILEHANDLE "$donnee";
   send back something 
    print "<html>
    print <title>
    print <body>
    print "This is what I wrote $donnee\n";
    print </body>
    print </html>
>close FILEHANDLE;

If this did work what goes back to the web page?  No data.

>If I add: print($donnee),"\n"; before openning the file, the result is 
>written on the screen, but not in the file...

>	Christophe

Check out the Perl site!

http://www.microserve.net/~soccer/

use password perlmisc

Geat tool for Developers>



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

Date: 12 Apr 1997 00:26:10 GMT
From: clin@cs.umd.edu (Charles Lin)
Subject: Re: Reply to Ousterhout's reply (was Re: Ousterhout and Tcl ...)
Message-Id: <5imkr2$l1o@mimsy.cs.umd.edu>

John Ousterhout (ouster@tcl.eng.sun.com) wrote:
[...]
|| OK, enough is enough.  I can see that I'm not going to be able to fool you
|| guys.  I confess everything.  You're right.  It all *was* an evil
|| conspiracy.  There really isn't a shred of merit in Tcl, or C++, or Perl,
|| or C; there is not a single reason on earth why anyone should use any of
|| these languages for any programming task.  Scheme truly is the perfect
|| language that solves every problem and combines the virtues of every
|| other language.  For years we've been plotting to trick programmers into
|| using bad languages.  Yes, I mean "we".  Many many people have participated
|| in this sinister plot, including Larry Wall, Dennis Ritchie, Bill Gates,
|| the Bureau of ATF, most of the LAPD, and Mark Fuhrman (sorry you guys, but
|| the truth has overwhelmed me so I've been forced to expose you).  I feel
|| just terrible at how I have set the programming world back, and I promise
|| to be a good boy from now on.

     And suddenly, we're going to see this quote in the preface
of every Scheme book out there.    All 3 of them.

--
Charles Lin
clin@cs.umd.edu



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

Date: Sat, 12 Apr 1997 10:51:31 +1000
From: Graham Matthews <graham.matthews@maths.anu.edu.au>
Subject: Re: Reply to Ousterhout's reply (was Re: Ousterhout and Tcl ...)
Message-Id: <334EDC93.2376@maths.anu.edu.au>


John Ousterhout wrote:
> OK, enough is enough.  I can see that I'm not going to be able to fool you
> guys.  I confess everything.  You're right.  It all *was* an evil
> conspiracy.  There really isn't a shred of merit in Tcl, or C++, or Perl,
> or C; there is not a single reason on earth why anyone should use any of
> these languages for any programming task.  Scheme truly is the perfect
> language that solves every problem and combines the virtues of every
> other language.  For years we've been plotting to trick programmers into
> using bad languages.  Yes, I mean "we".  Many many people have participated
> in this sinister plot, including Larry Wall, Dennis Ritchie, Bill Gates,
> the Bureau of ATF, most of the LAPD, and Mark Fuhrman (sorry you guys, but
> the truth has overwhelmed me so I've been forced to expose you).  I feel
> just terrible at how I have set the programming world back, and I promise
> to be a good boy from now on.

John you overplay your hand. Almost no-one has suggested that there is
no merit in Tcl. What they have suggested is that some of the merits
*you are claiming* are not true. That is a very different claim.

I would like you ask you a question. You claim that the "everything is a
string" approach is the be-all-and-end-all, the way to go, etc, etc. Why
then has Tcl8.0 moved away from this philosophy?

grahm

-- 
                         On the streets tonight
                         The innocent are dying
                        And the world's not right
                         So many millions dying


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

Date: Fri, 11 Apr 1997 18:02:39 -0700
From: autopen@quake.net (Laurel Shimer)
Subject: Re: Splitting Hairs, or strings, rather
Message-Id: <autopen-1104971802390001@l82.d22.quake.net>

As usual Devin has a much more clever solution that I did. Well that's how
you learn this stuff. (Or does it just flow in by osmosis?)

My newsreader isn't showing this response, which came to me in email, so
I'm posting it, in case it didn't come through. Forgive me if this causes
a double posting. I know that Devin is very religious about sharing w/ the
group.

Laurel
-----------------------


Date: Fri, 11 Apr 1997 15:22:44 -0700
From: Devin Ben-Hur <dbenhur@egames.com>
Reply-To: dbenhur@egames.com
Organization: eGames.com, Inc.
MIME-Version: 1.0
Newsgroups: comp.lang.perl.misc
To: Laurel Shimer <autopen@quake.net>
CC: jkugler@inreach.com
Subject: Re: Splitting Hairs, or strings, rather

[mail&post]
Laurel Shimer wrote:
> In article <3346dc89.16327060@news.inreach.com>, jkugler@inreach.com
> (Joshua J. Kugler) wrote:
> > Hi.  I am looking for some efficient code to split strings in to 100
> > character sub strings.  I was given some, and have been concocting
[snip]
> > @arr = &splitter($var)

> Been trying to figure out how to do Joshua's 'break a string into chunks
> of 100'  and so far having no luck.
[snip rampling about methods]
> But am I on the right track with this?

A concise way to do this would be:
  @arr = $var =~ /(.{1,100})/gs;

In an array context the /g modifier makes the match operator
return a list of all (...) enclosed matching subexpressions.
The /s just makes . also match newlines.  So /.{1,100}/
matches 1 to 100 of any character.  Because of regex greediness,
this will match 100 character chunks for each iteration of
the /g except for at the end of the string if its length
is not a multiple of 100.

However, any method using regular expressions is probably 
going to be slower than using substr or unpack.  Here's two
reasonbly efficient solutions:

sub splitter1 {
  my $str = shift;   # string to split
  my $size = shift;  # size of chunks
  my $l = length $str;
  my @result = ();
  for ($i=0; $i < $l; $i += $size) {
    push(@result, substr($str,$i,$size));
  }
  return @result;
}

sub splitter2 {
  my $str = shift;
  my $size = shift;
  return unpack("A$size"x(length($str)/$size).'A*', $str);
}

Feel free to benchmark them yourself (see Benchmark.pm) 
to figure out what's fastest.

HTH
--
Devin Ben-Hur      <dbenhur@egames.com>
eGames.com, Inc.   http://www.egames.com/
eMarketing, Inc.   http://www.emarket.com/
"It's people like you wot cause unrest!"

-- 
        The Reader's Corner: Mystery, Romance, Fantasy 
         http://www.autopen.com/index.shtml 
     Subscribe to our free StoryBytes publication
 New: Fashion Challenges for the Time Traveling Heroine     http://www.autopen.com/romance.well.dressed.shtml


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

Date: Sat, 12 Apr 1997 02:03:29 GMT
From: jefflv@tir.com (Jeff Vannest)
Subject: Transliterate from a pattern?
Message-Id: <334eed3a.13080337@news.tir.com>

Does anyone know of a method of transliterating a string by a pattern?
It's not even really a transliteration; I want to delete leading and
trailing spaces from a string.

The tr// would work except that it deletes ALL spaces in the string
and will not recognize the patterns "^ "   (caret +space) or " $"
(space+dollar).


Any ideas?  currently I'm using:

$value  =~ /^ /;
if ($& eq " ") {
     $value = $';
}
$value  =~ / $/;
if ($& eq " ") {
     $value = $`;
}

but it looks WAY too clunky for me (although it works).

Thanks for your ideas.

Jeff Vannest
 ========================================
 Jeff Vannest, Web Technician
 South East Michigan Council of Governments
 http://www.semcog.org
 jefflv@tir.com


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

Date: Sat, 12 Apr 97 00:47:47 GMT
From: tomw@tsys.demon.co.uk (Tom Wheeley)
Subject: Re: Unix and ease of use  (WAS: Who makes more ...)
Message-Id: <860806067snz@tsys.demon.co.uk>

In article <5ili63$kad$1@earth.execpc.com>
           madings@earth.execpc.com "Steve Mading" writes:

> Besides, "lines of code" is an absolutely horrible way to measure
> source code.  Different indentation standards can as much as
> double the number of lines of code in programs that are syntactically
> exactly the same.  (Plus there's the issue of how much comments are
> used.)

IBM measured programmer's performace based on kLOC/hour (or whatever),
giving no priority as to the *quality* of that code...  I'll leave the
obvious results of that mismanagement to your imagination

-- 
:sb)



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

Date: Sat, 12 Apr 97 00:49:08 GMT
From: tomw@tsys.demon.co.uk (Tom Wheeley)
Subject: Re: Unix and ease of use  (WAS: Who makes more ...)
Message-Id: <860806148snz@tsys.demon.co.uk>

In article <01bc4681$20d9c740$87ee6fce@timpent.a-sis.com>
           tim@a-sis.com "Tim Behrendsen" writes:

> Timothy Watson <tmwatson@umich.edu> wrote in article
> <TMWATSON.97Apr10184314@lukyduk!.umich.edu>...
> > In article <01bc45c0$691ee100$87ee6fce@timpent.a-sis.com> "Tim
> > Behrendsen" <tim@a-sis.com> writes:
> > > Perl4 is 33800 LOC (including comments, blank lines, etc), and Perl5
> > > is 51718.
> > 
> > How about GRASS GIS (Geographical Information System) by the US Army
> > Corp of Engineers? That's HUGE.
> 
> I don't think you can call software developed by US Army "free"
> software, even if it's freely distributed, since the people who
> developed it were paid to do it.

Thus gcc is not free software?  The FSF employ a good few people now.  Money
has absolutely nothing to do with the free-ness of software, save as a way
of preventing its programmers from starving.

-- 
:sb)



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

Date: 11 Apr 1997 18:40:30 -0700
From: Randal Schwartz <merlyn@stonehenge.com>
To: mcravit@shell3.ba.best.com (Matthew Cravit)
Subject: Re: why can't arg 1 to shift be split?
Message-Id: <8ck9m9j9wx.fsf@gadget.cscaper.com>

>>>>> "Matthew" == Matthew Cravit <mcravit@shell3.ba.best.com> writes:

Matthew> I'm not sure precisely why the example you gave doesn't work;
Matthew> my guess would be that it has something to do with the shift
Matthew> not being able to tell if split is returning a list or a
Matthew> scalar. That's only a guess, though.

Not bad, as guesses go. :-)

shift needs an *array variable*[1] as an argument, because shift has to
*change* something.  It's actually a pretty consistent rule, once you
get used to it.

[1] Well, technically, an array "lvalue".

print "Just another Perl hacker," # but not what the media calls "hacker!" :-)
## legal fund: $20,495.69 collected, $182,159.85 spent; just 507 more days
## before I go to *prison* for 90 days; email fund@stonehenge.com for details

-- 
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@ora.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me


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

Date: 12 Apr 1997 02:23:27 GMT
From: "Dave Roth" <rothd@roth.netX>
Subject: Win32 extension proposal
Message-Id: <01bc46e8$40610b70$16906ec6@main2>

Here is a thought for use Win32 hacks. How about an extension that will
allow us to send keys and messages to targeted windows? Since Win32 is so
damned GUI that you can not get most of your work done without mouse clicks
or keystrokes it would be rather useful for the ability to tell a window to
do things for you.
Since most of the administrative tasks I perform are not on OLE server
applications it seems to me that we could all benefit from this type of
extension.

Anyone willing? I'm finishing a new Win32 extension so I am counting me out
but is anyone else interested??

dave

-- 
================================================================
Dave Roth                               ...glittering prizes and
Roth Consulting                     endless compromises, shatter
rothd@roth.net                         the illusion of integrity

 My email address is disguised to fool automailers. Remove the
                 trailing 'X' to send me email.
****************************************************************
Use of  this message or  email address  for commercial  purposes
(including "junk" mailings) is strictly prohibited and protected
under  current  international  copyright laws  and United States
Code, Title 47, Chapter 5, Subchapter II.



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

Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 8 Mar 97)
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.misc (and this Digest), send your
article to perl-users@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.

The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.

The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.

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 V8 Issue 285
*************************************

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