[17995] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 155 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Jan 27 03:05:42 2001

Date: Sat, 27 Jan 2001 00:05:08 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <980582707-v10-i155@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Sat, 27 Jan 2001     Volume: 10 Number: 155

Today's topics:
    Re: Basic string question  (Craig Berry)
    Re: Form Processing - newbie question (David Efflandt)
    Re: Form Processing - newbie question <paanwa@hotmail.com>
        help on getting parameter value of GET <vinaip@singnet.com.sg>
    Re: How to connect/disconnect a PPPoE DSL connection w. <bcaligari@my-deja.com>
    Re: Internal Server Error- Newbie Question. <apbeatty@yahoo.com>
    Re: Internal Server Error- Newbie Question. (Eric Bohlman)
        locking an NDBM_File with a semaphore file <johnm@acadiacom.net>
    Re: locking an NDBM_File with a semaphore file (Garry Williams)
    Re: MS Access <a565a87@my-deja.com>
        Object Oriented newbie dilemma <jeano@my-deja.com>
    Re: Object Oriented newbie dilemma <joe+usenet@sunstarsys.com>
        OOP: How to point/reference on a Class? <soeder@ai-lab.fh-furtwangen.de>
    Re: perl editors <kevin@vaildc.net>
    Re: perl editors (Rich Lafferty)
    Re: Perl Style Guide - uncuddled elses (Garry Williams)
    Re: Perl Style Guide - uncuddled elses <uri@sysarch.com>
    Re: regex question (Craig Berry)
    Re: Regular expression question (Garry Williams)
    Re: Regular expression question (Garry Williams)
    Re: Script to "rotate" the chars in a string. (Craig Berry)
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Sat, 27 Jan 2001 07:28:08 -0000
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Basic string question 
Message-Id: <t74u4892v7m472@corp.supernews.com>

nesta (nesta@psi.com.mx) wrote:
: Is there a way to divide a string in letters and put each element into an
: array ?

See the doc on the split function (perldoc -f split).  However, note that
most of the time, treating a string as an array of characters indicates
that you're on the wrong design path.  It's generally more productive to
use regexes and substr to operate directly on the intact string.

: $string = "something "
: @array = split (/\w/,$string);

That's telling split that \w (word) characters are the boundaries on which
to split, not the items to be found inside the resulting array.

: but @array always is empty.

Also, notice that the result array isn't actually empty in your example: 

  $string = "something ";
  @array = split (/\w/,$string);
  print "[$_]" foreach @array;

yields

  [][][][][][][][][][ ]

The positions between the \w characters account for the zero-length
strings, and the space at the end shows up as well.

-- 
   |   Craig Berry - http://www.cinenet.net/~cberry/
 --*--  "The hills are burning, and the wind is raging; and the clock
   |   strikes midnight in the Garden of Allah." - Don Henley


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

Date: Sat, 27 Jan 2001 03:03:48 +0000 (UTC)
From: efflandt@xnet.com (David Efflandt)
Subject: Re: Form Processing - newbie question
Message-Id: <slrn974ejg.gi4.efflandt@efflandt.xnet.com>

On Fri, 26 Jan 2001 09:23:05 -0500, PaAnWa <paul_wasilkoff@ucg.org> wrote:
>> >print FILE "\"$in{'check1'}\",";
>> >print FILE "\"$in{'check2'}\",";
>> >print FILE "\"$in{'check3'}\",";
>> >print FILE "\"\","; #blank field
>> >print FILE "\"\","; #blank field - this makes a total of 5 entries.
>>
>> for ($i = 1; $i < 6; $i++) {
>>     print FILE '"', ($in{'check'.$i}) ? $in{'check'.$i} : '', '",';
>> }
>
>Thank you David.  This answers part of my question but I am still int he
>dark as to how I should put the values into the counter in the first place.
>The user has the choice of over 25 checkboxes but can choose up to 5 - any
>5.

If you use CGI.pm you could use a checkbox group (each checkbox has same
name) which returns a list, and then iterate through that list.  Suppose
the checkboxes are named 'check', with CGI function method you could
iterate through it similarly like this:

@checks = param('check');
for ($i = 0; $i < 5; $i++) {
    print '"', ($checks[$i]) ? $checks[$i] : '', '",';
}


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


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

