[9901] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3494 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Aug 20 17:07:46 1998

Date: Thu, 20 Aug 98 14:00:23 -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           Thu, 20 Aug 1998     Volume: 8 Number: 3494

Today's topics:
    Re: CGI/Perl Permissions (Abigail)
        Code Style (Was: How to sort this associative array?) (Matt Knecht)
    Re: Coderef as hash-index (Abigail)
        Easy regx please help.... chad@gurucom.net
    Re: Easy regx please help.... <duarte@okay.net>
    Re: eq and == difference >>Abigail -> You are a LOSER.  (J.M. Davitt)
    Re: Help wanted please. (Abigail)
        HELP! Weird numeric errors (Harry McGreggor)
    Re: HELP! Weird numeric errors (Steve Linberg)
    Re: HELP! Weird numeric errors (Harry McGreggor)
    Re: HELP! Weird numeric errors (Josh Kortbein)
    Re: Help: Problem with Pattern-Matching (Josh Kortbein)
    Re: Help: Problem with Pattern-Matching <ajohnson@gpu.srv.ualberta.ca>
    Re: Help: Problem with Pattern-Matching (Abigail)
    Re: How do I execute perl from html program (Jon Bell)
    Re: How to sort this associative array? <jdporter@min.net>
        Looking for Perl FAQ Bot (Harry McGreggor)
        LWP::Simple Question <jjune@midway.uchicago.edu>
    Re: LWP::Simple Question <franzen@pmel.noaa.gov>
    Re: Nested regexp (Abigail)
    Re: Nested regexp (Josh Kortbein)
    Re: NT: redirect stdout to file jhildeb2@my-dejanews.com
        Perl IDE (George Y. Lembersky)
    Re: Problem with $^I in W95 (Bbirthisel)
    Re: Recommend a good editor (J.M. Davitt)
        regex question: striphtml and misformed tags patrick@cre8tivegroup.com
    Re: retrieving html source from url (Josh Kortbein)
        Sigh <arabung@neweducation.com>
    Re: such a thing as a "perl user"? (Jon Bell)
    Re: undef $/ in one-liner? (Abigail)
        what is 'sub f () {555};' <steves@wco.com>
    Re: what is 'sub f () {555};' <ajohnson@gpu.srv.ualberta.ca>
    Re: what is 'sub f () {555};' (Karlon West)
    Re: what is 'sub f () {555};' (Josh Kortbein)
        Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)

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

Date: 20 Aug 1998 19:03:13 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: CGI/Perl Permissions
Message-Id: <6rhrth$p2k$1@client3.news.psi.net>

Patrick Herrington (patrickh@innova.net) wrote on MDCCCXV September
MCMXCIII in <URL: news:35DC58C4.B9F66A75@innova.net>:
++ I am a novice Perl user who has been asked to write some pretty
++ complicated scripts. (At least I think they're complicated) The one I am
++ working on now stops and starts several services, including inetd,
++ sendmail and others.
++ 
++ The problem I am having involves starting sendmail from the CGI
++ interface I have setup. If I run the script from the command line,
++ sendmail starts correctly, but if run from the web interface, sendmail
++ responds with a 501 Permission Denied.

Which means it's not a Perl problem.

++ Sendmail can be stopped from both the command line and the web interface
++ with no problem.
++ 
++ Does anyone have any suggestions? I am currently starting sendmail using
++ a subroutine that runs the following:
++ 
++ system "/etc/rc.d/init.d/senmail start";

First of all, it's spelled sendmail, not senmail. Second, sendmail
listens to port 25. Binding to a port < 1024 requires root permission.
Third, that's a command you usually run while booting up the machine,
not just before sending out mail. Fourth, and most important, you aren't
checking the return value of system.

++ I am calling Perl using #!/usr/local/bin/perl -U

You don't want that. For CGI programs, you want -Tw, not -U!


The following works fine, and is a bit more secure:
[local-machine] $ ssh remote-machine
 ...
[remote-machine] $ su -
Password:
[remote-machine] # /etc/init.d/sendmail start



Abigail
-- 
perl -MNet::Dict -we '(Net::Dict -> new (server => "dict.org")\n-> define ("foldoc", "perl")) [0] -> print'


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

Date: Thu, 20 Aug 1998 20:43:46 GMT
From: hex@voicenet.com (Matt Knecht)
Subject: Code Style (Was: How to sort this associative array?)
Message-Id: <6U%C1.211$b16.1414295@news3.voicenet.com>

John Porter <jdporter@min.net> wrote:
>for (
>  map { $_->[0] }
> sort { $b->[1] <=> $a->[1] } # descending numeric
>  map { [ $_, (split ',',$team{$_})[3] ] }
> keys %team
>) {
>  print "$_ = $team{$_}\n";
>}

You've touched on a petty little problem I've been trying to solve.
That is, how to format such a beast as above.  I realize you just typed
that monstrosity on the fly, so you shouldn't be held too accountable
for its readability, but how would you format that in real code?
Unfortunately perlstyle.pod doesn't mention this (Although, I don't quite
agree with everything in there anyway).

