[13604] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1014 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Oct 7 16:05:37 1999

Date: Thu, 7 Oct 1999 13:05:11 -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: <939326710-v9-i1014@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Thu, 7 Oct 1999     Volume: 9 Number: 1014

Today's topics:
        AV,HV,SV <-> XML? yacob@rcn.com
        Backtick programs oliver.cookIYAPCR@ukonline.co.uk
    Re: Backtick programs <makkulka@cisco.com>
    Re: Backtick programs <marshalc@americasm01.nt.com>
    Re: Backtick programs <emschwar@rmi.net>
    Re: Backtick programs (Larry Rosler)
    Re: Broken Pipe? (Clinton Pierce)
    Re: Delete a line in a file <laurensmith@sprynet.com>
    Re: Do you now an affordable Perl editor for Windows NT <tnabbott@concentric.net>
    Re: exec() argument problem with ActiveState 520 (Clinton Pierce)
    Re: Help - Perl regular expression question! jennyng@my-deja.com
    Re: html strip regexp error (Larry Rosler)
        html tables <tnabbott@concentric.net>
    Re: mkdir... and then!? <emschwar@rmi.net>
    Re: mkdir... and then!? (Clinton Pierce)
    Re: odd or even numbers? (Craig Berry)
    Re: Parsing Through Multiple lines (Tad McClellan)
    Re: Passwords (Larry Rosler)
    Re: Perl & java <surya@ucdavis.edu>
        Perl -> TN3270 <slartibartfast@awardsforfjords.com>
        Perl calling pkzip UNC path problem <dlewright@nuworld.com>
    Re: Question about alarm and run away processes <ilya@speakeasy.org>
    Re: Regex question (Tad McClellan)
        scanning websites <rolftegen@yahoo.com>
    Re: scanning websites <makkulka@cisco.com>
        set startup page a1234_ec@yahoo.com
    Re: set startup page <makkulka@cisco.com>
    Re: set startup page (d.k. henderson)
    Re: Use of unitialized value (Clinton Pierce)
    Re: Use of unitialized value (Ghost)
    Re: We do complex Perl Programming (Craig Berry)
        Wrong?  s/\n\n/#/g; <myriad@erols.com>
    Re: Wrong?  s/\n\n/#/g; (Eric Bohlman)
    Re: Wrong?  s/\n\n/#/g; <sjohns17@uic.edu>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Thu, 07 Oct 1999 19:35:46 GMT
From: yacob@rcn.com
Subject: AV,HV,SV <-> XML?
Message-Id: <7tismh$6gl$1@nnrp1.deja.com>

Greetings,

  I am working on a problem where it would be *nice* if I could send an
SV and HV data structure from a client to a broker and back to an
adapter to recover into Perl name space intact (reblessed and ready to
go) on the receiving end.

  Assuming closely related versions of Perl on either end, the dirty
work I expect would be chasing pointers and copying data into an SV
payload (XML seemed to be a good choice).

  Is there some traditional means by which to do this?

thanks,

/Daniel


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


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

Date: 7 Oct 1999 18:07:03 GMT
From: oliver.cookIYAPCR@ukonline.co.uk
Subject: Backtick programs
Message-Id: <7ting7$hed$1@apple.news.easynet.net>


I'm writing a program which needs to call several shell programs. To
run them I use the following format:

`command1`;
`command2`;

however, command2 is started as soon as command1 is. How can I make is
to that command2 isn't started until command1 is finished?

REgards,
Ollie

Please remove the IYAPCR before replying by email.

***** Posted via the UK Online online newsreader *****

 Go to http://www.ukonline.co.uk to find out
 about other online services we offer our subscribers.




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

Date: Thu, 07 Oct 1999 11:34:01 -0700
From: Makarand Kulkarni <makkulka@cisco.com>
Subject: Re: Backtick programs
Message-Id: <37FCE798.834A26CE@cisco.com>