Date: Sat, 27 Jan 2001 03:21:52 GMT
From: "paanwa" <paanwa@hotmail.com>
Subject: Re: Form Processing - newbie question
Message-Id: <k9rc6.45860$_B2.5090788@typhoon.kc.rr.com>

> If you use CGI.pm you could use a checkbox group (each checkbox has same
> name) which returns a list, and then iterate through that list.  Suppose
> the checkboxes are named 'check', with CGI function method you could
> iterate through it similarly like this:
>
> @checks = param('check');
> for ($i = 0; $i < 5; $i++) {
>     print '"', ($checks[$i]) ? $checks[$i] : '', '",';
> }

Zounds David!!

Yer a genius, I tell ya, a genius.

Simple and elegant.  I thanks you!!

PAW




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

Date: Sat, 27 Jan 2001 15:20:15 +0800
From: "Vinai Prakash" <vinaip@singnet.com.sg>
Subject: help on getting parameter value of GET
Message-Id: <94tsfm$vv2$1@dahlia.singnet.com.sg>

Hi,

I am trying to get the input of a form displayed in the cgi program. But all
I get is errors. The program runs fine with simulated parameters, but
dosen't run on Tripod or my PC well. Note that Tripod supports cgi-bin.

The error I got was
    Proxy Error
    The proxy server received an invalid response from an upstream server.
    The proxy server could not handle the request GET /cgi-bin/rssurvey.cgi.
    Reason: Could not connect to remote machine: Connection timed out

Perl Program:
#!/usr/bin/perl
use CGI qw(param);
my $lname = param('lname');
my $email = param('email');
my $fname = param('fname');
print "Content-type: text/html\n\n";
print "<html><h1>Dear Reader,
Thank you very much for completing this survey.</h1></html>\n";
print $lname             ;
print $fname;
#---------------- Perl Program ends.

The URL on my submit button is
file:///C:/My%20Documents/Tripod%20Recipe%20Secrets%20Web/cgi-bin/rssurvey.c
gi?fname=Vinai&lname=Prakash&sex=1&email=vinaip@singnet.com.sg&Submit=Submit

On my PC, the output of the Submit button is almost like a dump of my perl
program
#!/usr/bin/perl use CGI qw(param); my $lname = param('lname'); my $email =
param('email'); my $fname = param('fname'); print "Content-type:
text/html\n\n"; print "
Dear Reader, Thank you very much for completing this survey.
\n"; print $lname ; print $fname;

Please help and suggest what could be wrong. Thanks for your help.

Regards,
Vinai
vinaip@singnet.com.sg






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

Date: Sat, 27 Jan 2001 07:40:18 GMT
From: Brendon Caligari <bcaligari@my-deja.com>
Subject: Re: How to connect/disconnect a PPPoE DSL connection w. Perl
Message-Id: <94tu12$bfk$1@nnrp1.deja.com>



On Win2k/Winnt, the 'rasdial' utility does the job.  Used it in
numerous places to schedule night batch transfers/etc.

B

In article <LKoc6.8150$49.1085719@news1.rdc2.pa.home.com>,
  "Nicholas Marino" <nmarino@home.com> wrote:
> Is there a way to use Perl to connect and disconnect a Dial-up
Networking
> connection for a PPPoE DSL line?
>
> I'm rewriting a WinBatch (anyone heard of it?) script in Perl.
Winbatch has
> nice dunconnect() and dundisconnect() functions, but I can't find a
way to
> do it in Perl.
>
> BTW - My DSL is from Verizon. It sucks. Besides using a byzantine
virtual
> adaptor/RAS/PPPoE/Dialer arrangement, it actually times out after
about 24
> hrs, even if the connection is kept in constant use, but doesn't
disconnect!
> So the internet connection just looks dead, but the connection is
still
> there. I verified this with Verizon. They don't seem to have a
problem with
> it. My computer sends a short "I'm alive" message to a central server
every
> 5 minutes, so you would think that the connection would either stay
active,
> or of they choose to drop it, that it would disconnect.
>
>


Sent via Deja.com
http://www.deja.com/


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

Date: Sat, 27 Jan 2001 02:54:25 GMT
From: "Andrew Beatty" <apbeatty@yahoo.com>
Subject: Re: Internal Server Error- Newbie Question.
Message-Id: <BLqc6.90695$g6.40937227@news1.elmhst1.il.home.com>