What I'm using for constructs like that is:

for (map { $_->[0] }
     sort { $b->[1] <=> $a->[1] } # descending numeric
     map { [ $_, (split ',',$team{$_})[3] ] }
     keys %team) {

    # Insert nifty code here
}

Which sucks, but follows my own loose formatting rules.
I usually run into the following case more often (This is a snippet from
a script to parse news logs):

    for (sort
            {
                $spool->{0}->{ng}->{$b}->{count}
                <=>
                $spool->{0}->{ng}->{$a}->{count}
            }
            keys %{$spool->{0}->{ng}}) {

        printf "\t    %-5s : %s\n",
                commify($spool->{0}->{ng}->{$_}->{count}),
                $_;
    }
}

Which also sucks.  Opinions on how to format these constructs, anyone?

-- 
Matt Knecht - <hex@voicenet.com>


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

Date: 20 Aug 1998 19:08:30 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Coderef as hash-index
Message-Id: <6rhs7e$p2k$2@client3.news.psi.net>

Jan Egil Hagen (janha@dromi.ifi.uio.no) wrote on MDCCCXV September
MCMXCIII in <URL: news:yaazpczit3k.fsf@dromi.ifi.uio.no>:
++ 
++ 
++ It looks as though it is possible to use a coderef as a hash-index, but
++ it is not possible to call the function.

Indeed. All hash keys are stringified, so your reference turns into a string.

++ What's going on? Is this a bug or a feature?

It's documented behaviour, so probably not a bug. I certainly would not
call it a feature. I'd classify it as "barely better than nothing".



Abigail
-- 
perl -we '$_ = q ?4a75737420616e6f74686572205065726c204861636b65720as?;??;
          for (??;(??)x??;??)
              {??;s;(..)s?;qq ?print chr 0x$1 and \161 ss?;excess;??}'


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

Date: Thu, 20 Aug 1998 20:02:26 GMT
From: chad@gurucom.net
Subject: Easy regx please help....
Message-Id: <6rhvci$1vb$1@nnrp1.dejanews.com>

I know this is essy, but i keep screwing it up could someone please give me
the regx to parse this line.  thanks.


$line = '<a href="http://i.am.stupid.com/index.html">Yes that's me</a>';

this is what I want:

($link, $title) = ( $line =~ /(?)(?)/; }

-thanks chad

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum


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

Date: Thu, 20 Aug 1998 22:23:17 +0200
From: Tito Duarte <duarte@okay.net>
To: chad@gurucom.net
Subject: Re: Easy regx please help....
Message-Id: <35DC85B5.D4612E90@okay.net>



chad@gurucom.net schrieb:

> I know this is essy, but i keep screwing it up could someone please give me
> the regx to parse this line.  thanks.

> $line = '<a href="http://i.am.stupid.com/index.html">Yes that's me</a>';
>
> this is what I want:
>
> ($link, $title) = ( $line =~ /(?)(?)/; }
>
> -thanks chad
>
> -----== Posted via Deja News, The Leader in Internet Discussion ==-----
> http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum

  I'm not very familiar with regx, but this should solf your Problem:

($link,$title)=split(/">/,$line);
$link=~ s/<a href="//g;
$title=~ s/<\/a>//g;

CUl8er!

Tito "Shorty" Duarte!!



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

Date: 20 Aug 1998 19:21:48 GMT
From: jdavitt@ripco.com (J.M. Davitt)
Subject: Re: eq and == difference >>Abigail -> You are a LOSER. Take that stick out of your ass!
Message-Id: <6rht0c$ns8$2@gail.ripco.com>

Kermit the frog (kermit@sesamestreet.com) wrote:
: Why are you so fu...

This is great!  I missed Abigail's follow-up the first time
around but had to go back to see what it said after encountering
this.

Loser?  Not.  The reposnse was perfect.


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

Date: 20 Aug 1998 19:24:50 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Help wanted please.
Message-Id: <6rht62$pcr$2@client3.news.psi.net>

Lord M Spencer LLB (lordy@tcp.co.uk) wrote on MDCCCXV September MCMXCIII
in <URL: news:6rho3d$kk3$1@zeus.tcp.net.uk>:
++ Please could somebody help me with a perl program that will read a text file
++ and extract email addresses from it. Unfortunately the email addresses are
++ in no specific order or format, so it needs to scan from the top and search
++ by @ signs.


Mastering Regular Expressions contains a regex that matches email addresses,
as long as there are no nested comments. For nested comments, you need a
state machine (or perhaps with those funky new regex extentions that are
in perl5.005).



Abigail
-- 
perl -wle '$, = " "; print grep {(1 x $_) !~ /^(11+)\1+$/} 2 .. shift'


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

Date: Thu, 20 Aug 1998 23:33:39 GMT
From: harry@dublin.net (Harry McGreggor)
Subject: HELP! Weird numeric errors
Message-Id: <35dcb17e.73589470@news.netcom.ca>

Hi,

Could someone please give me a few pointers to why this doesn't work?

Cheers!

#!/usr/bin/perl

$number = "1234567890";
$number = $number + 1;

open(TEST,">/tmp/testing");

$test = printf("%.0f\n",$number);

print TEST $test;

close(TEST);

- Now I run the perl program
benz$ perl ./test.pl
1234567891

benz$ cat /tmp/testing
1benz$ 

- why is it 1? It should be 1234567891!


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

Date: Thu, 20 Aug 1998 15:43:35 -0400
From: linberg@literacy.upenn.edu (Steve Linberg)
Subject: Re: HELP! Weird numeric errors
Message-Id: <linberg-2008981543350001@projdirc.literacy.upenn.edu>

In article <35dcb17e.73589470@news.netcom.ca>, harry@dublin.net (Harry
McGreggor) wrote:

> Hi,
> 
> Could someone please give me a few pointers to why this doesn't work?
> 
> Cheers!
> 
> #!/usr/bin/perl
> 
> $number = "1234567890";

Why are you putting your numeric value in quotes?

> $number = $number + 1;
> 
> open(TEST,">/tmp/testing");
> 
> $test = printf("%.0f\n",$number);

How about sprintf instead?

> 
> print TEST $test;
> 
> close(TEST);
> 
> - Now I run the perl program
> benz$ perl ./test.pl
> 1234567891
> 
> benz$ cat /tmp/testing
> 1benz$ 
> 
> - why is it 1? It should be 1234567891!
_____________________________________________________________________
Steve Linberg                       National Center on Adult Literacy
Systems Programmer &c.                     University of Pennsylvania
linberg@literacy.upenn.edu              http://www.literacyonline.org


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

Date: Fri, 21 Aug 1998 00:04:49 GMT
From: harry@dublin.net (Harry McGreggor)
Subject: Re: HELP! Weird numeric errors
Message-Id: <35dcb967.75615303@news.netcom.ca>

Hi Steve,

#!/usr/bin/perl

$number = 1234567890;
$number = $number + 1;

open(TEST,">/tmp/testing");

$test = sprintf("%.0f\n",$number);

print TEST $test;

close(TEST);

benz$ perl ./test.pl
benz$ cat /tmp/testing
1234567891

Volia! Thanks for the sprintf tip.

Cheers,


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

Date: 20 Aug 1998 20:16:47 GMT
From: kortbein@iastate.edu (Josh Kortbein)
Subject: Re: HELP! Weird numeric errors
Message-Id: <6ri07f$bvv$7@news.iastate.edu>

Harry McGreggor (harry@dublin.net) wrote:
: Hi,

: Could someone please give me a few pointers to why this doesn't work?

: Cheers!

: #!/usr/bin/perl

: $number = "1234567890";
: $number = $number + 1;

: open(TEST,">/tmp/testing");

: $test = printf("%.0f\n",$number);

Read the documentation for printf(). It says it's equivalent to
print <blah blah blah>, and print() returns TRUE if successful.
So $test should be true if the print worked. Note that "true"
doesn't necessarily imply any specific non-false value. So
$test could be almost any value.

I think you want sprintf() instead.

: print TEST $test;

: close(TEST);

: - Now I run the perl program
: benz$ perl ./test.pl
: 1234567891

: benz$ cat /tmp/testing
: 1benz$ 



Josh

-- 
Omnia apud me mathematica fiunt.
[With me everything turns into mathematics.]
           - Rene Descartes



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

Date: 20 Aug 1998 18:51:17 GMT
From: kortbein@iastate.edu (Josh Kortbein)
Subject: Re: Help: Problem with Pattern-Matching
Message-Id: <6rhr75$bvv$3@news.iastate.edu>

setro@my-dejanews.com wrote:
: Hi!

: In a perl-script (packing Mail to a pager)
: I want to change a string!

: All words should start with a big letter,
: all ofther letters of the Words should be small.
: And I want to delete all space.

: So I try to make all letters small: tr/[A-Z]/[a-z]/  that's no problem Now
: make all first letters big (=letters after a space and the first in string)
: ?????  Here is the problem!!! Than delete all spaces: s/ //g that's no
: problem

: Example: "Many greetings to Petra and Sebastian!"
: result:  "ManyGreetingsToPetraAndSebastian!"

: Thanx for an email with a solution!

Sorry, too lazy to email.

Grepping the perl documentation for "lowercase" would have gotten
you your answer much more quickly, but this seems to do what
you want:

#!/usr/local/bin/perl -w
use strict;

my $string = join(' ', @ARGV);
$string =~ s/\b(\w+)\b/\u\L$1\E/g;
$string =~ s/ //g;

print $string, "\n";
__END__


Josh

-- 
Prosecutors will be violated.



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

Date: Thu, 20 Aug 1998 14:12:02 -0500
From: Andrew Johnson <ajohnson@gpu.srv.ualberta.ca>
Subject: Re: Help: Problem with Pattern-Matching
Message-Id: <35DC7502.3AA0B6E5@gpu.srv.ualberta.ca>

Mooneer Salem wrote:
!
! setro@my-dejanews.com wrote:
! >
! [snip]
! 
! > Example: "Many greetings to Petra and Sebastian!"
! > result:  "ManyGreetingsToPetraAndSebastian!"
! >
! 
! Try something like this:
! 
! $text = "Many greetings to Petra and Sebastian";
! $text =~ tr/A-z/a-z/;
! $text =~ s/\s*(.)(*)\s*/$1$2/g;
! $text =~ s/ //g;
! 
! Hope this helps.

doesn't look like it will help, did you try it?

here's one that fares a little better:

$_ = 'Many greetings to Petra and Sebastian';
($_=lc)=~s/(?:^| )(\w)/\u$1/g;
print;

regards
andrew


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

Date: 20 Aug 1998 19:22:29 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Help: Problem with Pattern-Matching
Message-Id: <6rht1l$pcr$1@client3.news.psi.net>

setro@my-dejanews.com (setro@my-dejanews.com) wrote on MDCCCXV September
MCMXCIII in <URL: news:6rhjgo$jqq$1@nnrp1.dejanews.com>:
++ 
++ 
++ So I try to make all letters small: tr/[A-Z]/[a-z]/  that's no problem Now

Wrong. That doesn't take care of accented letters. And why on earth
are you replacing '[' and ']' with '[' and ']'?

++ make all first letters big (=letters after a space and the first in string)
++ ?????  Here is the problem!!! Than delete all spaces: s/ //g that's no
++ problem

So, then just do it:

    $str = lc $str;   # Lowercase.
    s/ (\w)/\u$1/g;   # Make all letters following a space uppercase.
    s/(\w)/\u$1/;     # Uppercase the first letter.
    s/ +//g;          # Delete all spaces.

But what about other white space? What about letters following punctuation?
Mix of digits and letters?


Abigail
-- 
sub _'_{$_'_=~s/$a/$_/}map{$$_=$Z++}Y,a..z,A..X;*{($_::_=sprintf+q=%X==>"$A$Y".
"$b$r$T$u")=~s~0~O~g;map+_::_,U=>T=>L=>$Z;$_::_}=*_;sub _{print+/.*::(.*)/s}
*_'_=*{chr($b*$e)};*__=*{chr(1<<$e)};
_::_(r(e(k(c(a(H(__(l(r(e(P(__(r(e(h(t(o(n(a(__(t(us(J())))))))))))))))))))))))


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

