[15613] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3026 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri May 12 09:08:40 2000

Date: Fri, 12 May 2000 06:05:12 -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: <958136711-v9-i3026@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Fri, 12 May 2000     Volume: 9 Number: 3026

Today's topics:
    Re: Activestate Perl 5.6 crashes (Bart Lateur)
    Re: Anyone got ideas? How could Perl coorporate with a  (Bart Lateur)
        Extending URI::URL francesc_guasch@my-deja.com
        Getopt chris2037@my-deja.com
    Re: Getopt (Rafael Garcia-Suarez)
    Re: Help using split and arrays <gnielson@charlotte.infi.net>
    Re: Help using split and arrays <gnielson@charlotte.infi.net>
        How to execute "cat *.c" ??? ovarene@webmails.com
    Re: How to execute "cat *.c" ??? <billy@arnis-bsl.com>
    Re: How to execute "cat *.c" ??? <andkaha@my-deja.com>
        how to get REFERER URL form perl cgi script? <kigm@nwgsm.com>
    Re: how to get REFERER URL form perl cgi script? (Rafael Garcia-Suarez)
    Re: Iteration <iltzu@sci.invalid>
    Re: linked list in perl (Bart Lateur)
        Passing parameters <lech@cu.kiev.ua>
    Re: PERL exe? pircher@informatik.tu-muenchen.de
    Re: Polly a stupid question (Bart Lateur)
    Re: Polly a stupid question <flavell@mail.cern.ch>
    Re: Polly a stupid question (Bart Lateur)
    Re: Problem: hash introducing extra space on output? (Bart Lateur)
    Re: Problem: hash introducing extra space on output? (Bill)
    Re: regular expression needed <andkaha@my-deja.com>
    Re: regular expression needed <andkaha@my-deja.com>
    Re: regular expression needed (Bart Lateur)
    Re: string and numeric data handling nobull@mail.com
    Re: Subroutine error stops module ?! <hans-jan@stack.nl>
    Re: Subroutine error stops module ?! nobull@mail.com
    Re: Using Modules Breaks "-w"? <morbus@disobey.com>
        Using the preprocessor <danielg@tid.es>
    Re: Video comes in bursts jlucande@my-deja.com
    Re: Video comes in bursts jlucande@my-deja.com
        What is $| ? <makau@multimania.com>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Fri, 12 May 2000 10:11:33 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Activestate Perl 5.6 crashes
Message-Id: <391ed5e2.4191766@news.skynet.be>

Bob Walton wrote:

>> Finally, I decompress the new XML::Parser package ZIP (2.28), as per the

>I think you will find that the ZIP file for XML::Parser is for Perl
>version 5.005_03, and is not advertised or intended to work with Perl
>5.6 .  XML::Parser version 2.27 seems to work well with Perl 5.6, but
>apparently the newer version for 2.28 isn't ready yet.

The problem is that it is NOT advertised. Nada. See this page:

	<http://www.activestate.com/ppm/>

Do you see it ANYWHERE that XML::Parser won't work on 5.6.0? 

Now, see 

	<http://www.activestate.com/ActivePerl/download.htm>

Do you see ANY link offer a download for 5.005_03? I don't.

So 5.6.0 is the only ActivePerl that you can download, and XML::Parser
2.28 is the new XML module. Since there isn't a mention of any
incompatibilities at all, I assumed that those were ment to work
together. I believe that is a fair assumption. 

>> p.s. Why do WE, the users, have to download the package, and the fix,
>> and the parser update, and apply the patch, while the whole thing is at
>> most a few weeks old?
>
>You don't have to.  You can choose not to download, etc.

What do you mean? I'm saying it's impossible to download an up to date
package. 

Oh  BTW, I can't find ANY link on the entire site to the module section.
Yet it exists at <http://www.activestate.com/PPMpackages/>. Is this a
backdoor or something? Are people not "in the know" not supposed to find
it?

p.s. I found another hidden section:
<http://www.activestate.com/download/> where you CAN find (all?) older
versions. Yet, I had to crawl in through the window to find it.

-- 
	Bart.


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

Date: Fri, 12 May 2000 10:14:11 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Anyone got ideas? How could Perl coorporate with a DLL
Message-Id: <391fd8fa.4984004@news.skynet.be>

wstsoi wrote:

>As title, do anybody know How could Perl coorporate with a DLL?
>mostly I need to call a DLL from a Perl script

Get Win32::API from <http://www.activestate.com/PPMpackages> and install
it. Although primarily intended to work with Windows' own built-in
functions, I'm told that it works with alien DLL's too.