Well first of all "premature end of script headers" can be caused by the CGI
output getting messed up.  This may be why you are only seeing the problem
with one set of data.  You should run the script on the command line and
take a look at the html it spits out to you.  Also use the -w flag when you
run it to help you see more problems.  I hope this helps.


"JCDixon" <jcdixon@aol.com> wrote in message
news:20010126190913.03811.00002566@ng-md1.aol.com...
> I am having trouble with a Perl script that is returning the same error;
i.e.
> "premature end of script headers" - an error for which there is no
> documentation at www.perl.com.  And here's the really wild thing: the
error is
> only generated when I access the script from home or work.  The guys at
the
> company hosting my site _can't_ get it to throw the error (they now
believe I
> am crazy).  And if that isn't enough, the script (which opens a template
file
> and a data file, and merges data into the template file) only throws the
error
> with a particular set of data - it works fine with all other template and
data
> files.  The script was created with Programmers File Editor, which allows
> saving in UNIX format, and I have checked the "shebang" line with the web
> hoster.  Ideas, anyone?




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

Date: 27 Jan 2001 04:00:06 GMT
From: ebohlman@omsdev.com (Eric Bohlman)
Subject: Re: Internal Server Error- Newbie Question.
Message-Id: <94th46$1a9$1@bob.news.rcn.net>

JCDixon <jcdixon@aol.com> wrote:
> I am having trouble with a Perl script that is returning the same error; i.e.
> "premature end of script headers" - an error for which there is no
> documentation at www.perl.com.  And here's the really wild thing: the error is

I'm not trying to be pedantic or to flame you here, but this is a case 
where your sloppy use of terminology is making it hard for you to find the 
problem.  It is not your script that is issuing that error message.  It is 
not the Perl interpreter that is issuing that error message.  It is your 
Web server that is issuing the message.  That's why you can't find it 
listed in Perl's documentation; it's coming from something that isn't part 
of Perl.

When you have a problem in a system (which by definition has multiple 
components) it's *vital* to understand the various roles played by the 
various components.  One of the responsibilities of a CGI program is to 
send a set of CGI headers to the Web server that invoked it.  If it fails 
to do so, the server issues the message that you got.  Knowing that, you 
can conclude that whenever you get that message, whatever part of your 
script generates the headers has either failed to run altogether or never 
got a chance to finish.  And this in turn means that either your script 
terminated with an error, or that there's some path of execution through 
your code that skips over the header generation.

> only generated when I access the script from home or work.  The guys at the
> company hosting my site _can't_ get it to throw the error (they now believe I
> am crazy).  And if that isn't enough, the script (which opens a template file
> and a data file, and merges data into the template file) only throws the error
> with a particular set of data - it works fine with all other template and data
> files.  The script was created with Programmers File Editor, which allows
> saving in UNIX format, and I have checked the "shebang" line with the web
> hoster.  Ideas, anyone?

The first thing you need to do is look at your server logs to see whether 
the Perl interpreter gave an error message when the problem happened.  If 
it did, it should point you to the part of your code where the error 
occurred.  If it didn't, then you've got a logic problem in your script, 
and you may need to include some temporary output statements.



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

Date: 27 Jan 2001 04:24:00 GMT
From: "John Michael" <johnm@acadiacom.net>
Subject: locking an NDBM_File with a semaphore file
Message-Id: <94tih0$60d@dispatch.concentric.net>

I am trying to lock a NDBM_File database file.  I was told that you had to
do it indirectly with a semaphore file, but have not found any documentation
on how to do so after looking and following serveral links for hours.  There
is'nt much info on NDBM_Files  everyone is saying to get the DB_File module,
but I am writing a script that I want to be portable to the novice user.

I need to know how to lock a NDBM_file:
This is what I have so far thanks to someone else.

use Fcntl qw(:flock);

my $file_name = "data/collected";
open(LOCK, ">>semaphore.file") || die "can't open semaphore.file: $!";
flock(LOCK, LOCK_EX) || die "can't lock semaphoe.file: $!";

tie(%addy, 'NDBM_File', $file_name , O_CREAT | O_RDWR, 0666) ||
&error('database_open_error',$file_name);

