[23372] in Perl-Users-Digest
Perl-Users Digest, Issue: 5591 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Sep 30 11:06:06 2003
Date: Tue, 30 Sep 2003 08:05:09 -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 Tue, 30 Sep 2003 Volume: 10 Number: 5591
Today's topics:
[newbie] scope of the variables (John)
Re: [newbie] scope of the variables (Tad McClellan)
Converting a VB typdef to Win32::API::Struct (Oistein Sorensen)
Debug Messages <kaspREMOVE_CAPS@epatra.com>
Re: Debug Messages <abigail@abigail.nl>
Re: Debug Messages <kaspREMOVE_CAPS@epatra.com>
Re: Debug Messages <abigail@abigail.nl>
Re: Debug Messages (Anno Siegel)
Difficult Perl DBI Question, multiple charsets (Frank Boegner)
Re: How are spammers exploiting my wwwboard code? <flavell@ph.gla.ac.uk>
Re: How To activate command line history in debugger? <kurt.kronschnabl-nospam@ica-intercom-akademie.de>
Re: How To activate command line history in debugger? (Peter Scott)
Re: LWP::Simple get() refined problem <flavell@ph.gla.ac.uk>
Re: newbie needs help [references and values] <xx087@freenet.carleton.ca>
Re: Perl command to copy one file into another (Bill)
regexp help (mani)
Re: regexp help <kaspREMOVE_CAPS@epatra.com>
Re: regexp help <ak+usenet@freeshell.org>
Re: regexp help <mgjv@tradingpost.com.au>
Re: regexp help <mgjv@tradingpost.com.au>
Re: <bwalton@rochester.rr.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 30 Sep 2003 07:35:39 -0700
From: news2003@wanadoo.es (John)
Subject: [newbie] scope of the variables
Message-Id: <3bd6db81.0309300635.2149d222@posting.google.com>
Hi all,
I am trying to create a module. and I have a question about the scope
of the variables.
lets say,
use strict;
sub one {
my ($rvalue) = @_; # here I define a variable
for my $i (0..$#$rvalue){ # here I define a local
# variable $i and I use it
# do something
}
}
sub second {
my ($rvalue) = @_; # on this second sub $rvalue
# is a new one or I carry it
# as the first one
for my $i (0..$#$rvalue){ # now the same case, $i was
# already defined and if the
# scope is just its
# own subsroutine, now this
# $i is something copletely
# new. Am I right?
# do something else
}
}
# Thanks for your help
# John
------------------------------
Date: Tue, 30 Sep 2003 09:54:45 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: [newbie] scope of the variables
Message-Id: <slrnbnj69l.nmc.tadmc@magna.augustmail.com>
John <news2003@wanadoo.es> wrote:
> I am trying to create a module. and I have a question about the scope
> of the variables.
None of the variables in your module code below will be visible
in the "use"ing program, they are all "lexical variables".
Learn all about Perl's two separate systems of variables at:
"Coping with Scoping":
http://perl.plover.com/FAQs/Namespaces.html
> for my $i (0..$#$rvalue){ # here I define a local
^^^^^
> # variable $i and I use it
^^^^^^^^
(I can't say "for" for "foreach". I reserve "for" for for(;;) :-)
In Perl, local() has to do with _package_ variables, which are
a form of _global_ variable, so it is confusing to use "local"
to mean "local". :-) or should it be :-( ?
You have defined a _lexical_ variable.
Lexical variables (my) always get you a completely new variable,
new memory allocated and all.
So, yes, $i will be visible only within the body of the foreach() block.
When the (foreach) block exits, $i will cease to exist.
> for my $i (0..$#$rvalue){ # now the same case, $i was
> # already defined and if the
> # scope is just its
> # own subsroutine, now this
> # $i is something copletely
> # new. Am I right?
You are right.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 30 Sep 2003 06:21:42 -0700
From: sorenso@sorenso.no (Oistein Sorensen)
Subject: Converting a VB typdef to Win32::API::Struct
Message-Id: <d913a339.0309300521.31f1521f@posting.google.com>
Hi,
I'm new to perl-win32 programming and need your help.
I'm trying to convert this VB typedef to a Win32::API::Struct:
Public Type ReskInfo
lSize As Long ' Size of the entire structure
' Denne må settes til
Len(ReskInfo) før Api-kallet
sKey As Integer
sFiller1 As Integer ' for future use
lKundeNummer As Long
szKundeNavn As String * 30
bNull_1 As String * 1
szAdresseI As String * 30
bNull_2 As String * 1
szAdresseII As String * 30
bNull_3 As String * 1
szPostNummer As String * 6
bNull_4 As String * 1
szPostSted As String * 25
bNull_5 As String * 1
szTelefon As String * 15
bNull_6 As String * 1
szFax As String * 15
bNull_7 As String * 1
szEmailAdresse As String * 64
bNull_8 As String * 1
szBankgiroNr As String * 15
bNull_9 As String * 1
szPostgiroNr As String * 15
bNull_10 As String * 1
szDeresRef As String * 30
bNull_11 As String * 1
szOrganisasjonsNr As String * 15
bNull_12 As String * 1
sKundeGruppe As Integer ' Nytt felt Build 750
sRabattGruppe As Integer ' Nytt felt Build 750
sPrisKode As Integer ' Nytt felt Build 750
sBehandlingsProfil As Integer ' Nytt felt Build 750
sDistriktsNr As Integer ' Nytt felt Build 750
sMedarbeiderNr As Integer ' Nytt felt Build 750
sFiller2 As Integer ' for future use
dKredittGrense As Double
dSaldo As Double
End Type
When I run my program I get seg-fault in DLL file.
Can anyone help me with the datatypes?
VB Perl
--------- ---------
Long -> long
String * 30 -> ??
Integer -> int
Double -> double
Best,
/oistein/
------------------------------
Date: Tue, 30 Sep 2003 15:37:05 +0530
From: "Kasp" <kaspREMOVE_CAPS@epatra.com>
Subject: Debug Messages
Message-Id: <blbkkc$kgu$1@newsreader.mailgate.org>
Hi,
I am looking for the conventional Perl way of printing debug messages.
What I want is something like this:
if(DEBUG) {print "Phase one completed properly";}
Messages like this can be placed strategically in the code. If a problem
occurs with the code, then the code can be run with a special command line
argument say - perl myBuggyCode.pl DEBUG.
So, if the debug mode is set like this. All the if(DEBUG) statements get
printed.
I understand & know how to get command line args (ARGV) and achieve the
above process. Also that there is good debugger. But my aim to provide a
perl script to a dumb client and then if a problem ever arises, he/she can
run the code in DEBUG mode and send me the trace file.
What I wish to know is if there is a standard way of achieving this with
some switch or assert etc?
TIA.
--
"Accept that some days you are the pigeon and some days the statue."
"A pat on the back is only a few inches from a kick in the butt." - Dilbert.
------------------------------
Date: 30 Sep 2003 11:22:02 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: Debug Messages
Message-Id: <slrnbnipqq.e7b.abigail@alexandra.abigail.nl>
Kasp (kaspREMOVE_CAPS@epatra.com) wrote on MMMDCLXXXII September MCMXCIII
in <URL:news:blbkkc$kgu$1@newsreader.mailgate.org>:
'' Hi,
''
'' I am looking for the conventional Perl way of printing debug messages.
'' What I want is something like this:
'' if(DEBUG) {print "Phase one completed properly";}
''
'' Messages like this can be placed strategically in the code. If a problem
'' occurs with the code, then the code can be run with a special command line
'' argument say - perl myBuggyCode.pl DEBUG.
''
'' So, if the debug mode is set like this. All the if(DEBUG) statements get
'' printed.
''
'' I understand & know how to get command line args (ARGV) and achieve the
'' above process. Also that there is good debugger. But my aim to provide a
'' perl script to a dumb client and then if a problem ever arises, he/she can
'' run the code in DEBUG mode and send me the trace file.
''
'' What I wish to know is if there is a standard way of achieving this with
'' some switch or assert etc?
Given that you already know how to get command line arguments,
what exactly is your question? Surely your "dumb clients" can
type '--debug' as a parameter?
Abigail
--
perl -MLWP::UserAgent -MHTML::TreeBuilder -MHTML::FormatText -wle'print +(
HTML::FormatText -> new -> format (HTML::TreeBuilder -> new -> parse (
LWP::UserAgent -> new -> request (HTTP::Request -> new ("GET",
"http://work.ucsd.edu:5141/cgi-bin/http_webster?isindex=perl")) -> content))
=~ /(.*\))[-\s]+Addition/s) [0]'
------------------------------
Date: Tue, 30 Sep 2003 17:53:05 +0530
From: "Kasp" <kaspREMOVE_CAPS@epatra.com>
Subject: Re: Debug Messages
Message-Id: <blbsjj$2j9$1@newsreader.mailgate.org>
"Abigail" <abigail@abigail.nl> wrote in message
news:slrnbnipqq.e7b.abigail@alexandra.abigail.nl...
> Given that you already know how to get command line arguments,
> what exactly is your question? Surely your "dumb clients" can
> type '--debug' as a parameter?
Here is the scenario:
I make a Perl script (test it) and send it to the clients. They use it.
On fine day, shit happens - bad input, disk full..etc.
At this stage, I want to give my client an option of running the script
(again) with --debug option so that some trace messages can be logged into a
log file.
The client sends me this trace file and I try to make sense of it as to why
the script is failing.
Now, in C/C++, we use the if(DEBUG) approach to log trace messages
if --debug is specified as a command line arg.
Is the approach in Perl any different or identical?
Thanks.
--
"Accept that some days you are the pigeon and some days the statue."
"A pat on the back is only a few inches from a kick in the butt." - Dilbert.
------------------------------
Date: 30 Sep 2003 13:38:10 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: Debug Messages
Message-Id: <slrnbnj1q2.elb.abigail@alexandra.abigail.nl>
Kasp (kaspREMOVE_CAPS@epatra.com) wrote on MMMDCLXXXII September MCMXCIII
in <URL:news:blbsjj$2j9$1@newsreader.mailgate.org>:
-- "Abigail" <abigail@abigail.nl> wrote in message
-- news:slrnbnipqq.e7b.abigail@alexandra.abigail.nl...
--
-- > Given that you already know how to get command line arguments,
-- > what exactly is your question? Surely your "dumb clients" can
-- > type '--debug' as a parameter?
--
-- Here is the scenario:
-- I make a Perl script (test it) and send it to the clients. They use it.
-- On fine day, shit happens - bad input, disk full..etc.
-- At this stage, I want to give my client an option of running the script
-- (again) with --debug option so that some trace messages can be logged into a
-- log file.
-- The client sends me this trace file and I try to make sense of it as to why
-- the script is failing.
--
-- Now, in C/C++, we use the if(DEBUG) approach to log trace messages
-- if --debug is specified as a command line arg.
-- Is the approach in Perl any different or identical?
Well, you can do anything with Perl you want. But if your question is
"can you do it in Perl this way", then the answer is yes.
But I'm surprised you ask. You said you understand how to read in
command line arguments. If you do understand, what are you asking?
Abigail
--
split // => '"';
${"@_"} = "/"; split // => eval join "+" => 1 .. 7;
*{"@_"} = sub {foreach (sort keys %_) {print "$_ $_{$_} "}};
%{"@_"} = %_ = (Just => another => Perl => Hacker); &{%{%_}};
------------------------------
Date: 30 Sep 2003 13:50:37 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Debug Messages
Message-Id: <blc1nd$2vn$1@mamenchi.zrz.TU-Berlin.DE>
Kasp <kaspREMOVE_CAPS@epatra.com> wrote in comp.lang.perl.misc:
> "Abigail" <abigail@abigail.nl> wrote in message
> news:slrnbnipqq.e7b.abigail@alexandra.abigail.nl...
>
> > Given that you already know how to get command line arguments,
> > what exactly is your question? Surely your "dumb clients" can
> > type '--debug' as a parameter?
>
> Here is the scenario:
> I make a Perl script (test it) and send it to the clients. They use it.
> On fine day, shit happens - bad input, disk full..etc.
> At this stage, I want to give my client an option of running the script
> (again) with --debug option so that some trace messages can be logged into a
> log file.
> The client sends me this trace file and I try to make sense of it as to why
> the script is failing.
>
> Now, in C/C++, we use the if(DEBUG) approach to log trace messages
> if --debug is specified as a command line arg.
I think you misremember. A common technique in C is to use a precompiler
macro like DEBBUG. It isn't set on the command line, but at compile time
through "cc -DDEBUG=1 ...", or an equivalent change in the source. Run time
flags (like --debug) don't enter the picture.
> Is the approach in Perl any different or identical?
The approach isn't as fixed as you make it out to be, not even in C/C++.
In Perl, the corresponding approach would be to have
use constant DEBUG => 0; # set to true for debugging
near the beginning of the program, and later do
print "Done one thing, starting another\n" if DEBUG;
Like the C approach, this doesn't even compile the debugging statements
when the constant is set to false, though that is no concern in most
C programs, and probably generally irrelevant in Perl.
Also like in C, it can't be (easily) activated from the command line. If
you want that, it is probably better to provide a key like --debug via
Getopt::Long and query the option.
I also find it worthwhile to write an almost-trivial subroutine like
sub debug {
print "@_\n" if $opt{ debug};
}
so you can easily make changes to all debugging output (such as directing it
to STDERR, or adding caller information).
Anno
------------------------------
Date: 30 Sep 2003 03:52:41 -0700
From: google@innovation-shop.de (Frank Boegner)
Subject: Difficult Perl DBI Question, multiple charsets
Message-Id: <723e5378.0309300252.2ac994cd@posting.google.com>
Is there an easy way to switch between different charsets when
connecting to a mysql server via DBI?
I have a list of several countries which have to be queried and
sorted. The result has to be displayed in different languages. Of
course, the order in which my results are sorted depend on the charset
I use. Therefore I want to use different charsets on establishing the
connection as I need them. Can this be done this way, or must I start
the mysql server with the desired charset?
Frank
------------------------------
Date: Tue, 30 Sep 2003 12:29:51 +0100
From: "Alan J. Flavell" <flavell@ph.gla.ac.uk>
Subject: Re: How are spammers exploiting my wwwboard code?
Message-Id: <Pine.LNX.4.53.0309301220540.8470@ppepc56.ph.gla.ac.uk>
On Mon, 29 Sep 2003, Buck wrote:
> Well... I didn't have time to read the *entire* script...
> First off, what is the permission to cgi-bin directory?
> Is it 711 -> rwx--x--x ?
>
> That will stop them reading your scripts.
Why is it that the clue-impaired always feel a compulsion to answer?
There's so much wrong with that advice that I don't know where to
start, and anyway it would take us way off topic for this group.
> Take any data you generate and put it somewhere else that is NOT the
> public directory. This way your data cannot be accessed.
There's a grain of sense in that, but I doubt it's the problem that
the hon Usenaut is suffering from.
> I'd change filenames and directory paths in your script, since they
> probably know your layout and can easily get by any scripting.
Yes, this could well be a clue. Attackers would know the
conventional URL and calling rules for wwwboard scripts and can run a
scanner looking for such scripts and spamming to them. But there's no
Perl-language-specifics, so it's offtopic here. Well, Perl does need
to be able to read scripts, so setting them execute-only to the web
server isn't going to be such a clever idea.
------------------------------
Date: Tue, 30 Sep 2003 14:09:06 +0200
From: Kurt Kronschnabl <kurt.kronschnabl-nospam@ica-intercom-akademie.de>
Subject: Re: How To activate command line history in debugger?
Message-Id: <blbt34$si7$03$1@news.t-online.com>
Peter Scott wrote:
> You need to install the missing module. Become root and type
>
> perl -MCPAN -e 'install Term::ReadKey'
Hello Peter,
I am afraid I have to install more then ReadKey. What I get is:
knoppix@p01kno:~$ perl -MCPAN -e 'install Term::ReadKey'
Can't locate object method "install" via package "Term::ReadKey" at -e
line 1.
Could you please give me an idea what is missing?
The Output of perl -V is as follows:
knoppix@p01kno:~$ perl -V
Summary of my perl5 (revision 5.0 version 8 subversion 0) configuration:
Platform:
osname=linux, osvers=2.4.19, archname=i386-linux-thread-multi
uname='linux cyberhq 2.4.19 #1 smp sun aug 4 11:30:45 pdt 2002 i686
unknown unknown gnulinux '
config_args='-Dusethreads -Duselargefiles -Dccflags=-DDEBIAN
-Dcccdlflags=-fPIC -Darchname=i386-linux -Dprefix=/usr
-Dprivlib=/usr/share/perl/5.8.0 -Darchlib=/usr/lib/perl/5.8.0
-Dvendorprefix=/usr -Dvendorlib=/usr/share/perl5
-Dvendorarch=/usr/lib/perl5 -Dsiteprefix=/usr/local
-Dsitelib=/usr/local/share/perl/5.8.0
-Dsitearch=/usr/local/lib/perl/5.8.0 -Dman1dir=/usr/share/man/man1
-Dman3dir=/usr/share/man/man3 -Dman1ext=1 -Dman3ext=3perl
-Dpager=/usr/bin/sensible-pager -Uafs -Ud_csh -Uusesfio -Uusenm
-Duseshrplib -Dlibperl=libperl.so.5.8.0 -Dd_dosuid -des'
hint=recommended, useposix=true, d_sigaction=define
usethreads=define use5005threads=undef useithreads=define
usemultiplicity=define
useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
use64bitint=undef use64bitall=undef uselongdouble=undef
usemymalloc=n, bincompat5005=undef
Compiler:
cc='cc', ccflags ='-D_REENTRANT -D_GNU_SOURCE -DDEBIAN
-fno-strict-aliasing -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
optimize='-O3',
cppflags='-D_REENTRANT -D_GNU_SOURCE -DDEBIAN -fno-strict-aliasing'
ccversion='', gccversion='3.2.2', gccosandvers=''
intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t',
lseeksize=8
alignbytes=4, prototype=define
Linker and Libraries:
ld='cc', ldflags =' -L/usr/local/lib'
libpth=/usr/local/lib /lib /usr/lib
libs=-lgdbm -ldb -ldl -lm -lpthread -lc -lcrypt
perllibs=-ldl -lm -lpthread -lc -lcrypt
libc=/lib/libc-2.3.1.so, so=so, useshrplib=true,
libperl=libperl.so.5.8.0
gnulibc_version='2.3.1'
Dynamic Linking:
dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-rdynamic'
cccdlflags='-fPIC', lddlflags='-shared -L/usr/local/lib'
Characteristics of this binary (from libperl):
Compile-time options: MULTIPLICITY USE_ITHREADS USE_LARGE_FILES
PERL_IMPLICIT_CONTEXT
Built under linux
Compiled at Feb 17 2003 12:38:57
@INC:
/etc/perl
/usr/local/lib/perl/5.8.0
/usr/local/share/perl/5.8.0
/usr/lib/perl5
/usr/share/perl5
/usr/lib/perl/5.8.0
/usr/share/perl/5.8.0
/usr/local/lib/site_perl
The onliest pm is /usr/share/perl/5.8.0/Term/ReadLine.pm and
/usr/share/perl5/Debconf/FrontEnd/Readline.pm but no ReadKey. This is
the case as well for suse 8.2. And there the history works perfect.
I am not (yet!) so familiar with perl packages and their installation
Best regards,
Kurt
------------------------------
Date: Tue, 30 Sep 2003 14:20:14 GMT
From: peter@PSDT.com (Peter Scott)
Subject: Re: How To activate command line history in debugger?
Message-Id: <yigeb.51936$TM4.21255@pd7tw2no>
In article <blbt34$si7$03$1@news.t-online.com>,
Kurt Kronschnabl <kurt.kronschnabl-nospam@ica-intercom-akademie.de> writes:
>Peter Scott wrote:
>> You need to install the missing module. Become root and type
>>
>> perl -MCPAN -e 'install Term::ReadKey'
>
>Hello Peter,
>
>I am afraid I have to install more then ReadKey. What I get is:
>
>knoppix@p01kno:~$ perl -MCPAN -e 'install Term::ReadKey'
>Can't locate object method "install" via package "Term::ReadKey" at -e
>line 1.
>
>Could you please give me an idea what is missing?
That's odd. That means that Term::ReadKey is already installed.
(You could get around that error to update it via CPAN.pm with
perl -MCPAN -e shell
install Term::ReadKey
but that is not the point.)
Let's make certain whether you have that module or not. Send the output of:
perl -MTerm::ReadKey -e 0
perl -dle 'print $INC{"Term/ReadKey.pm"}' # Then type 'c'
perl -MCPAN -le 'print $INC{"Term/ReadKey.pm"}'
I am having a hard time seeing how the same perl as gave you the debugger
problem can give you that output. Are you sure that root doesn't have a
different path causing it to run a different perl?
>The Output of perl -V is as follows:
[snip]
>
>The onliest pm is /usr/share/perl/5.8.0/Term/ReadLine.pm and
>/usr/share/perl5/Debconf/FrontEnd/Readline.pm but no ReadKey. This is
>the case as well for suse 8.2. And there the history works perfect.
--
Peter Scott
http://www.perldebugged.com
------------------------------
Date: Tue, 30 Sep 2003 13:24:56 +0100
From: "Alan J. Flavell" <flavell@ph.gla.ac.uk>
Subject: Re: LWP::Simple get() refined problem
Message-Id: <Pine.LNX.4.53.0309301318310.8470@ppepc56.ph.gla.ac.uk>
On Tue, 30 Sep 2003, Bart Lateur wrote:
> Hon Guin Lee - Web Producer - SMI Marketing wrote:
>
> >$ua->proxy(['http','https','ftp'], 'file:///usr/dist/share/proxy_config/uk.pac'); # set proxy
>
> I don't think that will work. A .pac file is typically a Javascript
> source file.
Indeed...
> Try using a real URL for the proxy.
Well, that file:///... thingy is in some senses a "real URL": maybe
it would be helpful to mention that the kind of URL that you had in
mind was something like http://wwwcache.dom.example:8080/
or http://11.22.33.44:8001/ , substituting appropriate DNS name or
IP address and port number. A read of the lwp cookbook might also be
helpful for the original poster.
cheers
------------------------------
Date: 30 Sep 2003 10:12:47 GMT
From: Glenn Jackman <xx087@freenet.carleton.ca>
Subject: Re: newbie needs help [references and values]
Message-Id: <slrnbnilpu.m6e.xx087@smeagol.ncf.ca>
John <news2003@wanadoo.es> wrote:
> I have just started on perl and I have a question about if the thing I
> copy is copy the value itself or I am copying the refence.
Read http://www.stonehenge.com/merlyn/UnixReview/col30.html
--
Glenn Jackman
NCF Sysadmin
glennj@ncf.ca
------------------------------
Date: 30 Sep 2003 07:41:42 -0700
From: wherrera@lynxview.com (Bill)
Subject: Re: Perl command to copy one file into another
Message-Id: <239ce42f.0309300641.21a18c@posting.google.com>
Abigail <abigail@abigail.nl> wrote in message
> I actually prefer to shell out to copy files (but not by using backticks,
> but by using system), because "cp" copies files in the way I expect, while
> File::Copy doesn't. File::Copy doesn't respect execute bits on files,
> "cp" does.
Yeah, I have a wrapper around File::Copy that does this. Seems to me
someone should write a rmscopy for Unix for that package.
------------------------------
Date: 30 Sep 2003 05:29:08 -0700
From: indian_spindoctor@yahoo.com (mani)
Subject: regexp help
Message-Id: <1c84265c.0309300429.4984afa2@posting.google.com>
Hi,
I have a problem with finding the regexp for this
Let us say
$x="# I have been";
if($x!~/^#/)
{
#stuff here
}
will make the code not get into the control loop for the current value
of x because $x starts with #. This is fine but if i give
$x=" #I have been\n";
then the if condition would be true. I want to avoid this I want to
ignore anything that starts with a <space># or # at the start. How do
i do it
I tried /s*^#/ which does not give what i want....
please help me....
------------------------------
Date: Tue, 30 Sep 2003 18:11:18 +0530
From: "Kasp" <kaspREMOVE_CAPS@epatra.com>
Subject: Re: regexp help
Message-Id: <blbtli$4b7$1@newsreader.mailgate.org>
> then the if condition would be true. I want to avoid this I want to
> ignore anything that starts with a <space># or # at the start. How do
> i do it
>
> I tried /s*^#/ which does not give what i want....
-----------^...this should be \s.
Try this regular expression:
/^(\s)*#/
--
"Accept that some days you are the pigeon and some days the statue."
"A pat on the back is only a few inches from a kick in the butt." - Dilbert.
------------------------------
Date: Tue, 30 Sep 2003 12:47:11 +0000 (UTC)
From: Andreas Kahari <ak+usenet@freeshell.org>
Subject: Re: regexp help
Message-Id: <slrnbniuqd.qea.ak+usenet@vinland.freeshell.org>
In article <blbtli$4b7$1@newsreader.mailgate.org>, Kasp wrote:
[cut]
>> I tried /s*^#/ which does not give what i want....
> -----------^...this should be \s.
> Try this regular expression:
> /^(\s)*#/
No need to parenthasize the \s.
--
Andreas Kähäri
------------------------------
Date: Tue, 30 Sep 2003 22:45:05 +1000
From: Martien Verbruggen <mgjv@tradingpost.com.au>
Subject: Re: regexp help
Message-Id: <slrnbniumh.d8h.mgjv@martien.heliotrope.home>
On 30 Sep 2003 05:29:08 -0700,
mani <indian_spindoctor@yahoo.com> wrote:
> if($x!~/^#/)
> I want to
> ignore anything that starts with a <space># or # at the start.
> I tried /s*^#/ which does not give what i want....
/^ ?#/
Or, if you meant "any whitespace" instead of "a <space>"
/^\s?#/
Or, if you meant any number of whitespace
/^\s*#/
And, please, don't just copy this, but read the perlre documentation,
and read about what I just told you. It'll help you solve these sorts of
problems yourself in the future.
Martien
--
|
Martien Verbruggen | Blessed are the Fundamentalists, for they
| shall inhibit the earth.
|
------------------------------
Date: Tue, 30 Sep 2003 22:45:20 +1000
From: Martien Verbruggen <mgjv@tradingpost.com.au>
Subject: Re: regexp help
Message-Id: <slrnbniun0.d8h.mgjv@martien.heliotrope.home>
On Tue, 30 Sep 2003 18:11:18 +0530,
Kasp <kaspREMOVE_CAPS@epatra.com> wrote:
>> then the if condition would be true. I want to avoid this I want to
>> ignore anything that starts with a <space># or # at the start. How do
>> i do it
>>
>> I tried /s*^#/ which does not give what i want....
> -----------^...this should be \s.
> Try this regular expression:
> /^(\s)*#/
Why the capturing parentheses?
Martien
--
|
Martien Verbruggen | Make it idiot proof and someone will make a
| better idiot.
|
------------------------------
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 5591
***************************************