[19623] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1818 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Sep 26 00:06:55 2001

Date: Tue, 25 Sep 2001 21:05:09 -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: <1001477109-v10-i1818@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Tue, 25 Sep 2001     Volume: 10 Number: 1818

Today's topics:
    Re: Book Recommendations (RoJo)
    Re: Book Recommendations (RoJo)
    Re: Book Recommendations (RoJo)
    Re: Creating modules (Stephane TOUGARD)
    Re: current dir. (Stephane TOUGARD)
    Re: Dump raw data (Stephane TOUGARD)
    Re: emailing contents of text file (Stephane TOUGARD)
    Re: faster execution (venus)
    Re: faster execution (Martien Verbruggen)
    Re: Goto and global variables <dscarlett@REMOVETHIS.optushome.com.au>
    Re: Goto and global variables <dscarlett@REMOVETHIS.optushome.com.au>
    Re: How do I compare strings? <bart.lateur@skynet.be>
        How To Copy Files in Script w/Shell? (Ralph Freshour)
        how to set baud on serial port on linux box <aschlies@ezwv.com>
    Re: Is there a better way to do this?? <davidhilseenews@yahoo.com>
    Re: Is there a better way to do this?? <aperlprogrammer@yahoo.com>
    Re: Is there a better way to do this?? <uri@sysarch.com>
        ONE QUESTION (hugh1)
        Pattern Matching <phookie@xmission.com>
    Re: Pattern Matching (Damian James)
    Re: Pattern Matching <please@no.spam>
    Re: Perl ROOT <glodalec@yahoo.com>
        Reading from HTML <dejan.tomazic@club.win-ini.si>
    Re: Reading from HTML <rob_13@excite.com>
    Re: regex variable length look behind <please@no.spam>
    Re: regex variable length look behind <please@no.spam>
    Re: regex variable length look behind <davidhilseenews@yahoo.com>
        XL saveas doesn't work (excel) <jeffpwright@home.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Wed, 26 Sep 2001 02:03:16 GMT
From: rojo@mindspring.com (RoJo)
Subject: Re: Book Recommendations
Message-Id: <3bb13750.10043131@news.mindspring.com>


Thank you, Ron.  I appreciate your taking the time.

On Tue, 25 Sep 2001 22:24:52 GMT, "Ron Hartikka" <ronh@iainc.com>
wrote:

>Perl Cookbook. Many questions asked in this forum and not answered, by
>example, in the documentation are answered in Perl Cookbook by Tom
>Christiansen and Nathan Torkington.
>
>
>"RoJo" <rojo@mindspring.com> wrote in message
>news:3bb0fa58.73725471@news.mindspring.com...
>>
>> I'd like to get a good book on PERL 5.  I've already got the Pocket
>> Reference.  I can find my way around the pod documentation, but I need
>> more.  I need  a book that emphasizes examples.  Suggestions?
>
>



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

Date: Wed, 26 Sep 2001 02:03:49 GMT
From: rojo@mindspring.com (RoJo)
Subject: Re: Book Recommendations
Message-Id: <3bb1376b.10070300@news.mindspring.com>


Jorge, thanks for your reply!

On Tue, 25 Sep 2001 19:25:27 -0300, Jorge Godoy <godoy@conectiva.com>
wrote:

>rojo@mindspring.com (RoJo) writes:
>
>> I'd like to get a good book on PERL 5.  I've already got the Pocket
>> Reference.  I can find my way around the pod documentation, but I need
>> more.  I need  a book that emphasizes examples.  Suggestions?
>
>For examples, buy the "Perl Cookbook". That's an O'Reilly book. 
>ISBN 1-56592-243-3.
>
>I'd also recommend the "Programmin Perl - 3rd Edition", ISBN
>0-596-0027-8. 
>
>
>See you,
>-- 
>Godoy. <godoy@conectiva.com>
>
>Solutions Developer       - Conectiva Inc. - http://en.conectiva.com
>Desenvolvedor de Soluções - Conectiva S.A. - http://www.conectiva.com.br



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

