[22214] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4435 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jan 20 18:10:45 2003

Date: Mon, 20 Jan 2003 15:10:12 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Mon, 20 Jan 2003     Volume: 10 Number: 4435

Today's topics:
    Re: Regex to find all words containing a single vowel? <pinyaj@rpi.edu>
        send arguments to included SSI-included CGI script? <stedman@siam.org>
    Re: send arguments to included SSI-included CGI script? <perl-dvd@darklaser.com>
        send arguments to included SSI-included script? <stedman@siam.org>
    Re: send arguments to included SSI-included script? <flavell@mail.cern.ch>
        Strange problem reading from file (Ogmios)
    Re: Strange problem reading from file <jurgenex@hotmail.com>
        Text manipulation <lou.moran@gellerandwind.com>
        Text::Autoformat doesn't format <usenet@dwall.fastmail.fm>
    Re: Text::Autoformat doesn't format <bongie@gmx.net>
        why does not this work (classical music)
    Re: why does not this work <jhalpin@nortelnetworks.com_.nospam>
    Re: why does not this work <eric.ehlers@btopenworld.com.nospam>
    Re: why does not this work (Damian James)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Mon, 20 Jan 2003 17:29:33 -0500
From: Jeff 'japhy' Pinyan <pinyaj@rpi.edu>
To: Martin <mrennix@totalise.co.uk>
Subject: Re: Regex to find all words containing a single vowel?
Message-Id: <Pine.SGI.3.96.1030120172528.662284A-100000@vcmr-64.server.rpi.edu>

[posted & mailed]

On 19 Jan 2003, Martin wrote:

>I need to find all words in a file containing only a single vowel.

Why?  Homework?  Job?  Fun?  A little background goes a long way.

>$string = "The quick brown fox jumped over the lazy dog";
>$string =~ /$regex/g;

>The
>brown
>fox
>the
>lazy
>dog

Here's one:

  $nv = qr/[^\W0-9_aeiou]/i;
  @single_vowel = $string =~ /\b$nv*[aeiou]$nv*\b/igo;

If you don't understand it, I can explain it briefly.  The $nv fragment of
the regex matches any word character that is not a digit, an underscore,
or a vowel (upper- or lowercase).  My main regex matches a word boundary,
zero or more non-vowels, a vowel, zero or more non-vowels, and then a word
boundary.

-- 
Jeff Pinyan            RPI Acacia Brother #734            2003 Rush Chairman
"And I vos head of Gestapo for ten     | Michael Palin (as Heinrich Bimmler)
 years.  Ah!  Five years!  Nein!  No!  | in: The North Minehead Bye-Election
 Oh.  Was NOT head of Gestapo AT ALL!" | (Monty Python's Flying Circus)



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

Date: Mon, 20 Jan 2003 17:01:24 -0500
From: "Josh Stedman" <stedman@siam.org>
Subject: send arguments to included SSI-included CGI script?
Message-Id: <Oj_W9.2306$io.104573@iad-read.news.verio.net>

I'm a programmer relatively new to the CGI scene, working in Perl at the moment.  I have good
experience with Perl coding, along with some minor experience in other languages, but that's all
neither here nor there.

I'm writing a CGI script for a site I'm working on, and I was wondering if it is at all possible to
send arguments from the web browser to a script that is included in a page via SSI.

I.E. --  I have a script foo.cgi that takes the argument date.  If you call the script directly, you
can go to mysite.com/foo.cgi?date=20030120

Now I have included foo.cgi in bar.shtml via <!-- #exec cgi="/foo.cgi" -->

is there any way for me to go to mysite.com/bar.shtml?date=20030120 and get the right output from
foo.cgi?  Or am I pipe-dreaming.