Date: Thu, 20 Aug 1998 20:17:07 GMT
From: jtbell@presby.edu (Jon Bell)
Subject: Re: How do I execute perl from html program
Message-Id: <Ey08CJ.7oF@presby.edu>

In article <903607362.26349.0.nnrp-08.c2deb1c5@news.demon.co.uk>,
Daniel Adams <dan@fearsome.net> wrote:
>
>Martien Verbruggen wrote in message <6rg31c$mas$2@nswpull.telstra.net>...
>>
>>Would you answer a question about the home-growing of bananas, if
>>asked on this group?
>
>Thats exactly the point - if I knew the answer then yes, I would. I would
>also of course mention that his question was about CGI [...]

I realize you didn't really intend this juxtaposition, but it still made
me laugh.  Thanks for brightening up my day!  :-)

-- 
Jon Bell <jtbell@presby.edu>


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

Date: Thu, 20 Aug 1998 16:14:42 -0400
From: John Porter <jdporter@min.net>
Subject: Re: How to sort this associative array?
Message-Id: <35DC83B2.333@min.net>

Robert Walker - Lucent ASCC wrote:
> 
> %team looks like this
> $team{A} = "4,2,6,0.67"
> $team{B} = "2,8,2,0.2"
> $team{C} = "3,8,4,0.25"
> $team{D} = "7,1,4,0.87"
> I would like %team to be sorted on the last comma
> separated value of the string

Are you aware that this is a Frequently Asked Question?
perldoc perlfaq4
	"How do I sort an array by (anything)?"
	"How do I sort a hash 
		(optionally by value instead of key)?"