Date: Wed, 26 Sep 2001 02:04:15 GMT
From: rojo@mindspring.com (RoJo)
Subject: Re: Book Recommendations
Message-Id: <3bb1378c.10103468@news.mindspring.com>


Chris, thanks for your feedback.  I apreciate it!


On Tue, 25 Sep 2001 22:41:29 GMT, cfedde@fedde.littleton.co.us (Chris
Fedde) wrote:

>In article <3bb0fa58.73725471@news.mindspring.com>,
>RoJo <rojo@mindspring.com> wrote:
>>
>>I'd like to get a good book on PERL 5.  I've already got the Pocket
>>Reference.  I can find my way around the pod documentation, but I need
>>more.  I need  a book that emphasizes examples.  Suggestions?
>
>Looking in the perl faq I see:
>
>    perldoc -q book
>    Found in /usr/local/lib/perl5/5.6.1/pod/perlfaq2.pod
>       Perl Books
>
>       A number of books on Perl and/or CGI programming are
>       available.  A few of these are good, some are OK, but many
>       aren't worth your money.  Tom Christiansen maintains a
>       list of these books, some with extensive reviews, at
>       http://www.perl.com/perl/critiques/index.html .
>
>
>Though that URL is showing some age.
>
>Good Luck
>  
>
>-- 
>    This space intentionally left blank



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

Date: Wed, 26 Sep 2001 09:20:45 +0800
From: s_tougard@hotmail.com (Stephane TOUGARD)
Subject: Re: Creating modules
Message-Id: <slrn9r2bbd.1k8.s_tougard@clipper.kirch>

In article <spc2rtcsn5t2tqfcref6cn7f58k54jm8s9@4ax.com>, GunneR wrote:
> Im having trouble creating a simple module (just to get started). I've
> had a bit of trouble finding good documentation on creating modules.
> Anyone know any informative sites? I've found McDougalls documentation
> but im looking for some further reading.

h2xs -cn my_module

will generate a directory named 'my_module' who contains all necessary
files to create your module with Perl and C code.