Unfortunately, the server is running IIS 5.0 on Windows 2000 Advanced Server, and there is nothing I
can do about that (trust me, I've tired.)

Thanks,

Josh Stedman




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

Date: Mon, 20 Jan 2003 22:29:09 GMT
From: "David" <perl-dvd@darklaser.com>
Subject: Re: send arguments to included SSI-included CGI script?
Message-Id: <VK_W9.16$EZ2.14120@news-west.eli.net>

"Josh Stedman" <stedman@siam.org> wrote in message
news:Oj_W9.2306$io.104573@iad-read.news.verio.net...
> I'm a programmer relatively new to the CGI scene, working in Perl at
the moment.  I have good
> experience with Perl coding, along with some minor experience in other
languages, but that's all
> neither here nor there.
>
> I'm writing a CGI script for a site I'm working on, and I was
wondering if it is at all possible to
> send arguments from the web browser to a script that is included in a
page via SSI.
>
> I.E. --  I have a script foo.cgi that takes the argument date.  If you
call the script directly, you
> can go to mysite.com/foo.cgi?date=20030120
>
> Now I have included foo.cgi in bar.shtml via <!-- #exec
cgi="/foo.cgi" -->
>
> is there any way for me to go to mysite.com/bar.shtml?date=20030120
and get the right output from
> foo.cgi?  Or am I pipe-dreaming.


Not the way your expecting to but yes you can.
You can put the params right in the include for example:

<!--#include virtual="/foo.cgi?date=20030120"-->
(I know, this is not what you wanted)

Or you can use javascript's document.write() to write out the include
code, which by the way with the right javascript can pull parameters off
of the url (this is what you wanted).
Let me just make it known that I dont recommend the javascript thing
though because of the 20%+ failure rate based on varias browsers and
such.


Regards,
David




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

Date: Mon, 20 Jan 2003 14:29:54 CST
From: "Josh Stedman" <stedman@siam.org>
Subject: send arguments to included SSI-included script?
Message-Id: <KPYW9.2301$io.104402@iad-read.news.verio.net>

I'm a programmer relatively new to the CGI scene, working in Perl at the moment.  I have good
experience with Perl coding, along with some minor experience in other languages, but that's all
neither here nor there.

I'm writing a CGI script for a site I'm working on, and I was wondering if it is at all possible to
send arguments from the web browser to a script that is included in a page via SSI.

I.E. --  I have a script foo.cgi that takes the argument date.  If you call the script directly, you
can go to mysite.com/foo.cgi?date=20030120

Now I have included foo.cgi in bar.shtml via <!-- #exec cgi="/foo.cgi" -->

is there any way for me to go to mysite.com/bar.shtml?date=20030120 and get the right output from
foo.cgi?  Or am I pipe-dreaming.

Unfortunately, the server is running IIS 5.0 on Windows 2000 Advanced Server, and there is nothing I
can do about that (trust me, I've tired.)

Thanks,

Josh Stedman


-- 
PLEASE NOTE: comp.infosystems.www.authoring.cgi is a
SELF-MODERATED newsgroup. aa.net and boutell.com are
NOT the originators of the articles and are NOT responsible
for their content.

HOW TO POST to comp.infosystems.www.authoring.cgi:
http://www.thinkspot.net/ciwac/howtopost.html



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

Date: Mon, 20 Jan 2003 14:53:36 CST
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: send arguments to included SSI-included script?
Message-Id: <Pine.LNX.4.40.0301202140330.15976-100000@lxplus071.cern.ch>

On Jan 20, Josh Stedman inscribed on the eternal scroll:

> I'm writing a CGI script for a site I'm working on, and I was
> wondering if it is at all possible to send arguments from the web
> browser to a script that is included in a page via SSI.

You need to be aware that SSI is a concept, rather than an
interworking specification.  So you need to consult the documentation
for your server's particular offering.

> I.E.

One might suspect yuo mean "e.g"...

> --  I have a script foo.cgi that takes the argument date.  If you
> call the script directly, you
> can go to mysite.com/foo.cgi?date=20030120
>
> Now I have included foo.cgi in bar.shtml via <!-- #exec cgi="/foo.cgi" -->

If you were using Apache, then you certainly must read its SSI
documentation http://httpd.apache.org/docs/howto/ssi.html

and in particular this bit of wisdom within
http://httpd.apache.org/docs/mod/mod_include.html :

    The include virtual element should be used in preference to exec
 cgi. In particular, if you need to pass additional arguments to a CGI
 program, using the query string, this cannot be done with exec cgi,
 but can be done with include virtual, as shown here:
 <!--#include virtual="/cgi-bin/example.cgi?argument=value" -->

> is there any way for me to go to
> mysite.com/bar.shtml?date=20030120 and get the right output from
> foo.cgi?

Apache surely can.  When do we get to your question about Perl?

> Unfortunately, the server is running IIS 5.0 on Windows 2000
> Advanced Server,

Standard answer: "upgrade to Apache".

> and there is nothing I can do about that (trust
> me, I've tired.)
           ^^^^^
Was that a freudian typo?  :-/

However, I stand by my advice that you need to read the documentation
for the server that you use.

If you want better portability between server implementations, then
turn the problem upside down and generate the whole page from the CGI
script, instead of trying to embed the results of the CGI script into
another page.


(I'm writing c.l.p.misc out of the plot at this point - f'ups set)

-- 

  Police are reported to be conducting a mouse-to-mouse search.


-- 
PLEASE NOTE: comp.infosystems.www.authoring.cgi is a
SELF-MODERATED newsgroup. aa.net and boutell.com are
NOT the originators of the articles and are NOT responsible
for their content.

HOW TO POST to comp.infosystems.www.authoring.cgi:
http://www.thinkspot.net/ciwac/howtopost.html



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

Date: 20 Jan 2003 11:39:41 -0800
From: ogmios@tiscalinet.be (Ogmios)
Subject: Strange problem reading from file
Message-Id: <a4f8df85.0301201139.333b4981@posting.google.com>

Maybe some perl guru out there can enlighten me.

I'm reading a complete file into memory in the following way:

    open(FILE, $input_file);
    my @array = <FILE>;
    close(FILE);

The problem I have is that when the characters +%D appear in the input
file, they're changed to +0. I must admit that the file is "big" (+-
4Mb) and when I isolate the offending line as only line in the input
the replacement isn't happen.

For the moment I tested this out on Activestate's Perl v5.6.1. Has
anyone already seen this problem and know how to fix this?

Regards,
Ogmios


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

Date: Mon, 20 Jan 2003 19:54:38 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Strange problem reading from file
Message-Id: <2uYW9.388$dU.364@nwrddc01.gnilink.net>

Ogmios wrote:
> Maybe some perl guru out there can enlighten me.
>
> I'm reading a complete file into memory in the following way:
>
>     open(FILE, $input_file);
>     my @array = <FILE>;
>     close(FILE);
>
> The problem I have is that when the characters +%D appear in the input
> file, they're changed to +0. I must admit that the file is "big" (+-
> 4Mb)

Small fish

> and when I isolate the offending line as only line in the input
> the replacement isn't happen.
>
> For the moment I tested this out on Activestate's Perl v5.6.1. Has
> anyone already seen this problem and know how to fix this?

Did you consider using "binmode"?

jue




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

Date: Mon, 20 Jan 2003 17:58:08 -0500
From: Lou Moran <lou.moran@gellerandwind.com>
Subject: Text manipulation
Message-Id: <ckso2v0t6bpr0i07r3ksvphv8bnn3s73t2@4ax.com>

I have three things to accomplish in a .csv file.

1 -- I need to replace all " with '
I have a pretty good handle on that

2 -- I need to remove all duplicates but leave one

3 -- I need to add a "Column" only when one doesn't exist

Here is an example of the data:

'Ron Albta','127 Diamond Street','#1','San Francisco, CA 94131'
'Ron Albta','127 Diamond Street','#1','San Francisco, CA 94131'
'Ron Albta','127 Diamond Street','#1','San Francisco, CA 94131'
'Julia Ascheson','P.O.Box 767','Redmond, WA  98073-2767',''
'Julia Ascheson','P.O.Box 767','Redmond, WA  98073-2767',''
'Julia Ascheson','P.O.Box 767','Redmond, WA  98073-2767',''
'Julia Ascheson','P.O.Box 767','Redmond, WA  98073-2767',''
'Julia Ascheson','P.O.Box 767','Redmond, WA  98073-2767',''
'Julia Ascheson','P.O.Box 767','Redmond, WA  98073-2767',''

As you can see Ron has an apartment number, or second address line but
Julia does not.  So I need to add an empty set of ' when the second
address line does not exist.

The problems are two fold for me:

I don't know how to search this question (b/c I am phrasing it all
wrong), and I can't find anything similar in the Perl Cookbook.

