[16960] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4372 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Sep 19 09:05:24 2000

Date: Tue, 19 Sep 2000 06:05:08 -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: <969368708-v9-i4372@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Tue, 19 Sep 2000     Volume: 9 Number: 4372

Today's topics:
    Re: 2 Questions <unicon@btconnect.com>
    Re: 2 Questions <andkaha@hello.to.REMOVE>
    Re: Email.pm and file attachments <alian@alianwebserver.com>
        Embed the perl mister <tom@hughesmedia.co.uk>
    Re: Form to Email with FILE UPLOAD HELP!!! <alian@alianwebserver.com>
    Re: Gratuitous incompatibilities (Was: Re: Range operat <bcaligari@my-deja.com>
    Re: HELP  on  NetServer::Generic <arolfes@dds.nl>
    Re: Help with Date geoff@jungle.com
    Re: How to Use strict with Find::File <alian@alianwebserver.com>
    Re: HTTP::Request lil prob <alian@alianwebserver.com>
        Newbie question <silvo.vidovic@tel.net.ba>
    Re: One program w/ many languages (Richard Bos)
        password authentication using text files and forms <powlow@my-deja.com>
    Re: password authentication using text files and forms (Tony L. Svanstrom)
    Re: Pure perl encrypt/decryption? grymoire@my-deja.com
        Regex Problem <jonfarmer@enta.net>
    Re: Regex Problem <stephenk@cc.gatech.edu>
    Re: Regex Problem <bcaligari@my-deja.com>
    Re: Regex Problem (Philip Lees)
        regexp problem <richard@green-it.com.au>
    Re: Req.: The perfect Perl Editor? <dafsdsfa@ccc.sh>
    Re: Substring Golf? <pdcawley@bofh.org.uk>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Tue, 19 Sep 2000 13:06:40 +0100
From: jfp <unicon@btconnect.com>
Subject: Re: 2 Questions
Message-Id: <39C756D0.9CB0D6F1@btconnect.com>

Looking at this thread as a whole nobody recommends Perl as a first language
then?........

Has anyone here learnt Perl first?

jfp





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

Date: 19 Sep 2000 14:21:32 +0100
From: Andreas Kähäri <andkaha@hello.to.REMOVE>
Subject: Re: 2 Questions
Message-Id: <39c75a4c@merganser.its.uu.se>

In article <39C756D0.9CB0D6F1@btconnect.com>,
jfp  <unicon@btconnect.com> wrote:
>Looking at this thread as a whole nobody recommends Perl as a first language
>then?........
>
>Has anyone here learnt Perl first?
>
>jfp
>
>
>

<offtopic where="in many NGs">

IMHO, a language like Perl (non-standard, huge, extensible, tons of
libraries) might be a little bit too much for a complete newbie to
comprehend (that goes for Java and C++ too). My first real language
was Pascal. Its complete grammar may be written on at most 2 sheets of
A4 paper. Yes, you're confined in a very tight space where you're not
allowed to do very much, but you can learn a lot about programming
from it.

[Non-visual, just ordinary] Basic is another good first language.

</offtopic>

/A

-- 
Andreas Kähäri, <URL:http://hello.to/andkaha/>. Junk mail, no.
------------------------------------------------------------------------
Be alert! The world needs more lerts.



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

Date: Tue, 19 Sep 2000 14:18:31 +0200
From: Alain BARBET <alian@alianwebserver.com>
Subject: Re: Email.pm and file attachments
Message-Id: <39C75997.740411AE@alianwebserver.com>

Hi,

See "Re:Form to Email with FILE UPLOAD HELP!!!"
--
Alain & Estelle BARBET
http://www.alianwebserver.com


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

Date: Tue, 19 Sep 2000 12:04:12 +0100
From: Tom Fotheringham <tom@hughesmedia.co.uk>
Subject: Embed the perl mister
Message-Id: <39C7482C.2EED3618@hughesmedia.co.uk>

I really want to use Perl in a similar way as PHP.  How can I embed perl
programs into HTML.  One way I thought of doing it was to read in top
and bottom HTML pages from within perl and the output them.

Can anyone shed some light on a more convientient way of doing it?
Any pointers would be gratefully recieved.

Tom
:wq




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

Date: Tue, 19 Sep 2000 14:16:06 +0200
From: Alain BARBET <alian@alianwebserver.com>
Subject: Re: Form to Email with FILE UPLOAD HELP!!!
Message-Id: <39C75906.F15D2FB2@alianwebserver.com>

Hi,

> #!/usr/local/bin/perl5
> push (@INC, '/cgi-bin');
> require ('cgi-lib.pl');

mmmh ...
Use CGI.pm for read your param !
use CGI.pm

> # This should match the mail program on your system.
> $mailprog = '/usr/lib/sendmail';
> 
> # This should be set to the username or alias that processes the
> # requests
> 
> #------ Change 1 ----- Replace the login with your actual login name
> 
> $recipient = "webmaster\@jmbprod.com";
> 
> # Print out a content-type for HTTP/1.0 compatibility
> print "Content-type: text/html\n\n";
> # Print a title and initial heading
> print "<Head><Title>FORM2EMAIL WITH FILE UPLOAD</Title></Head>";

print header,start_html('FORM2EMAIL WITH FILE UPLOAD');

> &ReadParse;
unuseful with CGI.pm

> open (MAIL, "|$mailprog $recipient") || die "Unable to send
 ...
> foreach $i (0 .. $#in_key){
> #print "$in_key[$i] = $in_val[$i], i = $i <p>";
> print MAIL "$in_key[$i] = $in_val[$i]\n";

By this way you make two mistakes:
1/ File are not read by same way that other param.
2/ You can't attach file in a mail by this way.
For do what you want, you must:
1/Use method post and ENCTYPE=multipart/form-data in your form
2/Obtain path of your file on the server:
my $tmpfile=tmpFileName(param('file'));
3/Use the module MIME::Lite to attach your file on the mail

> And the cgi-lib  looks like:

Thanks, we know it ;-)

HTH,
--
Alain & Estelle BARBET
http://www.alianwebserver.com


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

Date: Tue, 19 Sep 2000 10:52:16 GMT
From: Brendon Caligari <bcaligari@my-deja.com>
Subject: Re: Gratuitous incompatibilities (Was: Re: Range operator with "... /^$/")
Message-Id: <8q7ggs$4f0$1@nnrp1.deja.com>

In article <MPG.1430b47af67004c198ad8e@nntp.hpl.hp.com>,
  Larry Rosler <lr@hpl.hp.com> wrote:
> In article <8q6ui9$gla$1@nnrp1.deja.com>, bcaligari@my-deja.com
says...
>
> ...
>
> > I always wondered why the people who came up with dos years
> > ago wanted 2 characters to mark an end of line.
>
> It made it trivial to generate the two motions needed to reposition a
> teletypewriter (Carriage Return plus Line Feed) directly from the
data
> stream (from a file, say), without needing a device driver (shudder!)
to
> interpret the two characters from a single-character logical
> representation of New Line.  Think 'raw' mode.
>
> The Unix use of a single character to represent New Line was clever;
the
> use of the character literally implementing Line Feed ("\12") instead
of
> an otherwise unused control character led to confusion.  Apple's
choice
> of Carriage Return ("\15") for the same logical function compounded
the
> confusion.
>
> Data interchangeability or program portability or programmer
> interoperability never entered into any of these willfully obtuse
> decisions (such as file-path separators '/', '\\', or ':').
> Differentiation on these trivia seemed a commercial virtue, not an
evil.
> We are still paying the price for these sins.

cool...thanks :) Lol...at least some wise guy had the
foresight to commission a 'standard' networking protocol.
Can you imagine what the world would have been like
without TCP/IP?

