[23367] in Perl-Users-Digest
Perl-Users Digest, Issue: 5586 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Sep 29 14:15:49 2003
Date: Mon, 29 Sep 2003 11:15:16 -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 Mon, 29 Sep 2003 Volume: 10 Number: 5586
Today's topics:
Re: dim <ddunham@redwood.taos.com>
Re: Hiding PERL code <derek@hiredgoons.org>
Re: Hiding PERL code <ak+usenet@freeshell.org>
Re: How exactly do I build %INC keys? (Tad McClellan)
Re: How exactly do I build %INC keys? <scriptyrich@yahoo.co.uk>
Re: How exactly do I build %INC keys? (Rafael Garcia-Suarez)
Re: LWP::Simple get() refined problem <Hon.Lee@Sun.COM>
Re: Max Memory in Perl and How to reuse gabage? (Chris Richmond - MD6-FDC ~)
Re: New FAQ: How do I compute the difference of two arr <usenet@dwall.fastmail.fm>
Re: newbie very basic question (Tad McClellan)
Problem in Set/Get Cookie (Sucpraran)
Re: Problem in Set/Get Cookie <noreply@gunnar.cc>
Re: Problem in Set/Get Cookie <tore@aursand.no>
reg exp help <david@wmol.com>
Re: reg exp help <noreply@gunnar.cc>
Re: reg exp help <ak+usenet@freeshell.org>
Re: reg exp help (Tad McClellan)
Re: reg exp help <noreply@gunnar.cc>
Re: reg exp help <ak+usenet@freeshell.org>
Re: reg exp help <syscjm@gwu.edu>
Re: reg exp help <abigail@abigail.nl>
Re: reg exp help <noreply@gunnar.cc>
Re: reg exp help <abigail@abigail.nl>
Re: sort problem (Greg Bacon)
strip newlines in TD cell ? (Richard A. DeVenezia)
Re: strip newlines in TD cell ? <jurgenex@hotmail.com>
Re: <bwalton@rochester.rr.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 29 Sep 2003 17:16:35 GMT
From: Darren Dunham <ddunham@redwood.taos.com>
Subject: Re: dim
Message-Id: <TNZdb.78$hB5.15667312@newssvr13.news.prodigy.com>
"Jürgen Exner" <jurgenex@hotmail.com> wrote:
>> I'm not sure, but I suspect it'd be faster to do:
>>
>> my $pat = join '|', @greplist; # at top of program
>> push @all, $_ if /$pat/i; # within file loop
> Not sure, maybe. You are trading the loop for a more complex RE.
> Now the RE engine itself must iterate over the alternatives. I don't know if
> this will be significantly faster.
But the RE runs in C, and the foreach loop runs in perlops. For larger
numbers I expect running an op tree to take more time.
> Would be interesting to run some benchmarks.
Yes indeedy!
--
Darren Dunham ddunham@taos.com
Unix System Administrator Taos - The SysAdmin Company
Got some Dr Pepper? San Francisco, CA bay area
< This line left intentionally blank to confuse you. >
------------------------------
Date: Tue, 30 Sep 2003 00:15:40 +1000
From: Derek Thomson <derek@hiredgoons.org>
Subject: Re: Hiding PERL code
Message-Id: <3f783e96$1@duster.adelaide.on.net>
Andreas Kahari wrote:
> In article <vnfviscbpo6jf1@corp.supernews.com>, David Oswald wrote:
>
>>"Forte Agent" <1443131@usenetplanet.com> wrote in message
>>news:754fnv0g3l4ndnjck564kain08om76ineb@4ax.com...
>>
>>>Is there some way to hide PERL source code (maybe
>>>encrypting/obfuscating it), so that you can distribute it without
>>>revealing source code? Thank you in advance.
>>
>>Who would want it? ;)
>
>
> I was once working for a company that didn't want to thow its
> "IP" around too much. Compiled Perl scripts was the only way to
> distribute Perl programs to the outside of the company.
>
> I'm not there anymore.
>
Okay, I'll bite.
How was it done? I'm pretty certain it's going to be easy to break,
given that "perl -MO=Deparse <file>" does a damned fine job of
decompiling anything that can be actually executed in Perl. Try it on
something Acme::Bleach-ed or Acme::EyeDrop-ed and see for yourself.
Regards,
Derek.
------------------------------
Date: Mon, 29 Sep 2003 14:39:28 +0000 (UTC)
From: Andreas Kahari <ak+usenet@freeshell.org>
Subject: Re: Hiding PERL code
Message-Id: <slrnbngh0s.1cv.ak+usenet@vinland.freeshell.org>
In article <3f783e96$1@duster.adelaide.on.net>, Derek Thomson wrote:
> Andreas Kahari wrote:
[cut]
>> I was once working for a company that didn't want to thow its
>> "IP" around too much. Compiled Perl scripts was the only way to
>> distribute Perl programs to the outside of the company.
[cut]
> How was it done? I'm pretty certain it's going to be easy to break,
> given that "perl -MO=Deparse <file>" does a damned fine job of
> decompiling anything that can be actually executed in Perl. Try it on
> something Acme::Bleach-ed or Acme::EyeDrop-ed and see for yourself.
Some Windows perl distribution + perl2exe. I haven't tried the
Acme::* stuff, and fortunately I don't have to.
--
Andreas Kähäri
------------------------------
Date: Mon, 29 Sep 2003 08:07:04 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: How exactly do I build %INC keys?
Message-Id: <slrnbngbjo.l74.tadmc@magna.augustmail.com>
Rich <scriptyrich@yahoo.co.uk> wrote:
> I know Win32 perl allows '/' as well as '\' directory separators,
It is not "Win32 perl" that allows / as the directory separator,
it is the Windows OS itself that allows that.
Only the command interpreter requires the use of backslash
(because forward slash is already used for something else, switches).
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Mon, 29 Sep 2003 14:41:13 +0100
From: Rich <scriptyrich@yahoo.co.uk>
Subject: Re: How exactly do I build %INC keys?
Message-Id: <bl9cik$nro$1@newsg4.svr.pol.co.uk>
Tad McClellan wrote:
> Rich <scriptyrich@yahoo.co.uk> wrote:
>
>> I know Win32 perl allows '/' as well as '\' directory separators,
>
>
> It is not "Win32 perl" that allows / as the directory separator,
> it is the Windows OS itself that allows that.
>
> Only the command interpreter requires the use of backslash
> (because forward slash is already used for something else, switches).
>
Ok, thanks for correcting my misunderstanding there.
As the point of my initial post wasn't terribly clear, here's a beter
version:
If I want to check that Data::Dumper (for example) has been used, will:
$INC{"Data/Dumper.pm"}
Work on all platforms, not just on the platforms I've tested on (Linux and
Win32)?
Thanks,
--
Rich
scriptyrich@yahoo.co.uk
------------------------------
Date: 29 Sep 2003 17:02:07 GMT
From: rgarciasuarez@free.fr (Rafael Garcia-Suarez)
Subject: Re: How exactly do I build %INC keys?
Message-Id: <slrnbngp1j.37m.rgarciasuarez@rafael.serd.lyon.hexaflux.loc>
Rich wrote:
>As the point of my initial post wasn't terribly clear, here's a beter
>version:
>
>If I want to check that Data::Dumper (for example) has been used, will:
>
> $INC{"Data/Dumper.pm"}
>
>Work on all platforms, not just on the platforms I've tested on (Linux and
>Win32)?
This is not a 100% reliable way to check whether a module has been
loaded, because if you do
require "../lib/Data/Dumper.pm";
you'll end up with $INC{"../lib/Data/Dumper.pm"} set.
(in fact perl bypasses @INC searching when the require'd filename
is absolute or begins with ./ or ../).
Moreover an @INC hook may fiddle with %INC entries as it wants.
But, to answer your original question : yes, file names in %INC are
normalized to use forward slashes.
Usually you don't have to worry about this, what's your actual problem ?
--
Uncontrollable is not *NIX
------------------------------
Date: Mon, 29 Sep 2003 18:21:01 +0100
From: Hon Guin Lee - Web Producer - SMI Marketing <Hon.Lee@Sun.COM>
Subject: Re: LWP::Simple get() refined problem
Message-Id: <3F7869FD.EF8F485@Sun.COM>
Dominik Seelow wrote:
>
> Hon Guin Lee - Web Producer - SMI Marketing wrote:
>
> > Hi all,
> >
> > The LWP::get() function manages to retrieve some of the localised web document content from local web servers displayed on my web browser using Mozilla 1.1, for URL's without the www.
> > However for URLs that begin with www, the get() functon just returns an undef (shown in subroutine get_url) hence the web browser unables to display the web content.
> >
> > To narrow the problem further, I used some of the other functions such as getstore(url,file) and mirror(url,file) where I replace url with shift, and a filename specified, but the LWP::Debug just throws up: -
> >
> > --------------------------------------------------------------------------
> >
> > LWP::UserAgent::new: () LWP::UserAgent::request: () LWP::UserAgent::send_request: GET http://sunweb.central.sun.com LWP::UserAgent::_need_proxy: Not proxied LWP::Protocol::http::request: () LWP::UserAgent::request: Simple response: Found LWP::UserAgent::request: () LWP::UserAgent::send_request: GET http://sunweb.central.sun.com/redirect.jsp LWP::UserAgent::_need_proxy: Not proxied LWP::Protocol::http::request: () LWP::Protocol::collect: read 57 bytes LWP::UserAgent::request: Simple response:
> > Found LWP::UserAgent::request: () LWP::UserAgent::send_request: GET http://sunweb.central.sun.com/location.jsp LWP::UserAgent::_need_proxy: Not proxied LWP::Protocol::http::request: () LWP::Protocol::collect: read 19 bytes LWP::UserAgent::request: Simple response: Found LWP::UserAgent::request: () LWP::UserAgent::send_request: GET http://sunweb.central.sun.com/redirect.jsp?location=Non-US LWP::UserAgent::_need_proxy: Not proxied LWP::Protocol::http::request: () LWP::Protocol::collect: read 57
> > bytes LWP::UserAgent::request: Simple response: Found LWP::UserAgent::request: () LWP::UserAgent::send_request: GET http://sunweb.central.sun.com/cachedir/cachedtab_Non-US_NEWS.html LWP::UserAgent::_need_proxy: Not proxied LWP::Protocol::http::request: () LWP::UserAgent::request: Simple response: Internal Server Error 500
> >
> > --This is a URL specifed for the local web server requesting some form of proxy.
> >
> > --------------------------------------------------------------------------
> >
> > LWP::UserAgent::new: () LWP::UserAgent::request: () LWP::UserAgent::send_request: GET http://www.sun.com LWP::UserAgent::_need_proxy: Not proxied LWP::Protocol::http::request: () LWP::UserAgent::request: Simple response: Internal Server Error 500
> >
> > --This is a URL specified for a www web docuument.
> >
> > --------------------------------------------------------------------------
> >
> > Any solutions/reasons why the get() function cannot retrieve unlocalised web content?
> >
> > Here is the script: -
> >
> > --------------------------------------------------------------------------
> >
> > #!/usr/local/perl5.6/bin/perl -wT
> >
> > # perl script to get remote
> > # urls and strip them and
> > # upload them to teamsite
> >
> > use LWP::Simple qw(!head);
> > use LWP::Debug '+';
> > use CGI qw(:standard); # then only CGI.pm defines a head()
> > use strict;
> >
> > print "Content-type: text/html\n\n";
> >
> > my $old_handle;
> >
> > $|++; #sets $| for STDOUT
> > $old_handle = select( STDERR ); #change to STDERR
> > $|++; #sets $| for STDERR
> > select( $old_handle ); #change back to STDOUT
> >
> > my ($url) = @_;
> > my $lang;
> >
> > process_form();
> > get_url($url);
> >
> > # Passes the data from the server,
> > # and takes them onto the PERL script.
> >
> > sub process_form {
> >
> > $url = param('url');
> > $url = "http://$url";
> > $lang = param('lang');
> >
> > }
> >
> > # Retrieves the contents of the
> > # specified URL.
> >
> > sub get_url {
> >
> > my $page = get(shift);
> >
> > unless (defined $page) {
> > print "Couldn't retrieve $url";
> > }
> > else {
> > print "$page\n";
> > }
> >
> > }
> > --------------------------------------------------------------------------
>
> Do you use a proxy to display web content from outside when using your
> browser?
>
> perldoc LWP says:
> ENVIRONMENT
> The following environment variables are used by LWP:
> <snip>
> http_proxy
> ftp_proxy
> xxx_proxy
> no_proxy
> These environment variables can be set to enable communication
> through a proxy server. See the description of the "env_proxy"
> method in LWP::UserAgent.
>
> It /might/ help to specify a proxy server.
>
> Good luck,
> Dominik
I have used a proxy server, usin the LWP::UserAgent module, from the new script as shown below: -
------------------------------------------------------------------------
#!/usr/local/perl5.6/bin/perl -wT
use LWP::UserAgent;
use LWP::Debug '+';
use CGI ':standard';
use strict;
print "Content-type: text/html\n\n";
my $content;
my $ua = new LWP::UserAgent;
my $old_handle;
my $url = param('url');
my $lang = param('lang');
$|++; #sets $| for STDOUT
$old_handle = select( STDERR ); #change to STDERR
$|++; #sets $| for STDERR
select( $old_handle ); #change back to STDOUT
$ua->proxy(['http','https','ftp'], 'file:///usr/dist/share/proxy_config/uk.pac'); # set proxy
$ua->env_proxy(); # load proxy info from environment variables
$ua->agent("Mozilla/1.1");
my $req = new HTTP::Request GET => $url;
my $res = $ua->request($req);
if ($res->is_success)
{
$content= $res->content;
}
else
{
die "Could not get content";
}
----------------------------------------------------------------------
The following error messages were shown: -
LWP::UserAgent::proxy: ARRAY(0x2d5e60) file:///usr/dist/share/proxy_config/uk.pac LWP::UserAgent::proxy: http file:///usr/dist/share/proxy_config/uk.pac
LWP::UserAgent::proxy: https file:///usr/dist/share/proxy_config/uk.pac LWP::UserAgent::proxy: ftp file:///usr/dist/share/proxy_config/uk.pac LWP::UserAgent::request: ()
LWP::UserAgent::request: Simple response: Bad Request Could not get content at /export/home/sdltool/www/cgi-bin/automation1-2.cgi line 40.
----------------------------------------------------------------------
------------------------------
Date: Mon, 29 Sep 2003 17:43:00 +0000 (UTC)
From: crichmon@filc8533.fm.intel.com (Chris Richmond - MD6-FDC ~)
Subject: Re: Max Memory in Perl and How to reuse gabage?
Message-Id: <bl9qv4$2h9$1@news01.intel.com>
In article <uFBdb.23175$ZR1.14953@nwrddc01.gnilink.net>,
"Jürgen Exner" <jurgenex@hotmail.com> writes:
>The maximum size of a Perl array is limited by the available amount of
>virtual memory and maximum index size. Depending on your OS, 32 versus 64
>bit, and your version of Perl that should be somewhere in the GB or TB
>range.
I will contend that this isn't necessarily true. At least on
Solaris, we had to make a special effort to enable more than a
1GB process size. The same application on AIX keeled over when
that limit was hit. Same thing on linux when I tried.
>Only limited by your virtual memory and the 32 resp. 64 bit index boundary.
Are you positive? We were using perl5.00404 at the time.
What actual perl process sizes have you dealt with?
Thx, Chris
--
Chris Richmond | I don't speak for Intel & vise versa
------------------------------
Date: Mon, 29 Sep 2003 14:20:19 -0000
From: "David K. Wall" <usenet@dwall.fastmail.fm>
Subject: Re: New FAQ: How do I compute the difference of two arrays?
Message-Id: <Xns9405692B6716Fdkwwashere@216.168.3.30>
Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> wrote:
> Gregory Toomey <nospam@bigpond.com> wrote in comp.lang.perl.misc:
>> It was a dark and stormy night, and Randal L. Schwartz managed to
>> scribble:
>>
>> >>>>>> "The" == The Poor <a@job.mx.2y.net> writes:
>> >
>> > The> -
>> > The> New:
>> > The> +
>> > The> How do I compute the difference of two arrays? How do I
>> > compute the The> intersection of two arrays?
>> >
>> > The> Use a hash. Here's code to do both and more. It
>> > assumes that each The> element is unique in a given array:
>> >
>> > Here's code that doesn't require that uniqueness, and would be
>> > a better candidate for the FAQ:
>> >
>> > my %tally;
>> > $tally{$_} .= "a" for @array_a;
>> > $tally{$_} .= "b" for @array_b;
>> > my @union = keys %tally;
>> > my @intersection = grep $tally{$_} =~ /ab/, @union;
>> > my @a_not_b = grep $tally{$_} =~ /a$/, @union;
>> > my @b_not_a = grep $tally{$_} =~ /^b/, @union;
>> >
>> > print "Just another Perl hacker,";
>>
>> Having coded this problem myself, your solution is minimal & very
>> elegant (as expected).
>
> ...a variation on the theme:
>
> my %tally;
> $tally{$_} += 1 for @array_a; # or |=
> $tally{$_} += 2 for @array_b;
> # use more powers of two for more arrays
> my @union = keys %tally;
> my @intersection = grep $tally{$_} == 3, @union;
This assumes there are no duplicated values in either array, right?
> my $a_not_b = grep $tally{$_} == 1, @union;
I think you mean @a_not_b.
> my $b_not_a = grep $tally{$_} == 2, @union;
^
> # etc.
Randal's solution allowed for non-unique values in @array_a and
@array_b. The above doesn't produce correct results for, say,
my @array_a = qw(a a a y z);
my @array_b = qw(b b b x y z);
Adding a third array:
my @array_c = qw(c c c x z);
my %tally;
$tally{$_} .= "a" for @array_a;
$tally{$_} .= "b" for @array_b;
$tally{$_} .= "c" for @array_c;
my @union = keys %tally;
my @intersection = grep $tally{$_} =~ /a+b+c/, @union;
my @a_only = grep $tally{$_} =~ /^a+$/, @union;
my @b_only = grep $tally{$_} =~ /^b+$/, @union;
my @c_only = grep $tally{$_} =~ /^c+$/, @union;
my @a_and_b = grep $tally{$_} =~ /a+b/, @union;
my @a_b_not_c = grep $tally{$_} =~ /a+b+(?!c)/, @union;
------------------------------
Date: Mon, 29 Sep 2003 08:17:05 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: newbie very basic question
Message-Id: <slrnbngc6h.l74.tadmc@magna.augustmail.com>
fabre <pedro.fabre.NO-SPAM@gen.gu.se> wrote:
> I was reading perldoc perlref
There is nothing relating to references in your code nor in your question.
> sub newprint {
> my $x = shift;
> they must
> me taken in shift, but the function of shift
And you know this because you read the documentation for shift(), right?
> is remove the first element
> from a list and pass this value out as return, but there is no list.
> Someone can explain this to me?
The documentation for the function you are using seems to do that:
perldoc -f shift
... If ARRAY is omitted, shifts the @_ array within the
lexical scope of subroutines ...
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 29 Sep 2003 06:57:39 -0700
From: sucpraran@yahoo.com (Sucpraran)
Subject: Problem in Set/Get Cookie
Message-Id: <938f9bf4.0309290557.d76bea@posting.google.com>
Hello:
Below is the Perl/JavaScript code to set and get a cookie in our
applicaion. The problem we are facing is, it works 90% but rest of the
10% we get nothing in getCookie. The browser is set up to accept
cookies(we are 100% that the browser settings are OK). We have users
across the country and we could not find a pattern with browser
type/versions or OS type/versions. In addition sometimes the same user
could login from different PC/Desktop but not from that desktop.
We do not have a clue on what could be wrong. Any suggestions?.
Thanks
<Begin: Perl Code to Set/Get Cookie Cookie Name: CSSession>
sub setCookie
{
my $name = $_[0] ;
my $value = $_[1] ;
my $Time = $_[2] ;
my %MonthNames = (1=>"Jan", 2=>"Feb", 3=>"Mar", 4=>"Apr", 5=>"May",
6=>"Jun", 7=>"Jul", 8=>"Aug", 9=>"Sep", 10=>"Oct", 11=>"Nov",
12=>"Dec") ;
my %Wdays = (0=>"Sunday", 1=>"Monday", 2=>"Tuesday",
3=>"Wednesday", 4=>"Thursday", 5=>"Friday", 6=>"Saturday") ;
my $secure = " secure" ;
my $seconds = time() + ($Time*60) ;
my @GMtime = gmtime($seconds) ;
my $Cyear = $GMtime[5] + 1900 ;
my $Cmonth = $GMtime[4] + 1 ;
my $expiration = sprintf("$Wdays{$GMtime[6]},
%02d-$MonthNames{$Cmonth}-%02d %02d:%02d:%02d GMT", $GMtime[3],
$Cyear, $GMtime[2], $GMtime[1], $GMtime[0]) ;
my $path = "" ;
my $domain = "" ;
my $cookiestr = "Set-Cookie: $name=$value; expires=$expiration" ;
return "$cookiestr" ;
}
sub getCookie
{
my ($GlobalPtr) = @_ ;
my (@rawCookies) = split (/; /,$ENV{'HTTP_COOKIE'});
$GlobalPtr->{'INCOOKIE'} = $ENV{'HTTP_COOKIE'} ;
foreach(@rawCookies)
{
($key, $val) = split (/=/,$_);
$GlobalPtr->{$key} = $val;
}
}
<End: Perl Code to Set/Get Cookie>
<JavaScript function to verify the cookie properties of browser>
<script language="JavaScript1.3">
<!--
function GetSessionID (name) {
var arg = name + "=";
var alen = arg.length;
var clen = document.cookie.length;
var i = 0;
while (i < clen)
{
var j = i + alen;
if (document.cookie.substring(i, j) == arg)
return getSessionVal (j);
i = document.cookie.indexOf(" ", i) + 1;
if (i == 0) break;
}
return null;
}
function getSessionVal (offset) {
var endstr = document.cookie.indexOf (";", offset);
if (endstr == -1)
endstr = document.cookie.length;
return unescape(document.cookie.substring(offset, endstr));
}
function focusAt(formname, felement){
window.document.forms[formname].elements[felement].focus();
}
function CheckSettings() {
var agt = navigator.userAgent.toLowerCase();
var appname = navigator.appName.toLowerCase() ;
var is_major = parseInt(navigator.appVersion);
var is_minor = parseFloat(navigator.appVersion);
var SessionID = GetSessionID('CSSession') ;
var clen = 0 ;
__redirectflag__
if(SessionID != null) {
clen = SessionID.length ;
document.LOGINFORM.userID.focus();
}
else {
if(RedirectFlag == 0) {
document.location.href="__nocookieurl__" ;
}
}
}
//-->
</script>
------------------------------
Date: Mon, 29 Sep 2003 16:37:22 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Problem in Set/Get Cookie
Message-Id: <bl9g2h$9do5f$1@ID-184292.news.uni-berlin.de>
Sucpraran wrote:
> Below is the Perl/JavaScript code to set and get a cookie in our
> applicaion. The problem we are facing is, it works 90% but rest of
> the 10% we get nothing in getCookie. The browser is set up to
> accept cookies(we are 100% that the browser settings are OK). We
> have users across the country and we could not find a pattern with
> browser type/versions or OS type/versions. In addition sometimes
> the same user could login from different PC/Desktop but not from
> that desktop.
>
> We do not have a clue on what could be wrong. Any suggestions?.
Well, the best suggestion would be that you ask for help in a suitable
newsgroup. clpmisc is for discussing Perl. ;-)
Anyway, you may want to try 'Sun' instead of 'Sunday', 'Mon' instead
of 'Monday', etc. as the values in %Wdays.
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Mon, 29 Sep 2003 19:02:11 +0200
From: Tore Aursand <tore@aursand.no>
Subject: Re: Problem in Set/Get Cookie
Message-Id: <pan.2003.09.29.15.31.46.195676@aursand.no>
On Mon, 29 Sep 2003 06:57:39 -0700, Sucpraran wrote:
> Below is the Perl/JavaScript code to set and get a cookie in our
> applicaion.
First of all: Use CGI.pm do to the shitty job of getting/setting the
cookie. It's very simple:
## Get
my $cookie_value = $cgi->cookie( 'cookie_name' );
## Set
my $cookie_value = 'foobar'; # Usually some random string
my $cookie = $cgi->cookie(-name => 'cookie_name',
-value => $cookie_value,
-expires => '+15m');
print $cgi->header(-cookie => $cookie );
Lookup 'perldoc CGI' for more information.
--
Tore Aursand <tore@aursand.no>
------------------------------
Date: Mon, 29 Sep 2003 11:18:30 -0400
From: "David Hill" <david@wmol.com>
Subject: reg exp help
Message-Id: <vngj0qmv76mv83@corp.supernews.com>
Hello -
I am trying to come up with a reg exp to fi tthe following criteria.
1.) can NOT be all digits
2.) can only contain A-Za-z0-9 _ and -
/[A-Za-z0-9_\-]/ is this correct? i dont think its satisfying the #1
criteria.
- David
------------------------------
Date: Mon, 29 Sep 2003 17:21:06 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: reg exp help
Message-Id: <bl9iki$9f6mm$1@ID-184292.news.uni-berlin.de>
David Hill wrote:
> I am trying to come up with a reg exp to fi tthe following criteria.
>
> 1.) can NOT be all digits
> 2.) can only contain A-Za-z0-9 _ and -
>
> /[A-Za-z0-9_\-]/ is this correct? i dont think its satisfying the #1
> criteria.
Think? What happened when you tried it??
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Mon, 29 Sep 2003 15:20:57 +0000 (UTC)
From: Andreas Kahari <ak+usenet@freeshell.org>
Subject: Re: reg exp help
Message-Id: <slrnbngjel.1cv.ak+usenet@vinland.freeshell.org>
In article <vngj0qmv76mv83@corp.supernews.com>, David Hill wrote:
> Hello -
> I am trying to come up with a reg exp to fi tthe following criteria.
>
> 1.) can NOT be all digits
> 2.) can only contain A-Za-z0-9 _ and -
>
> /[A-Za-z0-9_\-]/ is this correct? i dont think its satisfying the #1
> criteria.
No, it doesn't. It still matches any integer.
Try this instead:
/[A-Za-z_0-9-]*[A-Za-z_-][A-Za-z_0-9-]*/
Which means "a valid character, flanked by zero or more valid
characters or digits on either side".
--
Andreas Kähäri
------------------------------
Date: Mon, 29 Sep 2003 10:30:37 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: reg exp help
Message-Id: <slrnbngk0t.lhi.tadmc@magna.augustmail.com>
David Hill <david@wmol.com> wrote:
> I am trying to come up with a reg exp to fi tthe following criteria.
>
> 1.) can NOT be all digits
> 2.) can only contain A-Za-z0-9 _ and -
untested:
/^[\w-]+$/ && /\D/
or
/^[\w-]*[a-zA-Z_-][\w-]*$/
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Mon, 29 Sep 2003 17:40:51 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: reg exp help
Message-Id: <bl9jpj$9gc54$1@ID-184292.news.uni-berlin.de>
Andreas Kahari wrote:
> In article <vngj0qmv76mv83@corp.supernews.com>, David Hill wrote:
>> I am trying to come up with a reg exp to fi tthe following
>> criteria.
>>
>> 1.) can NOT be all digits 2.) can only contain A-Za-z0-9 _ and -
>>
>> /[A-Za-z0-9_\-]/ is this correct? i dont think its satisfying
>> the #1 criteria.
>
> No, it doesn't. It still matches any integer.
>
> Try this instead:
>
> /[A-Za-z_0-9-]*[A-Za-z_-][A-Za-z_0-9-]*/
>
> Which means "a valid character, flanked by zero or more valid
> characters or digits on either side".
Actually, that matches the same strings as
/[A-Za-z_-]/
and does not preclude the existence of other characters.
How about two regexes, one for each criteria:
/^[-\w]+$/ && /[a-zA-Z_-]/
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Mon, 29 Sep 2003 15:44:57 +0000 (UTC)
From: Andreas Kahari <ak+usenet@freeshell.org>
Subject: Re: reg exp help
Message-Id: <slrnbngkrl.1cv.ak+usenet@vinland.freeshell.org>
In article <bl9jpj$9gc54$1@ID-184292.news.uni-berlin.de>, Gunnar Hjalmarsson wrote:
[cut]
> Actually, that matches the same strings as
>
> /[A-Za-z_-]/
Bummer. What if you anchor it in both ends?
> How about two regexes, one for each criteria:
>
> /^[-\w]+$/ && /[a-zA-Z_-]/
Yeah, that's a good approach.
--
Andreas Kähäri
------------------------------
Date: Mon, 29 Sep 2003 12:01:46 -0400
From: Chris Mattern <syscjm@gwu.edu>
Subject: Re: reg exp help
Message-Id: <3F78576A.8080904@gwu.edu>
Gunnar Hjalmarsson wrote:
> Andreas Kahari wrote:
>
>> In article <vngj0qmv76mv83@corp.supernews.com>, David Hill wrote:
>>
>>> I am trying to come up with a reg exp to fi tthe following
>>> criteria.
>>>
>>> 1.) can NOT be all digits 2.) can only contain A-Za-z0-9 _ and -
>>>
>>> /[A-Za-z0-9_\-]/ is this correct? i dont think its satisfying
>>> the #1 criteria.
>>
>>
>> No, it doesn't. It still matches any integer.
>>
>> Try this instead:
>>
>> /[A-Za-z_0-9-]*[A-Za-z_-][A-Za-z_0-9-]*/
>>
>> Which means "a valid character, flanked by zero or more valid
>> characters or digits on either side".
>
>
> Actually, that matches the same strings as
>
> /[A-Za-z_-]/
>
> and does not preclude the existence of other characters.
>
> How about two regexes, one for each criteria:
>
> /^[-\w]+$/ && /[a-zA-Z_-]/
>
How about simply specifying that the entire string must
meet the restriction: /^[A-Za-z_0-9-]*[A-Za-z_-][A-Za-z_0-9-]*$/
Chris Mattern
------------------------------
Date: 29 Sep 2003 16:10:44 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: reg exp help
Message-Id: <slrnbngmc4.knq.abigail@alexandra.abigail.nl>
David Hill (david@wmol.com) wrote on MMMDCLXXXI September MCMXCIII in
<URL:news:vngj0qmv76mv83@corp.supernews.com>:
[] Hello -
[] I am trying to come up with a reg exp to fi tthe following criteria.
[]
[] 1.) can NOT be all digits
[] 2.) can only contain A-Za-z0-9 _ and -
[]
[] /[A-Za-z0-9_\-]/ is this correct? i dont think its satisfying the #1
[] criteria.
/^(?=.*\D)[-\w]+$/
Abigail
--
split // => '"';
${"@_"} = "/"; split // => eval join "+" => 1 .. 7;
*{"@_"} = sub {foreach (sort keys %_) {print "$_ $_{$_} "}};
%{"@_"} = %_ = (Just => another => Perl => Hacker); &{%{%_}};
------------------------------
Date: Mon, 29 Sep 2003 18:11:02 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: reg exp help
Message-Id: <bl9li6$9i1q2$1@ID-184292.news.uni-berlin.de>
Andreas Kahari wrote:
> Gunnar Hjalmarsson wrote:
>> Andreas Kahari wrote:
>>>
>>> /[A-Za-z_0-9-]*[A-Za-z_-][A-Za-z_0-9-]*/
>>
>>Actually, that matches the same strings as
>>
>> /[A-Za-z_-]/
>
> Bummer. What if you anchor it in both ends?
Yep. That's one possible approach, also suggested by Tad and Chris.
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: 29 Sep 2003 16:14:12 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: reg exp help
Message-Id: <slrnbngmik.knq.abigail@alexandra.abigail.nl>
Andreas Kahari (ak+usenet@freeshell.org) wrote on MMMDCLXXXI September
MCMXCIII in <URL:news:slrnbngkrl.1cv.ak+usenet@vinland.freeshell.org>:
__ In article <bl9jpj$9gc54$1@ID-184292.news.uni-berlin.de>, Gunnar Hjalmarsson wrote:
__ [cut]
__ > Actually, that matches the same strings as
__ >
__ > /[A-Za-z_-]/
__
__ Bummer. What if you anchor it in both ends?
Then it ought to work, but it might be slow if there's no match,
because it allows for much backtracking.
/^\d*[-A-Za-z_][-\w]*$/
doesn't allow significant backtracking.
__ > How about two regexes, one for each criteria:
__ >
__ > /^[-\w]+$/ && /[a-zA-Z_-]/
__
__ Yeah, that's a good approach.
Unless you need a single regex (because it's an argument to a
function, read from a config file, etc).
Abigail
--
#!/opt/perl/bin/perl -w
$\ = $"; $SIG {TERM} = sub {print and exit};
kill 15 => fork for qw /Just another Perl Hacker/;
------------------------------
Date: Mon, 29 Sep 2003 13:13:53 -0000
From: gbacon@hiwaay.net (Greg Bacon)
Subject: Re: sort problem
Message-Id: <vngc0h3os4us4f@corp.supernews.com>
In article <mbudash-AEF2B3.10115428092003@typhoon.sonic.net>,
Michael Budash <mbudash@sonic.net> wrote:
: close, but col one is not sorting by date [...]
Oh crud, good catch. Three cheers for YYYY-MM-DD!
Greg
--
Moreover, if a free market were to be enacted in both intrastate and
interstate markets, then the politicians and bureaucrats would find
themselves in that most terrible (for them) condition: irrelevance.
-- William L. Anderson
------------------------------
Date: 29 Sep 2003 09:58:00 -0700
From: radevenz@ix.netcom.com (Richard A. DeVenezia)
Subject: strip newlines in TD cell ?
Message-Id: <e320eda1.0309290858.1f6a10fe@posting.google.com>
Can't figure this one out...
How can I strip all the newlines of stuff between <TD and </TD> ?
I read in and join some HTML
<TABLE><TR><TD>1
2
3
</TD>
<TR><TD>A
B
C</TD></TR></TABLE>
that I want process as
<TABLE><TR><TD>1 2 3</TD>
<TR><TD>A B C</TD></TR></TABLE>
Thanks.
------------------------------
Date: Mon, 29 Sep 2003 17:09:13 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: strip newlines in TD cell ?
Message-Id: <ZGZdb.26655$ZR1.15452@nwrddc01.gnilink.net>
Richard A. DeVenezia wrote:
> Can't figure this one out...
>
> How can I strip all the newlines of stuff between <TD and </TD> ?
>
> I read in and join some HTML
Maybe by using an HTML parser to parse HTML?
Contrary to popular believe parsing HTML correctly is close to rocket
science and nobody with a sane mind would attempt to do that using REs
alone.
For further details please see the FAQ. 'perldoc -q HTML':
"How do I remove HTML from a string?"
jue
------------------------------
Date: Sat, 19 Jul 2003 01:59:56 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re:
Message-Id: <3F18A600.3040306@rochester.rr.com>
Ron wrote:
> Tried this code get a server 500 error.
>
> Anyone know what's wrong with it?
>
> if $DayName eq "Select a Day" or $RouteName eq "Select A Route") {
(---^
> dienice("Please use the back button on your browser to fill out the Day
> & Route fields.");
> }
...
> Ron
...
--
Bob Walton
------------------------------
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 5586
***************************************