untie(%addy);                         # Close the database file
close(LOCK);                         # Unlock the resource (database file
semaphore)

How to I relate the semaphore file to the NDBM_File to get the lock.
I am guessing that I use the filehandle in some way to communicate with the
hash, but how?
Thanks
John Michael




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

Date: Sat, 27 Jan 2001 05:31:44 GMT
From: garry@zvolve.com (Garry Williams)
Subject: Re: locking an NDBM_File with a semaphore file
Message-Id: <43tc6.912$GF2.32726@eagle.america.net>

On 27 Jan 2001 04:24:00 GMT, John Michael <johnm@acadiacom.net> wrote:
>I am trying to lock a NDBM_File database file.  I was told that you had to
>do it indirectly with a semaphore file, but have not found any documentation
>on how to do so after looking and following serveral links for hours.  There
>is'nt much info on NDBM_Files  everyone is saying to get the DB_File module,
>but I am writing a script that I want to be portable to the novice user.
>
>I need to know how to lock a NDBM_file:
>This is what I have so far thanks to someone else.
>
>use Fcntl qw(:flock);
>
>my $file_name = "data/collected";
>open(LOCK, ">>semaphore.file") || die "can't open semaphore.file: $!";
>flock(LOCK, LOCK_EX) || die "can't lock semaphoe.file: $!";
>
>tie(%addy, 'NDBM_File', $file_name , O_CREAT | O_RDWR, 0666) ||
>&error('database_open_error',$file_name);


Here's where you do your updating of the NDBM file.  


>untie(%addy);       # Close the database file
>close(LOCK);        # Unlock the resource (database file semaphore)
>
>How to I relate the semaphore file to the NDBM_File to get the lock.
>I am guessing that I use the filehandle in some way to communicate with the
>hash, but how?

The file `semaphore.file' _represents_ the NDBM file.  All processes
that want access to the NDBM file adopt the _convention_ that
`semaphore.file' will represent the NDBM file.  Therefore all
cooperating processes will lock the representative file *before*
accessing the NDBM file and they will close the NDBM file *before*
unlocking the representative file.  

This convention, when adopted by all cooperating processes, will
serialize updates to the NDBM file.  (This does not work for threads
in a single process on many Unix systems.  But they all have other
services which can be used to synchronize processing among threads.)  

Unix lacks a general service to allow abstract exclusive (or shared)
enqueuing on arbitrary resources.  So use flock() and a conventional
file in a conventional location to represent any serially reusable
resource.  

-- 
Garry Williams   misses MVS (ENQ/DEQ)


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

Date: Sat, 27 Jan 2001 04:11:44 GMT
From: Rob <a565a87@my-deja.com>
Subject: Re: MS Access
Message-Id: <94thpt$356$1@nnrp1.deja.com>

jt,

I'd hate for this question to fall by the wayside.  I think I can help
you with the DAO Automation syntax that would connect you up with
Access.

First though--and I may be a little dense about this--what should your
single table look like?  Do you see 2 columns (fields) on this table?
In other words, what do you mean when you say that you want to "be able
to open and display a couple of lines in a Microsoft Access file"?  I
don't understand.

Do you see a single table comprised of 2 columns (fields) and four rows
(records)?

I've run your client-side PL.  I can't get anything from the source
file when I run it.

Here's how I've tested your client:

$datafile = 'r:/TestServer1.txt';
open(QUESTIONSFILE, "$datafile") || die "I can't open $datafile\n";
@Questions = <QUESTIONSFILE>;
close QUESTIONSFILE;

$QMax=0;
foreach $ThisQuestion (@Questions)
{
$QMax++;
}

if ($QNum > $QMax)
{
  foreach $ThisQuestion (@Questions)
  {
  @TempData = split (/\|\|/, $ThisQuestion);
  if($TempData[0] eq $QNum)
  {
  print "<TR>\n";
  print "<TD><B>$TempData[0]</B></TD><TD COLSPAN=2><B>$TempData[1]
</B></TD>";
  print "</TR>\n";
  #etc.
}
}
}


And here's how I've prepared the server--which I've named
named "Testserver1.txt":

1||How ____ you?||A||0||Am||B||0||Is||C||1||Are||D||0||||20||clip1.rpm||


