[11261] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4861 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Feb 10 07:07:40 1999

Date: Wed, 10 Feb 99 04:00:22 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Wed, 10 Feb 1999     Volume: 8 Number: 4861

Today's topics:
        [Q]how can i implemet repeat enabled ra(Real Audio) pla <toBpro@netsgo.com>
        About creating local filehandles <fabascal@gredos.cnb.uam.es>
        Calculate yesterdays date <Peter.Webb@cern.ch>
    Re: Calculate yesterdays date <jhi@alpha.hut.fi>
        Can't get hash to return properly. <ken.wilson@home.com>
    Re: Can't get hash to return properly. (Sam Holden)
    Re: Converting CSV to LDIF <martin.lonnar@edt.ericsson.se>
    Re: Converting CSV to LDIF <martin.lonnar@edt.ericsson.se>
    Re: Converting CSV to LDIF (Bart Lateur)
    Re: fun with strings... (Bart Lateur)
    Re: Getting the last number in an IP addr with a regex. <ava@weblink.ru>
    Re: Getting the last number in an IP addr with a regex. <Tony.Curtis+usenet@vcpc.univie.ac.at>
    Re: How do I Send a form to a printer ? <ava@weblink.ru>
        how to use map for complex sort???? (Timothy Vroom)
    Re: how to use map for complex sort???? <dgris@moiraine.dimensional.com>
        newbie perl and cgi question..... <sys-admin@dont_spam_me.com>
    Re: newbie perl and cgi question..... (Sam Holden)
    Re: newbie perl and cgi question..... <Tony.Curtis+usenet@vcpc.univie.ac.at>
    Re: Perl 'zine (Jon Orwant)
        perl x- times an equal sentence simc@gmx.net
    Re: Problems with Content-Type Header in PERL/CGI (Administrator)
        search engine problem <hvermeulen@correctnl.com>
    Re: Speed of Python <mstenber@cc.Helsinki.FI>
        What's wrong with this???? (Administrator)
    Re: What's wrong with this???? <dean_darlison@dial.pipex.com>
        XML::Parser and xsl <fge@elsamprojekt.dk>
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: Wed, 10 Feb 1999 18:23:04 +0900
From: "toBpro" <toBpro@netsgo.com>
Subject: [Q]how can i implemet repeat enabled ra(Real Audio) player on the web?
Message-Id: <RS6BXZNV#GA.207@news3.netsgo.com>

I konw it is possible to play .ra file if plug-in was installed
(ex) RealPlayer..etc

But .. when i met this home-page's cgi...
I wonder how to ??
How can they play .ra file repeatedly ??

Please show me how to play it.. reapatedly

Bellow Site has that cgi..
Visit bellow site and mail me... please~~~
http://www.mbc.co.kr/NETOP/9902/hitsong/repeat_990204.htm

I will wait your answer...






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

Date: Wed, 10 Feb 1999 11:25:26 +0100
From: Federico Abascal <fabascal@gredos.cnb.uam.es>
Subject: About creating local filehandles
Message-Id: <36C15E96.1CF271EF@gredos.cnb.uam.es>

Help!
Is it possible to create a local filehandle (i.e. , inside a function)?
If so, how?
Thanks in advance.
Jose Maria and Federico



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

Date: Wed, 10 Feb 1999 11:01:22 +0100
From: Peter Webb <Peter.Webb@cern.ch>
Subject: Calculate yesterdays date
Message-Id: <36C158F1.463073ED@cern.ch>


Is there a quick way of calculating yesterdays date?

Peter.


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

Date: 10 Feb 1999 13:11:06 +0200
From: Jarkko Hietaniemi <jhi@alpha.hut.fi>
Subject: Re: Calculate yesterdays date
Message-Id: <oee7ltqh5th.fsf@alpha.hut.fi>


Peter Webb <Peter.Webb@cern.ch> writes:

> Is there a quick way of calculating yesterdays date?

localtime(time()-86400)

-- 
$jhi++; # http://www.iki.fi/jhi/
        # There is this special biologist word we use for 'stable'.
        # It is 'dead'. -- Jack Cohen


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

Date: Wed, 10 Feb 1999 09:29:32 GMT
From: Ken Wilson <ken.wilson@home.com>
Subject: Can't get hash to return properly.
Message-Id: <36C15178.C9F8AD55@home.com>