-- 
	Bart.


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

Date: Fri, 12 May 2000 10:03:48 GMT
From: francesc_guasch@my-deja.com
Subject: Extending URI::URL
Message-Id: <8fgktu$f98$1@nnrp1.deja.com>

I need to extend URI::URL because I need to add a field of my
own to it and keep the other methods working.

I made my own object and did the @ISA stuff, so now I successfully
use URI::myURL and the older scripts work fine.

Now I wanted to start adding my own methods but URI::URL is
not an object based on a hash, it looks it's based in a list.

I think if I start adding $self->[2] fields I could break
compatibitily with further URL::URI development. I haven't
seen a list of field numbers inside the module source.

I wonder if someone else has done this before and could help
me extend this module.


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


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

Date: Fri, 12 May 2000 10:00:24 GMT
From: chris2037@my-deja.com
Subject: Getopt
Message-Id: <8fgkni$f87$1@nnrp1.deja.com>

Hi Perlies,

Having some problems with this simple bit of code:


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

use Getopt::Std;


getopt('d') or die "Usage: $0 [-d] [file1] [file2]\n";

 while (<>) {

             print $_ ;
                       }


This is it in its entirety. Two problems:


1)  Regardless of what you type at the command line, it will always die.
I want the user to be able to type

somescript file1 file2

or

somescript -d file1 file2

As you can see, the script is trivial - I am merely using it to get
getopt working. However it should work and should have same outcome as
if I type

cat file1 file2

at shell prompt.

2) Because it dies no matter what you do, I changed the line containing
getopt to

getopt ('d');

So now at least it won't die. It'll work for

somescript file1 file2

but not

somescript -d file1 file2

What happens here is that file2 is cat but not file1. Somehow the option
has killed the first filename ??? Thanks for your help.



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


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

Date: Fri, 12 May 2000 12:14:02 GMT
From: garcia_suarez@hotmail.com (Rafael Garcia-Suarez)
Subject: Re: Getopt
Message-Id: <slrn8hnthk.sbq.garcia_suarez@r-garcia.kazibao.net>

chris2037@my-deja.com wrote in comp.lang.perl.misc:
>Hi Perlies,
>
>Having some problems with this simple bit of code:
>
>
>#!/usr/local/bin/perl -w
>
>use Getopt::Std;
>
>
>getopt('d') or die "Usage: $0 [-d] [file1] [file2]\n";
>
> while (<>) {
>
>             print $_ ;
>                       }
>
>
>This is it in its entirety. Two problems:
>
>
>1)  Regardless of what you type at the command line, it will always die.
>I want the user to be able to type
>
>somescript file1 file2
>
>or
>
>somescript -d file1 file2

The docs of Getopt::Std do not mention any return value. You don't have
to include an 'or die' clause (unless you want to rely on undocumented
behavior...)

>As you can see, the script is trivial - I am merely using it to get
>getopt working. However it should work and should have same outcome as
>if I type
>
>cat file1 file2
>
>at shell prompt.
>
>2) Because it dies no matter what you do, I changed the line containing
>getopt to
>
>getopt ('d');

use getopts('d') or getopt('d:'). The way you write it, the -d option takes
an argument. Look at the docs for more info.

>
>So now at least it won't die. It'll work for
>
>somescript file1 file2
>
>but not
>
>somescript -d file1 file2
>
>What happens here is that file2 is cat but not file1. Somehow the option
>has killed the first filename ??? Thanks for your help.

-- 
Rafael Garcia-Suarez


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

Date: Fri, 12 May 2000 06:50:33 -0400
From: Gary Nielson <gnielson@charlotte.infi.net>
Subject: Re: Help using split and arrays
Message-Id: <391BE1F9.8F89397D@charlotte.infi.net>



Tad McClellan wrote:

> On Thu, 11 May 2000 15:38:01 -0400, Gary Nielson <gnielson@charlotte.infi.net> wrote:
>
> >I am having trouble using an array and split to parse an html document.
>                                                  ^^^^^^^^^^^^^^^^^^^^^^
>
> You should be using a module for that (if you want it to be correct).
>
> >I am trying to isolate just those lines that contain urls and links and
>                                               ^^^^^^^^^^^^^^^^^^^^^^
>
> There is a module specifically for extracting links
>
>        HTML::LinkExtor - Extract links from an HTML document
>

From the documentation I read on LinkExtor, it appeared that you could only extract URLs,
but not the links, so if you had <a href="http://www.link.com/">The link</a>, you could
pull out http://www.link.com but not "The Link." If I am mistaken, that would be a
perfect module for me.




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