I'm running Win NT.  I've run my TestClient1.PL with and without the
TestServer1.txt in place and if the plaintext server file is not in the
path it will throw the quoted exception outlined on line 2.  However,
If I do put the plaintext file you've written into the r: root, I get
nothing from the interpreter.  Tell me why.  Am I testing this code of
your correctly?  Please look over what I written above and get me on
the right track.

I want to see exactly what it is you expect of the program before I
respond with a suggestion.  I am also a rank beginner at Perl--this is
not a language I know.  But believe it or not, I can show you how to
implement DAO in Perl if I know what your objective is.

-Rob


Sent via Deja.com
http://www.deja.com/


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

Date: Sat, 27 Jan 2001 06:54:14 GMT
From: jay <jeano@my-deja.com>
Subject: Object Oriented newbie dilemma
Message-Id: <94tram$9rj$1@nnrp1.deja.com>

I am trying to teach myself OO perl.  I have written an Album.pm file.
It mostly works.  My problem is that the Album object has a data member
called "title." I can set the "title" data member just fine when using
the constuctor.  But then I try to change the "title" data member by
calling:

$album->setKeyValue(title => "Beat It");

but it does not seem to work.  Please check my code and the output below
for more info.  I am sure I am making some Newbie mistake but I don't
know what it is...  Thanks.

-j

================excerpt from Album.pm=====================
sub new {
  my $invocant = shift;
  my $class = ref($invocant) || $invocant;
  my $self = {@_};
  bless($self, $class);
  print "Created a new Album.\n";
  return $self;
}

sub setKeyValue {
  my $self = shift;
  print "Entered setKeyValue().\n";
  print "The value of self is $self.\n";
  $self = {@_};
  print "Set has been called.\n";
  print "The value of title is $self->{title}.\n";
  print "Leaving setKeyValue()\n";
}

sub getTitle {
  my $self = shift;
  return $self->{title};
}

====================excerpt from test.pl=============
my $album = Album->new();
$album->setTitle("Thriller");
$title = $album->get("title");
print "The title is $title.\n";
$album->setKeyValue(title => "Beat It");
print "The title is $title.\n";

=====================Output from test.pl================

Created a new Album.
The value of self is Album=HASH(0x80a2180).
The value of key is title.
Leaving get() with Thriller.
The title is Thriller.
Entered setKeyValue().
The value of self is Album=HASH(0x80a2180).
Set has been called.
The value of title is Beat It.
Leaving setKeyValue()
The title is Thriller.


Sent via Deja.com
http://www.deja.com/


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

Date: 27 Jan 2001 02:33:45 -0500
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: Object Oriented newbie dilemma
Message-Id: <m3bssto3dy.fsf@mumonkan.sunstarsys.com>

jay <jeano@my-deja.com> writes:

> But then I try to change the "title" data member by calling:
> 
> $album->setKeyValue(title => "Beat It");
> 
> but it does not seem to work.  

> sub setKeyValue {
>   my $self = shift;
>   $self = {@_};
    ^^^^^^^^^^^^    
THat's useless; all you're doing is changing the 
value of $self from a reference to your object to
a reference to an anonymous hash.  That has no effect
on the object itself - you're manipulating the finger
here, not the moon.

You could it try this way instead

        %{$self} = @_ ;


Note that this will destroy any old attributes in your 
object. If you just want to replace certain attributes 
with newer ones, you could try using a slice instead

        my %hash = @_;
        @$self{ keys %hash } = ( values %hash ) ;

HTH

-- 
Joe Schaefer



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

Date: Sat, 27 Jan 2001 08:31:25 +0100
From: Oliver =?iso-8859-1?Q?S=F6der?= <soeder@ai-lab.fh-furtwangen.de>
Subject: OOP: How to point/reference on a Class?
Message-Id: <3A72794D.1E4AA0E5@ai-lab.fh-furtwangen.de>

Does a class have an own pointer type or do you just use a
hash reference for a blessed hash etc.?

Oliver S=F6der


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

Date: Fri, 26 Jan 2001 22:47:39 -0500
From: Kevin Michael Vail <kevin@vaildc.net>
Subject: Re: perl editors
Message-Id: <kevin-78B67F.22473926012001@news.his.com>

In article <94np7f$483$1@nnrp1.deja.com>, hanja <hanja@my-deja.com> 
wrote:

> Out of curiousity, what editor do you use to write your scripts?

On Unix:  vi
On Windoze:  UltraEdit
On MacOS:  BBEdit
-- 
Kevin Michael Vail | a billion stars go spinning through the night,
kevin@vaildc.net   | blazing high above your head.
 . . . . . . . . .  | But _in_ you is the presence that
 . . . . . . . . . | will be, when all the stars are dead.  (Rainer Maria Rilke)


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

Date: 27 Jan 2001 04:59:36 GMT
From: rich@bofh.concordia.ca (Rich Lafferty)
Subject: Re: perl editors
Message-Id: <slrn974lfr.quc.rich@bofh.concordia.ca>

In comp.lang.perl.misc,
Kevin Michael Vail <kevin@vaildc.net> wrote:
> In article <94np7f$483$1@nnrp1.deja.com>, hanja <hanja@my-deja.com> 
> wrote:
> 
> > Out of curiousity, what editor do you use to write your scripts?
> 
> On Unix:  vi
> On Windoze:  UltraEdit
> On MacOS:  BBEdit

So comPLEX! :-)

