[18300] in Perl-Users-Digest
Perl-Users Digest, Issue: 468 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Mar 12 03:05:56 2001
Date: Mon, 12 Mar 2001 00:05:13 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <984384312-v10-i468@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Mon, 12 Mar 2001 Volume: 10 Number: 468
Today's topics:
Access mdb <ils@gil.com.au>
Re: Beginners question <john@particlewave.com>
Re: Beginners question <peter.sundstrom-eds@eds.com>
complex pattern matching with backslashes <hugo@fractalgraphics.com.au>
Re: complex pattern matching with backslashes <wyzelli@yahoo.com>
Re: complex pattern matching with backslashes <c_clarkson@hotmail.com>
Re: complex pattern matching with backslashes <wyzelli@yahoo.com>
Re: complex pattern matching with backslashes <c_clarkson@hotmail.com>
from SETL to Perl <cyberian_bear@hotmail.com>
Re: Help Matt with small programs <tzz@beld.net>
Help with integration problem between CGI Perl and Java (Falc2199)
How to reverse a loop ? euterpe21@yahoo.com
Re: Newbies welcome <raman@raman-sinha.com>
Re: Newbies welcome <uri@sysarch.com>
Pass in variables to web page <tomcat@visi.com>
Re: Pass in variables to web page (Damian James)
Please Help in Perl <mrizvi@telus.net>
Re: Please Help in Perl (Damian James)
Re: Please Help in Perl <joe+usenet@sunstarsys.com>
Sore head <hafateltec@hotmail.com>
Re: Sore head <hafateltec@hotmail.com>
usage of $SIG{__WARN__} and $SIG{__DIE__} <johnlin@chttl.com.tw>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 12 Mar 2001 14:30:37 +1000
From: "Phil Sutcliffe" <ils@gil.com.au>
Subject: Access mdb
Message-Id: <3aac5040$0$6342@wodc7nh6.news.uu.net>
Is it possible to read data from a table in an Access mdb on a Linux machine
and if so, how does one go about doing this? How about an Excel spreadsheet?
Thanks,
Phil.
------------------------------
Date: Sun, 11 Mar 2001 18:56:32 -0800
From: John Lockwood <john@particlewave.com>
Subject: Re: Beginners question
Message-Id: <1geoat45lduj0nr3mce9g5q8n171nnajjd@4ax.com>
You could add a line at the end to grab a line of input, e.g.
$foo = <STDIN>;
I find it more convenient to simply work at a command prompt ("DOS"
box), running my scripts and editor and so forth from there.
John
On Mon, 12 Mar 2001 01:57:50 GMT, Julien Gauthier <julg@sympatico.ca>
wrote:
>Is there a command line that will ask the user to press a given key
>before continuing?
>
>Right now I'm doing my first steps in Perl using the Window(*)
>environment and my problem is as follow : every time I run a perl
>script, it immediatly dissapear without giving me a chance to see wether
>the appropriate result is good. It will wait for imputs, but I can't see
>the final result.
>
>
>Thanks,
>
>JG
>
>(*) I know, thats the problem ...Asking me to switch to linux is not
>exactly an option because I most often work at the uni where I don't
>really have the choice.
------------------------------
Date: Mon, 12 Mar 2001 16:44:21 +1300
From: "Peter Sundstrom" <peter.sundstrom-eds@eds.com>
Subject: Re: Beginners question
Message-Id: <98hgn3$61o$1@hermes.nz.eds.com>
"Julien Gauthier" <julg@sympatico.ca> wrote in message
news:3AAC2E70.581B184E@sympatico.ca...
> Is there a command line that will ask the user to press a given key
> before continuing?
>
> Right now I'm doing my first steps in Perl using the Window(*)
> environment and my problem is as follow : every time I run a perl
> script, it immediatly dissapear without giving me a chance to see wether
> the appropriate result is good. It will wait for imputs, but I can't see
> the final result.
Start->Programs->ActiveState ActivePerl->Documentation
Read the "Readme"
------------------------------
Date: Mon, 12 Mar 2001 11:24:23 +0800
From: Hugo Bouckaert <hugo@fractalgraphics.com.au>
Subject: complex pattern matching with backslashes
Message-Id: <3AAC4167.A8CF8705@fractalgraphics.com.au>
Hi
I need to do some complex pattern matching and I don't seem to be able
to get it right.
I want to to do the following:
I have the following path when I am on a windows machine:
\\SomeComputer\directory1\directory2\directory3\filename.doc
I would like to convert this to
/directory2/directory3/filename.doc
Note that there could be more than 3 directories ie I could have
\\SomeComputer\directory1\directory2\directory3\directory4\directory5\filename.doc
which should become:
/directory2/directory3/directory4/directory5/filename.doc
With all the backslashes and forward slashes interpreted wrongly, I am
running into trememdous problems.
Basically what I want to do is: see if this general pattern of filepath
occurs, and if so, do a substitution:
if ( Stringvariable =~
\\SomeComputer\directory1\directory2\directory3\filename.doc ) {
$anothervariable = s/ / /;
}
However, I am having real trouble finding filling in the pattern matches
for the substitution.
Anyone has dome something like this before?
Any help will be highly appreciated.
Thanks
Hugo
--
Dr Hugo Bouckaert
R&D Support Engineer, Fractal Graphics
39 Fairway, Nedlands Western Australia 6009
Tel: +618 9386 7917
Email:hugo@fractalgraphics.com.au
Web: http://www.fractalgraphics.com.au
------------------------------
Date: Mon, 12 Mar 2001 13:23:32 +0930
From: "Wyzelli" <wyzelli@yahoo.com>
Subject: Re: complex pattern matching with backslashes
Message-Id: <2zXq6.9$_S2.4040@vic.nntp.telstra.net>
"Hugo Bouckaert" <hugo@fractalgraphics.com.au> wrote in message
news:3AAC4167.A8CF8705@fractalgraphics.com.au...
> Hi
>
> I need to do some complex pattern matching and I don't seem to be able
> to get it right.
>
> I want to to do the following:
>
> I have the following path when I am on a windows machine:
>
> \\SomeComputer\directory1\directory2\directory3\filename.doc
>
> I would like to convert this to
>
> /directory2/directory3/filename.doc
>
What may be throwing you is the fact that the backslash at the start of
the string is escaping the second backslash, (even in a single quoted
string) so in effect you only have one backslash to deal with.
This achieves what you described:
$string =
'\\SomeComputer\directory1\directory2\directory3\filename.doc';
$another = $1 if $string =~ m/\\\w+\\\w+\\(.*)/;
$another =~ s|\\|/|g;
print "$string\n$another\n";
Wyzelli
--
($a,$b,$w,$t)=(' bottle',' of beer',' on the wall','Take one down, pass
it around');
for(reverse(1..100)){$s=($_!=1)?'s':'';$c.="$_$a$s$b$w\n$_$a$s$b\n$t\n";
$_--;$s=($_!=1)?'s':'';$c.="$_$a$s$b$w\n\n";}print"$c*hic*";
------------------------------
Date: Mon, 12 Mar 2001 00:17:28 -0600
From: "Charles K. Clarkson" <c_clarkson@hotmail.com>
Subject: Re: complex pattern matching with backslashes
Message-Id: <C150AD1AE848ADAD.CDDE37D63F16AAB8.67D6D4C9465A9892@lp.airnews.net>
Hugo Bouckaert <hugo@fractalgraphics.com.au> wrote:
: Hi
:
: I need to do some complex pattern matching and I don't seem to be able
: to get it right.
:
: I want to to do the following:
:
: I have the following path when I am on a windows machine:
:
: \\SomeComputer\directory1\directory2\directory3\filename.doc
:
: I would like to convert this to
:
: /directory2/directory3/filename.doc
:
: Note that there could be more than 3 directories ie I could have
:
:
\\SomeComputer\directory1\directory2\directory3\directory4\directory5\filena
me.doc
:
: which should become:
:
: /directory2/directory3/directory4/directory5/filename.doc
:
: With all the backslashes and forward slashes interpreted wrongly, I am
: running into trememdous problems.
:
Translate it:
my $path = '\\SomeComputer\directory1\directory2\directory3\filename.doc';
$path =~ tr|\\|/|;
print $path;
tr|\\|/| will automagically reduce \\ to / and change \ to /.
HTH,
Charles k. Clarkson
------------------------------
Date: Mon, 12 Mar 2001 16:05:55 +0930
From: "Wyzelli" <wyzelli@yahoo.com>
Subject: Re: complex pattern matching with backslashes
Message-Id: <jYZq6.19$_S2.4575@vic.nntp.telstra.net>
"Charles K. Clarkson" <c_clarkson@hotmail.com> wrote in message
news:C150AD1AE848ADAD.CDDE37D63F16AAB8.67D6D4C9465A9892@lp.airnews.net..
.
>
> Translate it:
>
> my $path =
'\\SomeComputer\directory1\directory2\directory3\filename.doc';
> $path =~ tr|\\|/|;
> print $path;
>
> tr|\\|/| will automagically reduce \\ to / and change \ to /.
>
If you print $path before the tr/// I think you will find it is not
tr/// that is effecting that 'automagic' you speak of.
Wyzelli
--
($a,$b,$w,$t)=(' bottle',' of beer',' on the wall','Take one down, pass
it around');
for(reverse(1..100)){$s=($_!=1)?'s':'';$c.="$_$a$s$b$w\n$_$a$s$b\n$t\n";
$_--;$s=($_!=1)?'s':'';$c.="$_$a$s$b$w\n\n";}print"$c*hic*";
------------------------------
Date: Mon, 12 Mar 2001 00:50:16 -0600
From: "Charles K. Clarkson" <c_clarkson@hotmail.com>
Subject: Re: complex pattern matching with backslashes
Message-Id: <27BE64DFB4A3173D.6222622906C4216A.B6D9DB4BEBB4DBF6@lp.airnews.net>
Wyzelli <wyzelli@yahoo.com> wrote:
: "Charles K. Clarkson" <c_clarkson@hotmail.com> wrote in message
:
: >
: > Translate it:
: >
: > my $path =
: '\\SomeComputer\directory1\directory2\directory3\filename.doc';
: > $path =~ tr|\\|/|;
: > print $path;
: >
: > tr|\\|/| will automagically reduce \\ to / and change \ to /.
: >
:
: If you print $path before the tr/// I think you will find it is not
: tr/// that is effecting that 'automagic' you speak of.
:
: Wyzelli
Wow, you're right. Guess you knew that though. :)
Thanks for the heads up.
Charles k. Clarkson
------------------------------
Date: Sun, 11 Mar 2001 23:58:42 -0500
From: "cyberian bear" <cyberian_bear@hotmail.com>
Subject: from SETL to Perl
Message-Id: <6OYq6.1$d93.94@typhoon.nyu.edu>
Hi guys I have 2 programs below that I must have in Perl but I have them
in SETL(whatever the hell that is) and I don't know anything about it. I
tried finding stuff about it on the web but all I found was two small,
irrelevant pages and no tutorials. The thing is, if at least I knew what the
'Euler path construction', or 'Prime factors' are, I could just program them
on my own without looking at the SETL code, but i don't. Basically I just
want to ask some good soul if he could translate these two programs for me
from SETL to Perl. I know chances of finding anyone who knows SETL are
negligibe but i guess it's worth a try.
I just want to thank anyone in advance if someone decides to help me. If not
that's OK I understand it's a lot to ask for.
Well. Thanx a lot guys.
cb
PS: my e-mail is cyberian_bear@yahoo.com
----------------------------------------------------------------------------
-------------------
program Euler; -- Eulerian path construction
graph := {[1,2], [2,3], [3,4], [4,1], [4,2]}; -- a small
graph
print(euler_path(graph + {[y, x]: [x, y] in graph})); -- which is
undirected.
procedure Euler_path(G); -- constructs Eulerian path for
graph G
nodes := domain(G); -- all nodes in thegraph.
if #(odds := {x in nodes | odd(#G{x})}) > 2 then
return OM; -- since more than two nodes are
end if; -- touched by an odd number of edges
-- odds is the set of all nodes of G that
-- are touched by an odd number of edges
x := arb(odds)?arb(nodes); -- pick a node of odds if possible
-- otherwise pick any node of G
path := [x] + build_path(x,G);
while exists z = path(i) | G{z} /= {} loop
new_p := build_path(z, G); -- insert new section into path
G -:= ({[y,x]: [x,y] in new_p} + {e: e in new_p});
path := path(i..i - 1) + new_p + path(i..);
end loop;
return path;
end Euler_path;
procedure build_path(x, rw G); -- builds maximal path section
starting at x,
-- and deletes all edges traversed
p := [ ];
while (y := arb G{x}) /= OM loop
-- while there exists an edge leaving the last point
reached
p with:= y; -- extend path to traverse the edge
G -:= {[x, y], [y, x]}; -- delete the edge just traversed
x := y; -- step to y
end loop;
return p;
end build_path;
end euler;
----------------------------------------------------------------------------
---------------------
package body prime_factors_pak;
procedure prime_factors(n); -- get tuple of prime factors of
n
facts := []; -- will collect
while even(n) loop facts with:= 2; n /:= 2; end loop; -- even
factors
while exists k in [3,5..ceil(sqrt(float(n)))] | n mod k = 0 loop
facts with:= k; n /:= k; -- smallest remaining factor,
up to sqrt(n)
end loop;
facts with:= n; -- the final factor
return facts;
end prime_factors;
end prime_factors_pak;
------------------------------
Date: 11 Mar 2001 21:44:16 -0500
From: Ted Zlatanov <tzz@beld.net>
Subject: Re: Help Matt with small programs
Message-Id: <m31ys3aepr.fsf@heechee.beld.net>
abigail@foad.org (Abigail) writes:
> Ted Zlatanov (tzz@beld.net) wrote on MMDCCXLVIII September MCMXCIII in <URL:news:m3snkl8t9n.fsf@heechee.beld.net>:
> "" abigail@foad.org (Abigail) writes:
> ""
> "" > {local $, = " ";
> "" > print grep {$_ % 5 == 0} 0 .. 99
> "" > }
> "" >
> "" Perhaps a less obfuscated choice might be:
> ""
> "" print join ' ', grep {$_ % 5 == 0} 0 .. 99;
> ""
> "" since it avoids localized variables and $,
>
> $_ is localized.
Actually the localized $, is what I was talking about. Localized $_
is well-accepted and makes perfect sense. $, is rarer in my
experience.
> But why do you make the suggestion localized variables are bad?
Localized variables, and your solution in particular, are perfectly
fine. I was just proposing an alternate solution which does the same
thing without localized magic variables. IMHO (hence the "Perhaps"
above) it is also less obfuscated.
--
Teodor Zlatanov <tzz@iglou.com>
"Brevis oratio penetrat colos, longa potatio evacuat ciphos." -Rabelais
-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 80,000 Newsgroups - 16 Different Servers! =-----
------------------------------
Date: 12 Mar 2001 03:19:08 GMT
From: falc2199@aol.comNOJUNK (Falc2199)
Subject: Help with integration problem between CGI Perl and JavaScript
Message-Id: <20010311221908.23660.00000703@ng-fb1.aol.com>
I am writing a web programming project in JavaScript but because it has no
capacirty for file I/O, I have to use Perl to retrieve some data.
I need to read in some lines of text from a flat file. And somehow I have to
get each line that has been read into a seperate element of a JavaScript array.
Something like...
while(<FILE>)
{
jScriptArray[n] = $_;
n++;
}
As you can see this code will never work because it has the two languages mixed
in.
Can anyone give me any pointers in the right way to go about solving this.
Thanks in advance for any help,
Jehan
To e-mail, remove NOJUNK
------------------------------
Date: Mon, 12 Mar 2001 08:51:26 +0100
From: euterpe21@yahoo.com
Subject: How to reverse a loop ?
Message-Id: <ctvoatcdd23qr6cs4qunl8rue2p98j35sa@4ax.com>
for (my $i=1; $i<scalar(@bids); $i++) {
my ($alias, $email, $bid, $time, $add1, $add2, $add3) = &read_bid
($bids[$i]);
my $bidtime = gmtime($time);
print "<FONT SIZE=-1>$alias \($bidtime\) - \GBP $bid</FONT><BR>";
returns:
alias (Mon Mar 12 06:25:22 2001) - GBP 1
alias (Mon Mar 12 06:25:46 2001) - GBP 2
alias (Mon Mar 12 06:26:01 2001) - GBP 3
I would like to get:
alias (Mon Mar 12 06:26:01 2001) - GBP 3
alias (Mon Mar 12 06:25:46 2001) - GBP 2
alias (Mon Mar 12 06:25:22 2001) - GBP 1
TIA for any help.
Jack
------------------------------
Date: Mon, 12 Mar 2001 02:13:32 GMT
From: Raman Sinha <raman@raman-sinha.com>
Subject: Re: Newbies welcome
Message-Id: <B6D18D61.5958%raman@raman-sinha.com>
heh heh. glad to help. i spent my whole weekend reading over most of the
general php documentation part II language reference, as well as the section
on arrays and the functions on mySQL as well as HTTP functions. i suggest
that everyone that wants to get into PHP read the chapters and then go
online and read the annotations as they're PRICELESS. i'm also
reading/practicing the php developers cookbook by sams as i believe it
belogns in everyone's bookbag.
contrary to what i said, there is a page or 2 on querystrings buried in
there. i guess since querystrings are nothign special in PHP, they dont'
need to put it front and center, like in ASP..
i'm assuming that if you didn't know about querystrings that you might be a
newbie to PHP like me so go ahead and don't be afraid to post "stupid"
questions here as i'm going to town posting the same ones..
-raman
in article FZaq6.8148$t1.568517@news6-win.server.ntlworld.com, Darren at
darrenls21@yahoo.com wrote on 3/9/01 2:19 PM:
> you must be good. You just answered a question before i asked it :-)
>
> Raman Sinha <raman@raman-sinha.com> wrote in message
> news:B6CDBC5D.4FF5%raman@raman-sinha.com...
>> some people simply don't know *how* to look. sometimes you have to hold a
>> newbies hand and let them take baby steps. for instance:
>>
>> i am an asp programmer (not by choice). in asp, to get values for
>> querystrings you need to do something like this if your querystring looks
>> like this:
>>
>> www.mypage.com/thispage.asp?asp=sucks
>>
>> so in my page to mess with it, i'd do something liek this:
>>
>> dim asp
>> howisasp=request.querystring("asp")
>>
>> (howisasp=sucks now)
>>
>> BUT the PHP documentation does not remotely go out of it's way to tell you
>> that PHP AUTOMATICALLY creates a variable who's name is the key and who's
>> value is the key's value.. very logical (why don't they do this in asp?
>> because asp sucks) BUT it isn't really mentioned anywhere. = big barrier
> to
>> entry. if it weren't for a tiny line somewhere on wired and/or someones
>> annotation that i barely saw in the documentation i would probably have
>> given up and said screw it, i'll do the website in asp instead of wasting
> 4
>> hours trying to figure it out and reading the docs over and over.
>>
>> of course, now i'm on my way to php gurudom :)
>>
>> so go ahead - ask a question. if i can't answer it for you i'll tell you
>> where you can find the answer in the documentation but you will eventually
>> learn to be resourceful.
>>
>> -raman
>>
>> in article 3AA857F4.33A84172@indent.com.au, Justin French at
>> justin@indent.com.au wrote on 3/8/01 10:12 PM:
>>
>>> Darren wrote:
>>>
>>>> Do not ever be afraid of asking a question on something relevent to the
>>>> newsgroup you are visiting.
>>>> Bear in mind that every single person on any newsgroup was a newbie
> once, so
>>>> if they slate you for being a newbie then they are hypocrites and
> should be
>>>> ignored. Do not give up. Everybody learns, even the so called
> experienced
>>>> though they would often not admit it
>>>
>>> Yeah, but consulting the manuals, or searching archives (if they exist)
>>> might help cut dwon the the traffic and abuse.
>>
>
>
------------------------------
Date: Mon, 12 Mar 2001 04:30:20 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Newbies welcome
Message-Id: <x78zmbbodm.fsf@home.sysarch.com>
>>>>> "RS" == Raman Sinha <raman@raman-sinha.com> writes:
RS> heh heh. glad to help. i spent my whole weekend reading over most
RS> of the general php documentation part II language reference, as
RS> well as the section on arrays and the functions on mySQL as well
RS> as HTTP functions. i suggest that everyone that wants to get into
RS> PHP read the chapters and then go online and read the annotations
RS> as they're PRICELESS. i'm also reading/practicing the php
RS> developers cookbook by sams as i believe it belogns in everyone's
RS> bookbag.
keep this thread out of comp.lang.perl.misc. it has no perl content.
<followups trimmed>
uri
--
Uri Guttman --------- uri@sysarch.com ---------- http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page ----------- http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net ---------- http://www.northernlight.com
------------------------------
Date: Mon, 12 Mar 2001 04:29:14 GMT
From: uNcONvEntiOnaL <tomcat@visi.com>
Subject: Pass in variables to web page
Message-Id: <ugYq6.916$Tg.111250@ruti.visi.com>
I have a perl script which is invoked from a html form:
$body = $in{"body"};
print "<a HREF='http://www.aol.com/contact.html?body=$bod
y'>Return\n";
The page that comes up in the browser is:
http://www.aol.com/contact.html?body=This is a test message
in this page that comes up I have a textarea named body
<TEXTAREA COLS=60 ROWS=14 NAME="body" value=""></TEXTAREA>
Question: Can I make this page that comes up display
"This is a test message" in the textarea named "body" ???
- will the html page accept me stuffing something into "value"
for textarea ??
Thanks
Tom
--
On the Hiway to Hell... // www.informationhiwaytohell.com
The Information Hiway to Hell... AC\\DC tomcat@visi.com uNcONvEntiOnaL
//
When encryption is made illegal, then *7^%,"JJr3%a}Z@9((l:^%$Hhr=+!
------------------------------
Date: 12 Mar 2001 05:04:17 GMT
From: damian@qimr.edu.au (Damian James)
Subject: Re: Pass in variables to web page
Message-Id: <slrn9aom6h.n1j.damian@puma.qimr.edu.au>
Thus spake uNcONvEntiOnaL on Mon, 12 Mar 2001 04:29:14 GMT:
>...
>
>in this page that comes up I have a textarea named body
><TEXTAREA COLS=60 ROWS=14 NAME="body" value=""></TEXTAREA>
>
>Question: Can I make this page that comes up display
>"This is a test message" in the textarea named "body" ???
>- will the html page accept me stuffing something into "value"
>for textarea ??
>
Yes, but not with a value element - rather, like this:
<textarea name='bleh'>Your value goes here</textarea>
This is a question about HTML. As such it is only tangentially
related to Perl. In future, please choose one of these (more relevant)
newsgroups:
comp.infosystems.www.authoring.html
comp.infosystems.www.authoring.cgi
Though you should read the FAQs there before posting. You might also be
interested in refering to the HTML specifiactions at w3.org.
If you are planning to use Perl to develop CGI programs, it would also be
very much worth your while to investigate the CGI module, which is in the
standard distribution. Just go to a command line and type 'perldoc CGI'.
HTH
Cheers,
Damian
--
@;=0..23;@;{@;}=split//,<DATA>;while(1){for($;=@;;--$;;){next if($:=rand($;+
1))==0+$;;@;[$;,$:]=@;[$:,$;];print "\x"for 0..2*(@|*23)}print map{$;{$_}}(@|
,@;);push@|,shift@;if$;[0]==@|;last if!@;;print"\b"x(@;+@|)}print"\n"__END__
Just another Perl Hacker
------------------------------
Date: Mon, 12 Mar 2001 04:42:59 GMT
From: "Mukarram Rizvi" <mrizvi@telus.net>
Subject: Please Help in Perl
Message-Id: <ntYq6.9984$Lm2.1016390@news0.telusplanet.net>
Hi,
Can someone please help me with my Perl problem. I want to pick up
everything between the word
INTO and the first ocurrence of the word FROM.
Presently, my program picks up everything between the the first INTO and the
second FROM (i.e. instead of
stopping at the first FROM, it goes on to the second FROM). Please see
source data below.
SOURCE DATA
-----------
select ename, job
into :ename, :job from employee
select ename2, job2
into :ename2, :job2 from employee;
If we assume that the above is the source data, presently, my program picks
up:
:ename, :job from employee
select ename2, job2
into :ename2, :job2
What I want it to pick up is:
:ename, :job
I am using Perl's regular expression. Is there any way that I can stop Perl
from being too greedy ?
2. Also, is it possible to use regular expression in Perl to say, whatever
is picked up, should not have the word in INTO in it e.g. ":ename, :job
INTO, :ename2, :job2"
has the word
INTO in-between therefore, I do not want to pick up this statement.
Your wisdom will be greatly appreciated.
Thank you
------------------------------
Date: 12 Mar 2001 05:12:58 GMT
From: damian@qimr.edu.au (Damian James)
Subject: Re: Please Help in Perl
Message-Id: <slrn9aommq.n1j.damian@puma.qimr.edu.au>
Thus spake Mukarram Rizvi on Mon, 12 Mar 2001 04:42:59 GMT:
>...
>Presently, my program picks up everything between the the first INTO and the
>second FROM (i.e. instead of
>stopping at the first FROM, it goes on to the second FROM). Please see
>source data below.
>
>...
>
>I am using Perl's regular expression. Is there any way that I can stop Perl
>from being too greedy ?
> ^^^^^^
You really should have included what you had tried in your post -- we are
left to guess just what you were actually doing. However, it looks like you
already know what is going on here, in which case you only need to look at
the perlre man page to find your answer.
Indeed, by default wildcards in (at least Perl) regular expressions are greedy.
Without seeing your actual code, I can't suggest how to change your syntax.
But before you go and post it -- just try going to a command line, typing
'perldoc perlre' and searching for the word 'greedy'.
>2. Also, is it possible to use regular expression in Perl to say, whatever
>is picked up, should not have the word in INTO in it
Yes, as you will discover when you read the man page.
HTH,
Cheers,
Damian
--
@;=0..23;@;{@;}=split//,<DATA>;while(1){for($;=@;;--$;;){next if($:=rand($;+
1))==0+$;;@;[$;,$:]=@;[$:,$;];print "\x"for 0..2*(@|*23)}print map{$;{$_}}(@|
,@;);push@|,shift@;if$;[0]==@|;last if!@;;print"\b"x(@;+@|)}print"\n"__END__
Just another Perl Hacker
------------------------------
Date: 12 Mar 2001 00:29:55 -0500
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: Please Help in Perl
Message-Id: <m3lmqbblm4.fsf@mumonkan.sunstarsys.com>
"Mukarram Rizvi" <mrizvi@telus.net> writes:
Subject: Please Help in Perl
^^^^^^^^^^^^^^^^^^^
Not very descriptive; how about "greedy regexp problem"?
> SOURCE DATA
> -----------
> select ename, job
> into :ename, :job from employee
> select ename2, job2
> into :ename2, :job2 from employee;
>
> If we assume that the above is the source data, presently, my program picks
> up:
>
> :ename, :job from employee
> select ename2, job2
> into :ename2, :job2
>
> What I want it to pick up is:
> :ename, :job
?What did you try?
?What about the FAQ answer?
?Have you searched
% man perlre
for the keyword "greed"?
> I am using Perl's regular expression. Is there any way that I can stop Perl
> from being too greedy ?
^
Yes there is. This statement is the subject of your post, so your
"Subject" header should reflect that. See if the FAQ answer in
% perldoc -q greed
helps any.
> 2. Also, is it possible to use regular expression in Perl to say, whatever
> is picked up, should not have the word in INTO in it e.g. ":ename, :job
> INTO, :ename2, :job2"
> has the word
>
> INTO in-between therefore, I do not want to pick up this statement.
Based on your data, handling the greediness issue should take care of
this for you. Perhaps something like this will work:
/into\s+(.+?)\s+from/i; # sticks interesting part in $1
HTH
Joe Schaefer
--
%ENV=(); $A="\rr jpeurls ht\ba \rcankotehe"x666;END{ system
"$^X -wT $0 $^S";print"r\n"}sub foo{$_=pop||exit;/$_/;print
eval 'BEGIN{$^H='. ($^H+=666) .'}$_[-(()=$A=~//g)+$[]';}@_=
reverse$A=~/./g;&foo while$ARGV[0]=~//g;#evil mess for *nix
------------------------------
Date: Mon, 12 Mar 2001 12:01:45 +1000
From: "Copenhagen" <hafateltec@hotmail.com>
Subject: Sore head
Message-Id: <R6Wq6.20$8Jx.6029409@news.randori.com>
I have a sore head from banging it against the wall on this problem.
I need to communicate with a remote sco machine thru telnet and grab some
information into an array.
In regular telnet I log in and run a program called cli, then run a command
from cli and get my results.
So the session looks as such.
login: xxxx (enter)
Password: xxxx (enter)
SCO OpenServer(TM) Release 5
(C) 1983-1995 The Santa Cruz Operation, Inc.
(C) 1980-1994 Microsoft Corporation
(C) 1976-1994 UNIX System Laboratories, Inc.
All rights reserved.
For complete copyright credits,
enter "copyrights" at the command prompt.
Welcome to the xxxx
from
xxxx
Terminal set to vt100
sonata.tel118.756>
sonata.tel118.756> cli (enter)
CLI> query hlr-sub imsi = 311070000001001 (enter)
HLR Subscriber Data
----------------------------------------------------------------------------
IMSI: 311070000001001
MSIDSN basic : 16717880016
MSISDN alert : NAT-ISDN-16717880016
MS category : unk subs status : granted
TS1 : all-ts provisioned : y
TS2 : null-ts provisioned : y
TS3 : null-ts provisioned : y
PIC code :
===================================
Operator Determined Barring
===================================
------------------------------
Barring of OUTGOING calls
------------------------------
All : n
International: n intl excl HPLMN : n
Premium info : n premium entertain: n
SS calls : n
------------------------------
Barring of INCOMING calls
------------------------------
Line 1/? Press h for help, q to quit
Sorry if this looks messy from the cut paste. Anyway, I am using
(unsuccesfully) Net::Telnet to try and bring the above info into an array.
#!/usr/bin/perl -w
use Net::Telnet ();
my $t = new Net::Telnet(Timeout => 10,
Prompt => '/sonata\.tel118\.\d\d\d\> $/');
$t->open("192.168.121.10") || die "Can't open $!";
$t->login(Name => 'xxxx',
Password => 'xxxx',
Prompt => '/sonata\.tel118\.\d{3}> $/',
Timeout => 10);
$t->print('cli');
$t->waitfor('/CLI> $/');
$t->print('query hlr-sub imsi = 311070000001001');
$t->waitfor('/q to quit $/'); #NOTE THIS IS WHERE IT HAS A PROBLEM
$t->print('q');
$t->waitfor('/CLI> $/');
$t->print('exit');
$t->waitfor('/sonata\.tel118\.\d\d\d\> $/');
$t->print('exit');
$t->close;
print "\nTest OK\n";
exit;
My problem is at line 14. "pattern match timed-out at telnet1.pl line 14" So
i guess my question is this.
1. Does Net::Telnet act the same as a regular telnet session by doing screen
breaks ?
2. Is it possable to change the prompt ?
--
##############Þ
print "\n Welcome to NEPP";$Þ=1;while ($Þ){
print "\n$Þ";$Þ++;if ($Þ == 1000) {
print "\n$Þ"."\nWell almost never ending :þ";exit;}}
##############Þ
------------------------------
Date: Mon, 12 Mar 2001 17:02:37 +1000
From: "Copenhagen" <hafateltec@hotmail.com>
Subject: Re: Sore head
Message-Id: <tw_q6.102$8Jx.8782250@news.randori.com>
"Copenhagen" <hafateltec@hotmail.com> wrote in message
news:R6Wq6.20$8Jx.6029409@news.randori.com...
> I have a sore head from banging it against the wall on this problem.
> I need to communicate with a remote sco machine thru telnet and grab some
> information into an array.
> In regular telnet I log in and run a program called cli, then run a
command
> from cli and get my results.
> So the session looks as such.
>
> login: xxxx (enter)
> Password: xxxx (enter)
>
> SCO OpenServer(TM) Release 5
>
> (C) 1983-1995 The Santa Cruz Operation, Inc.
> (C) 1980-1994 Microsoft Corporation
> (C) 1976-1994 UNIX System Laboratories, Inc.
> All rights reserved.
>
> For complete copyright credits,
> enter "copyrights" at the command prompt.
>
>
> Welcome to the xxxx
>
> from
>
> xxxx
>
> Terminal set to vt100
> sonata.tel118.756>
> sonata.tel118.756> cli (enter)
> CLI> query hlr-sub imsi = 311070000001001 (enter)
> HLR Subscriber Data
> --------------------------------------------------------------------------
--
>
> IMSI: 311070000001001
> MSIDSN basic : 16717880016
> MSISDN alert : NAT-ISDN-16717880016
> MS category : unk subs status : granted
>
> TS1 : all-ts provisioned : y
> TS2 : null-ts provisioned : y
> TS3 : null-ts provisioned : y
>
> PIC code :
> ===================================
> Operator Determined Barring
>
> ===================================
> ------------------------------
> Barring of OUTGOING calls
> ------------------------------
>
> All : n
> International: n intl excl HPLMN : n
> Premium info : n premium entertain: n
>
> SS calls : n
> ------------------------------
> Barring of INCOMING calls
> ------------------------------
>
> Line 1/? Press h for help, q to quit
>
> Sorry if this looks messy from the cut paste. Anyway, I am using
> (unsuccesfully) Net::Telnet to try and bring the above info into an array.
>
> #!/usr/bin/perl -w
> use Net::Telnet ();
> my $t = new Net::Telnet(Timeout => 10,
> Prompt => '/sonata\.tel118\.\d\d\d\> $/');
> $t->open("192.168.121.10") || die "Can't open $!";
> $t->login(Name => 'xxxx',
> Password => 'xxxx',
> Prompt => '/sonata\.tel118\.\d{3}> $/',
> Timeout => 10);
>
> $t->print('cli');
> $t->waitfor('/CLI> $/');
> $t->print('query hlr-sub imsi = 311070000001001');
> $t->waitfor('/q to quit $/'); #NOTE THIS IS WHERE IT HAS A PROBLEM
> $t->print('q');
> $t->waitfor('/CLI> $/');
> $t->print('exit');
> $t->waitfor('/sonata\.tel118\.\d\d\d\> $/');
> $t->print('exit');
> $t->close;
> print "\nTest OK\n";
> exit;
>
> My problem is at line 14. "pattern match timed-out at telnet1.pl line 14"
So
> i guess my question is this.
> 1. Does Net::Telnet act the same as a regular telnet session by doing
screen
> breaks ?
> 2. Is it possable to change the prompt ?
>
>
>
#!/usr/bin/perl -w
use Net::Telnet ();
my $t = new Net::Telnet(Timeout => 10,
Prompt => '/sonata\.tel118\.\d\d\d\> $/');
$t->open("192.168.121.10") || die "Can't open $!";
$t->login(Name => 'xxxx',
Password => 'xxxx',
Prompt => '/sonata\.tel118\.\d{3}> $/',
Timeout => 10);
$t->print('cli');
$t->waitfor('/CLI> $/');
($line) = $t->print('query hlr-sub imsi = 311070000001001');
$t->close;
print "\nTest OK\n";
print $line;
exit;
Sorry, this is closer to the code I am actually trying now. All I get is
"1" Instead of what I am looking for.
------------------------------
Date: Mon, 12 Mar 2001 11:11:32 +0800
From: "John Lin" <johnlin@chttl.com.tw>
Subject: usage of $SIG{__WARN__} and $SIG{__DIE__}
Message-Id: <98hen8$mfu@netnews.hinet.net>
Dear all,
When I first learned Perl, I often used $SIG{__WARN__}
and $SIG{__DIE__} in cron jobs to capture and redirect
error messages to log files. They often caused trouble
if other modules also use $SIG{__DIE__}.
Until I learned the usage of open(STDERR,">>logfile"),
now I doubt whether my previous usage of $SIG{__DIE__}
and $SIG{__WARN__} was inappropriate.
Since exceptions are catchable by eval {}, in what
situation will you use $SIG{__DIE__} ?
The same question on $SIG{__WARN__}, in what situation
would $SIG{__WARN__} be considered useful?
Thank you very much.
John Lin
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 99)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V10 Issue 468
**************************************