Date: Fri, 12 May 2000 07:52:57 -0400
From: Gary Nielson <gnielson@charlotte.infi.net>
Subject: Re: Help using split and arrays
Message-Id: <391BF099.4A5D4CF4@charlotte.infi.net>

Thanks, Matthew. Your solution worked like a charm.

Matthew Stoker wrote:

> You can do:
>
> for ($i = 0; $i < @headlines; $i++)
> {
>   splice (@headlines, $i, 1, split(/$delimiter/,$headlines[$i]));
> }
>
> This loops through each element of @headlines, splits it on $delimiter
> and inserts the resulting list back into @headlines at the starting
> position of the original element.  I think this is what you are looking
> for, although there are probably better ways to do what you desire using
> the CPAN module HTML::Parser.
>
> Gary Nielson wrote:
> >
> > I am having trouble using an array and split to parse an html document.
> >
> > I am trying to isolate just those lines that contain urls and links and
> > create an array whose elements I can then insert into a form, with urls
> > and links as separate elements.
> >
> > First, I find just though lines that contain an A HREF and grab that
> > entire line. I then get rid of extraneous markup language until I am
> > left with just the code I want, the URL and the link, separated by a "
> > ". The script works fine until I try to use split. My limited (but
> > hopefully growing) understanding of perl is that you can't perform
> > substitutions on arrays, just scalar variables. So as the script loops
> > through the file and finds the desired lines, it pushes the scalar
> > variable into an array.
> >
> > But then how do I split the array since perl won't let you split arrays,
> > just scalars, but when I try to convert the array to a scalar, the
> > syntax is telling perl $variable = @array to give me the number of
> > elements. So I feel like I am caught in my own loop of sorts mixing
> > scalars and arrays when trying to use split.
> >
> > So for now, I can get one array element that includes both the link and
> > the URL, which is not what I want; I want each element to contain only a
> > link or only the URL.
> >
> > Code below:
> >
> > $var = "";
> > @headlines = "";
> > $delimiter = "   ";
> > $filename = "docs/filename.htm";
> > open(FILE, $filename);
> > while (<FILE>)
> > {
> >  if (/<A HREF=/) # line contains <A HREF tag
> >  {
> >   $var = $_;
> >
> > # strip out crap
> >
> >   $var =~ s/<DIGEST>|<\/DIGEST>|<\/FONT>|<\/TD>//g;
> > #  $var =~ s/<[A-Za-z\_].+DIGEST[A-Za-z\_].+>|<\/FONT>|<\/TD>//g;
> >   $var =~ s/\n/$delimiter/g;
> >   $var =~ s/<\/A>//g;
> >   $var =~ s/\">/$delimiter/g;
> >   push(@headlines, $var);
> >  }
> > }
> > close (FILE);
> > #$tmp = @headlines ## won't work because returns the number of elements,
> > doesn't convert back to scalar
> > #split(m/$delimiter/, @headlines); ## wont work because I dont think
> > split works on arrays, just scalars.
> >
> > print @headlines;
> >
> > Any help appreciated. Please email reply as well.
> >
> > Gary
>
> --
> /------------------------------------------------------------------\
> | Matt Stoker                |     email: matt.stoker@motorola.com |
> | Unit Process Modeling      | Mail Drop: M360                     |
> | DigitalDNA(TM) Laboratories|     Phone: (480)655-3301            |
> | Motorola, SPS              |       Fax: (480)655-5013            |
> | 2200 W Broadway Road       |     Pager: (888)699-8803            |
> | Mesa, AZ 85202             |                                     |
> \------------------------------------------------------------------/



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

Date: Fri, 12 May 2000 10:26:24 GMT
From: ovarene@webmails.com
Subject: How to execute "cat *.c" ???
Message-Id: <8fgm86$gui$1@nnrp1.deja.com>

Hello,

I'd like to make a system call with an asterix wild card (*), like for
exemple: cat *.c.

I tried things based on system();
>@sys_args=("cat","*.c");
>system(@sys_args);

and other based on
>use Shell;
>cat("*.c");

but always get the following error message:
>cat: Cannot open *.c: No such file or directory

the trouble seems to come from the argument "*.c"
so i tried '*.c', "*\.c", ....
but nothing worked !

