[29679] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 923 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Oct 10 14:14:17 2007

Date: Wed, 10 Oct 2007 11:14: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           Wed, 10 Oct 2007     Volume: 11 Number: 923

Today's topics:
        Regex problem. <ashishrai@gmail.com>
    Re: Regex problem. <bik.mido@tiscalinet.it>
    Re: Regex problem. <simon.chao@fmr.com>
    Re: Regex problem. <ben@morrow.me.uk>
    Re: Regex problem. <wahab@chemie.uni-halle.de>
    Re: Regex problem. <ashishrai@gmail.com>
    Re: Regex problem. <ashishrai@gmail.com>
    Re: Regex problem. <ashishrai@gmail.com>
    Re: Regular Expression $1? <josef.moellers@fujitsu-siemens.com>
    Re: Regular Expression $1? <mritty@gmail.com>
    Re: Regular Expression $1? <Cloink_Friggson@ntlworld.com>
    Re: Script not able to work on Server 2003 <rkb@i.frys.com>
    Re: Script not able to work on Server 2003 <nospam@somewhere.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Wed, 10 Oct 2007 14:44:03 -0000
From:  Ash <ashishrai@gmail.com>
Subject: Regex problem.
Message-Id: <1192027443.295692.203290@19g2000hsx.googlegroups.com>

A B B c A c B d A A

I have a string as represented above. They are separated by spaces of
unknown length. I need to match As and Bs and store them in array in
the order they occur, or as they occur. The array filled from above
string should contain: ABBABAA.

The split function on spaces cannot be used because A,B and Cs are
representative of bigger string which may itself contain spaces for
example A may represent "clever fox" and B may represent "jumps over"
in which case the sequence ABB becomes "clever fox jumps over clever
fox",so space cannot be used as delimiter.
Global matching also cannot be used because it doesn't give me the
order different pattern occur.

Is there a way to solve this problem? Thank you.



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

Date: Wed, 10 Oct 2007 16:52:05 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: Regex problem.
Message-Id: <amppg39o9b68kff1t450q940bvftvmdctd@4ax.com>

On Wed, 10 Oct 2007 14:44:03 -0000, Ash <ashishrai@gmail.com> wrote:

>A B B c A c B d A A
>
>I have a string as represented above. They are separated by spaces of
>unknown length. I need to match As and Bs and store them in array in
>the order they occur, or as they occur. The array filled from above
>string should contain: ABBABAA.

my @AandBs = /[AB]/g;


Michele
-- 
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
 .'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,


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

Date: Wed, 10 Oct 2007 14:55:22 -0000
From:  it_says_BALLS_on_your forehead <simon.chao@fmr.com>
Subject: Re: Regex problem.
Message-Id: <1192028122.909410.261670@d55g2000hsg.googlegroups.com>

On Oct 10, 10:52 am, Michele Dondi <bik.m...@tiscalinet.it> wrote:
> On Wed, 10 Oct 2007 14:44:03 -0000, Ash <ashish...@gmail.com> wrote:
> >A B B c A c B d A A
>
> >I have a string as represented above. They are separated by spaces of
> >unknown length. I need to match As and Bs and store them in array in
> >the order they occur, or as they occur. The array filled from above
> >string should contain: ABBABAA.
>
> my @AandBs = /[AB]/g;

That won't quite work since 'A' and 'B' are representative of more
complex strings, and so can't fit into a character class.



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

Date: Wed, 10 Oct 2007 16:13:55 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: Regex problem.
Message-Id: <jq6vt4-du1.ln1@osiris.mauzo.dyndns.org>


Quoth Ash <ashishrai@gmail.com>:
> A B B c A c B d A A
> 
> I have a string as represented above. They are separated by spaces of
> unknown length. I need to match As and Bs and store them in array in
> the order they occur, or as they occur. The array filled from above
> string should contain: ABBABAA.
> 
> The split function on spaces cannot be used because A,B and Cs are
> representative of bigger string which may itself contain spaces for
> example A may represent "clever fox" and B may represent "jumps over"
> in which case the sequence ABB becomes "clever fox jumps over clever
> fox",so space cannot be used as delimiter.
> Global matching also cannot be used because it doesn't give me the
> order different pattern occur.