More informations in the Perl Cook Book (O'Reilly)

Stephane



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

Date: Wed, 26 Sep 2001 09:22:45 +0800
From: s_tougard@hotmail.com (Stephane TOUGARD)
Subject: Re: current dir.
Message-Id: <slrn9r2bf5.1k8.s_tougard@clipper.kirch>

In article <3BB08955.81D08C63@metadyne.uk.com>, Jeffrey Porter wrote:
> This is a multi-part message in MIME format.
> --------------5DC71650AE9537D21B5F9108
> Content-Type: text/plain; charset=us-ascii
> Content-Transfer-Encoding: 7bit
> 
> 
> 
> I'm trying to write a perl program to go through each directory and list
> the files in it & the path to that file.
> 
> I've managed to write the code to list/change directories & list the
> files in them.
> 
> What I can't work out is how to get the full path of the current
> directory I am in.

use Cwd;

my $current_dir = getcwd();

Stephane

>


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

Date: Wed, 26 Sep 2001 09:26:49 +0800
From: s_tougard@hotmail.com (Stephane TOUGARD)
Subject: Re: Dump raw data
Message-Id: <slrn9r2bmp.1k8.s_tougard@clipper.kirch>

In article <3BB032C7.D149A04C@sxb.bsf.alcatel.fr>, Philippe PERRIN wrote:
> Hi
> 
> I need to regularly dump a whole hash on disk, and reload it later. Is
> there a way to write its "raw data" on a file descriptor (I mean the way
> Perl stores it in memory) ? I'm looking for a pair of functions which
> would work that way :
> 
> # save %table to disk
> open(S, "> saveFile");
> binmode S;
> saveData(*S, \%table);   # this function
> close(S);
> 
> # load %table from disk
> open(S, "saveFile");
> binmode S;
> loadData(*S, \%table);   # and that one
> close(S);
> 
> I'm looking for this kind of functions to save/restore hashes fastly and
> efficiently (less wasted space than ASCII files).

my %hash;

dbmopen(%hash,'file',0500) or die $!;

$hash{'value'} = 'your information';

dbmclose(%hash);


more information with perldoc -f dbmopen



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

Date: Wed, 26 Sep 2001 09:34:20 +0800
From: s_tougard@hotmail.com (Stephane TOUGARD)
Subject: Re: emailing contents of text file
Message-Id: <slrn9r2c4s.1k8.s_tougard@clipper.kirch>

In article <3baffd06.60522038@nntp.ix.netcom.com>, jcole wrote:
> while(<EMAILADDRESSFILE>)
> {
>    open MAIL, "|mail " . $_;
>    print MAIL $heading . $quote; 
>    close MAIL;
> }
> 
> I want  $heading . $quote;  to be changed to the contents of a text
> file.  In other words, I want to have a text file sitting in the
> directory this script is in, and have that text file contain the body 
>  of my mass email, so I would be able to write something like
> 
> while(<EMAILADDRESSFILE>)
> {
>    open MAIL, "|mail " . $_;
>    print MAIL [a filename]; 
>    close MAIL;
> }
> 
> Help! I need a solution quick. 

An other solution I prefer to this one, because it's more efficient :


my $from = 'your_adresse@your_domaine';

open(IN,"<file_email") or die $!;
my @to = (<IN>);
close(IN);

open(IN,"<text_to_send_file") or die $!;
@text = (<IN>);
close(IN);

my $sendmail = "/usr/sbin/sendmail -t";
my $text = join(//,@text);
my $subject = "What you want";
my $tmp;

foreach $tmp(@to)
{
	open(OUT,"|$sendmail") or die $!;
	print OUT"From: $from\nTo: $to\nSubject: $subject\n\n";
	print OUT"$text\n";
	close(OUT);
}

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

Be carrefull when you make the mail, the respect ot the format is very
important.

If you system is a Solaris, you have to use /usr/lib/sendmail instead of
/usr/sbin/sendmail

Stephane


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

Date: 25 Sep 2001 20:16:34 -0700
From: train2venus@hotmail.com (venus)
Subject: Re: faster execution
Message-Id: <bce84cea.0109251916.2a7596e6@posting.google.com>

Hi...

The script runs halfway and stopped with the message:

Segmentation fault (core dumped)

while (<INPUT_FILE>) {


   s/^\s+//;
   s/\r?\n$//;
($city, $statecode, $countrycode, $date1, $max1, $min1, $cond1,
$date2, $max2, $min2, $cond2,
         $date3, $max3, $min3, $cond3, $date4, $max4, $min4, $cond4,
         $date5, $max5, $min5, $cond5, $date6, $max6, $min6, $cond6 )
= split (/,/);
  
   $location = "$city,$statecode,$countrycode";

        while(my($k, $v) = each %LOCATION) {
             push @{$LOCATIONS{$v}}, $k;
        }

        foreach (@{$LOCATIONS{$location}}) {
                if(exists $LOCATIONS{$location}){
            print OUTPUT_FILE"$_,$date1,$max1,$min1,$cond1\n";
        }
        }


Am I missing something here?  

Thank you and regards...


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

Date: Wed, 26 Sep 2001 03:43:55 GMT
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: faster execution
Message-Id: <slrn9r2jnr.eug.mgjv@verbruggen.comdyn.com.au>

[you're responding to some other post, but my server doesn't have it,
and you don't leave any context in your post, so I'll have to treat it
as a new post]

On 25 Sep 2001 20:16:34 -0700,
	venus <train2venus@hotmail.com> wrote:
> Hi...
> 
> The script runs halfway and stopped with the message:
> 
> Segmentation fault (core dumped)

This means that your Perl is broken. Perl should never bomb out like
that, and if it does, it is either a bug in Perl, a bug in your OS
libraries, a bug in a module that uses external libraries, or internal
compiled machine code [1]. Since I can't see any use of external modules
in your code, I can only assume that your Perl is broken (or some
system library it relies upon).

Very hard to say anything sensible about it. I would advise you to
recompile Perl.

> while (<INPUT_FILE>) {
> 
> 
>    s/^\s+//;
>    s/\r?\n$//;
> ($city, $statecode, $countrycode, $date1, $max1, $min1, $cond1,
> $date2, $max2, $min2, $cond2,
>          $date3, $max3, $min3, $cond3, $date4, $max4, $min4, $cond4,
>          $date5, $max5, $min5, $cond5, $date6, $max6, $min6, $cond6 )
>= split (/,/);

yuck. Why don't you use an array and indexes?

>    $location = "$city,$statecode,$countrycode";
> 
>         while(my($k, $v) = each %LOCATION) {
>              push @{$LOCATIONS{$v}}, $k;
>         }

What is this supposed to do? It more or less inverts what is in
%LOCATION, and puts it in %LOCATIONS, but why is that done for each
line of input? The least that you should do is move this out of the
loop.

>         foreach (@{$LOCATIONS{$location}}) {
>                 if(exists $LOCATIONS{$location}){
>             print OUTPUT_FILE"$_,$date1,$max1,$min1,$cond1\n";
>         }
>         }
> 
> Am I missing something here?  

Nothing that has anything to do with the core dump. As I said, a core
dump in Perl most likely signifies that there is something wrong with
your perl binary.

Martien

[1] I suspect you can probably get this stuff as well if you're not
careful in signal handlers, and there may be one or more other, more
obscure, possibilities.
-- 
Martien Verbruggen              | 
Interactive Media Division      | Hi, Dave here, what's the root
Commercial Dynamics Pty. Ltd.   | password?
NSW, Australia                  | 


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

Date: Wed, 26 Sep 2001 01:36:08 GMT
From: "David Scarlett" <dscarlett@REMOVETHIS.optushome.com.au>
Subject: Re: Goto and global variables
Message-Id: <cias7.3907$98.19090@news1.rivrw1.nsw.optushome.com.au>

"Mark Jason Dominus" <mjd@plover.com> wrote in message
news:3bb0a94a.72be$8@news.op.net...
> In article <ower7.12876$Tv6.66631@news1.rdc1.nsw.optushome.com.au>,
> David Scarlett <dscarlett@REMOVETHIS.optushome.com.au> wrote:
> >"If you have a thing for parentheses, then LISP is the programming
language
> >for you!"
> >        -My Computing Fundamentals lecturer
>
> That's silly.  Perl probably uses almost as many parentheses as Lisp.

Bah. It was funny at the time - he had a slide up with a piece of sample
lisp code, and half the characters in it were parentheses. ;-)


--
David Scarlett
dscarlett@REMOVETHIS.optushome.com.au
http://www.listen.to/artifice/
http://members.optushome.com.au/dscarlett/

"Damn it, Kif, where's the little umbrella? That's what makes it a scotch on
the rocks!"
        -Capt. Zapp Brannigann, Futurama




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

Date: Wed, 26 Sep 2001 01:38:27 GMT
From: "David Scarlett" <dscarlett@REMOVETHIS.optushome.com.au>
Subject: Re: Goto and global variables
Message-Id: <nkas7.3908$98.19161@news1.rivrw1.nsw.optushome.com.au>

"Tramm Hudson" <hudson@swcp.com> wrote in message
news:9oqclh$cbd$1@sloth.swcp.com...
>
> Nor is my favorite use of this construct -- tail recursion.

What exactly is tail recursion? Judging by your example I'd say that it's
where, up until the last call, the functions don't return anything to their
calling functions..... Is this correct? So it's sort of like accumulator
recursion then?


--
David Scarlett
dscarlett@REMOVETHIS.optushome.com.au
http://www.listen.to/artifice/
http://members.optushome.com.au/dscarlett/

"Why am I talking to myself? More importantly, why am I expecting a reply?"
        -Daria




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

Date: Wed, 26 Sep 2001 02:05:40 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: How do I compare strings?
Message-Id: <htd2rt48lfhtq31sl7hlogh4uog71m9pki@4ax.com>

Benjamin Goldberg wrote:

>> How can I find this position, short of writing a for loop that will go
>> through each string and use substr to compare character by character?
>
>	$pos = index( "$str1" ^ "$str2", "\0" );
>
>Using index should be faster than using a regex.  Plus, this is a little
>bit clearer.

Except it's useless. The OP wants the first byte that's DIFFERENT from
"\0", not the first one that's the same.

-- 
	Bart.


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

Date: Wed, 26 Sep 2001 03:32:40 GMT
From: ralph@primemail.com (Ralph Freshour)
Subject: How To Copy Files in Script w/Shell?
Message-Id: <3bb14d67.8673524@news-server>

I want to run a perl script and do a backup of some of my files to
another linux server.  My test script below gives me errors when I do
a perl -c on it  Any help appreciated!


#!/usr/bin/perl -w
#backup2.pl
#

scp /home/cust/*.cust herring:/home/cust/

exit(0);



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

Date: Tue, 25 Sep 2001 16:59:58 -0400
From: "Tony Schliesser" <aschlies@ezwv.com>
Subject: how to set baud on serial port on linux box
Message-Id: <3bb1457e_2@corp.newsgroups.com>

Consider the following bit of code on a linux box:

if (open(PHONE,"/dev/$serial")) {
    while (<PHONE>) {


This works fine when the linux box decides to boot up and have the serial
port setup for the right speed.  Ideally, I would like to set up the port
for n81 at 2400 baud - however I am not sure how to accomplish this in perl.
I don't consider myself a perl developer so please be gentle with any
suggestions.  :)

Thanks
Tony






-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----==  Over 80,000 Newsgroups - 16 Different Servers! =-----


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

Date: Wed, 26 Sep 2001 01:13:25 GMT
From: "David Hilsee" <davidhilseenews@yahoo.com>
Subject: Re: Is there a better way to do this??
Message-Id: <VY9s7.4796$G71.1398485@news1.rdc1.md.home.com>


"Carlos C. Gonzalez" <aperlprogrammer@yahoo.com> wrote in message
news:MPG.161ad4b9f32e6afb9897a7@news.edmonton.telusplanet.net...
> Hi everyone,
>
> I have some code and I was wondering if anyone could suggest a better way
> to do what I do in it.
>
> The code:
>
> if (not %data = found('jacky@ardvark.com')) {
>   print "Nothing there!\n";
> }
> else {
>   print $data{email_address};
> }
>
> I sort of don't like all the stuff that is happening inside the if
> statement.
>
> found() is a function which searches through a database for the email
> address passed as a parameter.  If the email address is there the found
> sub returns a hash with the values of the record's fields.  If not it
> returns an empty hash.
>
> I am a bit uncomfortable using found() like this because the %data hash
> is filled through the if statement.  It makes the code harder to follow
> since I may be using data from inside the %hash way down in the code.  If
> I look at the code 6 months from now I may have trouble finding where in
> the world it got initialized to and why sometimes it is initialized and
> sometimes not.
>
> Can anyone suggest a better way to do this?  I've thought of passing the
> %hash as a modifiable reference parameter into found().  But is there
> some other way?  Maybe I should break the found() into two subs.  One to
> strictly do a find operation and one to fill %hash with the values of the
> record.  Only this might involve two database operations.
>
> Any comments?
>
> Thanks.
>
> ---
> Carlos
> www.internetsuccess.ca (not operational yet)

If you don't like a lot of action in your if clauses, then take the action
out.

%data = found('jacky@ardvark.com');
if ( not %data )...

You can do this with lots of things if you like.  If you have some
complicated condition, you could wrap it up into a single scalar value and
test the scalar.

$data_is_valid = $n == 0 && $c eq "something" && ...;
if ( $data_is_valid )
{
    # code...
}

No need to stuff it in there if you don't want to.

David Hilsee




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

Date: Wed, 26 Sep 2001 02:58:53 GMT
From: Carlos C. Gonzalez <aperlprogrammer@yahoo.com>
Subject: Re: Is there a better way to do this??
Message-Id: <MPG.161af23bd6d5049c9897a8@news.edmonton.telusplanet.net>

David Hilsee at davidhilseenews@yahoo.com said...
> 
> If you don't like a lot of action in your if clauses, then take the action
> out.
> 
> %data = found('jacky@ardvark.com');
> if ( not %data )...
> 

Thanks David.  Believe it or not in all the staring at the code that I 
have been doing what you suggested did not even enter my mind.  

---
Carlos 
www.internetsuccess.ca (not operational yet)


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

Date: Wed, 26 Sep 2001 03:28:29 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Is there a better way to do this??
Message-Id: <x766a6bpfs.fsf@home.sysarch.com>

>>>>> "CCG" == Carlos C Gonzalez <aperlprogrammer@yahoo.com> writes:

  CCG> David Hilsee at davidhilseenews@yahoo.com said...
  >> 
  >> If you don't like a lot of action in your if clauses, then take the action
  >> out.
  >> 
  >> %data = found('jacky@ardvark.com');
  >> if ( not %data )...
  >> 

also learn to use unless. i don't like seeing bare not/! in
conditions. i reserve them for when they are needed in expressions.

	unless( %data ) {

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture and Stem Development ------ http://www.stemsystems.com
Search or Offer Perl Jobs  --------------------------  http://jobs.perl.org


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

Date: 25 Sep 2001 21:04:50 -0700
From: weiwe1@yeah.net (hugh1)
Subject: ONE QUESTION
Message-Id: <7dcf30ba.0109252004.694376e4@posting.google.com>

IN BOOK <<advanced programming perl >> 
   
   charpe six package   auto load .

   sub AUTOLOAD {
    
        .....some creat sub function.....

       goto &$AUTOLOAD-----------> IT will del the AUTOLOAD sub
function's                                        stack. WHY ???

    }


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

Date: Tue, 25 Sep 2001 19:36:20 -0600
From: phookie <phookie@xmission.com>
Subject: Pattern Matching
Message-Id: <3BB13113.1DB9A133@xmission.com>

How would one match/sub a string which begins with a "<" with zero or
more"<", ">" alphanumerics, quotes, equal signs, period, commas,
semi-colons, underscores, forward "/" and back "\" slashes, white space,
etc and ends with a ">" character.
This does not appear to work

   $mystring =~ s/^<[A-Z a-z 0-9 "=.,;_/\\\s].+>$/my_new_string/;

Thanks...

Lee



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

Date: 26 Sep 2001 01:41:41 GMT
From: damian@qimr.edu.au (Damian James)
Subject: Re: Pattern Matching
Message-Id: <slrn9r2ce1.cr1.damian@puma.qimr.edu.au>

On Tue, 25 Sep 2001 19:36:20 -0600, phookie said:
>How would one match/sub a string which begins with a "<" with zero or
>more"<", ">" alphanumerics, quotes, equal signs, period, commas,
>semi-colons, underscores, forward "/" and back "\" slashes, white space,
>etc and ends with a ">" character.
>This does not appear to work
>
>   $mystring =~ s/^<[A-Z a-z 0-9 "=.,;_/\\\s].+>$/my_new_string/;
>

It looks like you are trying to parse html. While it may seem like
you could do it with simple pattern matching, this is not in fact the
case. You need a fully fledged parser.

See perlfaq9: How do I remove HTML from a string?
(type 'perldoc -q html' at the command prompt).

This FAQ contains a few tips that you will find valuable, even if
Ihave misread the above and you are trying to parse something other
than html.

HTH

Cheers,
Damian
-- 
@:=grep!(m!$/|#!..$|),split//,<DATA>;@;=0..$#:;while($:=@;){$;=rand
$:--,@;[$;,$:]=@;[$:,$;]while$:;push@|,shift@;if$;[0]==@|;select$,,
$,,$,,1/80;print qq x\bxx((@;+@|)*$|++),@:[@|,@;],!@;&&$/}  __END__
Just another Perl Hacker,### http://home.pacific.net.au/~djames.hub


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

Date: Wed, 26 Sep 2001 01:58:13 GMT
From: Andrew Cady <please@no.spam>
Subject: Re: Pattern Matching
Message-Id: <871yku7m17.fsf@homer.cghm>

phookie <phookie@xmission.com> writes:

> How would one match/sub a string which begins with a "<" with zero
> or more"<", ">" alphanumerics, quotes, equal signs, period, commas,
> semi-colons, underscores, forward "/" and back "\" slashes, white
> space, etc and ends with a ">" character.  This does not appear to
> work
> 
>    $mystring =~ s/^<[A-Z a-z 0-9 "=.,;_/\\\s].+>$/my_new_string/;

The ".+" matches one or more instance of any character (except \n),
which kind of defeats the purpose of your character class (currently
you only require that character class for the first character on the
line).  Also \s doesn't work in a character class, you have to use
[:space:], which is almost the same.  You want:

/^<[ [:space:] [:alnum:] "=.,;_/\\ ]+>/

Although I have to ask, are you sure those are the only characters you
want to include?  A negated character class may be more appropriate.
If you want to match everything except the closing >, that's very
easy:

/^<[^>]+>/


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

Date: Wed, 26 Sep 2001 05:49:36 +0200
From: Marvin <glodalec@yahoo.com>
Subject: Re: Perl ROOT
Message-Id: <MPG.161b6ebc62c50e72989708@news.siol.net>

In article <CR_r7.24$Jh3.226437@news.interact.net.au>, 
tintin@snowy.calculus says...
> 
> "Marvin" <glodalec@yahoo.com> wrote in message
> news:MPG.161a4bf73c5a59a0989706@news.siol.net...
> > Hi !
> >
> > I installed perl on exported FS under /tools/usr/local/....
> >
> > Every client has mounted that directory.
> > Now when Im trying to run a perl script, it looks in /usr/local/....
> > structure for libraries. Is there any way I can change perl root
> > directory to be /tools.
> > I also tried with
> > use lib "/tools/usr/local/lib/perl5/..." ;
> > use lib "/tools/usr/local/lib/perl5/..." ;
> > use lib "/tools/usr/local/lib/perl5/..." ;
> 
> Link /tools/usr/loca/lib/perl5 to /usr/local/lib/perl5
> 
> 
> 
I don't want to do this. /tools is automounted from the fileserves, 
which shares /tools to 30 other servers (on different platforms 
(Sun,Digital) and I want to get rid of setting each server. I'm trying 
to use -I option now, no success yet though.


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

Date: Wed, 26 Sep 2001 04:32:51 +0200
From: "Dejan" <dejan.tomazic@club.win-ini.si>
Subject: Reading from HTML
Message-Id: <X1bs7.539$8v1.18371@news.siol.net>

Hi,
how can I read from HTML where is an option radio button its value into perl
script. I'd like to have a $variable that is depending on witch radio button
is selected.

Thanks to all. Dejan




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

Date: Wed, 26 Sep 2001 03:20:37 GMT
From: "Rob - Rock13.com" <rob_13@excite.com>
Subject: Re: Reading from HTML
Message-Id: <Xns9127ED6614602rock13com@64.8.1.226>

Dejan <news:X1bs7.539$8v1.18371@news.siol.net>:

> how can I read from HTML where is an option radio button its
> value into perl script. I'd like to have a $variable that is
> depending on witch radio button is selected.

Well since this is a Perl group, you would write a Perl script to 
use in the ACTION of the HTML Form. The CGI module may help.

-- 
Rob - http://rock13.com/
Web Stuff: http://rock13.com/webhelp/


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

Date: Wed, 26 Sep 2001 01:44:40 GMT
From: Andrew Cady <please@no.spam>
Subject: Re: regex variable length look behind
Message-Id: <87bsjy7mns.fsf@homer.cghm>

Joseph Shraibman <jks@spam.me.not.akula.com> writes:

> If I try to do this:
> @companies = split /(?<!\&\w+);/ , $temp; 
> 
> I get:
> /(?<!&\w+);/: variable length lookbehind not implemented at
> prnfeed.pl line 121.
> 
> I'm using version 5.005_03.  Will variable length look
> aheads/behinds be implemented soon?  Are there any workarounds?
> This isn't the first time I have had this problem.

Variable length lookaheads *are* implemented, at least in perl5.6.1.
That's because they're easy; with a variable-length lookahead you just
run the lookahead sub-regex against the remaining string and fail to
match if it fails.  Fixed-length lookbehind is also easy; you just
back up however many characters and do a lookahead.  But with
variable-length lookbehind, the only straightforward way is to run the
sub-regex at every preceding character in the entire string, checking
for any match that ends at the current position, and that would be too
slow.  There's no easy way to tell whether a generic variable-length
regex could END a certain position.  For some regexes, though, you can
reverse the string and the regex and use a lookahead.

push(@companies, $x=reverse) for (reverse split(/;(?!\w+&)/, reverse
        $temp));

I have absolutely no idea why, but that doesn't work on my perl
without the $x= in there.  It seems to me like it should, and that
reverse is behaving improperly, but anyway the above code seems to
work for what you're trying to do, although it looks pretty ugly to
me, there are probably much better ways.

HTH.


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

Date: Wed, 26 Sep 2001 01:49:24 GMT
From: Andrew Cady <please@no.spam>
Subject: Re: regex variable length look behind
Message-Id: <8766a67mfx.fsf@homer.cghm>

Andrew Cady <please@no.spam> writes:

> push(@companies, $x=reverse) for (reverse split(/;(?!\w+&)/, reverse
>         $temp));
> 
> I have absolutely no idea why, but that doesn't work on my perl
> without the $x= in there.

*Sigh*, it's in list context.

push(@companies, scalar reverse) .... works.


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

Date: Wed, 26 Sep 2001 01:53:25 GMT
From: "David Hilsee" <davidhilseenews@yahoo.com>
Subject: Re: regex variable length look behind
Message-Id: <pyas7.4889$G71.1435978@news1.rdc1.md.home.com>



"Andrew Cady" <please@no.spam> wrote in message
news:87bsjy7mns.fsf@homer.cghm...
> Joseph Shraibman <jks@spam.me.not.akula.com> writes:
>
> > If I try to do this:
> > @companies = split /(?<!\&\w+);/ , $temp;
> >
> > I get:
> > /(?<!&\w+);/: variable length lookbehind not implemented at
> > prnfeed.pl line 121.
> >
> > I'm using version 5.005_03.  Will variable length look
> > aheads/behinds be implemented soon?  Are there any workarounds?
> > This isn't the first time I have had this problem.
>
> Variable length lookaheads *are* implemented, at least in perl5.6.1.
> That's because they're easy; with a variable-length lookahead you just
> run the lookahead sub-regex against the remaining string and fail to
> match if it fails.  Fixed-length lookbehind is also easy; you just
> back up however many characters and do a lookahead.  But with
> variable-length lookbehind, the only straightforward way is to run the
> sub-regex at every preceding character in the entire string, checking
> for any match that ends at the current position, and that would be too
> slow.  There's no easy way to tell whether a generic variable-length
> regex could END a certain position.  For some regexes, though, you can
> reverse the string and the regex and use a lookahead.
>
> push(@companies, $x=reverse) for (reverse split(/;(?!\w+&)/, reverse
>         $temp));
>
> I have absolutely no idea why, but that doesn't work on my perl
> without the $x= in there.  It seems to me like it should, and that
> reverse is behaving improperly, but anyway the above code seems to
> work for what you're trying to do, although it looks pretty ugly to
> me, there are probably much better ways.
>
> HTH.

perldoc -f reverse
  reverse LIST
          In list context, returns a list value consisting of the elements
          of LIST in the opposite order. In scalar context, concatenates
          the elements of LIST and returns a string value with all
          characters in the opposite order.

I think you want a scalar reverse.

--
David Hilsee




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

Date: Wed, 26 Sep 2001 02:31:36 GMT
From: Jeff Wright <jeffpwright@home.com>
Subject: XL saveas doesn't work (excel)
Message-Id: <3BB13DBE.8F98F68A@home.com>

OK perl win32 OLE Excel gurus...
I cannot figure out why this doesn't work: I am trying to convert an
excel macro to perl and it just doesn't work.  It saves the .csv file,
but it is excel format, not csv.
Here is the basic vb:
 ActiveWorkbook.SaveAs FileName:= _
        "C:\temp\New Microsoft Excel Worksheet.csv", _
        FileFormat:=xlCSV, CreateBackup:=False
Anyone know how this should work in Perl??
Jeff Wright



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

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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.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 1818
***************************************


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