How can I use the "*" wildcard (wildcard to be interpreted in the shell
environement ?

Thanks

Olivier
oliveir.varene@sita.int


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


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

Date: Fri, 12 May 2000 10:49:18 GMT
From: Ilja <billy@arnis-bsl.com>
Subject: Re: How to execute "cat *.c" ???
Message-Id: <8fgnjb$i51$1@nnrp1.deja.com>

In article <8fgm86$gui$1@nnrp1.deja.com>,
  ovarene@webmails.com wrote:
> Hello,
>
> I'd like to make a system call with an asterix wild card (*), like for
> exemple: cat *.c.
>
> I tried things based on system();
> @sys_args=("cat","*.c");
> system(@sys_args);
>
> but always get the following error message:
> >cat: Cannot open *.c: No such file or directory
>
 ...skip...
> How can I use the "*" wildcard (wildcard to be interpreted in the shell
> environement ?
>

$command = ('cat *.c');
system($command);

Culsult 'perldoc -f system' (or
http://www.cpan.org/doc/manual/html/pod/perlfunc/system.html) for details.

Good luck.
Ilja.


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


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

Date: Fri, 12 May 2000 10:50:06 GMT
From: Andreas Kahari <andkaha@my-deja.com>
Subject: Re: How to execute "cat *.c" ???
Message-Id: <8fgnkq$i6j$1@nnrp1.deja.com>

In article <8fgm86$gui$1@nnrp1.deja.com>,
  ovarene@webmails.com wrote:
> Hello,
>
> I'd like to make a system call with an asterix wild card (*), like for
> exemple: cat *.c.
>
> I tried things based on system();
> >@sys_args=("cat","*.c");
> >system(@sys_args);
>
> and other based on
> >use Shell;
> >cat("*.c");
>
> but always get the following error message:
> >cat: Cannot open *.c: No such file or directory
>
> the trouble seems to come from the argument "*.c"
> so i tried '*.c', "*\.c", ....
> but nothing worked !
>
> How can I use the "*" wildcard (wildcard to be interpreted in the
shell
> environement ?
>
> Thanks

One way (out of a few) is to use the 'glob' function to get a list of
files matching '*.c' and the loop over this list doing 'system("cat
$fname")' on each one.

See the perlfunc manual for more info on 'glob'.

/A

--
# Andreas Kähäri, <URL:http://hello.to/andkaha/>.
# All junk email is reported to the appropriate authorities.


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


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

Date: Fri, 12 May 2000 15:23:06 +0400
From: "Konstantin Mikhailov" <kigm@nwgsm.com>
Subject: how to get REFERER URL form perl cgi script?
Message-Id: <8fgpnm$8pd$1@news.wplus.spb.ru>


Can somebody tell me how to get REFERER URL from my perl script?

That means that I want to know where a visitor come from.
As I know Apache have this information, but how get it from CGI script?

Help you by all means,
    Konstantin Ig. Mikhailov





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

Date: Fri, 12 May 2000 12:16:22 GMT
From: garcia_suarez@hotmail.com (Rafael Garcia-Suarez)
Subject: Re: how to get REFERER URL form perl cgi script?
Message-Id: <slrn8hntm0.sbq.garcia_suarez@r-garcia.kazibao.net>

Konstantin Mikhailov wrote in comp.lang.perl.misc:
>
>Can somebody tell me how to get REFERER URL from my perl script?
>
>That means that I want to know where a visitor come from.
>As I know Apache have this information, but how get it from CGI script?

It's in the environment variable $ENV{'HTTP_REFERER'}. But don't rely on it, it
can be faked or proxies may have dumped it.

-- 
Rafael Garcia-Suarez


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

Date: 12 May 2000 12:52:11 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: Iteration
Message-Id: <958135603.26874@itz.pp.sci.fi>

In article <8fek4a$1vu$1@gxsn.com>, Andy Chantrill wrote:
>Okay, so how would I access individual key elements of "@{$hash{$key}}"? And
>how would I retrieve the number of keys in the hash?
>
>I basically want to iterate through the HoL using a for loop, *not* foreach

use PSI::ESP;

Ok, I see you want to iterate over the keys of a hash without building
a list of them. A C-style for(;;) loop won't help (much) here, but you
can use each() in a while loop:

  while (my ($key, $val) = each %hash) {
      print "$key\t$val\n";
  }

-- 
Ilmari Karonen - http://www.sci.fi/~iltzu/
Please ignore Godzilla and its pseudonyms - do not feed the troll.



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

Date: Fri, 12 May 2000 10:12:08 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: linked list in perl
Message-Id: <391dd3bc.3641747@news.skynet.be>

Perl Discussion wrote:

>is it possible to have a linked list in perl?
>i simply need to have a structure with 2 items:
>  one variable to contain data/value
>  one pointer to next/another structure

Why? Perl's built-in (onedimenional) arrays do everything you could
possibly want from a linked list.

I rememeber somebody posting code to emulate Scheme (a successor to
Lisp) operations in plain Perl, a few months ago.

If you insist, you can do it thehard way. Having a "Node" object instead
of raw perl structures could help in keeping it relatively simple.

	my $list = [ undef, 'gamma' ];
	$list = [ $list , 'beta' ];
	$list = [ $list , 'alpha' ];
	for(my $node = $list; $node; $node = $node->[0]) {
	    print "Node: '$node->[1]'\n";
	}

	
-- 
	Bart.


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

Date: Fri, 12 May 2000 14:00:47 +0200
From: "Vladimir Lech" <lech@cu.kiev.ua>
Subject: Passing parameters
Message-Id: <8fgob7$1sp4$1@whale.gu.net>

Hello to All,
Please help me to solve this kind of task.
There is a script with two subroutines.
First one prints an html page with links and contains hidden fields.
When user clicks on link script calls a second subroutine and here is a
trick.
A second one does not "see" parameters from hidden fields.
Where is my fault?

Please, help.

Best regards,
Lech




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

Date: Fri, 12 May 2000 09:58:28 GMT
From: pircher@informatik.tu-muenchen.de
Subject: Re: PERL exe?
Message-Id: <8fgkjv$f6d$1@nnrp1.deja.com>

In article <958120702.653952922@news.uswest.net>,
  Bill <bilmcchr@uswest.net> wrote:
> I am curious if anyone can point  me ot some information about
> compiling PERL
> scripts to excutables. Thanks.

http://www.dynamicstate.com/perl2exe.htm

GreetingX,
 Alex


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


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

Date: Fri, 12 May 2000 10:12:05 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Polly a stupid question
Message-Id: <391cd17f.3068934@news.skynet.be>

Darren wrote:

>Imagine a scenario where a form calls a cgi script that will pipe a
>web page back to the browser......how do I stop the browser from using
>the path of the script. The problem being that the data I pass back
>with the script uses images of the path 'images/x.gif' except when
>piped from the cgi script the current dir is /cgi-bin when I actually
>want the current dir to be '/'.
>
>Now I'm just at a loss as to what to do (I understand why this is
>happening just not how best to fix it).

This question has better chance of being properly answered in the
newsgroup <news:comp.infosystems.www.authoring.cgi>.

Anyway, I'll take a shot: use the 

	<BASE HREF="http://yourserver/your/path/">

tag in the header section of the generated document. You can even try
relative paths, I'm not sure.

	<BASE HREF="../images/">

-- 
	Bart.


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

Date: Fri, 12 May 2000 12:59:02 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Polly a stupid question
Message-Id: <Pine.GHP.4.21.0005121253560.21334-100000@hpplus01.cern.ch>

On Fri, 12 May 2000, Bart Lateur wrote:

> You can even try
> relative paths, I'm not sure.
> 
> 	<BASE HREF="../images/">

Unwise to offer advice of which one is not sure.  The HTML
specifications are freely accessible.

http://www.w3.org/TR/REC-html40/struct/links.html#h-12.4

BASE HREF mandates an _absolute_ URI.

And experience says that advice on usenet that says "try this" usually
isn't worth the electrons it's written on.  This seems to be no
exception, I'm sorry to have to say (I'm only doing this because your
advice usually seems to be well-founded, and it seems a pity to
devalue it in this way).

ttfn



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

Date: Fri, 12 May 2000 12:29:02 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Polly a stupid question
Message-Id: <391befa0.221237@news.skynet.be>

Alan J. Flavell wrote:

>BASE HREF mandates an _absolute_ URI.
>
>And experience says that advice on usenet that says "try this" usually
>isn't worth the electrons it's written on.  This seems to be no
>exception, I'm sorry to have to say (I'm only doing this because your
>advice usually seems to be well-founded, and it seems a pity to
>devalue it in this way).

:-)