platform independence was one of the reasons why I decided
to learn perl.  I have replaced most of the compiled C code
I had running (log file filters, email gateways to a variety
of stuff, etc) to sed / perl (I love sed...awk I shelved
since starting perl except for short one liners in shell
scripts).  I cannot but say that my life has been made
way simpler...and manegeable!!!

Once I am comfortable with perl (still a semi-clueless
newbie) I intend to learn some Java.  All the things I
have worked on so far are all running silently in the
background....away from prying eyes.  I want to be in
a position to write some apps that run on user computers
and originally meant to learn some VC++.  I gave up
when I saw the complexity and haphazardness of windows
programming and when I saw some Java based apps (management
tools for networking products) I got sold to the idea.

I think web/java front end and back end processing on
perl / java / sql to be quite sound and future/platform
proof.  Guess it's up to the market to decide the ultimate
fate of us common mortals.

Brendon
++++


Brendon
++++


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


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

Date: Tue, 19 Sep 2000 13:37:01 +0200
From: MegaNerd <arolfes@dds.nl>
Subject: Re: HELP  on  NetServer::Generic
Message-Id: <C03HOXpOA0tTNA1EzBPqyqDzpPO4@4ax.com>


Thanks a lot pal! This is *exactly* what i need! I use this
serverscript in conjunction with the telnet module on the client-side.
I'm now able to give response (i.e. result of database transaction) on
a request.