> My current method it to create another array
> that would just contain the key and value of interest.
>    @tmp{"A", "B", "C", "D"} = (0.67, 0.2, 0.25, 0.87)
> then sort this array on the values, then I have the array
> sorted.
> but maybe there is away to do this w/o a tmp array?

Actually that's not a bad way to do it.

But if you want to use a Schwartzian Transform, 
it might look very much like this:

# given:
%team = (
  A => '4,2,6,0.67',
  B => '2,8,2,0.2',
  C => '3,8,4,0.25',
  D => '7,1,4,0.87',
);

# sort using a ST:
for (
  map { $_->[0] }
 sort { $b->[1] <=> $a->[1] } # descending numeric
  map { [ $_, (split ',',$team{$_})[3] ] }
 keys %team
) {
  print "$_ = $team{$_}\n";
}

Here you've all kinds of temporary intermediate data;
it's just in anonymous storage (on the stack).

-- 
John Porter


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

Date: Fri, 21 Aug 1998 00:17:36 GMT
From: harry@dublin.net (Harry McGreggor)
Subject: Looking for Perl FAQ Bot
Message-Id: <35dcbc1b.76307209@news.netcom.ca>

Hi!

I'm looking for a Perl FAQ Bot which spits out entrys in a given FAQ
according to the users input. Do any such programs exist?

Cheers,


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

Date: Thu, 20 Aug 1998 19:04:02 GMT
From: "Joseph June" <jjune@midway.uchicago.edu>
Subject: LWP::Simple Question
Message-Id: <01bdcc6d$41453c80$81128780@joe>

I think my previous posting did not go through... so here it is again... 

THanks!
JJ

Hello,

I have a simple question for all the perl gurus out there... any help would
be appreciated... 

I am using LWP::Simple to load a file from the internet... something like

$page = get
"http://www.ncbi.nlm.nih.gov/htbin-post/Entrez/query?db=n&form=6&uid=$access
ion&dopt=g&save=s&html=no"

where I am specifying $accession through a form on a web page.  This
particular reference returns a document that does not have any HTML tags on
it... 

so $page has a value of 

LOCUS       DMU31961   338234 bp    DNA             INV       28-DEC-1995
DEFINITION  Drosophila melanogaster bithorax complex (BX-C), complete
sequence.
ACCESSION   U31961
NID         g969077
KEYWORDS    .
SOURCE      fruit fly.

<---snip>

How can a parse the data so that I can have $DEFINITION = "Drosophila
melanogaster... ", $ACCESSION = U31961... etc...??

I can't seem to parse it because $page does not take in value line by
line... but all at once when used with "get"


any ideas?  Any helps would be very very appreciated!..

Thank you for your help in advance!

-JJ


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

Date: Thu, 20 Aug 1998 12:13:12 -0700
From: Nathan Franzen <franzen@pmel.noaa.gov>
Subject: Re: LWP::Simple Question
Message-Id: <Pine.SOL.3.96.980820114750.9004C-100000@corona.pmel.noaa.gov>

On Thu, 20 Aug 1998, Joseph June wrote:

> I am using LWP::Simple to load a file from the internet... something like
 ...
> I can't seem to parse it because $page does not take in value line by
> line... but all at once when used with "get"

I guess your problem is that the whole chunk of data is now stored in a
single string, and not as a series of values. Obviously you want to split
it up.

'split' does all kinds of fancy operations, heavily documented.  Try 
typing 
		perldoc -f split

It seems to me that you would prefer to put the data into a hash, rather
than assigning variables like $LOCUS, so...

I think your problem is related to a question that I've had for some
time, which is, how do you efficiently split a string into key-value pairs
and tranform it into a hash, noting that the boundary between key and
value is different from the boundary between value and key?  I don't have
an answer that I'm fully satisfied with.  There *is* an example in the
'split' documentation that I've tweaked a little bit.

The example below is verbose.  I particularly don't like the 'shift @hash'
bit.

#!/opt/local/bin/perl -w

undef $/;
$page = <DATA>;
$page =~ s/\s*$//s;   #strip trailing newlines, whitespace
@hash = split /(?:\A|\n)([A-Z]+)/s, $page; #split on key, drop trailing\n 
shift @hash;   # get rid of the first null element
%hash = @hash;  # assign to hash

for (keys %hash){
  print " $_ => $hash{$_}\n";
}

__DATA__
LOCUS       DMU31961   338234 bp    DNA             INV       28-DEC-1995
DEFINITION  Drosophila melanogaster bithorax complex (BX-C), complete
sequence.
ACCESSION   U31961
NID         g969077
KEYWORDS    .
SOURCE      fruit fly.





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

Date: 20 Aug 1998 19:34:53 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Nested regexp
Message-Id: <6rhtot$pcr$3@client3.news.psi.net>