I don't usually start out by reading the official doculments. They're
too unreadable. I start by experimenting, and when I think I understand
what's going on, *then* I can make sense ofthe docs.

I had found out that "<BASE HREF="/path/to/dir/"> doesn't work. It's a
pity, because now I have to hardcode my server name, protocol and
possibly port number as well, into the document. I hadn't tried the
relative URL, but it would have been a saviour. Why does it require
absolute URL's? It ain't practical. I can't move my document trees
between servers, for instance.

I was too lazy to test right now, let alone read up on it.

Ah. My HTML reference book says: "The URL should be fully qualified.".
You have to understand the jargon, to know that they mean "absolute".

-- 
	Bart.


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

Date: Fri, 12 May 2000 10:19:46 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Problem: hash introducing extra space on output?
Message-Id: <3920da1c.5274008@news.skynet.be>

Bill wrote:

>%filename =  ("employer.html",    "@employer",
>              "position.html",    "@position",
>              "animals.html",     "@animals",
 ...
>);

That's a bit strange. You realize you're turning arrays into a combined
string, don't you? You know that the special variable $" (space by
default) will be inserted between you list items?

>The problem is that the output from the 'print OUTFIL "$filename{$_}";'
>statement looks like this:
>
><li><a href="j20000412f05.html">...
> <li><a href="j20000412f03.html">...
> <li><a href="j20000414f01.html">...
>
>rather than the desired:
>
><li><a href="j20000412f05.html">...
><li><a href="j20000412f03.html">...
><li><a href="j20000414f01.html">...