Err... it does for me:

    ~% perl -le'$_ = "clever fox jumps over foo bar clever fox";
        print for /(clever fox|jumps over)/g'
    clever fox
    jumps over
    clever fox
    ~%

Ben



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

Date: Wed, 10 Oct 2007 17:23:49 +0200
From: Mirco Wahab <wahab@chemie.uni-halle.de>
Subject: Re: Regex problem.
Message-Id: <feiqq4$165l$1@nserver.hrz.tu-freiberg.de>

Ash wrote:
> A B B c A c B d A A
> 
> I have a string as represented above. They are separated by spaces of
> unknown length. I need to match As and Bs and store them in array in
> the order they occur, or as they occur. The array filled from above
> string should contain: ABBABAA.
> 
> The split function on spaces cannot be used because A,B and Cs are
> representative of bigger string which may itself contain spaces for
> example A may represent "clever fox" and B may represent "jumps over"
> in which case the sequence ABB becomes "clever fox jumps over clever
> fox",so space cannot be used as delimiter.
> Global matching also cannot be used because it doesn't give me the
> order different pattern occur.

I don't really understand your problem. *If* you have
a string as you say above, then a simple:


  ...
  my $string='A B B c A c B d A A';
  my @array = $string=~/(?:\bA)|(?:\bB)/g;
  ...
  ...
  print "$_\n" for @array;
  ...


should suffice. Whats meant by "doesn't give me the order different pattern occur"?

Regards

M.


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

Date: Wed, 10 Oct 2007 16:56:20 -0000
From:  Ash <ashishrai@gmail.com>
Subject: Re: Regex problem.
Message-Id: <1192035380.812332.283800@k79g2000hse.googlegroups.com>

Thanks for the replies guys, solution by Michele  does work,
apparently I didn't use "|" operator between regexs :(.



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

Date: Wed, 10 Oct 2007 16:56:58 -0000
From:  Ash <ashishrai@gmail.com>
Subject: Re: Regex problem.
Message-Id: <1192035418.575112.214190@19g2000hsx.googlegroups.com>

Thanks for the replies guys, solution by Michele  does work,
apparently I didn't use "|" operator between regexs :(.



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

Date: Wed, 10 Oct 2007 17:31:48 -0000
From:  Ash <ashishrai@gmail.com>
Subject: Re: Regex problem.
Message-Id: <1192037508.366740.233570@d55g2000hsg.googlegroups.com>

Thanks for the replies guys, solution by Michele  does work,
apparently I didn't use "|" operator between regexs :(.



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

Date: Wed, 10 Oct 2007 09:16:48 +0200
From: Josef Moellers <josef.moellers@fujitsu-siemens.com>
Subject: Re: Regular Expression $1?
Message-Id: <fehu97$6jc$1@nntp.fujitsu-siemens.com>