deepak@npac.syr.edu (deepak@npac.syr.edu) wrote on MDCCCXV September
MCMXCIII in <URL: news:6rhi68$ik0$1@nnrp1.dejanews.com>:
++ Hello all, Here is my substitution line $fulltag =~
++ s/$targeturl/$changedrel/; where $targeturl = c++.html (a link on a html page
++ to a file named c++.html) $changedrel = cplucplu.html (The new name of the
++ c++.html file) On script execution I get the following error: /c++.html/:
++ nested *?+ in regexp at cdrommap/copytopc.pl line 855, <I> chunk 23


That's discussed in the faq.



Abigail
-- 
perl -wle 'print "Prime" if ("m" x shift) !~ m m^\m?$|^(\m\m+?)\1+$mm'


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

Date: 20 Aug 1998 19:48:05 GMT
From: kortbein@iastate.edu (Josh Kortbein)
Subject: Re: Nested regexp
Message-Id: <6rhuhl$bvv$4@news.iastate.edu>

deepak@npac.syr.edu wrote:
: Hello all, Here is my substitution line $fulltag =~
: s/$targeturl/$changedrel/; where $targeturl = c++.html (a link on a html page
: to a file named c++.html) $changedrel = cplucplu.html (The new name of the
: c++.html file) On script execution I get the following error: /c++.html/:
: nested *?+ in regexp at cdrommap/copytopc.pl line 855, <I> chunk 23

: Is there anyway I can "protect" the targeturl variable so that it ignores the
: + characters in the string?

Try s/\Q$targeturl\E/$changedrel/ and read perldoc -f quotemeta.


Josh

-- 
Omnia apud me mathematica fiunt.
[With me everything turns into mathematics.]
           - Rene Descartes



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

Date: Thu, 20 Aug 1998 18:54:45 GMT
From: jhildeb2@my-dejanews.com
Subject: Re: NT: redirect stdout to file
Message-Id: <6rhrdl$rok$1@nnrp1.dejanews.com>

I'm not 100% sure about this so please forgive me if I'm wrong.  I think that
NT's command line parser may take the redirection characters as command
separators.  If that is true then when you run a perl script using sample.pl
>output.txt it looks up the association for a .pl file and translates it into

something like perl sample.pl %* (where %* means all the supplied parameters
like %1 %2 %3 etc.)  The redirection portion of the command isn't a parameter
to sample.pl so it isn't included in the translated command.  On the other
hand, when you run perl sample.pl <output.txt it doesn't have to do any
translation and uses the whole command line including the redirection.

As I said, I not sure this is 100% accurate but it makes sense to me.

HTH (Hope This Helps)

Jim Hildebrand


In article <35D93FEB.1FC8BC58@ubs.com>,
  Ian Maloney <ian.maloney@ubs.com> wrote:
> Gerhard Wrodnigg wrote:
>
> > I tried to redirect stdout to a file
> >
> > eg. sample.pl >output.txt
> > but this doesn't work :(
>
> Try this, it works for me:
>
> perl sample.pl >output.txt
>
> It appears that if you tell NT what program to run (i.e. perl) it works
> OK. But if NT has to work it out using file extension association it
> loses the redirect. I don't know what exactly is happening - but if you
> do find out let me know.
>
> Regards
> Ian
>
> ---------------------------------------------------------
> Ian Maloney UBS +41 1 236 1629 (FAX +41 1 236 6930)
>

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum


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

Date: 20 Aug 1998 18:46:24 GMT
From: gyl8384@is.nyu.edu (George Y. Lembersky)
Subject: Perl IDE
Message-Id: <6rhqu0$g31$1@news.nyu.edu>

Does anyone know of any IDEs for Perl?


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

Date: 20 Aug 1998 19:45:26 GMT
From: bbirthisel@aol.com (Bbirthisel)
Subject: Re: Problem with $^I in W95
Message-Id: <1998082019452600.PAA00973@ladder01.news.aol.com>

Hi Tye and Louie:

>) Finally, if I try $^I = 'bak'; the
>) original file is erased and a 0 byte copy (numbers.txtbak) is created.
>) 
>) Is this just MS-DOS weirdness? Thanks.
>
>Well, this last one might be an MS-DOS weirdness.

There have been reports on the Win32 Users list of various timing
and functional problems with renames and unlinks. You're trying
to do all of those in a bundle. The problem appears to be related
to Win95 attempts to preserve both long- and short- filenames
through "any-possible-combination" of file operations by legacy
applications. There is a magic 15 second window indroduced by
the file system driver. c.f. Systems Programming for Windows 95,
Walter Oney, $MS press, p. 627.

I haven't seen a solution.

-bill
Making computers work in Manufacturing for over 25 years (inquiries welcome)


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

Date: 20 Aug 1998 19:07:15 GMT
From: jdavitt@ripco.com (J.M. Davitt)
Subject: Re: Recommend a good editor
Message-Id: <6rhs53$ns8$1@gail.ripco.com>