I use it for the following:

Web-Client (via cgi-script) sends a request for a
server-utilization-report (SAR) to a server somewhere in the backyard.

Server sends a well-formated (HTML) report back on the socket,
cgi-script lurks the report and passes it to the browser.

This way of working is much safer than getting the report with rsh
(which i used before).



On 18 Sep 2000 15:41:16 -0500, Ted Zlatanov <tzz@iglou.com> wrote:

>In article <hOPFOcWESZFqTMGde=SBsLx+XSFa@4ax.com>, MegaNerd wrote:
>>Trying to build a server which responses on requests to a specific
>>TCP-port.
>>
>>I saw that NetServer::Generic can provide such a service. Has anyone a
>>working script? I can't get the examples in the documention to work.
>
>The code following works OK.  Though it is not mentioned in the docs, the
>hostname('') invocation must be done before things will work - the default is
>to reject connections, I think.  Corrections are welcome :)
>
>#!/usr/bin/perl -w
>use strict;
>use NetServer::Generic;
>
>my $server_cb = sub 
>{
> my $s = shift;
> # just use STDIN and STDOUT here to read/write from the socket
> # the child process will exit at the end of the subroutine
>};
>
>my $server = new NetServer::Generic;
># for debugging:
>#$NetServer::Debug = 1;
>$server->hostname(''); # allow all hosts to connect
>$server->port(5555);
>$server->callback($server_cb);
>$server->mode("forking");
>$server->run();



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

Date: Tue, 19 Sep 2000 11:36:57 +0000
From: geoff@jungle.com
To: Keat <Keat@beal.org.uk>
Subject: Re: Help with Date
Message-Id: <39C74FD9.6CB981B4@jungle.com>

Keat wrote:
>       $date = "on $days[$wday], $months[$mon] $mday, 19$year at
> $hour:$min:$sec";
>       print FILE "<!--time--><b>Last use was added $date</b><hr>\n";
> 

Human perpetuated y2k issue is your problem:

What you need to be aware is that Perl (in particular localtime(time) )
sees years as starting from 1900 ie. 2000 = 100 in Perl speak. 

Your $date is a string being 'created' by interpolating variables (ie
$year, $mday etc) and relying on saying 19$year to concatenate 19 with
$year - WRONG!. 

Simple solution is to remember that localtime returns years since 1900
and to simply add 1900 to that value.

ie.
## START CODE ##
     ($sec,$min,$hour,$mday,$mon,$year,$wday) =
(localtime(time))[0,1,2,3,4,5,6];
      if ($sec < 10) { $sec = "0$sec"; }
      if ($min < 10) { $min = "0$min"; }
      if ($hour < 10) { $hour = "0$hour"; }
      if ($mday < 10) { $mday = "0$mday"; }
      $year = 1900 + $year;
      # ^^^^^^^^^^^^^^^^^^^^^
      # add this to make $year 'human' readable

      $date = "on $days[$wday], $months[$mon] $mday, $year at
$hour:$min:$sec";
      #                                               ^ remove '19'
      #
      print FILE "<!--time--><b>Last use was added $date</b><hr>\n";

