[27006] in Perl-Users-Digest
Perl-Users Digest, Issue: 8938 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Feb 9 21:06:11 2006
Date: Thu, 9 Feb 2006 18:05:05 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Thu, 9 Feb 2006 Volume: 10 Number: 8938
Today's topics:
Re: Getting Values <FJRussonc@earthlink.net>
Re: Getting Values <1usa@llenroc.ude.invalid>
Regex won't work <cwattengard.spam@gmail.com>
Re: Regex won't work <cwattengard.spam@gmail.com>
Re: Regex won't work <noreply@gunnar.cc>
Script in Linux to access SQL Server <parth@motorola.com>
Re: Script in Linux to access SQL Server <abigail@abigail.nl>
Re: Script in Linux to access SQL Server <glex_no-spam@qwest-spam-no.invalid>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 09 Feb 2006 19:33:49 GMT
From: "Frank J. Russo" <FJRussonc@earthlink.net>
Subject: Re: Getting Values
Message-Id: <xOMGf.16393$vU2.10974@newsread3.news.atl.earthlink.net>
I am receiving from a web site form 30 pieces of information.( 30 keys / 30
values )
I know that the child1 - child8 keys are found in the 22 - 30 elements. I
want a way to directly refer to the values for these elements without
refering to the keys.
I was able to use a split and return the value. Adds an additional 2 steps
but it works. I just wanted to find a more direct way to get the values.
($key, $val) = split(/=/,$family[$i],2); # splits on the first =.
Frank
------------------------------
Date: Thu, 09 Feb 2006 20:09:07 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Getting Values
Message-Id: <Xns97659A387E90Easu1cornelledu@127.0.0.1>
"Frank J. Russo" <FJRussonc@earthlink.net> wrote in
news:xOMGf.16393$vU2.10974@newsread3.news.atl.earthlink.net:
[ Please quote some context when you reply. Have you read the
posting guidelines yet? ]
> I am receiving from a web site form 30 pieces of information.( 30 keys
> / 30 values )
>
> I know that the child1 - child8 keys are found in the 22 - 30
> elements. I want a way to directly refer to the values for these
> elements without refering to the keys.
>
> I was able to use a split and return the value. Adds an additional 2
> steps but it works. I just wanted to find a more direct way to get
> the values.
>
> ($key, $val) = split(/=/,$family[$i],2); # splits on the first =.
Your last two posts are possibly some of the most cryptic I have seen.
It is very hard to discern what you are talking about.
Are you talking about a CGI script? If so, are you using CGI.pm? If not,
you should.
What is in @family?
If I am guessing correctly, you have multiple input fields that are
related, and named child1-child8. Just as it is a bad idea in Perl to
use variables $child1-$child8 instead of an array @children with 8
elements, it is a bad idea to have eight fields child1-child8 in your
form.
Instead, you should use:
<p>
Child1: <input type="text" name="children"><br>
Child2: <input type="text" name="children"><br>
Child3: <input type="text" name="children"><br>
Child4: <input type="text" name="children"><br>
Child5: <input type="text" name="children"><br>
Child6: <input type="text" name="children"><br>
Child7: <input type="text" name="children"><br>
Child8: <input type="text" name="children"><br>
</p>
in your form. Then, you can get all the submitted fields by simply
using:
my @children = $cgi->param('children');
This way, your CGI script would not have to be changed every time the
form is changed.
Sinan
PS: Have you read the posting guidelines yet?
--
A. Sinan Unur <1usa@llenroc.ude.invalid>
(reverse each component and remove .invalid for email address)
comp.lang.perl.misc guidelines on the WWW:
http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html
------------------------------
Date: Thu, 09 Feb 2006 23:14:01 +0100
From: =?ISO-8859-1?Q?Christian_Watteng=E5rd?= <cwattengard.spam@gmail.com>
Subject: Regex won't work
Message-Id: <43ebbeb3$1@news.broadpark.no>
I'm trying to extract some info from a line I read from a file.
My program looks like this:
----
#!/usr/bin/perl -w
open(FR, "< vin.htm");
my $ctr = 0;
while (<FR>){
my $t1, $t2, $t3, $t4, $t5, $t6;
#print $_;
#print "\n\n";
$t1, $t2, $t3 = $1, $2, $3
if $_ =~ m!"-1">(.*)</td>
<td><im.*(\d).gif.>.*-1">(\d\d,\d\d)</font>.*"-1">(\w*)\sfra\s(\w*)\s-?\s?(.*)</font>!;
$ctr++;
print "Linje ".$ctr." - ";
print "1: ".$t1."\n" if $t1;
print "2: ".$t2."\n" if $t2;
print "3: ".$t3."\n" if $t3;
}
----
the wordwrap in the regex is not there in the original file ;)
the lines i'm trying to read are from the file
http://www.wattengard.no/vin.htm
Have I misunderstood how the filereading works or something like that?
The result i want should be something like:
$t1 = winename
$t2 = points (identified by the gif filename)
$t3 = price
$t4 = winetype (rødvin = red wine ;) )
$t5 = country
$t6 = region
Christian...
------------------------------
Date: Thu, 09 Feb 2006 23:15:51 +0100
From: =?ISO-8859-1?Q?Christian_Watteng=E5rd?= <cwattengard.spam@gmail.com>
Subject: Re: Regex won't work
Message-Id: <43ebbf22@news.broadpark.no>
Christian Wattengård wrote:
> I'm trying to extract some info from a line I read from a file.
> My program looks like this:
Edited the program a bit:
> ----
#!/usr/bin/perl -w
open(FR, "< vin.htm");
my $ctr = 0;
while (<FR>){
my $t1, $t2, $t3, $t4, $t5, $t6;
#print $_;
#print "\n\n";
$t1, $t2, $t3, $t4, $t5, $t6 = $1, $2, $3, $4, $5, $6
if $_ =~ m!"-1">(.*)</td>
<td><im.*(\d).gif.>.*-1">(\d\d,\d\d)</font>.*"-1">(\w*)\sfra\s(\w*)\s-?\s?(.*)</font>!;
$ctr++;
print "Linje ".$ctr." - ";
print "1: ".$t1."\n" if $t1;
print "2: ".$t2."\n" if $t2;
print "3: ".$t3."\n" if $t3;
print "4: ".$t4."\n" if $t4;
print "5: ".$t5."\n" if $t5;
print "6: ".$t6."\n" if $t6;
}
> ----
> the wordwrap in the regex is not there in the original file ;)
>
> the lines i'm trying to read are from the file
> http://www.wattengard.no/vin.htm
>
> Have I misunderstood how the filereading works or something like that?
> The result i want should be something like:
> $t1 = winename
> $t2 = points (identified by the gif filename)
> $t3 = price
> $t4 = winetype (rødvin = red wine ;) )
> $t5 = country
> $t6 = region
>
> Christian...
------------------------------
Date: Fri, 10 Feb 2006 01:12:06 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Regex won't work
Message-Id: <4523utF4gta7U1@individual.net>
Christian Wattengård wrote:
> I'm trying to extract some info from a line I read from a file.
You may want to consider this approach:
my @wines; # array of hashes
use locale; # include characters like 'ø' in \w
my $re = qr{ # precompile the regex
>
([^<]+) # name
.*
(\d) # points
\.gif.*>
(\d+,\d\d) # price
<.*>
(\w+) # type
\sfra\s
(.*?) # area
<
}x;
open my $FR, '<', 'vin.htm' or die $! "Couldn't open: $!";
while (<$FR>) {
if (/$re/) {
push @wines, {
name => $1,
points => $2,
price => $3,
type => $4,
area => $5,
};
} else {
warn "Line $. did not match\n";
}
}
for my $wine (@wines) {
print "$wine->{name}\n",
"$wine->{points}\n",
"$wine->{price}\n",
"$wine->{type}\n",
"$wine->{area}\n\n";
}
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Thu, 9 Feb 2006 13:37:35 -0800
From: "Parth Thakker" <parth@motorola.com>
Subject: Script in Linux to access SQL Server
Message-Id: <dsgcs7$ltq$1@newshost.mot.com>
Hello,
I need to write a Perl script in Linux that needs to access a SQL Server DB,
hosted on a Windows server. Any suggestions? Can I use the DBI module to
achieve this? If so, what would be an appropriate driver (DBD-?) for it?
Will appreciate any help. Thanks.
------------------------------
Date: 09 Feb 2006 22:51:23 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: Script in Linux to access SQL Server
Message-Id: <slrndunhra.cm.abigail@alexandra.abigail.nl>
Parth Thakker (parth@motorola.com) wrote on MMMMDXLV September MCMXCIII
in <URL:news:dsgcs7$ltq$1@newshost.mot.com>:
**
** I need to write a Perl script in Linux that needs to access a SQL Server DB,
** hosted on a Windows server. Any suggestions?
Use vi.
HTH. HAND.
Abigail
--
$_ = "\x3C\x3C\x45\x4F\x54";
print if s/<<EOT/<<EOT/e;
Just another Perl Hacker
EOT
------------------------------
Date: Thu, 09 Feb 2006 17:50:08 -0600
From: "J. Gleixner" <glex_no-spam@qwest-spam-no.invalid>
Subject: Re: Script in Linux to access SQL Server
Message-Id: <QyQGf.34$u_2.2559@news.uswest.net>
Parth Thakker wrote:
> Hello,
>
> I need to write a Perl script in Linux that needs to access a SQL Server DB,
> hosted on a Windows server. Any suggestions? Can I use the DBI module to
> achieve this? If so, what would be an appropriate driver (DBD-?) for it?
>
> Will appreciate any help. Thanks.
For modules, please take a look at CPAN: http://search.cpan.org You
would likely have found your answer quite quickly. (DBD::Sybase)
Also, try searching the Internet for possible solutions to these types
of generic questions. Simply putting in 'perl "SQL Server"' returned a
lot of possible places to start.
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc. For subscription or unsubscription requests, send
#the single line:
#
# subscribe perl-users
#or:
# unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.
#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V10 Issue 8938
***************************************