This is HTML, so it doesn't really matter. But, if you're the
perfectionist you appear to be ( ;-), I think it's indeed $" creeping in
between them.

-- 
	Bart.


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

Date: Fri, 12 May 2000 11:16:26 GMT
From: wfeidt@cpcug.org (Bill)
Subject: Re: Problem: hash introducing extra space on output?
Message-Id: <8F324C3D6wfeidthiscom@207.126.101.97>

bart.lateur@skynet.be (Bart Lateur) wrote in 
<3920da1c.5274008@news.skynet.be>:

>Bill wrote:
>
>>%filename =  ("employer.html",    "@employer",
>>              "position.html",    "@position",
>>              "animals.html",     "@animals",
>...
>>);
>
>That's a bit strange. You realize you're turning arrays into a combined
>string, don't you? You know that the special variable $" (space by
>default) will be inserted between you list items?

Indeed, that appears to have been the cause of the problem, Bart.  Thanks
very much.  I resolved it by adding:

  $"="";              <------------
  %filename =  ("employer.html",    "@employer",
                "position.html",    "@position",
                "animals.html",     "@animals",
  [...]

and now the output reads the way I intended.

>>The problem is that the output from the 'print OUTFIL "$filename{$_}";'
>>statement looks like this:
>>
>><li><a href="j20000412f05.html">...
>> <li><a href="j20000412f03.html">...
>> <li><a href="j20000414f01.html">...
>>
>>rather than the desired:
>>
>><li><a href="j20000412f05.html">...
>><li><a href="j20000412f03.html">...
>><li><a href="j20000414f01.html">...
>
>This is HTML, so it doesn't really matter. But, if you're the
>perfectionist you appear to be ( ;-), I think it's indeed $" creeping in
>between them.

Right, I know that it makes no difference as far as the HTML is
concerned, but I'm trying to understand as much as I can about
how this all works.  In another instance it may matter.  But,
you're probably correct too about my predilection in the direction
of perfection. ;-)

--

Bill
wfeidt@cpcug.org




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

Date: Fri, 12 May 2000 10:56:48 GMT
From: Andreas Kahari <andkaha@my-deja.com>
Subject: Re: regular expression needed
Message-Id: <8fgo1b$ino$1@nnrp1.deja.com>

In article <391BC85D.4C7F088F@fh-wedel.de>,
  nils@triquart.de wrote:
> Hi
> I am lookin for an expression wich substitude something like that
> s/label(:(.*)?)/you wrote \2/
> now in the case that \2 is an empty string instead of \2 'nothing'
> should be insert
> anyone an idea how to do that?
> thanks nils
>
>

Use the '/e' switch to evalueate a small perl expression in the
substitution text. See the perlre manual.

$string1 = "label: The dark side of the spoon";
$string2 = "label:";

$string1 =~ s/label:\s*(.*)/"You wrote '" . ($1 ? $1 : 'nothing') .
"'"/e;
$string2 =~ s/label:\s*(.*)/"You wrote '" . ($1 ? $1 : 'nothing') .
"'"/e;

print "$string1\n";
print "$string2\n";

OUTPUT:

You wrote ' The dark side of the spoon'
You wrote 'nothing'

/A

--
# Andreas Kähäri, <URL:http://hello.to/andkaha/>.
# All junk email is reported to the appropriate authorities.


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


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