Steve Bohler (skbohler@sprynet.com) wrote:
: I've searched through previous posts, but am not finding a recommendation
: for an easy-to-use Perl editor that runs on Windows.  I've used emacs
: before, but was wondering if there was something better.

: Thanks in advance for any suggestions.
: Steve

I've heard it said, "Real programmers use `cat' as their editor."
Would the DOS varient be `COPY CON: FILE?'



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

Date: Thu, 20 Aug 1998 20:28:35 GMT
From: patrick@cre8tivegroup.com
Subject: regex question: striphtml and misformed tags
Message-Id: <6ri0ti$3jh$1@nnrp1.dejanews.com>

I'm trying to master regexes.  I've been using the Irregular Expressions post
and the striphtml script from Tom C as a basis.  I've run into a problem
though with the HTML tags section, however, which I don't understand.  It
deals with misformed tags.  Tags such as <IMG SRC="blah.gif" WIDTH=150"
HEIGHT="10">.  The missing double quote causes perl to go to 100% CPU usage
and ties up the resources on my system.

In Tom's Code:
  s{ <                    # opening angle bracket

    (?:                 # Non-backreffing grouping paren
         [^>'"] *       # 0 or more things that are neither > nor ' nor "
            |           #    or else
         ".*?"          # a section between double quotes (stingy match)
            |           #    or else
         '.*?'          # a section between single quotes (stingy match)
    ) +                 # repetire ad libitum
                        #  hm.... are null tags <> legal? XXX
   >                    # closing angle bracket
}{}gsx;                 # mutate into nada, nothing, and niente

The problem is the [^>'"] * portion of the code.  If I remove the ", it works
fine.  Why is this?  This works fine so long as there is 2 or more double
quotes in the tag.  If there is only one, it won't remove that tag.

More importantly, why does the bad tag cause a runaway process?  Shouldn't it
just die?

Thanks for your help!

Patrick Gardella
patrick@cre8tivegroup.com

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum


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

Date: 20 Aug 1998 20:03:59 GMT
From: kortbein@iastate.edu (Josh Kortbein)
Subject: Re: retrieving html source from url
Message-Id: <6rhvff$bvv$5@news.iastate.edu>

Rasan Rasch (rasan@horizonlive.com) wrote:
: Hi,

: Is there a way to connect to a URL and read the contents of an .html
: file as if I were just reading something on my own file system, e.g. $in
: = new IO::File(somefile)?

If you're lazy, you can make a system call to

lynx -source url

if lynx is installed on your system.

If you're not lazy, or if you need something more robust, use LWP.



Josh

-- 
Omnia apud me mathematica fiunt.
[With me everything turns into mathematics.]
           - Rene Descartes



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

Date: Thu, 20 Aug 1998 16:55:43 -0400
From: Adam Rabung <arabung@neweducation.com>
Subject: Sigh
Message-Id: <35DC8D4F.1E222AC1@neweducation.com>

I retire from this newsgroup.  It seeming consists only of
    1.  Beginning programmers who are too lazy to type "man"
    2. Seasoned, angry programmers ready to pounce on anyone,
brandishing references to endless reams of faqs, man pages, and web
pages.

Why have seemingly all of the programmers who actually know Perl
appointed themselves to be the Universal Stewards of Moral
Rightousness?  So much typing is consumed here complaining about people
not using "man perlop" instead of answering the simple question!  Perl
is an eccentric language, and it's not always clear exactly what should
be looked up.
Presumably, seasoned programmers are here to help.  If you know the
answer, let the group know.  Otherwise, roll your eyes and click "next".



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

Date: Thu, 20 Aug 1998 20:13:12 GMT
From: jtbell@presby.edu (Jon Bell)
Subject: Re: such a thing as a "perl user"?
Message-Id: <Ey0860.7FG@presby.edu>

In article <linberg-2008980846340001@projdirc.literacy.upenn.edu>,
Steve Linberg <linberg@literacy.upenn.edu> wrote:
>
>This group is littered with "Michael Jordans," as you put it; people I
>know I will never be as good as.  Not because I couldn't if I put in the
>time, but because Perl isn't as central to my life. 

It's well-known in software circles that there is a fantastic range in
ability between different programmers, whether in terms of speed of
coding, or insight, or design skills, or whatever.  There are a relative
handful of people who are miles ahead of everybody else.  Don't let it get
you down.  After all, no basketball player in his right mind would get
depressed because he isn't Michael Jordan, would he?  :-)

-- 
Jon Bell <jtbell@presby.edu>


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

Date: 20 Aug 1998 19:41:01 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: undef $/ in one-liner?
Message-Id: <6rhu4d$pcr$4@client3.news.psi.net>

Matt Edwards (matt.edwards@thinkinc.com) wrote on MDCCCXV September
MCMXCIII in <URL: news:6rhgfj$ksr$1@strato.ultra.net>:
++ I can't seem to use to any avail:
++ 
++ perl -pi.bak -e 'undef $/; s/foo\nbar/foo bar\n/g' foobar.txt

Think about it. As the documentation says, it places an implicit
"while (<>) {" before your code, and an "print}" after it.

So you get:

   while (<>) {
      undef $/;
      s/foo\nbar/foo bar\n/g;
      print;
   }

which is a bit late for $/.

Either use:

   perl -pi.bak -e 'BEGIN {undef $/} s/foo\nbar/foo bar/g' foobar.txt

or

   perl -i.bak -e 'undef $/; $_ = <>; s/foo\nbar/foo bar/g; print' foobar.txt



Abigail
-- 
perl5.004 -wMMath::BigInt -e'$^V=new Math::BigInt+qq;$^F$^W783$[$%9889$^F47$|88768$^W596577669$%$^W5$^F3364$[$^W$^F$|838747$[8889739$%$|$^F673$%$^W98$^F76777$=56;;$^U=substr($]=>$|=>5)*(q.25..($^W=@^V))=>do{print+chr$^V%$^U;$^V/=$^U}while$^V!=$^W'


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

Date: Thu, 20 Aug 1998 11:58:32 -0700
From: Steven Smith <steves@wco.com>
Subject: what is 'sub f () {555};'
Message-Id: <35DC71D8.858B5CA8@wco.com>

I'm trying to understand a lib we pulled off of the net.  I've never
seen this before.
what would a sub declaration like this do??

sub f () {555};


Thanks
Steve Smith
DSC Corporation
Petaluma, CA



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

Date: Thu, 20 Aug 1998 14:17:32 -0500
From: Andrew Johnson <ajohnson@gpu.srv.ualberta.ca>
Subject: Re: what is 'sub f () {555};'
Message-Id: <35DC764C.497EA827@gpu.srv.ualberta.ca>

Steven Smith wrote:
> 
> I'm trying to understand a lib we pulled off of the net.  I've never
> seen this before.
> what would a sub declaration like this do??
> 
> sub f () {555};

why didn't you try it and see?

sub f() {555};
print f;

then try it with an argument.
then read the perlsub manpage.
(do the last one first and maybe
you can skip the first two :-)

regards
andrew


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

Date: 20 Aug 1998 19:51:41 GMT
From: karlon@bnr.ca (Karlon West)
Subject: Re: what is 'sub f () {555};'
Message-Id: <6rhuod$6f0@crchh14.us.nortel.com>

Steven Smith (steves@wco.com) wrote:
> I'm trying to understand a lib we pulled off of the net.  I've never
> seen this before.
> what would a sub declaration like this do??

> sub f () {555};

Wow, this'll be my 2nd post :)

Anyway, here's a contrived example to show it's use:

   #!/usr/bin/perl -w
   use strict;
   sub R_XR_XR_X () {0555}
   sub RWXR_XR_X () {0755}

   my $oldmask=umask 0;
   mkdir("tempdir1",R_XR_XR_X) or die "failed mkdir $!\n";
   mkdir("tempdir2",RWXR_XR_X) or die "failed mkdir $!\n";
   umask $oldmask;

   system("/bin/ls -ldog tempdir?");

Running, gives this:

  dr-xr-xr-x   2      24 Aug 20 14:47 tempdir1
  drwxr-xr-x   2      24 Aug 20 14:47 tempdir2

So, since functions do not have to be preceeded by "&" and/or
followed by parens, if the functions are defined before they
are used, functions that return values make handy C-like
contstants.

Otherwise, the above would use scalars like:

      $R_XR_XR_X=0555;

and that just doesn't look nearly as pleasant (to some anyway :)

Karlon



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

Date: 20 Aug 1998 20:06:51 GMT
From: kortbein@iastate.edu (Josh Kortbein)
Subject: Re: what is 'sub f () {555};'
Message-Id: <6rhvkr$bvv$6@news.iastate.edu>

Steven Smith (steves@wco.com) wrote:
: I'm trying to understand a lib we pulled off of the net.  I've never
: seen this before.
: what would a sub declaration like this do??

: sub f () {555};

Have you tried it?

It looks to me like it returns 555, regardless of the argument
provided - which leads me to believe that it's either (a) useless,
or (b) capable of doing something else that I don't see. AFAIK,
though, it just returns 555.


Josh

-- 
Omnia apud me mathematica fiunt.
[With me everything turns into mathematics.]
           - Rene Descartes



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

Date: 12 Jul 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Special: Digest Administrivia (Last modified: 12 Mar 98)
Message-Id: <null>


Administrivia:

Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.

If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu. 


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

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