[18301] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 469 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Mar 12 09:05:40 2001

Date: Mon, 12 Mar 2001 06:05:14 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <984405914-v10-i469@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Mon, 12 Mar 2001     Volume: 10 Number: 469

Today's topics:
    Re: Access mdb <Peter.Dintelmann@dresdner-bank.com>
    Re: Access mdb <bart.lateur@skynet.be>
        ANNOUNCE: PerlPoint-Converters 0.009 <lorenz.domke@01019freenet.de>
    Re: Can a regex do this? (Miguel Cruz)
    Re: Can a regex do this? <thunderbear@bigfoot.com>
    Re: Can a regex do this? <tinamue@zedat.fu-berlin.de>
    Re: Can a regex do this? <bart.lateur@skynet.be>
        CGI question <rother@nortelnetworks.com>
        cgi redirect & cookies <replytogroup@nowhere.com>
    Re: cgi redirect not working <mkuin@globalrangers.com>
        Criticism? (comparing contents of two arrays) <NOSPAM4MEdrh@engineer.com>
    Re: Criticism? (comparing contents of two arrays) (Martien Verbruggen)
        DBM issues - cgi; hash of hashes; locking; etc <gtoomey@usa.net>
        Excaping Characters CGI Problem <lxq79@REMOVE.CAPITALS.hotmail.com>
    Re: Excaping Characters CGI Problem <peter.s@tjgroup.dk>
    Re: Excaping Characters CGI Problem <peter.s@tjgroup.dk>
        File::Tail on Win32 <Galstonian@MailAndNews.com>
    Re: from SETL to Perl <djohnson@math.utah.edu>
        functions, operators and () <alun.moon@unn.ac.uk>
    Re: Help Matt with small programs (Abigail)
    Re: Help Matt with small programs <bart.lateur@skynet.be>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Mon, 12 Mar 2001 12:42:16 +0100
From: "Dr. Peter Dintelmann" <Peter.Dintelmann@dresdner-bank.com>
Subject: Re: Access mdb
Message-Id: <98icai$a351@news-1.bank.dresdner.net>

    Hi,

"Phil Sutcliffe" <ils@gil.com.au> wrote in message
news:3aac5040$0$6342@wodc7nh6.news.uu.net...
> Is it possible to read data from a table in an Access mdb on a Linux
machine

    yes.

> and if so, how does one go about doing this?

    One solution is presented in

http://tlowery.hypermart.net/perl_dbi_dbd_faq.html#HowDoIAccessMSWindowsDB

> How about an Excel spreadsheet?

    searching CPAN you will find Spreadsheet::ParseExcel.
    Give it a try.

    Best regards,

        Peter Dintelmann





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

Date: Mon, 12 Mar 2001 13:22:54 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Access mdb
Message-Id: <4sipatoi6b4n3c1f9bvuovssvqfkndon5f@4ax.com>

Phil Sutcliffe wrote:

>Is it possible to read data from a table in an Access mdb on a Linux machine
>and if so, how does one go about doing this?


No. Although, *.mdb is a form of OLE format, so I wouldn't be surprised
if somebody can prove me wrong. You can connect from within Linux to an
Access database on a Windows PC, provided that enough parts of Access
are installed on that PC, that you have a network connection between the
two, and have an ODBC driver on the Linus machine.

>How about an Excel spreadsheet?

There are some modules that can parse Excel files, I guess.

	<http://search.cpan.org/search?dist=Spreadsheet-ParseExcel>

On Windows, you can use Win32::OLE, if you have Excel.

But why not an alternative? Surely there are better, native, even free
database engines available for Linux. You'll have to import the data
from the Access database into your native database, either with
assistence from Access, or through exported table files, but that is a
one time process. Surely that will be the faster approach.

-- 
	Bart.


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

Date: Mon, 12 Mar 2001 08:57:58 +0100
From: Lorenz Domke <lorenz.domke@01019freenet.de>
Subject: ANNOUNCE: PerlPoint-Converters 0.009
Message-Id: <tap5bk7fri1rf9@corp.supernews.com>

The PerlPoint-Converters Package 0.009 has been uploaded to CPAN
================================================================

Regards, Lorenz Domke

>From Changes:
-------------
Revision history for PerlPoint-Converters.

Version 0.009   03/04/2001
-  require PerlPoint::Parser 0.32
-  new parameters --box_width and --filters for pp2html
-  URL_INDEX did point to last page, not to index (bug reported by
   Jeffrey Haemer)
