[25899] in Perl-Users-Digest
Perl-Users Digest, Issue: 8127 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon May 30 00:05:38 2005
Date: Sun, 29 May 2005 21:05:05 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Sun, 29 May 2005 Volume: 10 Number: 8127
Today's topics:
Re: CGI::Session <pilkowsk@informatik.uni-marburg.de>
Re: CGI::Session <tadmc@augustmail.com>
Re: newbie Perl question <westshestcostsheastsheri@westshestcostsheastsher.com>
Re: newbie Perl question <noreply@gunnar.cc>
Re: newbie Perl question <westshestcostsheastsheri@westshestcostsheastsher.com>
Re: newbie Perl question <tadmc@augustmail.com>
Re: newbie Perl question <westshestcostsheastsheri@westshestcostsheastsher.com>
Re: newbie Perl question <1usa@llenroc.ude.invalid>
Re: Regex help: delete text only if not within quotatio <nobull@mail.com>
Re: Regex help: delete text only if not within quotatio <nobull@mail.com>
Re: Regex help: delete text only if not within quotatio (Anno Siegel)
Re: regexp replace problem <noreply@gunnar.cc>
Re: regexp replace problem <pilkowsk@informatik.uni-marburg.de>
Re: regexp replace problem <tadmc@augustmail.com>
Session retrieving data <alexj@freesurf.ch>
Re: Session retrieving data <alexj@freesurf.ch>
Re: Session retrieving data <alexj@freesurf.ch>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sun, 29 May 2005 20:32:04 +0200
From: Fabian Pilkowski <pilkowsk@informatik.uni-marburg.de>
Subject: Re: CGI::Session
Message-Id: <3fug48F9kn0oU1@individual.net>
* Alexandre Jaquet schrieb:
>>
>> Does anybody know what's the problem with my code :
>>
>> my $CGISESSID;
>> my $session;
>>
>> $session = new CGI::Session();
>> $CGISESSID = $session->id();
Could you explain why each of your my-statements needs an extra line of
code? It is not necessary, unless your salary primarily depends on the
number of lines you programmed for your boss. Consider to use
my $session = new CGI::Session();
my $CGISESSID = $session->id();
IMHO it's more readable if you declare your vars where you need them
(and not some lines above).
>>
>> error message :
>>
>> CGI::Session doesn't seem to be a valid CGI::Session driver. At least
>> one method ('store') is missing at
>
> finally solved by modify the session creation :
>
> $session = new CGI::Session ("driver:File", undef, {Directory =>
> 'C:/tmp' });
Well, it is not wrong to read the documentation ;-)
regards,
fabian
------------------------------
Date: Sun, 29 May 2005 13:12:32 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: CGI::Session
Message-Id: <slrnd9k1gg.e3c.tadmc@magna.augustmail.com>
Alexandre Jaquet <alexj@freesurf.ch> wrote:
> Alexandre Jaquet a écrit :
>> $session = new CGI::Session();
>> error message :
>>
>> CGI::Session doesn't seem to be a valid CGI::Session driver. At least
>> one method ('store') is missing at
> finally solved
How did you discover the solution?
That is, where did you find that solution?
> by modify the session creation :
>
> $session = new CGI::Session ("driver:File", undef, {Directory =>
> 'C:/tmp' });
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sun, 29 May 2005 15:01:45 -0700
From: Westcoast Sheri <westshestcostsheastsheri@westshestcostsheastsher.com>
Subject: Re: newbie Perl question
Message-Id: <BEBF89D8.748D7%westshestcostsheastsheri@westshestcostsheastsher.com>
> Please put the subject of your post in the Subject of your post.
> Be aware that the subject you have used will be read by mant people as
> "Question I'm too lazy to figure out of myself. I'm too lazy to even
> bother working out how what my question actually is".
That is their (your) problem!
> What do you mean by "the LAST occurrence of each quotation mark"? Each
> quotation mark can onlt appear once.
"Onlt appear once," he says......
Shall we work on your SPELLING, or shall we work on those, "definitions."
Let's tackle definitions, first. I'll try to help you with that real
pickle-of-a-word, "last." Here, let me help. I'll use it in an example: "You
are the LAST person that should be answering this post, if you don't
understand the word, 'last.'"
> Do you mean repace a quotation mark if it is the last character in the
> string?
>
> s/"$/."/;
>
> Or do you mean replace the last quotation mark in the string?
>
> s/"(?=[^"]*$)/."/;
>
> or
>
> s/(.*)"/$1."/;
Why are you even bothering to "show off," with all kinds of,
"do-you-mean-this" examples? The previous poster answered my question
elegantly, in one simple line. Kudos to him, and a heartfelt thanks to him
for not asking me to explain that I spent hours, already, trying to find an
answer to my question.
The rest of your post merely takes up bandwidth. Particularly because my
question was already answered.
Perhaps YOU should read the guidelines.
Good day.
------------------------------
Date: Mon, 30 May 2005 00:29:47 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: newbie Perl question
Message-Id: <3fuu7jF8j3e4U1@individual.net>
Westcoast Sheri wrote:
>> Please put the subject of your post in the Subject of your post.
>> Be aware that the subject you have used will be read by mant people as
>> "Question I'm too lazy to figure out of myself. I'm too lazy to even
>> bother working out how what my question actually is".
>
> That is their (your) problem!
Now it's also your problem, because the most knowledgable people here
won't likely concern themselves with another question from you.
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Sun, 29 May 2005 15:38:39 -0700
From: Westcoast Sheri <westshestcostsheastsheri@westshestcostsheastsher.com>
Subject: Re: newbie Perl question
Message-Id: <BEBF927F.74A0D%westshestcostsheastsheri@westshestcostsheastsher.com>
Something tells me it took you a very long time to post that nugget of
wisdom....
> From: Gunnar Hjalmarsson <noreply@gunnar.cc>
> Newsgroups: comp.lang.perl.misc
> Date: Mon, 30 May 2005 00:29:47 +0200
> Subject: Re: newbie Perl question
>
> Westcoast Sheri wrote:
>>> Please put the subject of your post in the Subject of your post.
>>> Be aware that the subject you have used will be read by mant people as
>>> "Question I'm too lazy to figure out of myself. I'm too lazy to even
>>> bother working out how what my question actually is".
>>
>> That is their (your) problem!
>
> Now it's also your problem, because the most knowledgable people here
> won't likely concern themselves with another question from you.
>
> --
> Gunnar Hjalmarsson
> Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Sun, 29 May 2005 19:11:25 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: newbie Perl question
Message-Id: <slrnd9kmhd.em6.tadmc@magna.augustmail.com>
Westcoast Sheri <westshestcostsheastsheri@westshestcostsheastsher.com> wrote:
>> Please put the subject of your post in the Subject of your post.
>> Be aware that the subject you have used will be read by mant people as
>> "Question I'm too lazy to figure out of myself. I'm too lazy to even
>> bother working out how what my question actually is".
>
> That is their (your) problem!
It is no longer _my_ problem.
*plonk*
> Good day.
Yeah, right.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sun, 29 May 2005 18:39:57 -0700
From: Westcoast Sheri <westshestcostsheastsheri@westshestcostsheastsher.com>
Subject: Re: newbie Perl question
Message-Id: <BEBFBCFD.74C97%westshestcostsheastsheri@westshestcostsheastsher.com>
Would you repeat that, please?
> It is no longer _my_ problem.
>
> *plonk*
------------------------------
Date: Mon, 30 May 2005 04:02:48 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: newbie Perl question
Message-Id: <Xns966643BEEDEasu1cornelledu@127.0.0.1>
Westcoast Sheri <westshestcostsheastsheri@westshestcostsheastsher.com>
wrote in
news:BEBF89D8.748D7%
westshestcostsheastsheri@westshestcostsheastsher.com:
>> Please put the subject of your post in the Subject of your post.
>> Be aware that the subject you have used will be read by mant people
>> as "Question I'm too lazy to figure out of myself. I'm too lazy to
>> even bother working out how what my question actually is".
>
> That is their (your) problem!
It is your problem because, after seeing your response, people will be
unwilling to help you the next time you have a question.
>> What do you mean by "the LAST occurrence of each quotation mark"?
>> Each quotation mark can onlt appear once.
...
>> Do you mean repace a quotation mark if it is the last character in
>> the string?
>>
>> s/"$/."/;
>>
>> Or do you mean replace the last quotation mark in the string?
>>
>> s/"(?=[^"]*$)/."/;
>>
>> or
>>
>> s/(.*)"/$1."/;
>
> Why are you even bothering to "show off," with all kinds of,
That is not showing off. Brian was trying to help you learn how to frame
a question to make it easier for you to get the appropriate answers.
> "do-you-mean-this" examples? The previous poster answered my question
Who is the previous poster?
> The rest of your post merely takes up bandwidth. Particularly because
> my question was already answered.
>
> Perhaps YOU should read the guidelines.
*PLONK*
--
A. Sinan Unur <1usa@llenroc.ude.invalid>
(reverse each component and remove .invalid for email address)
comp.lang.perl.misc guidelines on the WWW:
http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html
------------------------------
Date: Sun, 29 May 2005 19:41:44 +0100
From: Brian McCauley <nobull@mail.com>
Subject: Re: Regex help: delete text only if not within quotation marks
Message-Id: <d7d2d9$d6t$1@slavica.ukpost.com>
Scott Bass wrote:
> "Scott Bass" <usenet739_yahoo_com_au> wrote in message
> news:4299ca7d$0$24291$5a62ac22@per-qv1-newsreader-01.iinet.net.au...
>
> [snip]
>
>
>>Quotes can appear as either:
>>
>>titles 'text "text" text'; ###
>>titles "text 'text' text"; ###
>>titles 'text ''text'' text';
>>titles "text ""text"" text";
>
>
> Sorry, these are also valid:
>
> titles 'text "unbalanced quotes';
> titles "text 'unbalanced quotes"; <<<
> titles 'text ''unbalanced quotes';
> titles "text ""unbalanced quotes";
Well coping with those isn't two hard - quoting quotes within quotes by
doubling is easy to parse.
The following replaces all occurances of 'target' with 'replace' except
where it appears inside a quoted string.
s/\G((?:[^"']*(["'])*[^\2]*\2)*[^"']*)target/${1}replace/g;
In another branch of this thread I'll now go think about your real /target/.
------------------------------
Date: Sun, 29 May 2005 20:05:00 +0100
From: Brian McCauley <nobull@mail.com>
Subject: Re: Regex help: delete text only if not within quotation marks
Message-Id: <d7d3os$db5$1@slavica.ukpost.com>
[ Please see my first follow-up (confusingly a bit further down this
thread) first ]
Scott Bass wrote:
> "Brian McCauley" <nobull@mail.com> wrote:
>
>> [...] you must first consider the implications of
>>quote characters appearing between the * and ;. In the above there can be
>>unbalanced quotes between * and ; and the ; is still seen as the end of
>>the comment. Is this right?
>
> Comments can be delimited by either /* */ or * ; and can either precede or
> follow the titles statements.
>
> Within the titles text, any comment delimiter (/* */ * ;) can appear as
> text, as well as unbalanced quotes.
Yes, but you didn't answer my question about quote characters inside
comments.
> '7titles "statement"; * Don\'t comment? ;',
> 'Etitles "statement"; /* Don\'t comment? */',
I'll assume from these examples the quote characters inside comments are
not treated as quotes.
Thus ignoring the small issue of ignoring comments within
quotes we have:
s/\/\*.*?\*\/|\*.*?;//g;
However if I join it all together...
s/\G((?:[^"']*(["'])*[^\2]*\2)*[^"']*)(?:\/\*.*?\*\/|\*.*?)/$1/g;
...it crashes the Perl compiler on this box (v5.8.4 built for
MSWin32-x86-multi-thread).
Oh well.
------------------------------
Date: 29 May 2005 21:36:25 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Regex help: delete text only if not within quotation marks
Message-Id: <d7dckp$8g2$1@mamenchi.zrz.TU-Berlin.DE>
Brian McCauley <nobull@mail.com> wrote in comp.lang.perl.misc:
[...]
> However if I join it all together...
>
> s/\G((?:[^"']*(["'])*[^\2]*\2)*[^"']*)(?:\/\*.*?\*\/|\*.*?)/$1/g;
>
> ...it crashes the Perl compiler on this box (v5.8.4 built for
> MSWin32-x86-multi-thread).
Same here (v5.8.6 built for darwin-2level). It doesn't segfault when the
second appearance of \2 is wrapped in a character class:
s/\G((?:[^"']*(["'])*[^\2]*[\2])*[^"']*)(?:\/\*.*?\*\/|\*.*?)/>$1</g;
That shouldn't change the semantics, but that's little comfort.
Anno
------------------------------
Date: Sun, 29 May 2005 20:07:28 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: regexp replace problem
Message-Id: <3fuf4tF9ko4tU1@individual.net>
Kasper wrote:
> I got a problem with regular expressions.
>
> My input data look like this :
>
> aaa,bbcc,bbdd,bbee
> aaa,bbcc,bbee,bbff,bbgg,bbhh
>
> (There could be many elements like (,[^,]*) in one line)
>
> I want to substitute every second and next element with first element.
> The result of presented lines should be :
>
> aaabbcc,aaabbdd,aaabbee
> aaabbcc,aaabbee,aaabbff,aaabbgg,aaabbhh
>
> It don't have to be one line substitution.
Besides the simple regex used with the split() function, I wouldn't use
regular expressions for this problem.
perldoc -f split
perldoc -f shift
perldoc -f map
perldoc -f join
> Please help - I have no idea how to do this and I tried almost everything.
Trying "almost everything", while having "no idea" how to do it, sounds
utterly stupid.
Please show us 10 or so of your attempts, and somebody may be able to
help you fix your best shot.
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Sun, 29 May 2005 20:16:58 +0200
From: Fabian Pilkowski <pilkowsk@informatik.uni-marburg.de>
Subject: Re: regexp replace problem
Message-Id: <3fuf82F9lf9jU1@individual.net>
* Kasper schrieb:
>
> My input data look like this :
>
> aaa,bbcc,bbdd,bbee
> aaa,bbcc,bbee,bbff,bbgg,bbhh
>
> I want to substitute every second and next element with first element.
> The result of presented lines should be :
>
> aaabbcc,aaabbdd,aaabbee
> aaabbcc,aaabbee,aaabbff,aaabbgg,aaabbhh
>
> It don't have to be one line substitution.
This should be easy if you do it that way you would do it in mind. Split
your string into an array, except the first element. Then put this first
one in front of each remaining element. That's all.
#!/usr/bin/perl -w
use strict;
while ( <DATA> ) {
my( $first, @a ) = split /,/;
print join ',', map $first.$_, @a;
}
__DATA__
aaa,bbcc,bbdd,bbee
aaa,bbcc,bbee,bbff,bbgg,bbhh
regards,
fabian
------------------------------
Date: Sun, 29 May 2005 13:19:11 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: regexp replace problem
Message-Id: <slrnd9k1sv.e3c.tadmc@magna.augustmail.com>
Kasper <kcecek@gmail.com> wrote:
> I got a problem with regular expressions.
No you don't.
Surely you can understand the /,/ regex, and that is all that is needed.
> My input data look like this :
>
> aaa,bbcc,bbdd,bbee
> aaa,bbcc,bbee,bbff,bbgg,bbhh
> I want to substitute every second and next element with first element.
"second and next" means the same thing as "second and third".
You must have meant "second and subsequent" or some such?
> The result of presented lines should be :
>
> aaabbcc,aaabbdd,aaabbee
> aaabbcc,aaabbee,aaabbff,aaabbgg,aaabbhh
-------------------
#!/usr/bin/perl
use warnings;
use strict;
foreach ( 'aaa,bbcc,bbdd,bbee', 'aaa,bbcc,bbee,bbff,bbgg,bbhh' ) {
my($prefix, @parts) = split /,/;
print join( ',', map $prefix . $_, @parts), "\n";
}
-------------------
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Mon, 30 May 2005 04:57:06 +0200
From: Alexandre Jaquet <alexj@freesurf.ch>
Subject: Session retrieving data
Message-Id: <429a8104$0$1147$5402220f@news.sunrise.ch>
Hi,
I currently 've a trouble when I try to read stored session data.
The $session->param("user_name") return an error can't call method param
on an undefined value
Any idea ?
here is my code :
#!perl -w
use CGI qw(:standard);
use Switch;
use Digest::MD5 qw(md5_hex);
use CGI::Session qw/-ip-match/;
my $query ;
execute ();
sub execute {
$query = new CGI ;
my $action = $query->param('action');
if ($action) {
switch ($action) {
case "login" {
login();
};
case "test" {
test();
};
}
}
}
sub login {
$session = new CGI::Session ("driver:File", undef, {Directory =>
'C:/sessions' }) if (!$session);
$session->param("user_name2", "alexj");
print "Content-type: text/html\n\n";
}
sub test {
my $test = $session->param("user_name2");
print "Content-type: text/html\n\n";
print "$test";
}
------------------------------
Date: Mon, 30 May 2005 05:19:30 +0200
From: Alexandre Jaquet <alexj@freesurf.ch>
Subject: Re: Session retrieving data
Message-Id: <429a8643$0$1159$5402220f@news.sunrise.ch>
Alexandre Jaquet a écrit :
> Hi,
>
> I currently 've a trouble when I try to read stored session data.
>
> The $session->param("user_name") return an error can't call method param
> on an undefined value
>
> Any idea ?
>
> here is my code :
>
> #!perl -w
> use CGI qw(:standard);
> use Switch;
> use Digest::MD5 qw(md5_hex);
> use CGI::Session qw/-ip-match/;
>
>
> my $query ;
>
>
> execute ();
>
>
> sub execute {
> $query = new CGI ;
> my $action = $query->param('action');
> if ($action) {
> switch ($action) {
> case "login" {
> login();
> };
> case "test" {
> test();
> };
> }
> }
> }
>
> sub login {
> $session = new CGI::Session ("driver:File", undef, {Directory =>
> 'C:/sessions' }) if (!$session);
> $session->param("user_name2", "alexj");
> print "Content-type: text/html\n\n";
> }
>
>
> sub test {
> my $test = $session->param("user_name2");
> print "Content-type: text/html\n\n";
> print "$test";
> }
finally I' do in test function a file open and then get stored values,
but I'm not sure if it's the best method
------------------------------
Date: Mon, 30 May 2005 06:00:06 +0200
From: Alexandre Jaquet <alexj@freesurf.ch>
Subject: Re: Session retrieving data
Message-Id: <429a8fc8$0$1156$5402220f@news.sunrise.ch>
Alexandre Jaquet a écrit :
> Alexandre Jaquet a écrit :
>
>> Hi,
>>
>> I currently 've a trouble when I try to read stored session data.
>>
>> The $session->param("user_name") return an error can't call method
>> param on an undefined value
>>
>> Any idea ?
>>
>> here is my code :
>>
>> #!perl -w
>> use CGI qw(:standard);
>> use Switch;
>> use Digest::MD5 qw(md5_hex);
>> use CGI::Session qw/-ip-match/;
>>
>>
>> my $query ;
>>
>>
>> execute ();
>>
>>
>> sub execute {
>> $query = new CGI ;
>> my $action = $query->param('action');
>> if ($action) {
>> switch ($action) {
>> case "login" {
>> login();
>> };
>> case "test" {
>> test();
>> };
>> }
>> }
>> }
>>
>> sub login {
>> $session = new CGI::Session ("driver:File", undef, {Directory =>
>> 'C:/sessions' }) if (!$session);
>> $session->param("user_name2", "alexj");
>> print "Content-type: text/html\n\n";
>> }
>>
>>
>> sub test {
>> my $test = $session->param("user_name2");
>> print "Content-type: text/html\n\n";
>> print "$test";
>> }
>
>
> finally I' do in test function a file open and then get stored values,
> but I'm not sure if it's the best method
>
another question is when I want to use MySQL for storing session datas
how can do to save my data's I was thinking we can use
$SESSION->param(-name=>'user_name', -value=>$username);
doe's I've to write a complete sql query to store my values ?
sub login {
#more code here
if ($user_name && $user_password) {
$CGI::Session::MySQL::TABLE_NAME = 'session';
my $SESSION = new CGI::Session(
"driver:MySQL",
$query,
{
DataSource=>"DBI:mysql:recordz:localhost",
User=>"alexj",
Password=>"xxx"
}
);
$SESSION->param(-name=>'user_name', -value=>$username);
#more code here
}
thanks :)
------------------------------
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.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
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 8127
***************************************