I have no idea how to approach the "add a column" problem.

Thanks for any input/CPAN/RTFM you have

--
There's more than one way to do it, but only some of them work


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

Date: Mon, 20 Jan 2003 19:34:07 GMT
From: "David K. Wall" <usenet@dwall.fastmail.fm>
Subject: Text::Autoformat doesn't format
Message-Id: <Xns930994323A512dkwwashere@204.127.199.17>

I'm trying to use Text::Autoformat, but it only seems to format the 
first line, or sometimes the first few lines.  I've tried variations of 
the program below, but none give me the expected output in the 
Text::Autoformat documentation.  

I'm using:
    Perl 5.6.1, Activestate build 633
    Text::Autoformat v. 1.04.
    winxp sp1

On my PC, this program prints the input text with no alterations.  What 
am I missing? (I hope I'm not going to feel stupid)(but it wouldn't be 
the first time)

----
use strict;
use warnings;
use Text::Autoformat;

$/ = '';
my $fixed = autoformat <DATA>, { left=>0, right=>50 };
print $fixed;

print $Text::Autoformat::VERSION;

__DATA__
In comp.lang.perl.misc you wrote:
: > <CN = Clooless Noobie> writes:
: > CN> PERL sux because:
: > CN>    * It doesn't have a switch statement and you have to put $
: > CN>signs in front of everything
: > CN>    * There are too many OR operators: having |, || and 'or'
: > CN>operators is confusing
: > CN>    * VB rools, yeah!!!!!!!!!
: > CN> So anyway, how can I stop reloads on a web page?
: > CN> Email replies only, thanks - I don't read this newsgroup.
: >
: > Begone, sirrah! You are a pathetic, Bill-loving, microcephalic
: > script-infant.
: Sheesh, what's with this group - ask a question, get toasted! And how
: *dare* you accuse me of Ianuphilia!