In a subsequent routine I get the keys to print out but the values are
lost.

Here is the code that's driving me up a wall.  Any assistance would be
appreciated.

#Purpose: Changes "surname, given" to "given surname" in hash values
#Given: \%hash where values are of format "surname, given names"
#Returns: Reference to hash where values are now "given names surname"
#Example: $r_users = reverseNames(\%users);
sub reverseNames {
    my ($ref_hash) = @_;
    foreach my $key (keys %$ref_hash) {
        my ($surname, $givenName) = split /, /, $$ref_hash{$key};
        $$ref_hash{$key} = "$givenName $surname";
    }
    return $ref_hash;
}

Note: Code works inside the foreach loop.


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

Date: 10 Feb 1999 09:40:03 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: Can't get hash to return properly.
Message-Id: <slrn7c2kvj.93t.sholden@pgrad.cs.usyd.edu.au>

On Wed, 10 Feb 1999 09:29:32 GMT, Ken Wilson <ken.wilson@home.com> wrote:
>In a subsequent routine I get the keys to print out but the values are
>lost.
>
>Here is the code that's driving me up a wall.  Any assistance would be
>appreciated.
>
>#Purpose: Changes "surname, given" to "given surname" in hash values
>#Given: \%hash where values are of format "surname, given names"
>#Returns: Reference to hash where values are now "given names surname"
>#Example: $r_users = reverseNames(\%users);
>sub reverseNames {
>    my ($ref_hash) = @_;
>    foreach my $key (keys %$ref_hash) {
>        my ($surname, $givenName) = split /, /, $$ref_hash{$key};
>        $$ref_hash{$key} = "$givenName $surname";
>    }
>    return $ref_hash;
>}
>
>Note: Code works inside the foreach loop.

Seems to work fine for me ...

use Data::Dumper;
print Dumper(reverseNames({bill => 'Smith, bill', fred => 'Jones, fred'}));

gives :

$VAR1 = {
          'fred' => 'fred Jones',
          'bill' => 'bill Smith'
        };

That seems to be what you want, so how is it wrong? Or is the problem
elsewhere?


-- 
Sam

comments on data are usually much more helpful than on algorithms
	--Rob Pike


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

Date: Wed, 10 Feb 1999 10:45:24 +0100
From: "Martin Lvnnar" <martin.lonnar@edt.ericsson.se>
Subject: Re: Converting CSV to LDIF
Message-Id: <36C15534.62C82380@edt.ericsson.se>

LDIF = LDAP Data Interchange Format.

/martin

Steve Palincsar wrote:

> CSV stands for "commas separated value" and there
> is a perl module in CPAN to help you parse it.
>
> What is LDIF?
>
> Aaron Tavistock wrote:
> >
> > What is a CSV file?
> >
> > I've done alot of scripts for converting other formats into LDIF, but I
> > have no idea what CSV is.
> >
> > Aaron Tavistock
> >
> > Martin Lvnnar wrote:
> > >
> > > Hi,
> > >
> > > Is there a script/module to quickly convert CSV files to LDIF files?
> > >
> > > /martin lvnnar





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

Date: Wed, 10 Feb 1999 10:49:33 +0100
From: "Martin Lvnnar" <martin.lonnar@edt.ericsson.se>
Subject: Re: Converting CSV to LDIF
Message-Id: <36C1562D.E00EA5ED@edt.ericsson.se>

It means "Comma separated values". In my case I guess it should be called
"TSV" for "Tab separated values".

I have a file extraction from an X.500 catalogue wich is a "TSV" file wich
needs to be converted to an LDIF file. How?

/martin

Aaron Tavistock wrote:

> What is a CSV file?
>
> I've done alot of scripts for converting other formats into LDIF, but I
> have no idea what CSV is.
>
> Aaron Tavistock
>
> Martin Lvnnar wrote:
> >
> > Hi,
> >
> > Is there a script/module to quickly convert CSV files to LDIF files?
> >
> > /martin lvnnar





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

Date: Wed, 10 Feb 1999 09:35:31 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Converting CSV to LDIF
Message-Id: <36c85266.6716009@news.skynet.be>

Craig Berry wrote:

>"Comma separated values".  Typically, in addition to commas separating
>values, values may be double-quoted strings to protect internal commas,
>and double quotes inside such strings may be backslashed to protect them.

Ouch. I don't think quotes are backslashed. Otherwise, you'd have to
backslash backslashes too. Quotes are generally *doubled*.

	"Hi", she said.
-->
	"""Hi"", she said."

	Bart.


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

Date: Wed, 10 Feb 1999 08:20:16 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: fun with strings...
Message-Id: <36c23ddd.1459082@news.skynet.be>

Marcos wrote:

>I am forced to deal with a scalar variable $this_is_given that was set
>to a string constant with '\n' or '\t' (not "\n" or "\t"). I need to be
>expand the \n and \t sequences to actual newlines and tabs.

Then, you probably need to convert "\\" to a single backslash, too. And
while we're at it: why not replace "\\\n" with "" (joining lines if line
ends with backslash).

Try this:

	%convert = ( n => "\n", t => "\t", "\n" => "" );
	for ($converted = $this_is_given) {
		s/\\(.)/exists($convert{$1})?$convert{$1}:$1/sge;
	}

Note: it's always better to do ALL the conversions in one loop, than to
repeat the loop for every conversion. You might end up replacing the
same thing more than once. Observe:

	$_ = "kinderen van de wereld";
	s/\bvan\b/de/g;
	s/\bde\b/le/g;
	print;
-->
	kinderen le le wereld

	$_ = "kinderen van de wereld";
	%replace = ( van => 'de', de => 'le' );
	s/\b(van|de)\b/$replace{$1}/g;
	print;
-->
	kinderen de le wereld

	Bart.


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

Date: Wed, 10 Feb 1999 14:39:09 +0300
From: "Alexei V. Alexandrov" <ava@weblink.ru>
To: Kim Saunders <kims@tip.net.au>
Subject: Re: Getting the last number in an IP addr with a regex.
Message-Id: <Pine.LNX.3.96.990210143708.5870A-100000@pns.softclub.net>



On Sun, 24 Jan 1999, Kim Saunders wrote:

>>Kim> That is, I have an IP w.x.y.z where w,x,y and z
>>Kim> are numbers between 1 and 255 or so (the actual
>>
>>What's wrong with 0?
why not use a thing like this:
$ip = "192.168.3.100";
@arr = split(/\./, $ip);
$last_no = pop(@arr);
print $last_no;
>
>
>Whatever, not important..... Actually, it is as I am testing on a subnet
>with a 0 in it...
>
>KimS
>
>
>
>



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

Date: 10 Feb 1999 12:35:57 +0100
From: Tony Curtis <Tony.Curtis+usenet@vcpc.univie.ac.at>
Subject: Re: Getting the last number in an IP addr with a regex.
Message-Id: <83hfsua3tu.fsf@vcpc.univie.ac.at>

Re: Getting the last number in an IP addr with a
regex., Alexei <ava@weblink.ru> said:

Alexei> On Sun, 24 Jan 1999, Kim Saunders wrote:

>>>  What's wrong with 0?

thanks for not citing my article (sarcasm).

Alexei> why not use a thing like this: $ip =
Alexei> "192.168.3.100"; @arr = split(/\./, $ip);
Alexei> $last_no = pop(@arr); print $last_no;

which is exactly what I suggested in my unattributed
reply.

tony
-- 
Tony Curtis, Systems Manager, VCPC,    | Tel +43 1 310 93 96 - 12; Fax - 13
Liechtensteinstrasse 22, A-1090 Wien.  | <URI:http://www.vcpc.univie.ac.at/>
"You see? You see? Your stupid minds!  | private email:
    Stupid! Stupid!" ~ Eros, Plan9 fOS.| <URI:mailto:tony_curtis32@hotmail.com>


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

Date: Wed, 10 Feb 1999 14:49:09 +0300
From: "Alexei V. Alexandrov" <ava@weblink.ru>
To: Jim and Lois <kf4dmb@camcomp.com>
Subject: Re: How do I Send a form to a printer ?
Message-Id: <Pine.LNX.3.96.990210144825.5870B-100000@pns.softclub.net>

On Sun, 24 Jan 1999, Jim and Lois wrote:

>I am building a Help desk app . I would like users when the fill the form
>out and press
use Unix lpr command, and print to it directly. Like you do with sendmail
to send mail.
>a button they send it to the help desk printer.
>
>
>
>



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

Date: 10 Feb 1999 07:54:59 GMT
From: vroom@cs.hope.edu (Timothy Vroom)
Subject: how to use map for complex sort????
Message-Id: <79re0j$82o@news.cs.hope.edu>


I need to do a complicated sort in which I split the strings in the array
which are separated by : then I sort on the addition between the second and
third fields

an example string stored in the array would be 123450678:12:1 

for this example I would like to compute the sum of the second and third field
12+1=13 and then sort on the value 13.

Any suggestions or code snippets would be much appreciated..

Thanks,

Tim Vroom
--
--------------------------------------------------------------------------
E-mail : vroom@cs.hope.edu          Homepage:http://www.cs.hope.edu/~vroom
--------------------------------------------------------------------------


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

Date: 10 Feb 1999 01:49:36 -0700
From: Daniel Grisinger <dgris@moiraine.dimensional.com>
Subject: Re: how to use map for complex sort????
Message-Id: <m3679abq3j.fsf@moiraine.dimensional.com>

vroom@cs.hope.edu (Timothy Vroom) writes:

> I need to do a complicated sort in which I split the strings in the array
> which are separated by : then I sort on the addition between the second and
> third fields
> 
> an example string stored in the array would be 123450678:12:1 

You need a Schwartzian Transform.

@sorted = map { $_ -> [0] }
          sort { $a -> [1] <=> $b -> [1] }
          map { [ $_ -> [0], $_ -> [2] + $_ -> [3] ] }
          map { [ $_, split /:/, $_ ] } @unsorted;

HTH.

dgris
-- 
Daniel Grisinger          dgris@moiraine.dimensional.com
perl -Mre=eval -e'$_=shift;;@[=split//;;$,=qq;\n;;;print 
m;(.{$-}(?{$-++}));,q;;while$-<=@[;;' 'Just Another Perl Hacker'


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

Date: Wed, 10 Feb 1999 09:33:27 -0000
From: "system administrator" <sys-admin@dont_spam_me.com>
Subject: newbie perl and cgi question.....
Message-Id: <79rjkf$3i8$1@newsreader3.core.theplanet.net>

Most of the tutorials i have seen for decoding form data sent to cgi
programs takes the following format:-

Read QUERY_STRING env and split at the & char and store contents in an array
variable.
Then for each of the elements of the array, split at the = char and store
the resulting split in to scalars:-
$key and $value.
Then use the $key and $value to create an associative array.

code follows:-

QUERY_STRING="user=bob&action=add"
export QUERY_STRING


#!/usr/bin/perl

print("Content-type:text/html\n\n");
print("<html>");

@query_string = split(/&/,$ENV{"QUERY_STRING"});

foreach $index (0..$#query_string) {
($key,$value) = split(/=/, $query_string[$index]) || die "died on 2nd
split...";
$output{$key}=$value;
};

print $output{"user"};
print("</html>");

However this program never produces any output. I am pretty sure the first
split is working ok,
as a can print $query_string[0,1]. I don;t think ther sencond split is
working correctly, as incorrect values
are being assigned to $key and null is being assigned to $value.

Any help much apprec.....



===========================
Volia le piste beaver....
le beaver c'est dans le piste....





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

Date: 10 Feb 1999 09:59:03 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: newbie perl and cgi question.....
Message-Id: <slrn7c2m36.93t.sholden@pgrad.cs.usyd.edu.au>

system administrator <sys-admin@dont_spam_me.com> wrote:
^^^^^^^^^^^^^^^^^^^^
I hope not... I would hope that a sysadmin would at least know how to do
some simple 'printf school' debugging, and to read documentation and thus
not reinvent the wheel...

>Most of the tutorials i have seen for decoding form data sent to cgi
>programs takes the following format:-
>
>Read QUERY_STRING env and split at the & char and store contents in an array
>variable.
>Then for each of the elements of the array, split at the = char and store
>the resulting split in to scalars:-
>$key and $value.
>Then use the $key and $value to create an associative array.

Why not just use CGI and have it all done for you...

>($key,$value) = split(/=/, $query_string[$index]) || die "died on 2nd
>split...";

Oops... That gets parsed as :

($key,$value) = ( split(/=/, $query_string[$index]) || die "died ..." );

That has the effect of putting the split into a scalar context. So as the
documentation says :

If not in list context, returns the number of fields found and splits into
the @_ array.

Thus $key gets assigned 2 and $value gets undef.

A couple of print statements would have revealed this to you in a few seconds.

>However this program never produces any output. I am pretty sure the first
>split is working ok,
>as a can print $query_string[0,1]. I don;t think ther sencond split is
>working correctly, as incorrect values
>are being assigned to $key and null is being assigned to $value.

So what one would do is the read the documentation and think, oh that
'incorrect' just happens to be the number of fields found. Oh the documentation
says when that happens, I wonder if that is what is happening...

>
>Any help much apprec.....

Of course the 'correct' way to do what your code did is :

#!/usr/local/bin/perl -wT
use CGI qw/:standard/;
print header;
print '<html>',param('user'),'</html>';


Don't reinvent the wheel...

-- 
Sam

You can blame it all on the internet. I do...
	--Larry Wall


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

Date: 10 Feb 1999 11:07:22 +0100
From: Tony Curtis <Tony.Curtis+usenet@vcpc.univie.ac.at>
Subject: Re: newbie perl and cgi question.....
Message-Id: <83btj2a7xh.fsf@vcpc.univie.ac.at>

Re: newbie perl and cgi question....., Sam
<sholden@pgrad.cs.usyd.edu.au> said:

Sam> #!/usr/local/bin/perl -wT use CGI
Sam> qw/:standard/; print header; print
Sam> '<html>',param('user'),'</html>';

Or...

print header,
      start_html("your title goes here"),
      param('user'),
      end_html;

IMHO bare HTML should be avoided at all costs when
you're generating it programmatically, and CGI.pm
gives you such nice shortcuts.

Sam> Don't reinvent the wheel...

because perl offers so many brightly coloured wheels
anyway :-)


hth
tony
-- 
Tony Curtis, Systems Manager, VCPC,    | Tel +43 1 310 93 96 - 12; Fax - 13
Liechtensteinstrasse 22, A-1090 Wien.  | <URI:http://www.vcpc.univie.ac.at/>
"You see? You see? Your stupid minds!  | private email:
    Stupid! Stupid!" ~ Eros, Plan9 fOS.| <URI:mailto:tony_curtis32@hotmail.com>


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

Date: 10 Feb 1999 04:56:52 GMT
From: orwant@alphaville.media.mit.edu (Jon Orwant)
To: webmaster@wondertek.com, carvdawg@patriot.net
Subject: Re: Perl 'zine
Message-Id: <ORWANT.99Feb9235652@alphaville.media.mit.edu>

In article <36C04633.3EC8EB2D@ecpi.com> "John T. Jarrett" <jjarrett@ecpi.com> writes:

>    From: "John T. Jarrett" <jjarrett@ecpi.com>
>    Newsgroups: comp.lang.perl.misc,comp.lang.perl.modules
> 
>    Also, when it came in print, we could have a page for Perl Monger
>    groups and their activities; a page for the Perl Institute with 
>    current projects, a project highlight, and request for project leaders; 
>    a sidebar on the future of perl. As far as Perl Institute's trying to 
>    get Perl better recognized, I think an effort like this would go a 
>    tremendous way toward doing that.
> 
>    Also, I can at least write articles and provide a web-area for putting 
>    basic scripts up onto websites with what-can-go-wrong and 
>    why-it-works-or-not, etc.
> 
>    John
> 
>    Marquis de Carvdawg wrote:
> 
>    > What I was hoping for, as I said, was something along the lines of
>    > TPJ...but more often.  I like the format of TPJ and the Linux Journal,
>    > in that things are explained and working code is provided.
>    >
>    > A couple of regular sections I'd like to see are:
>    >
>    > Perl on Unix/Linux
>    > Perl on Win32
>    > CGI (various platforms)
>    > Background info, examples, projects, etc
 
I guess I'm a little bit confused by how TPJ isn't meeting your
needs.  If it's not frequent enough (I'm working on that; it'll
go bimonthly in 2000, and all-glossy with the next issue), then
that's one thing that argues for electronic distribution -- but
now you're talking about print as well?  

The more magazines the merrier, I suppose -- it only points to Perl's
health that two competing magazines could exist.  But note that it
costs $20K/issue to print and mail an issue, and there are a lot of
boring details you'll learn the hard way.  I did; it's been three
years of 90-hour weeks.  I wouldn't wish it on anyone, but if you
choose that road please let me know so I can help you avoid all the
mistakes I made. 

I've long been asking for a recurring page on what the Perl Monger
groups are doing, but no one has stepped up to the plate. 

I always encourage people to talk about their projects, and I have
Win32 articles in every issue.

As a founding director of The Perl Institute, I always encourage
the heads of big projects to talk about them in the magazine.

Now: If anyone wants to write about these things for TPJ, I'll be
happy to pay you.

If anyone wants to help put out an electronic (and more frequent)
version of TPJ, I'll be happy to pay you too.

If anyone wants to just go all-out and compete with TPJ, give
me a call and I'll tell you how to start.  But you should make
sure that you distinguish your magazine from TPJ somehow so that
we don't both die.  

-Jon

------------------------------------
Jon Orwant            http://tpj.com
Editor & Publisher, The Perl Journal

--


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

Date: Wed, 10 Feb 1999 09:23:59 GMT
From: simc@gmx.net
Subject: perl x- times an equal sentence
Message-Id: <79rj77$2k8$1@nnrp1.dejanews.com>

hi all ...

i 've a problem with perl: when i want to attache (>>) a sentence to a
existing file, the command 'print SFILE "xyz";' print 'xyz' x- times (where x
is the count of the existing sentences), after this operation i have so x-
times the equal sentence in the file. does someone have an idea that is
situated?

thanx

simc

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Wed, 10 Feb 1999 10:00:56 +0100
From: EMAG-Herzberg@t-online.de (Administrator)
Subject: Re: Problems with Content-Type Header in PERL/CGI
Message-Id: <36C14AC8.356A991@emag.de>

Lynch Man wrote:
> 
> I am rather new at CGI PERL, so any help would be appreciated.
> I am writing a guestbook CGI ( i know, it is simple ) but I am having
> some problems with it.  I am trying to have the CGI return both text AND
> image files to the browser.  Basically I have the CGI "print" the HTML
> out. However, I cannot seem to get both the image ( a jpeg file - being
> used for the title of the messages page) and the text to disple in the
> browser at the same time.  The problem is the content header.  Right now
> it is set to:
> Content-Type: text/HTML
> 
> and I can get graphics to display if I do:
> Content-Type: image/jpeg
> 
> Is there a way I can have both at the same time on the same CGI? I would
> really like to be able to have the graphics (jpeg files) along with the
> text through a single CGI....

No. That would be an inline binary within an HTML doc.


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

Date: 10 Feb 1999 09:52:50 GMT
From: "Henry Vermeulen" <hvermeulen@correctnl.com>
Subject: search engine problem
Message-Id: <79rkti$8om@news3.euro.net>

Hi to you all.
I need a hand with this piece of a search engine.
Only links build whith <A HREF are followed.
But i have a lot of pulldown menus with <OPTION VALUE.
I,m working on this for about 3 days but due the fact im a perl minor it
won't work.
a href or option value but not both.
What do i need to do to make it work?

regards Henry

sub get_href {
   my($file) = @_;
   my ($i, $link, $url, $page);
   my(@links) ;
   my(@lnks);

   $page = &readFile($file);
   @links = split(/<A[\s]+HREF[\s]*=[\s]*/i, $page);
   foreach $i (1..$#links) {
      $link = $links[$i];
      if ($link =~ /^\"?([^>\"\s]*)\"?/) {
   push(@lnks, $1);
      }
   }
   return @lnks;
}

sub readFile {
   my($file) = @_;
   local(*FH);
   my(@page);
   my($string);

   open (FH, $file) || warn "Cannot open file $file: $@";
   @page = <FH>;
   close FH;
   $string = join("",@page);
   return $string;
}




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

Date: 10 Feb 1999 11:12:59 +0200
From: Markus Stenberg <mstenber@cc.Helsinki.FI>
Subject: Re: Speed of Python
Message-Id: <al81zjy8vvo.fsf@myntti.helsinki.fi>

dragons@scescape.net (Matthew Bafford) writes:
> Tue, 9 Feb 1999 20:02:33 +0100, Thomas Ackermann <tgm@math.uni-bonn.de> wrote:
> [snip]
> -> @x=<>;                                          from sys import stdin
> ->                                                 a=stdin.read()
> I know not Python, but my reading of this says those two are not the same.

They are not. Perl composes an array of lines, that example in Python just
produces single string.

Here's equivalent code:

Perl:
	@x = <>;				     import sys
						     x = sys.stdin.readlines()

Just for laughs, timings on largest text file I could find (~11M of ping
data):

 ./foo.pl < ping/x  3.82s user 0.39s system 93% cpu 4.512 total
 ./foo.pl < ping/x  3.83s user 0.38s system 92% cpu 4.539 total
 ./foo.pl < ping/x  3.77s user 0.42s system 92% cpu 4.533 total
 ./foo.pl < ping/x  3.85s user 0.39s system 92% cpu 4.582 total
 ./foo.pl < ping/x  3.79s user 0.45s system 92% cpu 4.584 total

 ./foo.py < ping/x  1.21s user 0.50s system 94% cpu 1.808 total
 ./foo.py < ping/x  1.26s user 0.45s system 93% cpu 1.836 total
 ./foo.py < ping/x  1.27s user 0.45s system 93% cpu 1.833 total
 ./foo.py < ping/x  1.27s user 0.44s system 94% cpu 1.809 total
 ./foo.py < ping/x  1.25s user 0.48s system 95% cpu 1.802 total

Still, seems like when comparing both builtin 'do array from file' methods,
Python is noticeably faster.

> Of course Perl would be slower in this case.  It still has to find the input
> separator ("\n" in this case) for each and every line.

Obviously.. Python is still faster in array-building stuff though, by
factor of (roughly) 2.5, apparently.

> --Matthew

-- 
	Markus Stenberg


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

Date: Wed, 10 Feb 1999 10:05:01 +0100
From: EMAG-Herzberg@t-online.de (Administrator)
Subject: What's wrong with this????
Message-Id: <36C14BBD.385679C1@emag.de>

I programmed this to do some syslog output, but nothing showed up on the
syslog screen (tty12)... what's wrong?

 ------------------------------
#!/usr/bin/perl

use Sys::Syslog;

openlog('me','perror','user');
syslog('info','This is a test.');
closelog();
 ------------------------------

Yes, the syslog config does allow info messages to display; warnings
didn't work either. the syslog call returns 29, or sometimes 28... (?!?)

Thanxs in advance...


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

Date: Wed, 10 Feb 1999 10:43:05 +0000
From: Dean Darlison <dean_darlison@dial.pipex.com>
Subject: Re: What's wrong with this????
Message-Id: <36C162B9.9671942C@dial.pipex.com>

Administrator wrote:

> I programmed this to do some syslog output, but nothing showed up on the
> syslog screen (tty12)... what's wrong?
>
> ------------------------------
> #!/usr/bin/perl
>
> use Sys::Syslog;
>
> openlog('me','perror','user');
> syslog('info','This is a test.');
> closelog();
> ------------------------------
>
> Yes, the syslog config does allow info messages to display; warnings
> didn't work either. the syslog call returns 29, or sometimes 28... (?!?)
>
> Thanxs in advance...

Don't know much about the syslog module. but you could try logger(1) to
verify that your syslog configuration,
syslog.conf, is doing what you think it is .

Cheers,
   Dean.

--
Dean.A.Darlison
Dasco Ltd.





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

Date: Wed, 10 Feb 1999 10:24:02 +0100
From: "F. Geeb" <fge@elsamprojekt.dk>
Subject: XML::Parser and xsl
Message-Id: <36C15032.D9F3175A@elsamprojekt.dk>

Hi,
I tried the perl XML::Parser and it works just fine; the same with
Jonathan Eisenzopf's xmlfaq.pl. But is there a perl-way to convert xml
to hmtl on the fly without coding every tag from each document like in
the xmlfaq.pl? - I'm looking for a program that parses xml-documents -
e.g. with XML::Parser - and converts them on the
basis of xsl-documents.

Franziskus Geeb
fge@elsamprojekt.dk





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

Date: 12 Dec 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 Dec 98)
Message-Id: <null>


Administrivia:

Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing. 

]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body.  Majordomo will then send you instructions on how to confirm your
]subscription.  This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.

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

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