On Unix:    emacs
On Windows: emacs
On MacOS:   emacs

Extrapolate as necessary. 

  -Rich

-- 
Rich Lafferty ----------------------------------------
 Nocturnal Aviation Division, IITS Computing Services
 Concordia University, Montreal, QC
rich@bofh.concordia.ca -------------------------------


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

Date: Sat, 27 Jan 2001 04:21:12 GMT
From: garry@zvolve.com (Garry Williams)
Subject: Re: Perl Style Guide - uncuddled elses
Message-Id: <Y0sc6.902$GF2.31367@eagle.america.net>

On Sat, 27 Jan 2001 00:50:42 GMT, Uri Guttman <uri@sysarch.com> wrote:
>>>>>> "EtB" == Eli the Bearded <elijah@workspot.net> writes:
>
>  EtB> In comp.lang.perl.misc, Uri Guttman  <uri@sysarch.com> wrote:
>  >> [] are usually called brackets (or redundantly square brackets).
>
>  EtB> That is not /so/ redundant when one thinks of <> as 'angle brackets'.
>
>but those are never referred as just brackets, whereas [] are commonly
>called that. and if you want to continue the short names, <> are called
>angles.

 ... or corners.  

-- 
Garry Williams


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

Date: Sat, 27 Jan 2001 04:31:00 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Perl Style Guide - uncuddled elses
Message-Id: <x7u26lty4b.fsf@home.sysarch.com>

>>>>> "GW" == Garry Williams <garry@zvolve.com> writes:

  GW> On Sat, 27 Jan 2001 00:50:42 GMT, Uri Guttman <uri@sysarch.com> wrote:
  >>>>>>> "EtB" == Eli the Bearded <elijah@workspot.net> writes:
  >> 
  EtB> In comp.lang.perl.misc, Uri Guttman  <uri@sysarch.com> wrote:
  >> >> [] are usually called brackets (or redundantly square brackets).
  >> 
  EtB> That is not /so/ redundant when one thinks of <> as 'angle brackets'.
  >> 
  >> but those are never referred as just brackets, whereas [] are commonly
  >> called that. and if you want to continue the short names, <> are called
  >> angles.

  GW> ... or corners.  

never heard that one. must be some subculture that uses it but not the
mainstream. (not that i would know all possible names for the paired
ascii symbols).

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page  -----------  http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net  ----------  http://www.northernlight.com


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

Date: Sat, 27 Jan 2001 05:53:34 -0000
From: cberry@cinenet.net (Craig Berry)
Subject: Re: regex question
Message-Id: <t74oiuq4kdu380@corp.supernews.com>

chris w. (chrisw@ec2.edu) wrote:
: I'm to look through a file and remove duplicates of a particular string,
: separated by whitespace. Here is an example of the file:
: 
: -----------------------------
: <p>           <p>
:      <p>    <p>Blah-blah-blah
: ------------------------------
: 
: I started out trying to use something like:
: 
: s/<p>\s+<p>/<p>/g;
: 
: Which everyone here will see that it only solves my problem half-way. I'm
: not sure if there is a way to substitute one-or-more <p> with just one <p>
: without going beyond a regular expression.