## END CODE ##


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

Date: Tue, 19 Sep 2000 14:05:01 +0200
From: Alain BARBET <alian@alianwebserver.com>
Subject: Re: How to Use strict with Find::File
Message-Id: <39C7566D.6416A5C3@alianwebserver.com>

Hi, 

Define yout list outside of function :
use strict;
my @FileList;
sub main {}
sub FileTraitment {}

> PS: by the way does any one know a good, simple, clear, and free
> Perl Paper that don't assume you know UNIX.

You don't like perldoc ?
--
Alain & Estelle BARBET
http://www.alianwebserver.com


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

Date: Tue, 19 Sep 2000 14:20:02 +0200
From: Alain BARBET <alian@alianwebserver.com>
Subject: Re: HTTP::Request lil prob
Message-Id: <39C759F2.12AFC5F0@alianwebserver.com>

Hi,

> Why do keep getting "Error: 400 URL is missing" but when I paste it in
> the browser it works fine ?
>                 my $req = HTTP::Request->new
> (POST 'http://testserver/commerce/shop/shop/esdposttest.asp',

When you test in browser, you use method "GET". May be error come from
here ?
HTH,
--
Alain & Estelle BARBET
http://www.alianwebserver.com


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

Date: Tue, 19 Sep 2000 14:13:31 +0200
From: "Silvo" <silvo.vidovic@tel.net.ba>
Subject: Newbie question
Message-Id: <8q7lbh$9jvu$1@as121.tel.hr>

How can I extract the Header and Record size of a DBF file opend in Perl
with
the open statement ?
Or, this will do it too, how to get the ASCII value of a character?

Please help.

Regards
Silvo






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

Date: Tue, 19 Sep 2000 11:02:54 GMT
From: info@hoekstra-uitgeverij.nl (Richard Bos)
Subject: Re: One program w/ many languages
Message-Id: <39c74227.610139199@news.worldonline.nl>

Kevin D. Quitt <KQuitt@IEEInc.com> wrote:

[ With the comments removed and the ^s changed to spaces. ]

> (*O); 
> int i;
> main () {
>   i=printf ("hello polyglots\n");
> }

You call a variadic function without a prototype in scope; that means
you have undefined behaviour and this is not, actually, a correct C
program. Using puts() instead of printf() would make this somewhat more
correct, though a C99 compiler would still complain, and would demand
you explicitely declare main() to return int as well.
Either way, you don't need i, at least not for C.

Richard


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

Date: Tue, 19 Sep 2000 11:16:21 GMT
From: Powlow <powlow@my-deja.com>
Subject: password authentication using text files and forms
Message-Id: <8q7htq$607$1@nnrp1.deja.com>

hey,

i'm trying to authorise a user using a script that gets a user's input
from a form.

the form elements show up fine. then i open a file that is the user's
name. in that file, there are two lines. a password and a greeting.
these seem to have an extra something on the end and i can't figure it
out.
 i thought it was a space (tried s/ // but that didn't work) then i
thought it was a newline (used chomp and that didn't work).

anyone have any ideas?

here's the whole script.

#!/usr/local/bin/perl
print   <<EOT;
Content-type: text/html

<Title>|fuck| </Title>
<H1>eat it</H1>
EOT

read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); # read form data
@pairs = split(/&/, $buffer);                 # split into pairs
foreach $pair (@pairs) {                      # seperate each pair
  ($name, $value) = split(/=/, $pair);
  $value =~ tr/+/ /;
  $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
  $FORM{$name} = $value;                      # $FORM now contains
}                                             # organized form data

$namein = $FORM{'user'};    # Now we can get user

$passin = $FORM{'pass'};    # name and password

open(USERFILE,$namein) or die("Couldn't get to your details
file...$namein : $!");
flock(USERFILE,0);   # lock file and start reading from start of file
(the 0)

$eatit = <USERFILE>;       # reads first line of USERFILE into variable
$mess = <USERFILE>;	   # reads next line of USERFILE into variable

#$eatit =~ s/ //;	   # remove trailing space when reading from
file
chomp($eatit);

close(USERFILE);

if ($passin eq $eatit) {
print   <<YEAH;

<Title>|fuck| </Title>
<H1>you got it right stupid</H1>
YEAH
details();
}

else {
print   <<NO;

<Title>|fuck| </Title>
<H1>no access...get it right stupid</H1>
NO
details();
}

sub details{
print   <<DET;

<h1>$namein</h1>
<h1>$passin</h1>
<h1>$eatit</h1>
<h1>$mess</h1>
<h1>$ENV{'HTTP_REFERER'}</h1>
<h1>$ENV{'SCRIPT_NAME'}</h1>
DET
print "$eatit";
}


this will be changed so the user is directed to a page if he's
authorised and another if he's not.

hope to hear from someone
thanks
-powlow
--
___________________________
       http://powlow.com/
___________________________

--
___________________________
       http://powlow.com/
___________________________

--
___________________________
       http://powlow.com/
___________________________


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


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

Date: Tue, 19 Sep 2000 13:45:44 +0200
From: tony@svanstrom.com (Tony L. Svanstrom)
Subject: Re: password authentication using text files and forms
Message-Id: <1eh7kti.j912v71y8sbvaN%tony@svanstrom.com>

Powlow <powlow@my-deja.com> wrote:

> #$eatit =~ s/ //;        # remove trailing space when reading from

Correction: Removes the first space, and nothing else (unless, as in
this case, it's been commented out of the action...).


     /Tony
-- 
     /\___/\ Who would you like to read your messages today? /\___/\
     \_@ @_/  Protect your privacy:  <http://www.pgpi.com/>  \_@ @_/
 --oOO-(_)-OOo---------------------------------------------oOO-(_)-OOo--
   on the verge of frenzy - i think my mask of sanity is about to slip
 ---ôôô---ôôô-----------------------------------------------ôôô---ôôô---
    \O/   \O/  ©99-00 <http://www.svanstrom.com/?ref=news>  \O/   \O/


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

Date: Tue, 19 Sep 2000 10:38:07 GMT
From: grymoire@my-deja.com
Subject: Re: Pure perl encrypt/decryption?
Message-Id: <8q7fmf$3pm$1@nnrp1.deja.com>

In article <8q60qe$eni$1@nnrp1.deja.com>,
  grymoire@my-deja.com wrote:

> That should do it! Thanks!
Oops! it only encrypts the first 8 characters.
I'll have to do it in chunks, I guess


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


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

Date: Tue, 19 Sep 2000 11:44:37 +0100
From: "Jon Farmer" <jonfarmer@enta.net>
Subject: Regex Problem
Message-Id: <39c74981.0@energise.enta.net>

I am a total newbie to Regex's and know that this one is totally out of my
league at the moment. So if anyone can help me I would be most grateful.

I need to search a database of telephone numbers for memorable numbers. Most
of the template searches I can handle without a problem however the
following is giving me a right headache.

I need to search for numbers which match the pattern

xxyyzz

where x,y,z are a number between 0-9 and where the number x,y,z is set to is
unique..

so for instance it would match..

334466

but not

333444

Anyone have any ideas on how to do this?

Regards



--
Jon Farmer
Web Architecture Development
ENTANET International Ltd.







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

Date: Tue, 19 Sep 2000 07:45:05 -0400
From: Stephen Kloder <stephenk@cc.gatech.edu>
Subject: Re: Regex Problem
Message-Id: <39C751C1.C073EEA5@cc.gatech.edu>

Jon Farmer wrote:

> I am a total newbie to Regex's and know that this one is totally out of my
> league at the moment. So if anyone can help me I would be most grateful.
>
> I need to search a database of telephone numbers for memorable numbers. Most
> of the template searches I can handle without a problem however the
> following is giving me a right headache.
>
> I need to search for numbers which match the pattern
>
> xxyyzz
>
> where x,y,z are a number between 0-9 and where the number x,y,z is set to is
> unique..
>
> so for instance it would match..
>
> 334466
>
> but not
>
> 333444
>
> Anyone have any ideas on how to do this?
>

You can use backreferences to check for repititions:
$num =~ /^(\d)\1(\d)\2(\d)\3$/ && $num !~ /(.).+\1/
The first regex checks for the pattern xxyyzz, and the second makes sure x != y
!= z.

Recall that the substring that matches the contents of first set of parentheses
is stored in $1, and can be searched for in a regex with \1.  Similar for $2 and
\2, $3 and \3, etc.

perldoc perlre

--
Stephen Kloder               |   "I say what it occurs to me to say.
stephenk@cc.gatech.edu       |      More I cannot say."
Phone 404-874-6584           |   -- The Man in the Shack
ICQ #65153895                |            be :- think.




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

Date: Tue, 19 Sep 2000 11:50:41 GMT
From: Brendon Caligari <bcaligari@my-deja.com>
Subject: Re: Regex Problem
Message-Id: <8q7jua$88a$1@nnrp1.deja.com>

In article <39c74981.0@energise.enta.net>,
  "Jon Farmer" <jonfarmer@enta.net> wrote:
> I need to search for numbers which match the pattern
>
> xxyyzz
>
> where x,y,z are a number between 0-9 and where the number x,y,z is
set to is
> unique..
>
> so for instance it would match..
>
> 334466
>
> but not
>
> 333444
>
	if (m/(\d)\1(\d)\2(\d)\3\b/)	{
		print("Matched\n");
	}
	else	{
		print("Not Matched\n");
	}

ie..match a digit....match the previous match...
 ...for three times
the \b means word boundary

Brendon
Just Another Clueless Newbie


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


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

Date: Tue, 19 Sep 2000 11:55:50 GMT
From: pjlees@ics.forthcomingevents.gr (Philip Lees)
Subject: Re: Regex Problem
Message-Id: <39c752a9.15281383@news.grnet.gr>

On Tue, 19 Sep 2000 11:44:37 +0100, "Jon Farmer" <jonfarmer@enta.net>
wrote:

>I am a total newbie to Regex's and know that this one is totally out of my
>league at the moment. So if anyone can help me I would be most grateful.

I'm a newbie too, so this advice is worth what you paid for it - I'm
sure some of the others here will come up with something much better.
However, I was looking for a regexp-ish problem to play around with at
the time I read your post.

>I need to search for numbers which match the pattern
>
>xxyyzz
>
>where x,y,z are a number between 0-9 and where the number x,y,z is set to is
>unique..
>
>so for instance it would match..
>
>334466
>
>but not
>
>333444

Given the caveats above, and if I've understood your requirements
correctly, the following seems to do what you want.

#!perl -w

use strict;

my @phones = ( '223344', '123456', '555555', '334433', '334466',
'333444', 'abcdef', '121212', '1a2b3c', '      ' );

foreach ( @phones ) {
	print;
	s/(\d)\1(?!\1)(\d)\2(?!\1|\2)(\d)\3/$1$1$2$2$3$3/ or print "
Invalid!";
	print " $_\n";
}


Phil
--
Philip Lees
ICS-FORTH, Heraklion, Crete, Greece
Ignore coming events if you wish to send me e-mail
'The aim of high technology should be to simplify, not complicate' - Hans Christian von Baeyer


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

Date: Tue, 19 Sep 2000 23:29:29 +1100
From: Richard Green <richard@green-it.com.au>
Subject: regexp problem
Message-Id: <39C75C29.BE49DD79@green-it.com.au>


I'm new to regular expressions, so any help with this is much
appreciated to solve this problem, which arises from a script to sort
out a web site which was made on Windoze and need to be tidied up before
moving to a UNIX system.


	$_ = "Some other stuff then ../Dir2/Dir3/File Name.HTML 
	and again ../Dir2/Dir3/File Name.HTML ";

I want to replace the matching right hand side part of the string 

	"/Dir1/Dir2/Dir3/File Name.HTML" 

with the equivalent right hand side part of 

	"/dir1/dir2/dir3/file_name.html" 

thus  returning $_ as 

	"Some other stuff then ../dir2/dir3/file_name.html and 
	again ../dir2/dir3/file_name.html "

The two strings used in the substitution are known, and always have the
same number of characters, so it is a matter of matching the right most
part of the test string and substituting it with a similar number of
characters from the right-hand side of the substitution string.

If it isn't possible to substitute using s/// matching and returning the
position and length of the substring would be ok.

Thanks & regards

Richard Green
In Olympic Sydney 2000


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

Date: 19 Sep 2000 12:01:38 GMT
From: "afdsfds" <dafsdsfa@ccc.sh>
Subject: Re: Req.: The perfect Perl Editor?
Message-Id: <01c02231$5dc509f0$5b23940a@u45333>

I like to use synedit http://www.mkidesign.com/synedit/ or pfe.
Ramesh

Marshall Neill <mzardoz@worldnet.att.net> schrieb im Beitrag
<ssdjtbimf25i4f@corp.supernews.com>...
> Gentlemen;
> I've just started programming in Perl and found that TextPad 4 is quite 
> useful.  It has highlighting, auto indenting, etc.  Perhaps you would 
> check that one out.  $27 for the Single-User version.
> I've been to more sites UltraEdit, SynEdit,Vim, visiPerl, etc.  All the 
> editors just don't seem to come up to TextPad 4.
> Apologies to Unix/Linux users, I believe this is Windows only.
> Anyway that's my 2 cents worth to this discussion.
> Tim Hammerquist wrote:
> > 
> > 
> > Abigail <abigail@foad.org> wrote:
> > > Tim Hammerquist (tim@degree.ath.cx) wrote
> > > ][ I'll tell you what I use in order of preference:
> > > ][ 
> > > ][ Unix/Linux:
> > > ][ vim( http://www.vim.org )
> > > ][ nvi, vile, or vanilla vi
> > > ][ pico
> > > ][ emacs
> > > ][ On Win32:
> > > ][ Win32 port of vim( http://www.vim.org )
> > > ][ UltraEdit-32( http://www.ultraedit.com ; ~US$30 )
> > > ][ Homesite 4.x( http://www.allaire.com ; ~US$90 )
> > > ][ Notepad
> > > 
> > > That's quite a range of editors! My use is far more limited:
> > > 
> > > Unix:   vile
> > >         vi
> > >         ed
> > > 
> > > Wind32: I don't do Windows. ;-)
> > 
> > Well, I had to use something before my life was greatly improved by
> > linux.  And when I do get stuck on Windows (clients' putas, usually), I
> > like to use something.
> > 
> > Plus, I like to try everything at least once.  Those are just the
> > editors in which I program effectively, not necessarily that I use on a
> > regular basis.
> > 
> > -- 
> > -Tim Hammerquist <timmy@cpan.org>
> > The great tragedy of Science -- the slaying
> > of a beautiful hypothesis by an ugly fact.
> > -- Thomas Henry Huxley
> 
> 
> --
> Posted via CNET Help.com
> http://www.help.com/
> 


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

Date: 19 Sep 2000 12:17:43 +0100
From: Piers Cawley <pdcawley@bofh.org.uk>
Subject: Re: Substring Golf?
Message-Id: <m1ya0oeilj.fsf@rt158.private.realtime.co.uk>

Ren Maddox <ren.maddox@tivoli.com> writes:

> Larry Rosler <lr@hpl.hp.com> writes:
> 
> > > my($num=shift)=~y/ //d;($numa,$numb,$numc,$numd)=split/(.{4})/,$num
> > > 
> > > It's quite short, and reasonably neat...
> > 
> > It would be much neater if it compiled correctly.
> 
> After fixing the syntax error, it would be even neater if it actually
> did what it was purported to do:
> 
> $ perl -e '(my $num=shift)=~y/ //d;
> ($numa,$numb,$numc,$numd)=split/(.{4})/,$num;
> print "$num=>", join ":", $numa, $numb, $numc, $numd, "\n";' 123456789012345
> 
> Gives:
> 123456789012345=>:1234::5678:
> 
> Gotta watch out when you use split and want only the delimiters --
> that's not what you get.

Argh. Repeats to self: "Always *check* the code before posting"

-- 
Piers


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

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


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