-  Index entries format changed. Now they look like
      text ref1 [, ref2, ref3 ...]
   with "text" beeing the (multiple) index entry and ref1, ref2 ...
   beeing Hyperlinks as references. The text for the references is
   either the page number or the chapter number when the --num_headers
   option has been set.
-  Cleanup with templates. It has not been quite clear, what has to go
   to the HTML templates and what is generated by pp2html. For example
   the <BODY> line and the <HTML> tag. There were cases where the
   <HTML> header and the <BODY> line were duplicated, and a "cleanup"
   in version 0.008 even introduced a bug :-(
   So I decided to make it more clear. Please read the docu for
   pp2html (pp2html --help) and the ppdoc.pp file for more information
   about that. In short: <HTML>, <TITLE> and <BODY> lines are
   alway provided by pp2html (with options from outside passe through).
   HTML Template Files ONLY contain HTML text which is placed inside the
   <BODY>.
-  templates adapted
-  Continued numbered lists ( the ## paragraphs are now supported)
-  Shiftlevels are handled correctly
-  the \BOXCOLOR and \BOXTEXT Tags are obsolete now. Their syntax was
   not consistent: \BOXCOLOR<green> has formerly been used to set the
   box color for code blocks. But normally all text in the tag body
   (between < and >) is part of the output and NOT a parameter to the
   (between < and >) is part of the output and NOT a parameter to the
   tag. Tag parameters are specified in curly brackets. Therefore
   the new tag is:
   \BOXCOLORS{bg=backgroundcolor fg=foregroundcolor}
   which replaces \BOXCOLR<backgroundcolor> and
\BOXTEXT<foregroundcolor>
-  bugfix: escapes in code-blocks were inactive after embedded code
-  bugfix: URLs in pp2html were doubled in the output
-  workaround for TreeApplet Bug: Headers which contain a / are not
allowed.
   Therefore all slashes are replaced with commas ...
-  Language parameter in \EMBED{lang=html ...} is now caseinsensitive
-  Version information clarified: pp2html and pp2latex have individual
version
   numbers (build numbers) and belong to a certain version of the
   PerlPoint-Converters package.
-  Individual colors (foreground and background) for table of contents,
index
   and normal slides, top and bottom templates: --bgcolor, --fgcolor,
   --toc_bgcolor, --toc_fgcolor, --idx_bgcolor --idx_fgcolor
   --top_bgcolor, --top_fgcolor, --bot_bgcolor, --bot_fgcolor
   --top_linkcolor, --bot_linkcolor, --toc_linkcolor, --idx_linkcolor,
 ...
-  new options: --no_contents_indent, --no_contents_bullets
   This will prevent the table of contents from beeing indented by <UL>
</UL> tags
   and the second option avoids bullets in front of each entry in the
table of contents.
-  optional background images for normal slides, index and table of
contents:
   --back_image, --toc_back_image, --idx_back_image
   --top_back_image, --bot_back_image
-  use Cwd instead of `pwd`
-  Images can now be part of an \XREF tag!
-  \IMAGE tag now supports BORDER=m option
-  XREF, PAGEREF and SECTIONREF now consider javascript navigation
-  --trans_table option re-implemented (had been part of an ancient
version of pp2html)
-  different bullet images for different indentation levels
   --bullet option can be used more than once!


>From README:------------
This is the README file for PerlPoint-Converters

$Id: README,v 1.8 2001/03/06 21:21:28 lorenz Exp $

Covered topics:

o  Introduction
o  About PerlPoint-Converters
o  Prerequisits
o  What's new
o  Bug Reports

Introduction
------------
PerlPoint is a simple text format which allows easy typing of text
with headlines, bullet lists, normal text paragraphs, indented
paragraphs for code examples etc., from which slides for presentations
can be generated by a script without the need of proprietary software.
Since there is a large variety of platforms which provide web browsers,
HTML is a good choice for the output format. In principle, however, it
is possible to generate each output format whose specification is
known. At the moment there exist converters for HTML, LaTeX (alpha
software)
and SDF. The latter both may be used to generate printable output or to
provide the basis for further processing.


About PerlPoint-Converters
--------------------------
This package provides two programs:
  pp2html
  pp2latex (still alpha software)

They convert an ASCII file written in the `PerlPoint' language to a set
of HTML files or to Latex Files respectively. The `PerlPoint' language
was initially invented by Tom Christiansen as a simple means for
preparing slides. The idea was to just write down your headings and
bullet items and then use a simple perl script to create the slides:

  =Header of first slide

  * Use your favourite editor

  * Start headings with a `='

  * Bullets items start with an asterisk `*'

The syntax of the original version was similar to POD and the layout
of the slides was hard coded in Tom's pp2html script. The new syntax
provides more felxibility and can be parsed with the PerlPoint::Parser
from Jochen Stenzel's PerlPoint-Package.
   The following list persents some of the features of pp2html and
pp2latex:
  - HTML template files for header, footer and navigation bar
  - Support of Frame Sets
  - Support of the TreeControl Applet in tabel of contents
  - Headers with different levels with or wihout numbering
    (1, 1.1, 1.2, 2, ...)
  - Hyperlinks to internal and external pages
  - Automatic generation of table of contents and navigation links
  - Automatic generation of index
  - Bullet-Lists with standard <LI> bullets or with bullets from a
gif/jpeg file
  - Numbered lists and definition lists
  - Simple tables
  - Simple text formatting possible

For more inforamtion about the PerlPoint syntax and history please
refer to the documentation in the PerlPoint-Package from Jochen Stenzel
(perldoc PerlPoint::Parser).
       

Prerequisits
------------
This version needs Perl5.005.
Note: The fields.pm Module which comes with Perl5.005 is quite old.
You should get the newest version from CPAN because the
PerlPoint::Parser
Module needs a newer version!

The pp2html program uses the following packages which are available on
CPAN
or come with your Perl distribution:

  Pod::Text
  Getopt::Long
  Getopt::ArgvFile
  PerlPoint::Parser
  PerlPoint::Backend
  PerlPoint::Constants

The TreeApplet classes are contained in the images subdirectory of this
distribution. For more information about the TreeApplet classes refer to
http://www.naturallyj.com.
This distribution contains an older version which was freely available.


What's new in this version
--------------------------
This is version 0.009

Please refer to file "Changes".


Bug Reports
-----------
Please send bug reports and requests to <lorenz.domke@gmx.de>

Lorenz Domke 

-- 
-------------------------------------------------------------------------
Lorenz Domke                                       
lorenz.domke@pixel.de
Endelhauserstr. 30     GnuPG Key-ID: BACCE490        
lorenz.domke@gmx.de
D-80686 München                                    Tel: (0 89) 5 70 33
80




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

Date: Mon, 12 Mar 2001 08:10:04 GMT
From: mnc@admin.u.nu (Miguel Cruz)
Subject: Re: Can a regex do this?
Message-Id: <wv%q6.5867$8I5.2617833@typhoon2.ba-dsg.net>

In article <98h7v4$1td9l$5@fu-berlin.de>, Tina Mueller  <news@tinita.de> wrote:
>> Can this be done on the same line?
>
> $test =~ s/1(.*)2(.*)3/a$1b$2c/;
>
> what's so difficult about it?

You used a semicolon at the end, which is a Perlism, so it wasn't a regex.

miguel


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

Date: Mon, 12 Mar 2001 10:40:05 +0100
From: =?iso-8859-1?Q?Thorbj=F8rn?= Ravn Andersen <thunderbear@bigfoot.com>
Subject: Re: Can a regex do this?
Message-Id: <3AAC9975.95532C1A@bigfoot.com>

blahblah wrote:

> Yet another fucking loser who can't read. I said REGEX. I never said
> PERL. I guess it's true that only old fucks who can't use current
> languages still use perl. Sad.

Have you considered for even the briefest of moments, asking people who
use the same language as you do?

-- 
  Thorbjørn Ravn Andersen              "...sound of...Tubular Bells!"
  http://bigfoot.com/~thunderbear


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

Date: 12 Mar 2001 10:40:03 GMT
From: Tina Mueller <tinamue@zedat.fu-berlin.de>
Subject: Re: Can a regex do this?
Message-Id: <98i923$21a68$1@fu-berlin.de>

Miguel Cruz <mnc@admin.u.nu> wrote:
> In article <98h7v4$1td9l$5@fu-berlin.de>, Tina Mueller  <news@tinita.de> wrote:
>>> Can this be done on the same line?
>>
>> $test =~ s/1(.*)2(.*)3/a$1b$2c/;
>>
>> what's so difficult about it?

> You used a semicolon at the end, which is a Perlism, so it wasn't a regex.

oh yeah, too bad... I was so close ... =)

-- 
http://tinita.de    \  enter__| |__the___ _ _ ___
tina's moviedatabase \     / _` / _ \/ _ \ '_(_-< of
search & add comments \    \ _,_\ __/\ __/_| /__/ perception
please don't email unless offtopic or followup is set. thanx


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

Date: Mon, 12 Mar 2001 13:11:22 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Can a regex do this?
Message-Id: <toipat0c8ci5tdfcr8cerus2b9495mrpoc@4ax.com>

Miguel Cruz wrote:

>> $test =~ s/1(.*)2(.*)3/a$1b$2c/;
>>
>> what's so difficult about it?
>
>You used a semicolon at the end, which is a Perlism, so it wasn't a regex.

Actually, the regex is the part between the first and the second slash.
A subsitution is not a regex. So no, a regex cannot do it.

-- 
	Bart.


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

Date: Mon, 12 Mar 2001 08:45:56 -0500
From: Gabe Rother <rother@nortelnetworks.com>
Subject: CGI question
Message-Id: <3AACD314.EE9C904@nortelnetworks.com>

I'm trying to get AnalogX CGISearch v3.00 to function properly on my NT4
webserver.  When it runs a search, it does the search properly, and
displays the results in the format of showing the title with a link,
then a description, then showing the URL without a link, then the size
and last modified date.

The url is displays in the third line is correct, however the actual
link in the title is not.  The title link always tries to take the page
out of the cgi-bin folder.

Ex.

if the url is http://gabe.rother.com/folder1/page1.html Then where it
shows the URL, it will this, the correct path.

But, the link will be http://gabe.rother.com/cgi-bin/page1.htm

Does anyone know what's wrong with this?  Could it have something to do
with the way the virtual directories are set up??

If you can help me out, that'd be great.  If you need more info, please
e-mail and I'll answer any additional questions you might have, to help
me out with this.

Gabe Rother
rother@nortelnetworks.com


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

Date: Mon, 12 Mar 2001 11:43:40 -0000
From: "st" <replytogroup@nowhere.com>
Subject: cgi redirect & cookies
Message-Id: <98icr9$cde$1@news5.svr.pol.co.uk>

I have a script which writes a cookie and then I want to redirect to a
different cgi script.
I understand using   print $q->redirect('http://www.domain.com/'):  you
should not write a content header.  This does work but when I write the
cookie it writes a header.  Does anyone know how to get round this problem

$cookie = $q->cookie (     -name=>'sessionid',
                                          -value=>'cookie_value',
                                            -expires=>'+1d',
                                             -path=>'/');
 print $q->header(-cookie=>$cookie);

print $q->redirect('http://www.google.com');

Is there another way to write a cookie without using the header line ?
The code above does not result but displays the redirection code instead of
directing the user to the next script.

Status: 302 Moved Location: http://www.goggle.com

Thanks for any help





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

Date: Mon, 12 Mar 2001 10:11:52 +0100
From: "Mark Kuin" <mkuin@globalrangers.com>
Subject: Re: cgi redirect not working
Message-Id: <98i499$g9$1@news1.xs4all.nl>

When you use $query->redirect('http://new_url/cgi-bin/script.cgi') you
should NOT use headers (at least that works for me).
so print $query->redirect('http://new_url/') should be the first output to
the browser.


> its displays this message
>
> status: 302 Moved Location: http://google.com





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

Date: Mon, 12 Mar 2001 08:55:13 GMT
From: David <NOSPAM4MEdrh@engineer.com>
Subject: Criticism? (comparing contents of two arrays)
Message-Id: <bm2patkusv5341fn0dovv2ad03pt8kec5g@4ax.com>

Hi

Would anyone care to comment on the following script?  It works fine,
though I'm sure it is not as efficient as it could be.

This script compares two text files containing product numbers, one per
line.  If a match is found, it is printed in a third text file
"matches.txt"  The text files are quite large - more than 20,000 product
numbers (lines) each.  For this reason, I'm not sure if the approach
I've taken (i.e. reading both files into arrays for comparison) is
optimal, but I'm looking for speed here, and I think comparing arrays is
faster than reading sequentially from disk (true?).

It seems to me that because most of the items being matched are numbers,
a higher level of "intelligent" matching could be used, i.e. searching
for a number within a small range instead of exhausting a large list.

I welcome your feedback.

Thanks in advance
David



###### Begin Code #######

use strict;
use warnings;

## Where matches will be logged
open (MATCHES , ">matches.txt")|| die "Can't open matches: $!\n";
## Open "master list" of product numbers for read
open (CUSTOMER , "customer.txt") || die "Can't open customer.txt: $!\n";
## Open list of numbers to match against
open (DSI , "dsi.txt") || die "Can't open dsi: $!\n";

chomp (my @cust = <CUSTOMER>);	##	Remove newlines from both arrays
chomp (my @dsi = <DSI>);	

@dsi = sort @dsi;			##	Sort lists for reliable indexing
@cust = sort @cust;	

my $bookmark;	##	Initialize placeholder
my $cust_product;
my $counter;		##	Initialize counter

## Step through each product ID in master list
foreach $cust_product (@cust){
	## Reset counter in case no match was found last loop
	$counter = $bookmark;			
		## Search through second array starting from last match
		for (@dsi[$bookmark .. $#dsi]){
		## Increment counter
		$counter++;
		## Log matches
		if ($cust_product eq $_) {
			print MATCHES "$cust_product\n";
			## Get index of successful match
			$bookmark = $counter;
			## Go to next product in master list
			last;
		}

	}
}


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

Date: Mon, 12 Mar 2001 21:58:37 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: Criticism? (comparing contents of two arrays)
Message-Id: <slrn9apaut.uuk.mgjv@martien.heliotrope.home>

On Mon, 12 Mar 2001 08:55:13 GMT,
	David <NOSPAM4MEdrh@engineer.com> wrote:
> Hi
> 
> Would anyone care to comment on the following script?  It works fine,
> though I'm sure it is not as efficient as it could be.
> 
> This script compares two text files containing product numbers, one per
> line.  If a match is found, it is printed in a third text file
> "matches.txt"  The text files are quite large - more than 20,000 product
> numbers (lines) each.  For this reason, I'm not sure if the approach
> I've taken (i.e. reading both files into arrays for comparison) is
> optimal, but I'm looking for speed here, and I think comparing arrays is
> faster than reading sequentially from disk (true?).

Instead of looping over two arrays, you should probably use a hash.

See also the Perl FAQ, section 4

Q: How can I tell whether a list or array contains a certain element?

Q: How do I compute the difference of two arrays?  How do I compute the
   intersection of two arrays?

Both of those probably contain elements of what you are trying to do
(which is finding the intersection of the two arrays).

> It seems to me that because most of the items being matched are numbers,
> a higher level of "intelligent" matching could be used, i.e. searching
> for a number within a small range instead of exhausting a large list.

Well.. I can't tell you about that, because you fail to provide data. In
other words: We don't know what the range of numbers is, and how sparse
the data is. We don't know whether there's any duplication either.

> use strict;
> use warnings;
> 
> ## Where matches will be logged
> open (MATCHES , ">matches.txt")|| die "Can't open matches: $!\n";
> ## Open "master list" of product numbers for read
> open (CUSTOMER , "customer.txt") || die "Can't open customer.txt: $!\n";
> ## Open list of numbers to match against
> open (DSI , "dsi.txt") || die "Can't open dsi: $!\n";
> 
> chomp (my @cust = <CUSTOMER>);	##	Remove newlines from both arrays
> chomp (my @dsi = <DSI>);	

Why do you remove the newlines when you're going to put them back later
anyway?

> @dsi = sort @dsi;			##	Sort lists for reliable indexing
> @cust = sort @cust;	

Sorting is quite expensive. Loading the stuff in a hash is probably
cheaper, especially since you only have to do it for one. And hash
slices (see perldata) make it easy enough to create one:

my %dsi;
@dsi{@dsi) = (0 .. $#dsi);

This will give you a hash with the product keys as numbers, and the
index into the original array as values, although I don't think you need
those, really.

If you don't care about where the keys came from, but only that they
exist, you can save quite some memory by doing something like:

my %dsi;
@dsi{<DSI>} = ();

Note that in this case, and in the case above if you don't chomp, the
newline is still there. Now you can just test with 'exist
$dsi{$other_key}'. In this case all the values in the hash will be
undefined, so be careful to test with 'exists' and not 'defined' or even
just the trueness of the value.

I'd probably write your program more like:

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

open DSI, "dsi.txt" or die $!;
my %dsi;
@dsi{<DSI>} = ();
close DSI;

open CUST, "customer.txt" or die $!;
open MATCH, ">match.txt" or die $!;

while (<CUST>)
{
	print MATCH $_ if exists $dsi{$_};
}

close MATCH;
close CUST;

I suspect that this is going to be quite a bit faster, and it probably
won't use more memory (I only have one of the two files in memory,
hopefully the smallest). The files need to become rather large for this
to be undoable on modern systems.

Checked on my system, with a dsi.txt file with 20000 unique random
numbers as output by perl's rand() (and they're reasonably long)

open DSI, "dsi.txt" or die $!;
my %dsi;
chomp(my $vsz_before = `ps -ovsz -p $$ | grep -v VSZ`);
@dsi{<DSI>} = ();
close DSI; 
chomp(my $vsz_after = `ps -ovsz -p $$ | grep -v VSZ`);

printf "$vsz_after - $vsz_before = %d\n", $vsz_after - $vsz_before;

OUTPUT:
 5716 -  2608 = 3108

That'a about 3 MB for 20000 keys. Not undoable at all.

I'll leave it up to you to make the die messages more meaningful, and
maybe do other things to it.

For a more precise advice, next time around, it might be nice if you
told us a bit more about the relationship of the files. Is customer.txt
a list of products bought by a customer? And is there any order in that
list? Is dsi.txt the list with all possible products? Does the output
need to have a certain ordering? I'm largely guessing now.

Maybe you should investigate whether this data doesn't really belong in
a relational database. The thing you're trying to do is a standard join
between two tables in one of those things.

Martien
-- 
Martien Verbruggen              | 
Interactive Media Division      | Begin at the beginning and go on till
Commercial Dynamics Pty. Ltd.   | you come to the end; then stop.
NSW, Australia                  | 


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

Date: Mon, 12 Mar 2001 22:23:16 +1000
From: "Gregory Toomey" <gtoomey@usa.net>
Subject: DBM issues - cgi; hash of hashes; locking; etc
Message-Id: <913r6.13582$v5.58328@newsfeeds.bigpond.com>

I am considering using dbm files as a
"poor man's database" and have a few questions.

1. Are ther problems with dbm files with cgi when there
are multiple readers/writers.
2. I have seen an 1996 article by Tom Christiansen that says
"You cannot easily tie a multilevel data structure (such as a hash of
hashes) to a dbm file".
Is this still the case with Perl 5?
3. Do I have to do the locking myself?

Any pointers to code/tutorials would be helpful.


Thanks,
G. Toomey




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

Date: Mon, 12 Mar 2001 22:20:24 +0900
From: LXQ <lxq79@REMOVE.CAPITALS.hotmail.com>
Subject: Excaping Characters CGI Problem
Message-Id: <20010312222024.4e02920b.lxq79@REMOVE.CAPITALS.hotmail.com>

Hello all,

I have a problem with excaping a ' (single quote) from my program. I wrote
a simple CGI program to test it, but the level_two() function always fails
to display the ' (single quote) properly. Please help, and thanks so much.


#!/usr/bin/perl -w

use CGI qw(:standard);
use strict;

my $ac = param("ac");

print header, start_html("Test");
print "$ac";

if ($ac == 1) {
    level_one();
}
elsif ($ac == 2) {
    level_two();
}
else {
    base_level();
}


sub base_level {
    print "<form action=test.pl method=post>";
    print "<input type=text name=anything>";
    print "<input type=hidden name=ac value=1>";
    print "<input type=submit>";
    print "</form>";
}

sub level_one {
    my $anything = param("anything");
    print "This is level one<br>";
    print "$anything";
    print "<form action=test.pl method=post>";
    print "<input type=hidden name=anything value='$anything'>";
    print "<input type=hidden name=ac value=2>";
    print "<input type=submit>";
    print "</form>";
}

sub level_two {
    my $anything = param("anything");
    print "This is level two<br>";
    print "$anything";
}


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

Date: Mon, 12 Mar 2001 14:45:17 +0100
From: "Peter Søgaard" <peter.s@tjgroup.dk>
Subject: Re: Excaping Characters CGI Problem
Message-Id: <98ijmb$h0$1@news.inet.tele.dk>

the problem is in your level 1 sub in the line:
print "<input type=hidden name=anything value='$anything'>";

say $anything contains "a'a". When you interpolate $anything, the above line
will be:
print "<input type=hidden name=anything value='a'a'>";

which is one ' too many...

Instead you could use escaped " in your print line above...as follows:
print "<input type=hidden name=anything value=\"$anything\">";

Hope this helps...


"LXQ" <lxq79@REMOVE.CAPITALS.hotmail.com> skrev i en meddelelse
news:20010312222024.4e02920b.lxq79@REMOVE.CAPITALS.hotmail.com...
> Hello all,
>
> I have a problem with excaping a ' (single quote) from my program. I wrote
> a simple CGI program to test it, but the level_two() function always fails
> to display the ' (single quote) properly. Please help, and thanks so much.
>
>
> #!/usr/bin/perl -w
>
> use CGI qw(:standard);
> use strict;
>
> my $ac = param("ac");
>
> print header, start_html("Test");
> print "$ac";
>
> if ($ac == 1) {
>     level_one();
> }
> elsif ($ac == 2) {
>     level_two();
> }
> else {
>     base_level();
> }
>
>
> sub base_level {
>     print "<form action=test.pl method=post>";
>     print "<input type=text name=anything>";
>     print "<input type=hidden name=ac value=1>";
>     print "<input type=submit>";
>     print "</form>";
> }
>
> sub level_one {
>     my $anything = param("anything");
>     print "This is level one<br>";
>     print "$anything";
>     print "<form action=test.pl method=post>";
>     print "<input type=hidden name=anything value='$anything'>";
>     print "<input type=hidden name=ac value=2>";
>     print "<input type=submit>";
>     print "</form>";
> }
>
> sub level_two {
>     my $anything = param("anything");
>     print "This is level two<br>";
>     print "$anything";
> }




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

Date: Mon, 12 Mar 2001 14:48:13 +0100
From: "Peter Søgaard" <peter.s@tjgroup.dk>
Subject: Re: Excaping Characters CGI Problem
Message-Id: <98ijro$111$1@news.inet.tele.dk>

 ...that will of course give the same problem if you wish to pring out double
quotes...a solution to this would be to swap double quotes in your $anything
with two single quotes before printing it out...

$anything =~ s/"/''/g

"Peter Søgaard" <peter.s@tjgroup.dk> skrev i en meddelelse
news:98ijmb$h0$1@news.inet.tele.dk...
> the problem is in your level 1 sub in the line:
> print "<input type=hidden name=anything value='$anything'>";
>
> say $anything contains "a'a". When you interpolate $anything, the above
line
> will be:
> print "<input type=hidden name=anything value='a'a'>";
>
> which is one ' too many...
>
> Instead you could use escaped " in your print line above...as follows:
> print "<input type=hidden name=anything value=\"$anything\">";
>
> Hope this helps...
>
>
> "LXQ" <lxq79@REMOVE.CAPITALS.hotmail.com> skrev i en meddelelse
> news:20010312222024.4e02920b.lxq79@REMOVE.CAPITALS.hotmail.com...
> > Hello all,
> >
> > I have a problem with excaping a ' (single quote) from my program. I
wrote
> > a simple CGI program to test it, but the level_two() function always
fails
> > to display the ' (single quote) properly. Please help, and thanks so
much.
> >
> >
> > #!/usr/bin/perl -w
> >
> > use CGI qw(:standard);
> > use strict;
> >
> > my $ac = param("ac");
> >
> > print header, start_html("Test");
> > print "$ac";
> >
> > if ($ac == 1) {
> >     level_one();
> > }
> > elsif ($ac == 2) {
> >     level_two();
> > }
> > else {
> >     base_level();
> > }
> >
> >
> > sub base_level {
> >     print "<form action=test.pl method=post>";
> >     print "<input type=text name=anything>";
> >     print "<input type=hidden name=ac value=1>";
> >     print "<input type=submit>";
> >     print "</form>";
> > }
> >
> > sub level_one {
> >     my $anything = param("anything");
> >     print "This is level one<br>";
> >     print "$anything";
> >     print "<form action=test.pl method=post>";
> >     print "<input type=hidden name=anything value='$anything'>";
> >     print "<input type=hidden name=ac value=2>";
> >     print "<input type=submit>";
> >     print "</form>";
> > }
> >
> > sub level_two {
> >     my $anything = param("anything");
> >     print "This is level two<br>";
> >     print "$anything";
> > }
>
>




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

Date: Mon, 12 Mar 2001 08:01:24 -0500
From: Galstonian <Galstonian@MailAndNews.com>
Subject: File::Tail on Win32
Message-Id: <3AB7A58E@MailAndNews.com>

I have some scripts which monitor log files and am trying to port this to 
Win32.  While the modules work they will cause operations on the files they 
are monitoring to fail, for example if you want to move or remove the file.  
Has anyone experience of this or pointers to something that might help (even 
an intro into how file handles are treated under Windows would help).

Thanks in advance,

-G-

------------------------------------------------------------
 Get your FREE web-based e-mail and newsgroup access at:
                http://MailAndNews.com

 Create a new mailbox, or access your existing IMAP4 or
 POP3 mailbox from anywhere with just a web browser.
------------------------------------------------------------



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

Date: 12 Mar 2001 03:40:49 -0700
From: Dean Johnson <djohnson@math.utah.edu>
Subject: Re: from SETL to Perl
Message-Id: <yoh4rwzuv66.fsf@sunray.math.utah.edu>


> Hi guys I have 2 programs below that I must have in Perl but I have
> them in SETL(whatever the hell that is) and I don't know anything
> about it. I tried finding stuff about it on the web but all I found
> was two small, irrelevant pages and no tutorials. The thing is, if
> at least I knew what the 'Euler path construction', or 'Prime
> factors' are, I could just program them on my own without looking at
> the SETL code, but i don't. Basically I just


 There is a good page on SETL here:
    http://birch.eecs.lehigh.edu/~bacon/doc.html

 A description of Eulerian graphs can be found here:
    http://hsu11.cis.nctu.edu.tw/Graph_Theory/euler/


Good Day,
 Dean


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

Date: 12 Mar 2001 09:59:20 +0000
From: Alun Moon <alun.moon@unn.ac.uk>
Subject: functions, operators and ()
Message-Id: <uelw3z4sn.fsf@unn.ac.uk>

I had a discussion with a colleague about teaching Perl.

Initially the students would be taught to use something like

  print("hello world\n");

Where I would use

 print "hello world\n";

I believe that the use of () alters the way the print handles the
parameters.  I've read through the Perldocs (perlfunc) and page 77 in
the Camel book.

My understanding is that the () make the print a function rather than
a list operator (though I'm not sure what the distinction is), and
alter the precidence of the statement.  Am I right?

I also advocated that we teach the 
  print "hello world\n";
version, as this is the form used in the perldocs and Camel book.
Does this seem right?

Many thanks

Alun

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Dr Alun Moon            Senior Lecturer in Computing
alun.moon@unn.ac.uk     School of Computing and Mathematics
(0191) 227 3643         University of Northumbria at Newcastle
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



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

Date: 12 Mar 2001 10:14:02 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Help Matt with small programs
Message-Id: <slrn9ap8ba.db9.abigail@tsathoggua.rlyeh.net>

Ted Zlatanov (tzz@beld.net) wrote on MMDCCL September MCMXCIII in
<URL:news:m31ys3aepr.fsf@heechee.beld.net>:
`` abigail@foad.org (Abigail) writes:
`` 
`` > Ted Zlatanov (tzz@beld.net) wrote on MMDCCXLVIII September MCMXCIII in <URL:news:m3snkl8t9n.fsf@heechee.beld.net>:
`` > "" abigail@foad.org (Abigail) writes:
`` > "" 
`` > "" > {local $, = " ";
`` > "" >  print grep {$_ % 5 == 0} 0 .. 99
`` > "" > }
`` > "" > 
`` > "" Perhaps a less obfuscated choice might be:
`` > "" 
`` > "" print join ' ', grep {$_ % 5 == 0} 0 .. 99;
`` > "" 
`` > "" since it avoids localized variables and $,
`` > 
`` > $_ is localized.
`` 
`` Actually the localized $, is what I was talking about.  Localized $_
`` is well-accepted and makes perfect sense.  $, is rarer in my
`` experience.
`` 
`` > But why do you make the suggestion localized variables are bad?
`` 
`` Localized variables, and your solution in particular, are perfectly
`` fine.  I was just proposing an alternate solution which does the same
`` thing without localized magic variables.  IMHO (hence the "Perhaps"
`` above) it is also less obfuscated.


I actually find seperation of formatting and solving the problem on hand
clearer than mixing formatting and algorithm in one statement.


Abigail
-- 
my $qr = /^.+?(;).+?\1|;Just another Perl Hacker;|;.+$/;
   $qr =~ s/$qr//g;
print $qr, "\n";


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

Date: Mon, 12 Mar 2001 13:09:59 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Help Matt with small programs
Message-Id: <6iipatctj1nh7ggvr93io97isgo8lls00t@4ax.com>

Ted Zlatanov wrote:

>Actually the localized $, is what I was talking about.  Localized $_
>is well-accepted and makes perfect sense.  $, is rarer in my
>experience.

Are you using the right language? Perl is a very big language, and you
shouldn't be afraid of using a lesser known technique, because "some
people" might find it confusing. I use $\, $, and friends ($") on a
daily basis. I use them more often than OO. The definition of "obscure"
may well depend on the viewer. The "average user" does not exist!

-- 
	Bart.


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

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 V10 Issue 469
**************************************


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