You can jigger such a thing together, but I'd prefer to substitute
repeatedly until there's nothing left to substitute:

  1 while s/<p>\s+<p>/<p>/g;

Note that for this to work across line boundaries as you've shown in your
example, you'll need to work on the whole file at once, as a single
string.  But the same regex works, as \n is is \s.  Do note that some
newlines may get eaten, though.

-- 
   |   Craig Berry - http://www.cinenet.net/~cberry/
 --*--  "The hills are burning, and the wind is raging; and the clock
   |   strikes midnight in the Garden of Allah." - Don Henley


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

Date: Sat, 27 Jan 2001 04:58:28 GMT
From: garry@zvolve.com (Garry Williams)
Subject: Re: Regular expression question
Message-Id: <Uzsc6.909$GF2.31367@eagle.america.net>

On Fri, 26 Jan 2001 18:46:04 GMT, Barry Margolin <barmar@genuity.net> wrote:
>In article <Pine.GSO.4.30.0101261251540.4890-100000@koala.cdf>,
>Kauser Ali Karim  <g9karkav@cdf.toronto.edu> wrote:
>>I need to get rid of the first fifteen charcters
>>(which are uppercase letters and numbers) of a line. How
>>would I do this using regular expressions.
>>
>>I know that something like this would work,
>>but would only get rid of the first character.
>>
>>s/[^A-Z0-9]//
>
>s/^.\{15\}//

I guess you didn't test this.  It will remove only strings that have
`{15}' beginning in the second position.  

 s/^.{15}//;

or just $_ = substr($_, 15);, if you allow a non-regex solution.  

  $ perl -wle '$_="a{15}bcdefghijklmnopqrstuvwxyz";s/^.\{15\}//;print'
  bcdefghijklmnopqrstuvwxyz
  $ perl -wle '$_="abcdefghijklmnopqrstuvwxyz";s/^.\{15\}//;print'
  abcdefghijklmnopqrstuvwxyz
  $ perl -wle '$_="abcdefghijklmnopqrstuvwxyz";s/^.{15}//;print'
  pqrstuvwxyz
  $ perl -wle '$_="abcdefghijklmnopqrstuvwxyz";print substr($_,15)'
  pqrstuvwxyz
  $ 

-- 
Garry Williams


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

Date: Sat, 27 Jan 2001 05:00:24 GMT
From: garry@zvolve.com (Garry Williams)
Subject: Re: Regular expression question
Message-Id: <IBsc6.910$GF2.31367@eagle.america.net>

On Fri, 26 Jan 2001 15:11:57 -0500, Kurt J. Lanza <kjl@inforonics.com> wrote:
>Kauser Ali Karim wrote:
>> 
>> Hi,
>> 
>> I need to get rid of the first fifteen charcters
>> (which are uppercase letters and numbers) of a line. How
>> would I do this using regular expressions.
>> 
>> I know that something like this would work,
>> but would only get rid of the first character.
>> 
>> s/[^A-Z0-9]//
>> 
>
>	S/^.{15}//
        ^
        ^


     s/^.{15}//;

-- 
Garry Williams


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

Date: Sat, 27 Jan 2001 06:17:09 -0000
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Script to "rotate" the chars in a string.
Message-Id: <t74pv5a2dejc75@corp.supernews.com>

James Kufrovich (eggie@REMOVE_TO_REPLYsunlink.net) wrote:
: 	I just put together a small script (at the bottom there) that will
: rotate the characters in a string (supplied on the command line) and print
: the resulting string out, both forwards and backwards.  In other words,
: giving the program the string "funky" will produce the following output:
: 
: funky
: unkyf
: nkyfu
: kyfun
: yfunk
: yknuf
: knufy
: nufyk
: ufykn
: fyknu

I'd tend to do it in two stages, like this:

  sub rotate {
    my $s = shift;
    print substr($s, $_),
          substr($s, 0, $_),
          "\n"
      for 0..length($s) - 1;
  }

  my $test = 'funky';

  rotate($test);
  rotate(scalar reverse $test);

-- 
   |   Craig Berry - http://www.cinenet.net/~cberry/
 --*--  "The hills are burning, and the wind is raging; and the clock
   |   strikes midnight in the Garden of Allah." - Don Henley


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

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 V10 Issue 155
**************************************


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