[16101] in Perl-Users-Digest
Perl-Users Digest, Issue: 3513 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jun 29 18:05:49 2000
Date: Thu, 29 Jun 2000 15:05:25 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <962316324-v9-i3513@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Thu, 29 Jun 2000 Volume: 9 Number: 3513
Today's topics:
$$$$$ username <username@domainname.com>
Re: $$$$$ username <care227@attglobal.net>
Re: $$$$$ username <abe@ztreet.demon.nl>
Re: - Learn how to SPEED UP your INTERNET connection b <gellyfish@gellyfish.com>
Re: 2nd level of reference <stephen.kloder@gtri.gatech.edu>
Re: 2nd level of reference <sun_tong_001@yahoo.com>
Re: 2nd level of reference <care227@attglobal.net>
a large amount of unique numbers in an efficient way? <aahz@writeme.com>
Re: a large amount of unique numbers in an efficient wa <aqumsieh@hyperchip.com>
Re: a large amount of unique numbers in an efficient wa <stephen.kloder@gtri.gatech.edu>
ActiveState, PPM, POD's & updating HTML jgrinwal@my-deja.com
ActiveState, PPM, POD's & updating HTML jgrinwal@my-deja.com
Re: Calling perl module from C sunandavenu@my-deja.com
Re: catch error SQL (jason)
Re: cgi question <gellyfish@gellyfish.com>
Re: cgi.pm & parsing question <dmeyers@panix.com>
Re: cgi.pm & parsing question (Malcolm Dew-Jones)
Re: cgi.pm & parsing question (Malcolm Dew-Jones)
Re: Check out this site...:) <gellyfish@gellyfish.com>
concatenate two lists <gorbeast@SPAMSUCKS.subduction.org>
Re: concatenate two lists <gorbeast@SPAMSUCKS.subduction.org>
concatenating two arrays (Gorbeast)
Re: concatenating two arrays <tina@streetmail.com>
Re: Convert value to numeric <jhaiten@yahoo.com>
Re: Convert value to numeric <aqumsieh@hyperchip.com>
Re: Convert value to numeric <abe@ztreet.demon.nl>
csds_sqerl <gte941n@prism.gatech.edu>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 28 Jun 2000 12:18:21 -0700
From: "/$username/" <username@domainname.com>
Subject: $$$$$ username
Message-Id: <hCp65.1$8a.45@news1.tor.primus.ca>
How do you check for/parse special PERL characters like $,@,% from FORM
fields on a POST.
For example,
if $_ = "a$b$c$d"
and i do this..
$_=~s/\x24/""/eg; #-- Tried "$" and variations instead of \x24
I should get this;
$_="abcd"
But I don't..
Application;
I'm checking fields on a FORM.
When the client enters $$$$$ as username, it totally wreaks havoc if not
creating error.
Help apprecited...
------------------------------
Date: Thu, 29 Jun 2000 14:38:33 -0400
From: Drew Simonis <care227@attglobal.net>
Subject: Re: $$$$$ username
Message-Id: <395B97A9.AD0E1CC5@attglobal.net>
"/$username/" wrote:
>
>
> For example,
> if $_ = "a$b$c$d"
>
> and i do this..
>
> $_=~s/\x24/""/eg; #-- Tried "$" and variations instead of \x24
>
$_ =~ s/\$//g;
------------------------------
Date: Thu, 29 Jun 2000 21:27:01 +0200
From: Abe Timmerman <abe@ztreet.demon.nl>
Subject: Re: $$$$$ username
Message-Id: <en8nls4dop02k1evlkdmvqshmi6u09ocgm@4ax.com>
On Wed, 28 Jun 2000 12:18:21 -0700, "/$username/"
<username@domainname.com> wrote:
> How do you check for/parse special PERL characters like $,@,% from FORM
> fields on a POST.
>
> For example,
> if $_ = "a$b$c$d"
>
> and i do this..
>
> $_=~s/\x24/""/eg; #-- Tried "$" and variations instead of \x24
>
> I should get this;
>
> $_="abcd"
tr/$//d;
--
Good luck,
Abe
------------------------------
Date: 29 Jun 2000 23:28:36 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: - Learn how to SPEED UP your INTERNET connection by 70-100% for FREE!
Message-Id: <8jgiik$v42$1@orpheus.gellyfish.com>
On Wed, 28 Jun 2000 12:31:56 -0500 Barry Grupe wrote:
> <uyurpz@speedyinternet.com> wrote in message
> news:iIT55.93842$m5.59849@typhoon.kc.rr.com...
>> Hey,
>> Sign up at Netsetter (for free!), and it will install some free software
> that will speed up you Internet connection by 100%! It helped me a lot with
> my connection! I now download a lot faster than before, and get lower pings
> in games, which eliminates lag!
>> Read more about it on their site if you doubt it!
>> Get it here:
>> http://XXXXXXXXXXXXXX.XXX.net
>>
>
>
> Just curious, does anybody track the headers for junk like this and contact
> the offender's provider?
>
>
No this is usenet - its your responsibility. I didnt see the original
post so it wouldnt seem right complaining about it .
/J\
--
** This space reserved for venue sponsor for yapc::Europe **
<http://www.yapc.org/Europe/>
------------------------------
Date: Thu, 29 Jun 2000 14:22:31 -0400
From: Stephen Kloder <stephen.kloder@gtri.gatech.edu>
Subject: Re: 2nd level of reference
Message-Id: <395B93E7.FF6217FE@gtri.gatech.edu>
Colin Watson wrote:
> Stephen Kloder <stephen.kloder@gtri.gatech.edu> wrote:
> >* Tong * wrote:
> >> my $myformat='[]$url_title\n $url_addr\n\n $url_intro\n\n' ;
> >
> >The problem is, as soon as you declare $myformat, it contains the values
> >of the interpolated variables at that time, and cannot update.
>
> If you read the code a little more closely, those are single quotes ...
>
I saw that. I figured that the problem was printing updated variables
without retyping the string. Since his post stated that he was printing in
many different places, I presumed variables were likely to change between
prints.
------------------------------
Date: 29 Jun 2000 17:19:31 -0300
From: * Tong * <sun_tong_001@yahoo.com>
Subject: Re: 2nd level of reference
Message-Id: <sa8k8f8jl4c.fsf@sun_tong_001.personal.yahoo.com>
tadmc@metronet.com (Tad McClellan) writes:
> On 29 Jun 2000 12:26:12 -0300, * Tong * <sun_tong_001@yahoo.com> wrote:
>
> >my $myformat='[]$url_title\n $url_addr\n\n $url_intro\n\n' ;
> >
> >My question is how to use it?
>
>
> Perl FAQ, part 4:
>
> "How can I expand variables in text strings?"
Which is:
$text = 'this has a $foo in it and a $bar';
$text =~ s/\$(\w+)/${$1}/g;
Wow, I think I've hit a hard rock. This is more difficult than I
thought. No follow-ups have even come close to the answer yet.
Please note that my question is really a natual request -- define a
string which can be used at many places. Otherwise, if I want to
change the string, I have to change many places, and even many
files. The varible is actually constant in nature, I should really
say:
my $MYFORMAT='[]$url_title\n $url_addr\n $url_intro\n\n' ;
^^^^^^^^^
To apply the technic in "How can I expand variables in text
strings?", I think I need to define a nother temp variable, which
seems a burden instead of a gain to me.
Interestingly, this is not a problem at all in Tcl, in which I
merely say:
set MYFORMAT {[]$url_title\n $url_addr\n $url_intro\n\n}
and use it just as I want. puts $MYFORMAT...
Hmmm, this is the FIRST time I realize that Perl is not powerful
enough, ... erhh, unless I find a neat anwser... :-)
--
Tong (remove underscore(s) to reply)
http://members.xoom.com/suntong001/
- All free contribution & collection & music from the heavens
------------------------------
Date: Thu, 29 Jun 2000 16:45:40 -0400
From: Drew Simonis <care227@attglobal.net>
Subject: Re: 2nd level of reference
Message-Id: <395BB574.37B9D3CF@attglobal.net>
* Tong * wrote:
>
> > Perl FAQ, part 4:
> >
> > "How can I expand variables in text strings?"
>
> Which is:
>
> $text = 'this has a $foo in it and a $bar';
> $text =~ s/\$(\w+)/${$1}/g;
>
>
> To apply the technic in "How can I expand variables in text
> strings?", I think I need to define a nother temp variable, which
> seems a burden instead of a gain to me.
-------------------------------8<-----------------------------------
#!/usr/bin/perl -w
use strict;
my $url_title = 'title here';
my $url_addr = 'addr here';
my $url_intro = 'intro stuffIngs';
my $myformat="[]$url_title\n $url_addr\n\n $url_intro\n\n" ;
$myformat =~ s/\$(\w+)/${$1}/g;
print $myformat;
----------------8<---------------------------------8<--------------------
The above works for me. Changed your single quotes to double quotes.
Didn't change anything else.
------------------------------
Date: Thu, 29 Jun 2000 21:01:15 GMT
From: Andrew Collington <aahz@writeme.com>
Subject: a large amount of unique numbers in an efficient way?
Message-Id: <395BB828.B41AEACD@writeme.com>
Hi there,
What would be the most efficient way to generate a large array of random
numbers, from, say 1000 to 9999?
I could get a random number and check to see if it's above 1000, if it's
not then create another and keep doing this till I have a number above
1000. Then I would have to check through the array of already created
numbers for a match, and repeat process if there is a match. I would
have to do this 1500 times or more (having to have 1500 unique numbers
;)
This seems to me to be very inefficient so I was wondering if anyone
knew a better way to do it?
Thanks for any help!
Andy
------------------------------
Date: Thu, 29 Jun 2000 21:20:09 GMT
From: Ala Qumsieh <aqumsieh@hyperchip.com>
Subject: Re: a large amount of unique numbers in an efficient way?
Message-Id: <7ad7l05gmt.fsf@merlin.hyperchip.com>
Andrew Collington <aahz@writeme.com> writes:
> Hi there,
>
> What would be the most efficient way to generate a large array of random
> numbers, from, say 1000 to 9999?
>
> I could get a random number and check to see if it's above 1000, if it's
> not then create another and keep doing this till I have a number above
> 1000. Then I would have to check through the array of already created
> numbers for a match, and repeat process if there is a match. I would
> have to do this 1500 times or more (having to have 1500 unique numbers
> ;)
>
> This seems to me to be very inefficient so I was wondering if anyone
> knew a better way to do it?
Well, first of all, you can guarantee that your number is between 1000
and 9999 (inclusive) by the following:
int(1000 + rand 10000)
So, to generate 1500 unique numbers, one solution would be:
my $count = 0;
my %hash;
while ($count < 1500) {
my $num = int(1000 + rand 10000);
$hash{$num}++, $count++ unless exists $hash{$num};
}
To speed things up (without much memory hit), I would use an array
instead of the hash:
$array[$num]++, $count++ unless $array[$num];
--Ala
------------------------------
Date: Thu, 29 Jun 2000 17:26:06 -0400
From: Stephen Kloder <stephen.kloder@gtri.gatech.edu>
Subject: Re: a large amount of unique numbers in an efficient way?
Message-Id: <395BBEEE.9F304A73@gtri.gatech.edu>
Andrew Collington wrote:
> Hi there,
>
> What would be the most efficient way to generate a large array of random
> numbers, from, say 1000 to 9999?
>
Here's the quickest method I can think of:
1) Generate a random number < 9000
2) Add 1000 to it
3) Put it in a hash
4) repeat steps 1-3 until there are 1500 keys in the hash
On average, this method required 1640 iterations to obtain 1500 distinct
random numbers. This took about a second on my machine (a P133).
------------------------------
Date: Thu, 29 Jun 2000 19:52:21 GMT
From: jgrinwal@my-deja.com
Subject: ActiveState, PPM, POD's & updating HTML
Message-Id: <8jg9dd$ql8$1@nnrp1.deja.com>
If you have seen ActiveState ppm install packages, they usually contain
updated HTML pages. I am trying to come up with a more complete and
automated way of doing this than I have. Here are the details.
I went to CPAN to get the latest Archive-Tar, Compress-Zlib, and
Archive-Zip modules, and am building them to incorporate into my
current ActiveState development package via PPM. The HTML
documentation is helpful with nmake, tar, gzip, and nmake ppd. I have
guessed (about 80-90%) on using pod2html.bat to generate the new HTML
page. However, the pages are not completely generated.
The ActiveState pages use the stylesheet
<link rel="stylesheet" href="../../../win32prk.css" type="text/css">
and have a leaf header and footer.
<body bgcolor="#FFFFFF">
<!-- beginning of leaf header-->
<table BORDER=0 CELLSPACING=0 CELLPADDING=0 WIDTH="100%" >
<tr>
<td VALIGN=CENTER WIDTH="100%" BGCOLOR="#CC0066"><font face="sans-
serif"><font color="#FF99CC"><font size=+1>
Zip - Provide an interface to ZIP archive
files.</font></font></font></td>
</tr>
</table>
<p><!-- end of leaf content-->
Anybody have an idea how to make sure these are generated? Also,
anybody have any idea on how to make pod2html generate the other pages
that need to be updated?
Thanks,
Jim
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Thu, 29 Jun 2000 19:56:24 GMT
From: jgrinwal@my-deja.com
Subject: ActiveState, PPM, POD's & updating HTML
Message-Id: <8jg9kv$qoo$1@nnrp1.deja.com>
If you have seen ActiveState ppm install packages, they usually contain
updated HTML pages. I am trying to come up with a more complete and
automated way of doing this than I have. Here are the details.
I went to CPAN to get the latest Archive-Tar, Compress-Zlib, and
Archive-Zip modules, and am building them to incorporate into my
current ActiveState development package via PPM. The HTML
documentation is helpful with nmake, tar, gzip, and nmake ppd. I have
guessed (about 80-90%) on using pod2html.bat to generate the new HTML
page. However, the pages are not completely generated.
The ActiveState pages use the stylesheet
<link rel="stylesheet" href="../../../win32prk.css" type="text/css">
and have a leaf header and footer.
<body bgcolor="#FFFFFF">
<!-- beginning of leaf header-->
<table BORDER=0 CELLSPACING=0 CELLPADDING=0 WIDTH="100%" >
<tr>
<td VALIGN=CENTER WIDTH="100%" BGCOLOR="#CC0066"><font face="sans-
serif"><font color="#FF99CC"><font size=+1>
Zip - Provide an interface to ZIP archive
files.</font></font></font></td>
</tr>
</table>
<p><!-- end of leaf content-->
Anybody have an idea how to make sure these are generated? Also,
anybody have any idea on how to make pod2html generate the other pages
that need to be updated?
Thanks,
Jim
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Thu, 29 Jun 2000 21:16:13 GMT
From: sunandavenu@my-deja.com
Subject: Re: Calling perl module from C
Message-Id: <8jgeau$jeg$1@nnrp2.deja.com>
I would like to know if we can successfuly pass
structures to perl from C or atleast if there is
a way to get around this problem.
Thanks
In article <393EB318.A11DEDCF@attglobal.net>,
Drew Simonis <care227@attglobal.net> wrote:
> Hardy Merrill wrote:
> >
> >
> > cc -I/usr/lib/perl5/5.00503/i386-linux/CORE
> > -L/usr/lib/perl5/5.500503/i386-linux/CORE -o
myfile myfile.o
> >
> > Has anyone else been able to successfully
implement invoking a Perl
> > subroutine from a C program? What are we
missing?
> >
>
> Did you check out the documentation at:
>
>
http://www.perl.com/pub/doc/manual/html/pod/perlem
bed.html
>
> called "How to embed perl in your C program"?
>
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Thu, 29 Jun 2000 20:08:47 GMT
From: elephant@squirrelgroup.com (jason)
Subject: Re: catch error SQL
Message-Id: <MPG.13c64a0f96a9898598975d@news>
eastking@my-deja.com writes ..
>I'm using DBI and DBD::Oracle to access database. when I use following
>source
>
> $sth = $dbh->prepare("select foo, bar from table where
>baz=?");
>
> $sth->execute( $baz );
>
> while ( @row = $sth->fetchrow_array ) {
> print "@row\n";
> }
>
>If execution failed, How can I know the whole SQL with "?" replaced
>with $baz?
I don't believe that there is a way to retrieve this value from the DBI
module .. you have two options as far as I can see
first is just to check the return from your execute call and if it's an
error then print out the $dbh->errstr (which often contains all the
clues you need to debug a problem)
second is to prepare a static query .. check out the DBI::quote method
in the docs - it will prepare your data correctly for the query based on
either it's type or the type you specify
so assuming that your baz field is a VARCHAR the line of code would look
something like this
my $sql = sprintf "select foo, bar from table where baz=%s"
=> $dbh->quote( $baz, SQL_VARCHAR);
you should still check the return value from your execute call
--
jason - elephant@squirrelgroup.com -
------------------------------
Date: 30 Jun 2000 00:28:45 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: cgi question
Message-Id: <8jgm3d$b28$1@orpheus.gellyfish.com>
<fixed jeopardy quote>
On Wed, 28 Jun 2000 11:25:01 -0600 Dan Manion wrote:
> "Robin Bank" <rbank@csf.edu> wrote in message
> news:8jd7el$1c5a$2@reader.nmix.net...
>> Can someone give me an idea of how to do a user database with usename,
>> password, and login information? I have to create a PERL CGI message
>> forum where a user signs in and then is able to post messages, and
>> accounts have to be created dynamically from a sign up form. The one
>> problem I have is the fact that I don't have any sort of database
>> access on my server. All I need are suggestions are to what the best
>> options would be for this kind of system, the general implementation. I
>> can do the programming, if I know what I'm writing.
>
> Try looking at DB_File. You can grab a copy off CPAN.
>
Well they could but of course this may require the downloading of some
external libraries which will need to be built on the system before the
module can be built. If using some tied DBM style 'database' is the
soluion then the OP would be better off looking at AnyDBM_File which should
already be on their system and will choose the best available DBM they have.
/J\
--
** This space reserved for venue sponsor for yapc::Europe **
<http://www.yapc.org/Europe/>
------------------------------
Date: 29 Jun 2000 16:24:23 -0400
From: David Meyers <dmeyers@panix.com>
Subject: Re: cgi.pm & parsing question
Message-Id: <yobpup0me14.fsf@panix3.panix.com>
perl_monkey@my-deja.com writes:
> In article <8jfpu6$qhl$1@coco.singnet.com.sg>,
> "Kimochi3D" <jtalbain@nospam.kimochi3d.com> wrote:
> > I'm wondering if after getting the necessary variables from the form
> into
> > the perl script, do I need to go though (parse or check) the variables
>
> YES! You need to check them for bad UNIX commands, paricularly if you
> ever use exec() system() or the backticks (like `ls $HOME`) in your
> program with some user data.
Note, especially, that this concern includes filenames as well as
things which are explicitly external calls. Please read the
documentation which came with your perl, particularly:
man perlsec
and read about untainting variables.
--d
------------------------------
Date: 29 Jun 2000 14:31:44 -0800
From: yf110@vtn1.victoria.tc.ca (Malcolm Dew-Jones)
Subject: Re: cgi.pm & parsing question
Message-Id: <395bc040@news.victoria.tc.ca>
David Meyers (dmeyers@panix.com) wrote:
: perl_monkey@my-deja.com writes:
: > In article <8jfpu6$qhl$1@coco.singnet.com.sg>,
: > "Kimochi3D" <jtalbain@nospam.kimochi3d.com> wrote:
: > > I'm wondering if after getting the necessary variables from the form
: > into
: > > the perl script, do I need to go though (parse or check) the variables
: >
: > YES! You need to check them for bad UNIX commands, paricularly if you
: > ever use exec() system() or the backticks (like `ls $HOME`) in your
: > program with some user data.
: Note, especially, that this concern includes filenames as well as
: things which are explicitly external calls. Please read the
: documentation which came with your perl, particularly:
: man perlsec
: and read about untainting variables.
If you aren't extremely clear about what's unsafe and why then tainting
will not solve your problem (though it should be left on for safety).
The general strategy for tainting in this situation is to parse all input
to make is safe before you use it. Tainting checks that you haven't
forgotten to parse the input, but this doesn't mean that you've parsed it
correctly, and therefore doesn't mean the data is safe.
You should instead try to find a way to predefine all the tasks that a
user could perform and code those tasks into your application, and only
let the user pick the actions as some kind of choice. The script then
just has to check that the user has selected one of the predefined and
completely tested options, and then run the selected option.
For example, if the script should send email then the script should define
all the possible receipients and only give the user an option to send
to those people.
e.g.
$mail_to = param('MAIL_TO');
$mail_body = param('USER_INPUT');
my $help_desk_mail = 'fred,sally,help_desk';
my $managers_mail = 'manager_list';
if ($mail_to eq 'HELP_DESK')
{
send_mail_to($help_desk_mail,$mail_body);
}elsif
($mail_to eq 'MANAGER')
{
send_mail_to($managers_mail,$mail_body);
}else
{
maybe_send_error_message_to_someone();
send_back_to_user('that wasn't an option on the list');
}
This isn't a well coded example, but shows what I mean.
------------------------------
Date: 29 Jun 2000 15:01:10 -0800
From: yf110@vtn1.victoria.tc.ca (Malcolm Dew-Jones)
Subject: Re: cgi.pm & parsing question
Message-Id: <395bc726@news.victoria.tc.ca>
Malcolm Dew-Jones (yf110@vtn1.victoria.tc.ca) wrote:
: David Meyers (dmeyers@panix.com) wrote:
: : perl_monkey@my-deja.com writes:
: : > In article <8jfpu6$qhl$1@coco.singnet.com.sg>,
: : > "Kimochi3D" <jtalbain@nospam.kimochi3d.com> wrote:
: : > > I'm wondering if after getting the necessary variables from the form
: : > into
: : > > the perl script, do I need to go though (parse or check) the variables
: : >
: : > YES! You need to check them for bad UNIX commands, paricularly if you
: : > ever use exec() system() or the backticks (like `ls $HOME`) in your
: : > program with some user data.
: : Note, especially, that this concern includes filenames as well as
: : things which are explicitly external calls. Please read the
: : documentation which came with your perl, particularly:
: : man perlsec
: : and read about untainting variables.
: If you aren't extremely clear about what's unsafe and why then tainting
: will not solve your problem (though it should be left on for safety).
: The general strategy for tainting in this situation is to parse all input
: to make is safe before you use it. Tainting checks that you haven't
: forgotten to parse the input, but this doesn't mean that you've parsed it
: correctly, and therefore doesn't mean the data is safe.
: You should instead try to find a way to predefine all the tasks that a
: user could perform and code those tasks into your application, and only
: let the user pick the actions as some kind of choice. The script then
: just has to check that the user has selected one of the predefined and
: completely tested options, and then run the selected option.
: For example, if the script should send email then the script should define
: all the possible receipients and only give the user an option to send
: to those people.
: e.g.
: $mail_to = param('MAIL_TO');
: $mail_body = param('USER_INPUT');
: my $help_desk_mail = 'fred,sally,help_desk';
: my $managers_mail = 'manager_list';
: if ($mail_to eq 'HELP_DESK')
: {
: send_mail_to($help_desk_mail,$mail_body);
: }elsif
: ($mail_to eq 'MANAGER')
: {
: send_mail_to($managers_mail,$mail_body);
: }else
: {
: maybe_send_error_message_to_someone();
: send_back_to_user('that wasn't an option on the list');
: }
: This isn't a well coded example, but shows what I mean.
I forgot to mention the safe module. I don't remember the name but it lets
you control the operations that are allowed. If the user's data causes
your script to do anything unexpected then you get an error.
------------------------------
Date: 30 Jun 2000 00:40:00 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Check out this site...:)
Message-Id: <8jgmog$d7a$1@orpheus.gellyfish.com>
On Thu, 29 Jun 2000 03:01:00 GMT akashgoel@my-deja.com wrote:
> Hi,
> The Links Archive (http://tla.swo.net) is a comprehensive database of
Werent you closed down for abuse already ?
/J\
--
** This space reserved for venue sponsor for yapc::Europe **
<http://www.yapc.org/Europe/>
------------------------------
Date: Thu, 29 Jun 2000 12:32:14 -0700
From: Gurujiwan <gorbeast@SPAMSUCKS.subduction.org>
Subject: concatenate two lists
Message-Id: <395BA43E.BCEC095D@SPAMSUCKS.subduction.org>
Hi there
I am trying to join the contents of '@emails' with only 1 element of
<DATA>. The script I have worked out below does it with ALL of them. I
cant figure it out. If you could help that would be very nice. Thanks,
G
--
#!/usr/bin/perl
while (<DATA>) {
@emails = ("foo\@bar.com", "bar\@foo.com", "no\@email.address") ;
$emails_ref = \@emails;
foreach $email (@$emails_ref) {
print "$email\n";
print; # (<DATA>);
}
}
__DATA__
line1
line2
line3
------------------------------
Date: Thu, 29 Jun 2000 12:41:23 -0700
From: Gurujiwan <gorbeast@SPAMSUCKS.subduction.org>
Subject: Re: concatenate two lists
Message-Id: <395BA662.E5020BF8@SPAMSUCKS.subduction.org>
I just realized what I said below is misleading. What I'm hoping for is :
email
line1
email2
line2
email3
line3
..and so on
Gurujiwan wrote:
> Hi there
>
> I am trying to join the contents of '@emails' with only 1 element of
> <DATA>. The script I have worked out below does it with ALL of them. I
> cant figure it out. If you could help that would be very nice. Thanks,
> G
>
> --
>
> #!/usr/bin/perl
> while (<DATA>) {
> @emails = ("foo\@bar.com", "bar\@foo.com", "no\@email.address") ;
> $emails_ref = \@emails;
> foreach $email (@$emails_ref) {
> print "$email\n";
> print; # (<DATA>);
> }
> }
>
> __DATA__
> line1
> line2
> line3
--
"If I had one wish, I would ask for a big enough ass for the whole world to
kiss."
--Marshall Mathers
------------------------------
Date: Thu, 29 Jun 2000 20:46:04 GMT
From: gorbeast@SPAMSUX.subduction.org (Gorbeast)
Subject: concatenating two arrays
Message-Id: <gAO65.16192$NP5.384657@newsread2.prod.itd.earthlink.net>
{{{{Sorry if I posted twice}}}}
I am trying to combine two lists. I am trying to use the simplest way that
I know of, although I am sure there is a better way. If you can help, that
would be great. Thanks
What I want is :
email_1
line1
email_2
line2
email_3
line3
here is the code:
---------------------------------------------------------------------------
#!/usr/bin/perl
while (<DATA>) {
@emails = ("foo\@bar.com", "bar\@foo.com", "no\@email.address") ;
$emails_ref = \@emails;
foreach $email (@$emails_ref) {
print "$email\n";
print; # (<DATA>);
}
}
__DATA__
line1
line2
line3
line4
---------------------------------------------------------------------------
what I get is
email_1
line1
email_1
line2
email_1
line3
email_2
line1
email_2
line2
...and so on for the rest of them. If you know a better, correct way, let
me know. Thanks!
------------------------------
Date: 29 Jun 2000 22:02:58 GMT
From: Tina Mueller <tina@streetmail.com>
Subject: Re: concatenating two arrays
Message-Id: <8jgh2i$hpuv$1@ID-24002.news.cis.dfn.de>
Gorbeast <gorbeast@spamsux.subduction.org> wrote:
> {{{{Sorry if I posted twice}}}}
> I am trying to combine two lists. I am trying to use the simplest way that
> I know of, although I am sure there is a better way. If you can help, that
> would be great. Thanks
> What I want is :
> email_1
> line1
> email_2
> line2
> email_3
> line3
> #!/usr/bin/perl
#!/usr/bin/perl -w
> while (<DATA>) {
> @emails = ("foo\@bar.com", "bar\@foo.com", "no\@email.address") ;
> $emails_ref = \@emails;
why the reference?
> foreach $email (@$emails_ref) {
> print "$email\n";
> print; # (<DATA>);
> }
> }
> __DATA__
> line1
> line2
> line3
> line4
here's one way:
while (<DATA>) {
@emails = ("foo\@bar.com", "bar\@foo.com", "no\@email.address") ;
print $emails[$.-1]."\n";
print; # (<DATA>);
}
but you have to make sure that there are n lines in
DATA and n elements in @emails, because otherwise you will
get an error ("Use of uninitialized value at ...")
tina
--
http://tinita.de \ enter__| |__the___ _ _ ___
tina's moviedatabase \ / _` / _ \/ _ \ '_(_-< of
search & add comments \ \ _,_\ __/\ __/_| /__/ perception
"The Software required Win98 or better, so I installed Linux."
------------------------------
Date: Wed, 28 Jun 2000 17:38:46 -0700
From: "Dr. Jeffrey Haiten" <jhaiten@yahoo.com>
Subject: Re: Convert value to numeric
Message-Id: <ggu65.154$ph.665@news2.tor.primus.ca>
> We can tell (because nobody calls it "PERL").
# newbie_semantics.pl
# Saves time when condescending "newbies"
# job security by lingustic obscurity.
# usage
# print "What language?";
# $in=<STDIN>
# &checkLangProper($in)
sub checkLangProper{
local ($out);
if ($_=~/"PERL"/){
# Condescend here;
$out = "Perl" is used to refer to the language proper.\n";
$out .= "\"perl\" is used to refer to the implementation of the
language\n";
$out ..= "(the interpreter).\n";
$out .= "\"PERL\" is not used\n.";
return $out;
}
}
------------------------------
Date: Thu, 29 Jun 2000 18:53:35 GMT
From: Ala Qumsieh <aqumsieh@hyperchip.com>
Subject: Re: Convert value to numeric
Message-Id: <7avgys5nf2.fsf@merlin.hyperchip.com>
"Dr. Jeffrey Haiten" <jhaiten@yahoo.com> writes:
> > We can tell (because nobody calls it "PERL").
>
> # newbie_semantics.pl
> # Saves time when condescending "newbies"
> # job security by lingustic obscurity.
> # usage
> # print "What language?";
> # $in=<STDIN>
> # &checkLangProper($in)
>
> sub checkLangProper{
> local ($out);
why local()? why not my()?
> if ($_=~/"PERL"/){
Where did the value for $_ come from?
In you comments above, you assign what you read to $in. $_ is not used
anywhere. I guess you meant $_[0]?
Moreover, what are those quotes doing there? Those will be matched
verbatim; this is not sed.
> # Condescend here;
> $out = "Perl" is used to refer to the language proper.\n";
The above generates a syntax error since your second quotes surround
'Perl' match the opening quotes and terminate the string.
> $out .= "\"perl\" is used to refer to the implementation of the
> language\n";
Here you escape the quotes. Why didn't you do that in the line before?
> $out ..= "(the interpreter).\n";
What are the two dots supposed to mean? Or do you mean only 1 dot?
> $out .= "\"PERL\" is not used\n.";
Perhaps you should learn to use here-docs.
> return $out;
> }
> }
And did you every try this code of yours?
Please don't post code that doesn't compile, even if it's a silly
example like that. You might actually confuse some newbies more than
help them.
--Ala
------------------------------
Date: Thu, 29 Jun 2000 21:22:55 +0200
From: Abe Timmerman <abe@ztreet.demon.nl>
Subject: Re: Convert value to numeric
Message-Id: <027nlsgvj0n9lpbtjjkmnmrjiio3760vm8@4ax.com>
On Wed, 28 Jun 2000 17:38:46 -0700, "Dr. Jeffrey Haiten"
<jhaiten@yahoo.com> wrote:
Did you actually test this? Did you use copy/paste to copy it into your
message?
#!/usr/bin/perl -w
use strict;
are missing.
> # newbie_semantics.pl
> # Saves time when condescending "newbies"
> # job security by lingustic obscurity.
> # usage
Gives syntax errors when the next three lines are uncommented.
> # print "What language?";
> # $in=<STDIN>
my $in = <STDIN>;
> # &checkLangProper($in)
You might want to do something with that result:
print checkLangProper($in);
>
> sub checkLangProper{
> local ($out);
In Perl5 you don't have to use local(), use my()
perldoc perlfaq7
You don't need it anyway.
> if ($_=~/"PERL"/){
$_ never got a value, so the match won't occur (the warning will
though). If $_ were the variable for the match, you wouldn't have to
mention it in the first place.
I'm not too happy with the regex aswell:
if ( $_[0] =~ /\bPERL\b/ ) {
> # Condescend here;
> $out = "Perl" is used to refer to the language proper.\n";
^^^^^^
Oops, got the quoting wrong.
> $out .= "\"perl\" is used to refer to the implementation of the
> language\n";
> $out ..= "(the interpreter).\n";
^^
Oops, the dot got stuck on your keyboard.
> $out .= "\"PERL\" is not used\n.";
> return $out;
And all that, where you could have used a HERE doc:
return <<EOSTORY;
"Perl" is used to refer to the language proper.
"perl" is used to refer to the implementation of the language (the
interpreter).
"PERL" is not used.
EOSTORY
--
Good luck,
Abe
------------------------------
Date: 29 Jun 2000 19:34:58 GMT
From: Benjamin David Garrison <gte941n@prism.gatech.edu>
Subject: csds_sqerl
Message-Id: <8jg8d2$s20$1@news-int.gatech.edu>
is there a way to extract a table from a "describe" statement using the
sql() command in sqerl? I'm trying to get a description of all of the
tables in a database. If I try
&sql("declare my_cursor cursor for describe $tablename"); and then try to
fetch the data out, it doesn't do anything. it doesn't give me an error,
it just doesn't fetch data out.
--
Ben Garrison * ICQ#20300203 * IM ben628496 * www.ben.f2s.com
Dilbert: "Why does it seem as though I am the only honest guy on earth?"
Dogbert: "Your type tends not to reproduce."
------------------------------
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 V9 Issue 3513
**************************************