-- 
David Wall - me@dwall.fastmail.fm
"Oook."


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

Date: Mon, 20 Jan 2003 22:48:44 +0100
From: "Harald H.-J. Bongartz" <bongie@gmx.net>
Subject: Re: Text::Autoformat doesn't format
Message-Id: <4091907.3Ru7j1gTHz@nyoga.dubu.de>

David K. Wall wrote:

> I'm trying to use Text::Autoformat, but it only seems to format the
> first line, or sometimes the first few lines.
[...]
> my $fixed = autoformat <DATA>, { left=>0, right=>50 };

  my $fixed = autoformat <DATA>, { left=>0, right=>50, all=>1 };

Yes, it's well buried in the docs:   :-)

"Normally, "autoformat" only reformats the first paragraph it
encounters, and leaves the remainder of the text unaltered. This
behaviour is useful because it allows a one-liner invoking the
subroutine to be mapped onto a con­venient keystroke in a text editor,
to provide one-paragraph-at-a-time reformatting: [...] To enable
"autoformat" to rearrange the entire input text at once, the "all"
argument is used:[...]"

Ciao,
        Harald
-- 
Harald H.-J. Bongartz <bongie@gmx.net>
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
The toughest time...in anyone's life...is when you have to kill a loved
one just because they're the devil.             -- Emo Phillips



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

Date: 20 Jan 2003 13:29:38 -0800
From: ndescripto@yahoo.com (classical music)
Subject: why does not this work
Message-Id: <b431b108.0301201329.2590c5bd@posting.google.com>

%a=%$b->{a}

does not work.

$a=$b->{a};
%a=%$a

works

Is it expected?  Why?


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

Date: 20 Jan 2003 15:45:24 -0600
From: Joe Halpin <jhalpin@nortelnetworks.com_.nospam>
Subject: Re: why does not this work
Message-Id: <yxs7iswjmr63.fsf@nortelnetworks.com_.nospam>

ndescripto@yahoo.com (classical music) writes:

> %a=%$b->{a}
> 
> does not work.
> 
> $a=$b->{a};
> %a=%$a
> 
> works
> 
> Is it expected?  Why?

%$b->{a} is invalid syntax. The -> operator only works with
references, but you've dereferenced the reference, so it's not a
reference any more.

%$a is valid syntax, since it just dereferences the reference and
assigns the result to a compatible type.

See perldoc perlref for a complete explanation



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

Date: Mon, 20 Jan 2003 22:19:58 +0000 (UTC)
From: "eric" <eric.ehlers@btopenworld.com.nospam>
Subject: Re: why does not this work
Message-Id: <b0hsme$rbu$1@knossos.btinternet.com>

"classical music" <ndescripto@yahoo.com> wrote in message
news:b431b108.0301201329.2590c5bd@posting.google.com...
> %a=%$b->{a}
>
> does not work.

you want
%a=%{$b->{a}};

$a and $b are special package variables (see perlvar) and if you reuse them
unwittingly you can get strange results.

use strict;
use warnings;
use Data::Dumper;
my $href={ hash1=> { key1=>"val1" } };
my %h;
%h=%$href->{hash1}; # warning - deprecated - and doesn't give you what you
think it does
print Dumper(%h);
%h=%{$href->{hash1}};
print Dumper(%h);
my $href2=$href->{hash1};
%h=%$href2;
print Dumper(%h);

output -
$VAR1 = 'HASH(0x15550f0)';
$VAR2 = undef;
$VAR1 = 'key1';
$VAR2 = 'val1';
$VAR1 = 'key1';
$VAR2 = 'val1';

-eric




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

Date: 20 Jan 2003 22:34:03 GMT
From: damian@qimr.edu.au (Damian James)
Subject: Re: why does not this work
Message-Id: <slrnb2ouaq.7fp.damian@puma.qimr.edu.au>

On 20 Jan 2003 15:45:24 -0600, Joe Halpin said:
>ndescripto@yahoo.com (classical music) writes:
>
>> %a=%$b->{a}
>> does not work.
>> $a=$b->{a};
>> %a=%$a
>> works
>> 
>> Is it expected?  Why?
>
>%$b->{a} is invalid syntax. The -> operator only works with
>references, but you've dereferenced the reference, so it's not a
>reference any more.

No, the OP is trying to dereference the hashref *contained in*
$b->{a}. The correct syntax for this would be %{ $b->{a} }.

%$b->{a} is the same as %{$b}->{a}, which is not a syntax error,
but is not what the OP wants. Note that using warnings would have
alerted the OP to this:

 Reference found where even-sized list expected...

The OP should note that $a and $b should be avoided since they are
used by sort(). See the entry for sort() in the perlfunc man page.

--damian


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

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


Administrivia:

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

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

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

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

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


------------------------------
End of Perl-Users Digest V10 Issue 4435
***************************************


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