{ oliver.cookIYAPCR@ukonline.co.uk wrote:

> I'm writing a program which needs to call several shell programs. To
> run them I use the following format:
> `command1`;
> `command2`;
> however, command2 is started as soon as command1 is. How can I make is
> to that command2 isn't started until command1 is finished?

`command1`  && `command2` ;



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

Date: Thu, 07 Oct 1999 14:23:03 -0500
From: Marshall Culpepper <marshalc@americasm01.nt.com>
Subject: Re: Backtick programs
Message-Id: <37FCF317.DFA87A33@americasm01.nt.com>

Makarand Kulkarni wrote:

  { oliver.cookIYAPCR@ukonline.co.uk wrote:

  > I'm writing a program which needs to call several shell programs. To
  > run them I use the following format:
  > `command1`;

you might want to do a system("command1"), this automatically waits on the
process to end for you.

from perldoc -f system:

Does exactly the same thing as "exec LIST" except that a fork is done
first, and the parent process waits for the child process to complete.

The only downside to this is you might want to assign some kind of value to
the return status of the command, but if
all you want is a quick exec with no return value you could just

exec("command1");
wait;



 > `command1`  && `command2` ;

isn't that kinda a waste of resources? why would you want to evaluate the
values of both? I could be wrong but I
think he just wants a simple call of a command.

~Marshall
--
Homer "No beer, No TV make Homer something something.",
Marge "Go crazy??",
Homer "Don't mind if I do!"




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

Date: 07 Oct 1999 13:59:17 -0600
From: Eric The Read <emschwar@rmi.net>
Subject: Re: Backtick programs
Message-Id: <xkfhfk39c2y.fsf@valdemar.col.hp.com>

Marshall Culpepper <marshalc@americasm01.nt.com> writes:
> The only downside to this is you might want to assign some kind of value to
> the return status of the command, 

I think you have this backwards-- i.e., the downside would be if you
wanted to assign the return status of the command to something.  The
return status is an rvalue; you can't assign anything to it.

> but if all you want is a quick exec with no return value you could just 
> 
> exec("command1");
> wait;

It's true; this will exec a program, but I don't think that's what the
original poster wanted.  See perlfaq8: "How come exec() doesn't return?"

-=Eric
-- 
"Cutting the space budget really restores my faith in humanity.  It
eliminates dreams, goals, and ideals and lets us get straight to the
business of hate, debauchery, and self-annihilation."
                -- Johnny Hart


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

Date: Thu, 7 Oct 1999 12:55:27 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Backtick programs
Message-Id: <MPG.12669a8a6083eecc98a057@nntp.hpl.hp.com>

In article <37FCF317.DFA87A33@americasm01.nt.com> on Thu, 07 Oct 1999 
14:23:03 -0500, Marshall Culpepper <marshalc@americasm01.nt.com> says...

 ...

> you might want to do a system("command1"), this automatically waits on the
> process to end for you.
> 
> from perldoc -f system:
> 
> Does exactly the same thing as "exec LIST" except that a fork is done
> first, and the parent process waits for the child process to complete.
> 
> The only downside to this is you might want to assign some kind of value to
> the return status of the command, but if
> all you want is a quick exec with no return value you could just
> 
> exec("command1");
> wait;

Have you read the documentation for 'exec'?  You might have a very long 
wait indeed!

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Thu, 07 Oct 1999 17:40:20 GMT
From: cpierce1@ford.com (Clinton Pierce)
Subject: Re: Broken Pipe?
Message-Id: <37fed9c0.175943974@news.ford.com>

[poster cc'd in e-mail]

On Thu, 7 Oct 1999 15:03:47 +0100, "Nick Liebmann" <Nick@ucecom.com>
wrote:
>I get a sporadic problem in that the Unix server I am using, gives me a
>'Broken pipe error'.

This is usually due to something running in backticks, open(F, "|") or
system that's exiting unexpectedly.

>However, I check and rechek the script and can see nothing wrong with them..

You know, if you would have posted your code to Usenet hundreds if not
thousands of people could have checked and rechecked your script for you.

We're not psychics.

>And then the error disappears, do you think it could be a browser issue or
>the method of posting.

Quite frankly, without seeing the code, how the hell are we supposed to
know?




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

Date: Thu, 7 Oct 1999 11:48:39 -0700
From: "Lauren Smith" <laurensmith@sprynet.com>
Subject: Re: Delete a line in a file
Message-Id: <7tipv6$6ut$1@brokaw.wa.com>

Gaetan wrote in message <37FCCA40.D338E545@eii.fr>...
>What can i do to delete just one line in a file.
Here's something that my girlfriend found in a CGI/Perl book yesterday.
I almost choked.

--SCRIPT--
#!perl -w
use strict;

my $file = "something.ext";
my $dontprintme = "blah blah\n";
open (AFILE, "+<$file") or die "$file: $!";
my @wstofspc = <AFILE>;
seek (AFILE,0,0);
for my $line (@wstofspc) {
   print AFILE $line unless ($line eq $dontprintme);
}
truncate (AFILE, tell(AFILE));
close AFILE;
--/SCRIPT--

--DATAFILE--
hello
i'm good
print me
blah blah
you didn't see anything...
;-)
--/DATAFILE--

Of course, if the author had read perlfaq5:"How do I change one line in
a file/delete a line in a file/insert a line in the middle of a
file/append to the beginning of a file?", the solution would have been
much simpler and less memory taxing.

At your prompt, type:
perldoc -q perldoc -q "delete a line in a file"

Lauren




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

Date: 07 Oct 1999 12:24:44 PDT
From: "Tom Abbott" <tnabbott@concentric.net>
Subject: Re: Do you now an affordable Perl editor for Windows NT
Message-Id: <7tis1s$bb7@chronicle.concentric.net>

I use UEDIT32 and add perl keywords and such to it's customizable sytax
dictionary.

- Tom Abbott



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

Date: Thu, 07 Oct 1999 17:32:30 GMT
From: cpierce1@ford.com (Clinton Pierce)
Subject: Re: exec() argument problem with ActiveState 520
Message-Id: <37fdd7a1.175400452@news.ford.com>

[poster cc'd in e-mail]

On Thu, 7 Oct 1999 15:50:37 GMT, sasdsv@wnt.sas.com (Scott Vance) wrote:
>Something I forgot to mention in the first post...
>It is the space between My and Document in the editor's 
>path that caused the problems.  If you change the editor to 
>something without spaces in the path (such as
>$Prog = "C:\\Winnt\\Notepad.exe";) the program works.
>
>>It seems that the parameters that get passed to editor are
>>different between the two versions, because the editor complains
>>about an invalid path name:
>>
>>C:\My Documents\Files\UltraEdit\UEdit32.exe C:\My Documents\Perl\junk.pl contains an invalid path.
>>
>># Simple perl Program to load a file into an editor.
>>
>>$Prog = "C:\\Program Files\\UltraEdit\\UEdit32.exe";
>>$FileLocation = "C:\\My Documents\\Perl";
>>$File = "junk.pl";
>>
>>exec ($Prog, "$FileLocation\\$File");

First, what's the fascination with backslashes?  They make things harder
to read and cause (quiet) problems if you forget and only use one.  Use
the "/"!

Secondly, I've seen problems like this between various builds of
Activestate, and between Windows 95/98.  I've had luck (when what you did
didn't work) by surrounding the pathname with quotes:

# Not tested!
exec($Prog, qq{"$FileLocation/$File"});
die "exec() failed: $!";





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

Date: Thu, 07 Oct 1999 18:47:56 GMT
From: jennyng@my-deja.com
Subject: Re: Help - Perl regular expression question!
Message-Id: <7tipsn$496$1@nnrp1.deja.com>

Thanks Larry and Lee for your replies!  I a bit confused and need to
digest your replies first.  Will post more responses later.

Once again, thank you very much!

- Jenny

In article <7tibq5$si6$1@rguxd.viasystems.com>,
  lee.lindley@bigfoot.com wrote:
> Larry Rosler <lr@hpl.hp.com> wrote:
> :>In article <7th6sk$hjs$2@rguxd.viasystems.com> on 7 Oct 1999
04:17:24
> :>GMT, lt lindley <ltl@rgsun40.viasystems.com> says...
> :>> Larry Rosler <lr@hpl.hp.com> wrote:
> :>>
> :>> :>s/($bigger)|$pattern/defined $1 ? $1 : $replacement/ego;
> :>>
> :>> Ilya and Rick Delany pointed out to me that there exists a bug
> :>> where $1 is not always reset on unsuccessful partial matches
> :>> (I can't think of a better phrase to describe it at the moment).
> :>> The bug makes me leary of depending on the defined'ness of $1.
>
> :>Avoiding a bug is not a valid criterion for evaluating a potential
> :>solution to a problem.  Workarounds can be discussed afterwards.
> :>Anyhow, the code works in my tests.
>
> Hee Hee.  When you deliver that program to your coworker and
> she complains that it doesn't work right every time, you can
> just say that your solution is valid.  It isn't your fault that
> there is a bug in perl.  :-)
>
> I know you didn't mean that as evidenced by your willingness
> to discuss workarounds afterwards, but it was too fat and juicy
> a target to resist.  No offense meant.
>
> [snip]
> :>I benchmarked both, and yours is more than twice as fast (not
counting
> :>any time required to split the larger pattern into three pieces).
>
> Those assertions in the re engine are really fast.  I am continuously
> amazed.
>
> :>> Potential missed overlaps was the only one I could think of
> :>> on first blush.
>
> :>I can't think of how that can happen with either approach.
>
> If the replacement string overlapped (contained a subset or superset)
> of the string it was replacing, then after a substitution, there may
> exist a new target for replacement.
>
> --
> // Lee.Lindley   /// I used to think that being right was everything.
> // @bigfoot.com  ///  Then I matured into the realization that getting
> ////////////////////   along was more important.  Except on usenet.
>


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


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

Date: Thu, 7 Oct 1999 11:22:25 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: html strip regexp error
Message-Id: <MPG.126684b89cf1872b98a056@nntp.hpl.hp.com>

In article <7ti8f9$8n7$1@enterprise.cistron.net> on 7 Oct 1999 13:50:33 
GMT, ton <no@email.com> says...
> Via the FAQ I got this regexp to strip HTML tags:
> 
> $val =~ s{<(?:[^>'"]*|".*?"'.*?')+>}{}gsx;
> 
> I'm using this statement to strip HTML from a string.
> In a CGI environment.  Now I get servererrors:
> 
> /<(?:[^>'"]*|".*?"'.*?')+>/: regexp *+ operand could be empty
> 
> Can any help to fix the expression, because it's a bit abracadabra to me.

There is an obvious error in the regex.

  $val =~ s{<(?:[^>'"]*|".*?"|'.*?')+>}{}gsx;
                             ^
                             ^
But I don't know what FAQ you got that from.  Mine (perlfaq9: "How do I 
remove HTML from a string?") has this regex:

  s/<(?:[^>'"]*|(['"]).*?\1)*>//gs

The substantive change there is the final '*' instead of '+'.

Perhaps that will fix your problem.

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: 07 Oct 1999 12:22:59 PDT
From: "Tom Abbott" <tnabbott@concentric.net>
Subject: html tables
Message-Id: <7tiruj$b9b@chronicle.concentric.net>

Hi All:

I want to handle parse html tables and output to a file or database.  Is
there a resource I can refer to for help on this??

Thank you,
Tom Abbott



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

Date: 07 Oct 1999 12:33:10 -0600
From: Eric The Read <emschwar@rmi.net>
Subject: Re: mkdir... and then!?
Message-Id: <xkfr9j79g2h.fsf@valdemar.col.hp.com>

emlyn_a@my-deja.com writes:
> I'm sure this is simple to all you Perl gurus, but I'm having a really
> tough time telling perl to separate literal strings from paths (it
> creates a folder called "/users/$NewUser/").

I have a feeling you're not quoting things properly.  Anything inside ''
quotes doesn't get interpolated.  Anything inside "" quotes will be
interpolated (most of the time).  You're probably doing something like:

mkdir '/users/$NewUser', 0755;

> I looked into the
> ENV{'PATH'}, but there are no clear examples of how this is used - and
> I've looked!

That has nothing to do with it, although you can learn more about
standard Perl variables (such as %ENV) in the perldata manpage.

-=Eric
-- 
"Cutting the space budget really restores my faith in humanity.  It
eliminates dreams, goals, and ideals and lets us get straight to the
business of hate, debauchery, and self-annihilation."
                -- Johnny Hart


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

Date: Thu, 07 Oct 1999 17:25:07 GMT
From: cpierce1@ford.com (Clinton Pierce)
Subject: Re: mkdir... and then!?
Message-Id: <37fcd654.175067533@news.ford.com>

[poster cc'd in e-mail]

On Thu, 07 Oct 1999 16:50:01 GMT, emlyn_a@my-deja.com wrote:
>I'm sorta new to perl, but I CANNOT find help for this seemingly simple
>problem:

I just can't understand what's bugging you...?

>I need to mkdir under an existing directory called "users" (in the root
>dir) using a $NewUser variable as the name. Creating the directory is no
>problem, except it doesn't create the directory UNDER "users", it just
>creates it in the root folder.

# Use appropriate permissions for your situation!
mkdir "/user/$NewUser", 0755 or die "Cannot create: $!";

>This is a problem, because then I need to create a new FILE within this
>newly-created directory. Is creating a new file (thefile.dat) under an
>existing directory done like this below?
>
>open (DATAFILE, ">/users/NewUser/thefile.dat")

Don't you mean:

open(DATAFILE, ">/users/$NewUser/thefile.dat") 
	or die "Cannot create thefile.dat: $!";

>I'm sure this is simple to all you Perl gurus, but I'm having a really
>tough time telling perl to separate literal strings from paths (it
>creates a folder called "/users/$NewUser/"). I looked into the
>ENV{'PATH'}, but there are no clear examples of how this is used - and
>I've looked!

What's confusing about this?  Just be sure to use double-quotes so that
$NewUser's value is substituted into the pathname...It sounds like you
tried to do this:

	# Probably wrong!
	mkdir '/users/$NewUser', 0755;

Which is not what you want at all, apparently.

-- 
Clinton A. Pierce       "If you rush a Miracle Man, you get rotten
clintp@geeksalad.org        Miracles."  -- Miracle Max, The Princess Bride
http://www.geeksalad.org


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

Date: Thu, 07 Oct 1999 18:35:35 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: odd or even numbers?
Message-Id: <rvppvnl7d6e95@corp.supernews.com>

homeless (homelessinseattle@yahoo.com) wrote:
: I actually pondered my wording for a good half hour while trying to fall
: asleep last night. (seriously).  I really should have replaced $number with
: $scalar_value. But, alas, I'm stickin to my guns with the "_integer" thing,
: mostly 'cos "_numeral" sounds too British for my liking:)

But they mean different things.  'Numeral' is more or less synonymous with
'digit' -- a single glyph/entity, denoting a value from 0 to (base - 1).
'Integer', on the other hand, is any number whatsoever having no
(nontrivial) fractional part.  The representation of an integer involves a
possible sign, followed by a string of numerals.

-- 
   |   Craig Berry - cberry@cinenet.net
 --*--    Home Page: http://www.cinenet.net/users/cberry/home.html
   |      "There it is; take it."  - William Mulholland


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

Date: Thu, 7 Oct 1999 04:00:12 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Parsing Through Multiple lines
Message-Id: <cujht7.4qj.ln@magna.metronet.com>

jtgr8guy@my-deja.com wrote:

: I've looked for ways to read in and parse thru
: text files on this newgroup, but I'm still having
: trouble figuring out how to read this in...

: I have this as part of a text file:
: ----------------------------------------------
: Elapsed Time =  0  :  9  :  4
                   ^^ ^^ ^^ ^^
                   ^^ ^^ ^^ ^^ multiple spaces


:  The script finished at:  9/20/99 1:43:49 PM


:  Total Tests  =  13
:  Total Passed =  13
: --------------------------------------------------
: Is it better to try to all this in a buffer
: before parsing?


   It depends on whether or not you _need_ to grab a whole chunk.

   You haven't said anything that requires a whole chunk.

   All you have talked about is the "Elapsed Time" line, so
   line-by-line will be fine.

   If there is something that you haven't told us, then we
   can't help you with it  :-)



: I have matched "Elapsed Time = " to start reading
: in the time. But it doesn't seem to match the
: time and store them into $1, $2, $3 when I use
: parentheses.  


   Because your pattern does not match your string.


: How would I read each line
: individually(while<>)?  


   You are reading each line individually. So no problem there...


: I have this bit of code
: to try tomatch the time and input them once I
: find "Elapsed Time =", but it doesn't seem to be
: inputing the time:

: while (<INFILE>) {	#reading in each line?
: 	if (m/Elapsed Time = / || /ElapsedTime:/){
: 	#look for "Elapsed Time = "
:            print "Found\n";
:          #correct way to read in the time?
:         if (m/([0-9]+) : ([0-9]+) : ([0-9]
                        ^ ^        ^ ^
                        ^ ^        ^ ^ single spaces


        if (m/([0-9]+)\s*:\s*([0-9]+)\s*:\s*([0-9])/)


--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Thu, 7 Oct 1999 11:10:59 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Passwords
Message-Id: <MPG.12668210c41a837f98a055@nntp.hpl.hp.com>

In article <37FCCBD1.2A346C@dasburo.de> on Thu, 07 Oct 1999 18:35:29 
+0200, Alexander Knack <ak@dasburo.de> says...
> perldoc -f crypt!
> 
> my $plain = 'har har 99';
> 
> my $crypted = crypt ($plain , time());
> print "$crypted\n";

time() is an extraordinaily poor choice for a 'salt'.  The integral 
value is converted to a string, and the two high-order digits are used 
to salt the encryption.  These digits are very predictable and change 
rather slowly.  So you are increasing the likelihood of cracking the 
encryption by 4096.

This is from the crypt doc you referred to:

join '', ('.', '/', 0..9, 'A'..'Z', 'a'..'z')[rand 64, rand 64] 

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Thu, 7 Oct 1999 11:45:00 -0700
From: "Surya P Kommareddy" <surya@ucdavis.edu>
Subject: Re: Perl & java
Message-Id: <7tip4k$hea$1@mark.ucdavis.edu>

Actually I would like to use Java applications which provide buttons,
graphics etc. inside an application which is primarily a perl-cgi program.
Any pointers... tutorials?

Surya.





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

Date: Thu, 07 Oct 1999 13:29:21 -0500
From: Slartibartfast <slartibartfast@awardsforfjords.com>
Subject: Perl -> TN3270
Message-Id: <37FCE681.78B97080@awardsforfjords.com>

Can anyone give me a starting point to use Perl to communicate with
TN3270 system?



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

Date: Thu, 07 Oct 1999 19:41:30 GMT
From: Dorr Lewright <dlewright@nuworld.com>
Subject: Perl calling pkzip UNC path problem
Message-Id: <37FCF76B.ACA21EF9@nuworld.com>

When calling pkzip.exe, or a Windows NT 4.0 batch file I am getting the
following error message:

\\LINSQL02\ftpdata\FtpIn\ESS\Input' is an invalid current directory
path.  UNC paths are not supported.
Defaulting to Windows directory.

What can I do to remedy this problem?

I am running perl release "5.005_03 built for MSWin32-x86-object".



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

Date: Thu, 07 Oct 1999 18:06:08 GMT
From: Ilya <ilya@speakeasy.org>
Subject: Re: Question about alarm and run away processes
Message-Id: <rvpo8ghqd6e21@corp.supernews.com>

> perlfaq8:  How do I timeout a slow event?

root@cherokee-pts/8-~> perldoc -q timeout
=head1 Found in /usr/lib/perl5/5.00503/pod/perlfaq8.pod

=head2 How do I timeout a slow event?

Use the alarm() function, probably in conjunction with a signal
handler, as documented L<perlipc/"Signals"> and chapter 6 of the


	 And what L<perlipc/"Signals"> is, I have no idea either.
	 A directory on a machine? A web site? An entry in the FAQ?




	==============================================================
	Paper money eventually returns to its intrinsic value -- zero.
                 				  -Voltaire
	==============================================================


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

Date: Thu, 7 Oct 1999 04:21:55 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Regex question
Message-Id: <37lht7.4qj.ln@magna.metronet.com>

michaels@packet.obtero.com.au wrote:

: I need to parse a text file and strip off everything before the digits
                                            ^^^^^^^^^^

   But you *don't* want to strip _everything_ before the digits...



: I also want to turn the = in to a |.  So far, I've got:


: Try as I might, I can't seem to do a regex  that will take the | and
: the digits after it, and strip the \n so that the next match isn't placed
: on a new line.

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

my $line;
while ($line = <DATA>)  {
   $line =~ s/.*=\s*(\d+)$/| $1/;
   print $line;
};


__DATA__
blah blah blah = 2
foo bar baz = 1
---------------


--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Thu, 07 Oct 1999 21:04:18 +0200
From: Rolf <rolftegen@yahoo.com>
Subject: scanning websites
Message-Id: <37FCEEB2.230387C7@yahoo.com>

Hello,

I have at the moment the following problem:
1. I want to scan all URLs from a website (that is a site with many
links)
and then
2. to open these scanned pages, to scan the source code to be able to
download all GIF-files from there.
A friend told me that this isn't possible with a perl script. But I
still hope.
Has someone an idea how i could solve one (or both) problem?
 Thanks a lot,
    rolf




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

Date: Thu, 07 Oct 1999 12:20:10 -0700
From: Makarand Kulkarni <makkulka@cisco.com>
Subject: Re: scanning websites
Message-Id: <37FCF269.BF339B9C@cisco.com>

{ Rolf wrote:

>  I want to scan all URLs from a website (that is a site with many
> links) and then to open these scanned pages, to scan the source code to
> be able to
> download all GIF-files from there.

perldoc  LWP::UserAgent
perldoc HTTP::Request::Common
--



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

Date: Thu, 07 Oct 1999 18:45:41 GMT
From: a1234_ec@yahoo.com
Subject: set startup page
Message-Id: <7tipoh$47r$1@nnrp1.deja.com>

Is it possible to write a perl script to automatically set a browser's
startup page?


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


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

Date: Thu, 07 Oct 1999 12:21:16 -0700
From: Makarand Kulkarni <makkulka@cisco.com>
Subject: Re: set startup page
Message-Id: <37FCF2AC.5C1A777B@cisco.com>

{ a1234_ec@yahoo.com wrote:

> Is it possible to write a perl script to automatically set a browser's
> startup page?

No.
--



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

Date: Thu, 07 Oct 1999 19:38:43 GMT
From: dalekh@hotmail.com (d.k. henderson)
Subject: Re: set startup page
Message-Id: <8E579F864dkhenderson@207.14.233.126>

 

I don't think so. You maybe able to using Javascript, because Javascript
is supported by the browser where as perl is supported by the server.


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

Date: Thu, 07 Oct 1999 17:54:34 GMT
From: cpierce1@ford.com (Clinton Pierce)
Subject: Re: Use of unitialized value
Message-Id: <3800dc3f.176582662@news.ford.com>

[poster cc'd in e-mail]

On Thu, 07 Oct 1999 07:50:39 GMT, ghost24@bctek.com (Ghost) wrote:
>I am new to perl, and am not to familiar with modules or 
>refrences so I probably screwed something up!

That's OK.  Let's look!

[re-arranged slightly for clarity]
>I get an error: Use of unitialized value at test.pl line 10.
>	if (exists($tag->{$key})) {	<-- err. line 10

Ok, there's two things there that could cause the warning.  First is the
value of $key, the second is $tag itself.  

We can eliminate $tag, because to have gotten to line 10 "keys %$tag"
would have had to reported...something.  (If $tag weren't a hash
reference, you would've gotten other kinds of errors.)

>I added the exist part thinking maybee I was accessing an
>undefined hash element. But still gives same error so I 
>can only think the unitialized value is $key. But it shouldnt
>have been passed if invalid right?

exists and defined are two different things.

It's possible to have a hash with an undefined key.  This is perfectly
valid Perl:

	$foo{undef}="stuff";
	exists $foo{undef};  # returns true!

When run with "-w" it does throw a warning at you, though.  

So apparently, the hash referenced in $tag has a key that's not defined.
You know the key exists (because keys() returned it) so there's no reason
for the exists test.

What you want to say is something like:

	foreach $key (keys %$tag){
		if ( defined $key ) {
			print "$key: $tag->{$key}\n";
		}else{
			# Don't print it either, that'll throw 
			# a warning too.
			print "\$key is <undefined>\n";
		}
	}


-- 
Clinton A. Pierce       "If you rush a Miracle Man, you get rotten
clintp@geeksalad.org        Miracles."  -- Miracle Max, The Princess Bride
http://www.geeksalad.org


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

Date: Thu, 07 Oct 1999 19:28:03 GMT
From: ghost24@bctek.com (Ghost)
Subject: Re: Use of unitialized value
Message-Id: <rvpt23mqd6e61@corp.supernews.com>

In article <3800dc3f.176582662@news.ford.com>,
	cpierce1@ford.com (Clinton Pierce) writes:
> [poster cc'd in e-mail]
> exists and defined are two different things.
> 
> It's possible to have a hash with an undefined key.  This is perfectly
> valid Perl:
> 
> 	$foo{undef}="stuff";
> 	exists $foo{undef};  # returns true!
> 
> When run with "-w" it does throw a warning at you, though.  
> 

    I dont seem to get any warnings just in the middle of the
output I get:  Use of unitialized value at ./test.pl line 10.

> So apparently, the hash referenced in $tag has a key that's not defined.
> You know the key exists (because keys() returned it) so there's no reason
> for  
> What you want to say is something like:
> 
> 	foreach $key (keys %$tag){
> 		if ( defined $key ) {
> 			print "$key: $tag->{$key}\n";
> 		}else{
> 			# Don't print it either, that'll throw 
> 			# a warning too.
> 			print "\$key is <undefined>\n";
> 		}
> 	}

	I did this modification and when run using to different mp3 files
get the exact same output which is as follows:

ALBUM: BLUE
YEAR: 1999
Use of uninitialized value at ./test.pl line 10.
GENRE: 
TITLE: Mac Daddy
COMMENT: http://mp3.com/kennsmith
ARTIST: Kenn Smith

ALBUM: 
YEAR: 1999
Use of uninitialized value at ./test.pl line 10.
GENRE: 
TITLE: I'm so happy
COMMENT: http://mp3.com/AlexandraScott
ARTIST: Alexandra Scott

Is the error coming up when trying to print the data refrenced to the 
'GENRE' key or is there some other key being passed which is invalid?

TIA..

-- 
 .................
 name:  ghost24 ...........
 email: ghost24@bctek.com ......
 web:   www.bctek.com/~ghost24 .
--------------------------------


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

Date: Thu, 07 Oct 1999 18:46:11 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: We do complex Perl Programming
Message-Id: <rvpqjjedd6e80@corp.supernews.com>

Sahil (sehgal@del2.vsnl.net.in) wrote:
: We are an E-commerce based company and do any type of complex Perl
: programming in record time.

You must be very proud of yourselves. :)

-- 
   |   Craig Berry - cberry@cinenet.net
 --*--    Home Page: http://www.cinenet.net/users/cberry/home.html
   |      "There it is; take it."  - William Mulholland


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

Date: Thu, 7 Oct 1999 14:11:54 -0400
From: "Myriad" <myriad@erols.com>
Subject: Wrong?  s/\n\n/#/g;
Message-Id: <7tinos$omn$1@autumn.news.rcn.net>

perl -pe s/\n\n/#/g; somedoc.txt

Can someone tell me why this won't work to remove replace double hard
returns in a text file?  Can't figure it out.   Thought maybe it was because
\n needed to be used in conjunction with \r, but that didn't work either.

Thanks!





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

Date: 7 Oct 1999 19:15:12 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: Wrong?  s/\n\n/#/g;
Message-Id: <7tirg0$b0p@dfw-ixnews4.ix.netcom.com>

Myriad (myriad@erols.com) wrote:
: perl -pe s/\n\n/#/g; somedoc.txt
: 
: Can someone tell me why this won't work to remove replace double hard
: returns in a text file?  Can't figure it out.   Thought maybe it was because
: \n needed to be used in conjunction with \r, but that didn't work either.

The problem is that by default \n is the input record separator, and the 
-p switch creates a "magic" loop that reads one input record into $_, 
executes your supplied code, and then does a print.  Therefore, your code 
will never get a $_ that contains two newlines in a row and the regex in 
your substitution will never match.

The solution depends on how your text file is structured and how you want 
to deal with runs of more than two consecutive newlines, if such a thing 
is possible in your file.  If they aren't, your best bet is to set the 
input record separator for "paragraph mode" in a BEGIN {} block:

 perl -pe 'BEGIN {$/=""} $_ .= q(#)' somedoc.txt

or you could just slurp the whole file in and do the substitution:

 perl -pe 'BEGIN {undef $/} s/\n\n/#/g' somedoc.txt

Both can run into problems if your text file is very large.



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

Date: Thu, 7 Oct 1999 14:33:22 -0500
From: Seth David Johnson <sjohns17@uic.edu>
Subject: Re: Wrong?  s/\n\n/#/g;
Message-Id: <Pine.A41.4.10.9910071430370.320980-100000@tigger.cc.uic.edu>

On Thu, 7 Oct 1999, Myriad wrote:

> perl -pe s/\n\n/#/g; somedoc.txt
> 
> Can someone tell me why this won't work to remove replace double hard
> returns in a text file?  Can't figure it out.   Thought maybe it was because
> \n needed to be used in conjunction with \r, but that didn't work either.

The -p option includes newlines, but per line. The following seems to do
what you want:

perl -pe "s/^\n$//; s/\n$/#/;" somedoc.txt

-Seth
 www.pdamusic.com



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

Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 16 Sep 99)
Message-Id: <null>


Administrivia:

The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.

For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V9 Issue 1014
**************************************


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