Jim Cochrane wrote:
> On 2007-10-10, Yang <ysongfinance@gmail.com> wrote:
>=20
>>I want to get everything between () in the file, say (5), (6), so I
>>wrote the following:
>>
>>while(my $line =3D <FIN>){
>>     chomp $line;
>>     if($line =3D~ /\(\d*\)/{
>>         print $1;
>>    }
>>}
>>
>>But it always returns error saying that $1 is uninitialized.
>>
>=20
>=20
> I think you want:
>=20
> if ($line =3D~ /(\(\d+\))/ {
> ...
> }

ITYM "/\((\d*)\)/"

Yang wanted "everything *between* ()".

--=20
These are my personal views and not those of Fujitsu Siemens Computers!
Josef M=F6llers (Pinguinpfleger bei FSC)
	If failure had no penalty success would not be a prize (T.  Pratchett)
Company Details: http://www.fujitsu-siemens.com/imprint.html



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

Date: Wed, 10 Oct 2007 03:51:11 -0700
From:  Paul Lalli <mritty@gmail.com>
Subject: Re: Regular Expression $1?
Message-Id: <1192013471.914775.226140@k79g2000hse.googlegroups.com>

On Oct 9, 9:12 pm, Yang <ysongfina...@gmail.com> wrote:
> I want to get everything between () in the file, say (5), (6), so I
> wrote the following:
>
> while(my $line = <FIN>){
>      chomp $line;
>      if($line =~ /\(\d*\)/{
>          print $1;
>     }
>
> }
>
> But it always returns error saying that $1 is uninitialized.

$1 is assigned to whatever is "captured" by parentheses in the pattern
match.  You have no capturing parentheses in the pattern match.  You
only have the litteral parenthses that you're trying to match.  You
need to surround what you want to capture with parentheses:

/\((\d*)\)/

Note that \d* means "0 or more digits" which means an empty () is a
valid match for this expression.  If you want to require at least one
digit, change the * to a +.

Paul Lalli



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

Date: Wed, 10 Oct 2007 08:55:04 -0700
From:  Cloink <Cloink_Friggson@ntlworld.com>
Subject: Re: Regular Expression $1?
Message-Id: <1192031704.798135.120340@o3g2000hsb.googlegroups.com>

Paul - well done for answering lucidly, it doesn't happen often, esp
not on Perl pages.



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

Date: Tue, 09 Oct 2007 21:50:42 -0700
From:  Ron Bergin <rkb@i.frys.com>
Subject: Re: Script not able to work on Server 2003
Message-Id: <1191991842.311643.238390@y42g2000hsy.googlegroups.com>

I skipped over another important issue, so here it is.

On Oct 9, 8:23 pm, Ron Bergin <r...@i.frys.com> wrote:
> John and Mumia have pointed out most of the problems, but here are
> some more.
>
> On Oct 8, 4:10 pm, Joe <jruff...@gailborden.info> wrote:
>
> > Here is my code, I picked one of my shorter scripts:
>
[snip a bunch]

> >    print OPAC_WEB hr();
> >    print OPAC_WEB "<FONT SIZE=\"4\" COLOR=\"#FFFFFF\">";
> >    print OPAC_WEB "<A NAME=\"ext\">External<\/A><\/font>";
> >    print OPAC_WEB "<A HREF=\"\#int\">Internal Hits<\/a>";
> >    print OPAC_WEB  p(@ext_line);
> >    print OPAC_WEB hr();
> >    print OPAC_WEB "</center>";
>
[snip some more]
>
> > use CGI; print redirect("$opac_month");
>
You're not printing the closing body or html tags.

> > } else {
>
> > ##########################################################################
> > # If a file name has not been given, process the file, create webpage
> > to
> > # ask for it
> > #
> >   print header, start_html("Monthly WebOpac"), h1("Monthly WebOpac
> > Report");
>
> >   print hr();
> >   print start_form();
> >   print p("Day File: ",textfield("dayopac"), "<b>   * form should be
> > WebOpac_(<i>3-letter Month</i></b>)");
> > #  print p("Check Test: ",checkbox("opaccheck"));
>
> >   print p(submit("Submit Entry"));
> >   print end_form(), hr();
>
> > }
>
> > print end_html;</code>




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

Date: Wed, 10 Oct 2007 01:32:42 -0400
From: "Thrill5" <nospam@somewhere.com>
Subject: Re: Script not able to work on Server 2003
Message-Id: <O_ydnRJ48Y9g_pHanZ2dnUVZ_q6hnZ2d@comcast.com>


"Tad McClellan" <tadmc@seesig.invalid> wrote in message 
news:slrnfgijc3.4s9.tadmc@tadmc30.sbcglobal.net...
> Joe <jruffino@gailborden.info> wrote:
>> I have PERL scripst that I created on a Windows 2000 Server, that work
>> great. We switched to a Windows 2003 Server, PERL is installed, but my
>> script that works on 2000, will not work with the 2003 server. I keep
>> getting the following error on all my scripts:
>>
>> "Content-type: text/html
>>
>> 'C:\Inetpub\wwwroot\cgi-bin\Employee_Status\employee_status.cgi'
>> script produced no output"
>>
>> Plus, I have tried changing the extension to cgi, and I get the same
>> error.
>>
>> Does anyone have any suggestions for me?  I'm almost positive it is
>> something simple, but I am just not seeing it.
>
>
> I'm almost positive it has nothing to do with Perl.
>
> It likely has to do with web server configuration.
>
> Ask in a newsgroup about web servers.
>
>
> -- 
> Tad McClellan
> email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"

Have you configured IIS to use Perl for ".pl" and/or ".cgi" files? Have you 
checked the IIS log file for errors?




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

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 V11 Issue 923
**************************************


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