Date: Fri, 12 May 2000 11:01:15 GMT
From: Andreas Kahari <andkaha@my-deja.com>
Subject: Re: regular expression needed
Message-Id: <8fgo9k$iqm$1@nnrp1.deja.com>

In article <8fgo1b$ino$1@nnrp1.deja.com>,
  Andreas Kahari <andkaha@my-deja.com> wrote:
[cut]
> You wrote ' The dark side of the spoon'
> You wrote 'nothing'

The space before "The" on the first line will not show up if you use the
code that I posted. That line above was generated using my first shot at
the RE (didn't contain '\s*').

/A

--
# Andreas Kähäri, <URL:http://hello.to/andkaha/>.
# All junk email is reported to the appropriate authorities.


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


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

Date: Fri, 12 May 2000 11:37:40 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: regular expression needed
Message-Id: <3921dd6f.6124906@news.skynet.be>

Nils wrote:

>s/label(:(.*)?)/you wrote \2/
>now in the case that \2 is an empty string instead of \2 'nothing'
>should be insert

	s/label(:(.*))/'you wrote ' .(length $2? $2 : 'nothing')/e;

You don't need the question mark. (.*) can be empty.

-- 
	Bart.


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

Date: 12 May 2000 12:51:37 +0100
From: nobull@mail.com
Subject: Re: string and numeric data handling
Message-Id: <u91z38c7g6.fsf@wcl-l.bham.ac.uk>

nfin8axs@hotmail.com writes:

> I am having some difficulty with the concept of string handling in PERL.
> Is there a construct  in PERL that does the equivalent of data casting
> in C? 

Yes, but there are very few cases you need to think about it
explicitly (see perldoc perlop/"Bitwise String Operators" for one of
these few cases).

> I have a string of numbers that I wish to convert to a numeric
> value. Will simple performing a numeric operation on the variable be
> enough? (eg : $data = $data + 0;) or is there a more intelligent method?

No that's why the "make numeric" operator in Perl is known as 0+ (see
perldoc overload).

The reverse operation is string interpolation:

$data = "$data";

That's why the "make string" operator in Perl is known as ""

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: 12 May 2000 10:13:04 GMT
From: Hans <hans-jan@stack.nl>
Subject: Re: Subroutine error stops module ?!
Message-Id: <8fglfg$8ku$1@news.tue.nl>

poppln@my-deja.com wrote:

>> sub print_file_list {
>> my $msg_in = @_;
>> .......
>> return $msg_in;

> A list in scalar context return the number of items in it.
> use should use:

>   my ($msg_in) = @_;

> or

>   my $msg_in = $_[0];


Thanks, it works ! 

Hans




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

Date: 12 May 2000 13:01:06 +0100
From: nobull@mail.com
Subject: Re: Subroutine error stops module ?!
Message-Id: <u9zopwasfx.fsf@wcl-l.bham.ac.uk>

poppln@my-deja.com writes:

> A list in scalar context return the number of items in it.

s/list/array/

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: Fri, 12 May 2000 07:04:29 -0400
From: Morbus Iff <morbus@disobey.com>
Subject: Re: Using Modules Breaks "-w"?
Message-Id: <morbus-4C9185.07042912052000@news.totalnetnh.net>

In article 
<Pine.GSO.4.10.10005110747240.16364-100000@user2.teleport.com>, Tom 
Phoenix <rootbeer@redcat.com> wrote:

> > #! /bin/perl - w
> 
> Do you mean to have that space before the w?

Nope, that was introduced in transit. Code contains it correctly. 
Have you run across these sorts of errors before in modules?

-- 
Morbus Iff
http://www.disobey.com/


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

Date: Fri, 12 May 2000 13:15:35 +0200
From: Daniel Garcia Fernandez <danielg@tid.es>
Subject: Using the preprocessor
Message-Id: <391BE7D6.79BC6D10@tid.es>

This is a multi-part message in MIME format.
--------------85F1AEB87E7010032BC055C0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

I have put some preprocesor in a perl script. All goes well when i run
it under unix, but when i try "perl -P" under win32 I get this message
"Error: Parse exception".
Why happens this ?
How can I solve It?
The code is:



#ifdef __win32
BEGIN
  {
    if ($^O eq "MSWin32")
      {
 print "Usas Guindows de 32 bits\n";
 use Win32::TieRegistry;
 $valueData= $Registry->{"LMachine\\Software\\Tid\\Mf\\\\BaseDirTemp"};
 print "$valueData\n";
 my($MfDir) = $ENV{'MFDIR'} ? $ENV{'MFDIR'} : "$valueData";
      }
    else
      {
 print "Usas Unix, no?\n";
 my($MfDir) = $ENV{'MFDIR'} ? $ENV{'MFDIR'} : "#(MFDIR)#";
      }
    push( @INC, "$MfDir/perl",
   $ENV{'PERLMOD'} ? $ENV{'PERLMOD'} : "$ENV{'HOME'}/Perl" );
  }
#endif




--------------85F1AEB87E7010032BC055C0
Content-Type: text/x-vcard; charset=us-ascii;
 name="danielg.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: Card for Daniel Garcia Fernandez
Content-Disposition: attachment;
 filename="danielg.vcf"

begin:vcard 
n:García;Daniel
tel;work:983-367798
x-mozilla-html:FALSE
org:Telefonica I+D;Tecnologia Multimedia
adr:;;;;;;
version:2.1
email;internet:danielg@tid.es
title:<img src="http://tid/images/telefonica.gif">
fn:Daniel Garcia
end:vcard

--------------85F1AEB87E7010032BC055C0--



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

Date: Fri, 12 May 2000 11:29:19 GMT
From: jlucande@my-deja.com
Subject: Re: Video comes in bursts
Message-Id: <8fgpu1$kki$1@nnrp1.deja.com>

Hi Tom!

  Tom Phoenix <rootbeer@redcat.com> wrote:

> Well, maybe you can make them _larger_ bursts. Do you have a reason to
> need the number 8 in the code above? Changing it to be 8192 (say) may
work
> better. (It's not as if you're going to have only a small amount of
data,
> when you're dealing with video!)
>
> You should perhaps also use lower-level calls to do this. Both the
read
> and the print may block, which could be a problem. For example, if the
> print has to block for a moment, the input buffer (from which you're
> reading) may fill up, causing the other process to block. Now a moment
> later, you read the entire input buffer, but the other process hasn't
> gotten a chance to replenish the buffer.
>
> I'd probably redo that loop to use sysread and syswrite, along with
the
> four-arg form of select. Of course, that means that you'll have to
> implement a buffer within your process; you should probably code in an
> upper limit of (say) 64K for that buffer's size.
>
> Good luck with it!
>
> --
> Tom Phoenix       Perl Training and Hacking       Esperanto
> Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/
>

Your advice has proven to be very accurate. Especially the idea to
implement a buffer got right to point. When I discussed of it with my
workmate, he instructed me to apply the time stamp mechanism which is
already built into our video transfer application. The time stamps
were originally used only when the video was played from a file.

Now the video comes smoothly enough. The thing that remains
to be tackled with is the delay that is caused when the client
initializes itself. This simply means that the scene shown is from
five to ten seconds old.
However that is a different adventure :)


Thank you for your help!


t: Jussi

Ps.
The Randal Schwartz Case was chilling one to read.
Let's hope the justice will prevail.


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


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

Date: Fri, 12 May 2000 11:48:13 GMT
From: jlucande@my-deja.com
Subject: Re: Video comes in bursts
Message-Id: <8fgr1o$lsa$1@nnrp1.deja.com>

Hi Bart!

  bart.lateur@skynet.be (Bart Lateur) wrote:
> jlucande@my-deja.com wrote:
>
> >$|=1;  # Forces the buffer to be flushed.
> >while (read SOCK, $data, 8) {
> >   print($data);
> >}
>
> You're reading and writing 8 bytes at a time? Isn't that just a bit
> extreme? I think that using chunks of, for example, 128 or 256 bytes,
> shoukld work just as well. There ain't too much video image in 8
bytes.
>
> >But the data still comes in bursts. Maybe the reason is
> >badly configured Apache 1.3.12 win32-version.
> >That leaves the question, why the data flows normally
> >through the original port number 8641.
>
> It must be the server buffering. You probably need some more, or
better
> configured, headers.
>
> Have you tried NPH (no parse headers)?
>
> --
> 	Bart.

Thanks for your help!
I increased the buffer to 256, changed read to sysread and print to
syswrite, applied the time stamp mechanism that was already
built in our video transfer application and now video runs smooth
enough :)
What comes to 'no parse headers' the name of the script
begins with nph- but I ques that is note needed anymore.

T: Jussi




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


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

Date: Fri, 12 May 2000 12:48:01 GMT
From: Makau Divangamene <makau@multimania.com>
Subject: What is $| ?
Message-Id: <8fguhs$pjq$1@nnrp1.deja.com>

Can someone explain me simply what $| is?
The Camel Book (ed2) gives obfuscating explanations that drive me crazy.

Please help!!


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


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

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


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