$a = 1;
@b = (1,2,3,4);
$i = grep(/$a/,@b);
print "in array" if $i > 0;
> -Original Message-
> From: Alex Cheung Tin Ka [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, September 26, 2002 5:00 PM
> To: [EMAIL PROTECTED]
> Subject: how to check variable in list
>
>
> Dear All,
> I woul
Dear All,
I would like to know how to check whether a variable exists in an array
here is my code
$a = 1;
@b = (1,2,3,4);
Regards.
Alex
This should work
split(/[;\/]+/,$authors[$x])
Shaun Bramley wrote:
> I have data that for some god foresaken reason is using two or three methods
> of delimitting names. Some are delimitted using '//' others with ';'.
>
> I have tried using @names = split( /(;)|(\/\/)/, $authors[$x]); howeve
Does this work?
split(/(;|\/+)/,$authors[$x])
-Original Message-
From: Shaun Bramley [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, September 25, 2002 10:01 PM
To: [EMAIL PROTECTED]
Subject: Help with regular expressions within a split statement
I have data that for some god foresaken re
I have data that for some god foresaken reason is using two or three methods
of delimitting names. Some are delimitted using '//' others with ';'.
I have tried using @names = split( /(;)|(\/\/)/, $authors[$x]); however
this doesn't have the intended result.
Is this possible? or am I doing som
On Wed, Sep 25, 2002 at 06:51:14PM -0500, James Edward Gray II wrote:
> On Wednesday, September 25, 2002, at 05:08 PM, Michael Fowler wrote:
> >I looked for telnet servers and found a few things. There's an OurNet
> >namespace for some sort of BBS system, and an Anarres::Mud::Driver
> >namespac
On Wed, Sep 25, 2002 at 10:11:25PM -0500, rob wrote:
> ppm
> then help
>
> ppm is perl package managment. This downloads and installs modules for you
> (but you have to know what you're interested in)
It should be noted that ppm is specific to an ActivePerl install. If you're
not using ActiveP
Steve wrote:
>Hey everyone, I've downloaded some scripts and I wanna mess with 'em and
>use 'em and see how they work but I can't find a place to download the
>modules specified in the scripts I've tried google, and CPAN shows
>me the list and links to the descriptions but I haven't been able
[EMAIL PROTECTED] wrote:
>
> Hi, i have a web application and
> i wonder if there is a way to get server date from ? client with perl?
> because i can't do it in javascript.
$ perldoc -f localtime
E.g.
$ perl -le 'print scalar localtime'
Wed Sep 25 22:33:01 2002
--
Steve
perldoc -qa.
Hey everyone, I've downloaded some scripts and I wanna mess with 'em and
use 'em and see how they work but I can't find a place to download the
modules specified in the scripts I've tried google, and CPAN shows
me the list and links to the descriptions but I haven't been able to
find simply a
Bob Showalter wrote:
> http://www.cpan.org/modules/by-module/Silly/
oh my god! i don't really mean to insult whoever wrote the module. i am just
using it as an example. :)
david
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
[EMAIL PROTECTED] wrote:
> Hello, All:
>
> When using...
>
> while ($x = readdir(DH)) {
> # What came before $x?
> # What will come after $x?
> }
>
> How can I look at the next item in the directory?
>
i don't really know what you mean by before or after. directoris are not
really in any or
- Original Message -
From: "david" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, September 25, 2002 6:37 PM
Subject: Re: My First Module Advice
> ...
> having said that, i do not mean that anyone should write a silly module
and
> submit it to CPAN
Heck, there's even a nam
- Original Message -
From: <[EMAIL PROTECTED]>
To: "Beginners Perl Mailing List" <[EMAIL PROTECTED]>
Sent: Wednesday, September 25, 2002 3:33 AM
Subject: Looping through readdir()
> Hello, All:
>
> When using...
>
> while ($x = readdir(DH)) {
> # What came before $x?
> # What will come a
James Edward Gray II wrote:
> On Wednesday, September 25, 2002, at 05:37 PM, david wrote:
>
>> bug, more efficient, more portable, etc. who knows maybe James' module
>> is
>> more efficient than the already exist CPAN module, maybe it's more
>> portable, maybe it's easier to use, maybe it has l
On Wednesday, September 25, 2002, at 05:37 PM, david wrote:
> bug, more efficient, more portable, etc. who knows maybe James' module
> is
> more efficient than the already exist CPAN module, maybe it's more
> portable, maybe it's easier to use, maybe it has less or no bug, so
> even
> there al
On Wednesday, September 25, 2002, at 05:08 PM, Michael Fowler wrote:
> You mention your module is a telnet server. Is that accurate? Does it
> actually understand the telnet protocol?
It is accurate, yes. It includes a basic Telnet implementation that
denies most options, and handles things
On Wed, Sep 25, 2002 at 03:37:51PM -0700, david wrote:
> a lot of modules in CPAN have overlap functionality. they exist solely
> for the users' benefit.
It depends on the module, and for many of the modules that may be true. But
there is another reason there are overlapping modules on CPAN: the
Hello, All:
When using...
while ($x = readdir(DH)) {
# What came before $x?
# What will come after $x?
}
How can I look at the next item in the directory?
--
Eric P.
Sunnyvale, CA
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED
On Wed, Sep 25, 2002 at 05:33:42PM -0400, Tanton Gibbs wrote:
> Here is how to do it in mysql
> http://www.mysql.com/doc/en/Cast_Functions.html
Have you tried it on the type of data the original poster was mentioning?
I'm suspecting it's going to have a problem when trying to cast "1b" as a
numb
Michael Fowler wrote:
> On Wed, Sep 25, 2002 at 03:34:26PM -0500, James Edward Gray II wrote:
>> '2.1 Do similar modules already exist in some form?'
> [snip]
>> My newly coded module is a Multiplexed Non-blocking I/O Telnet Server.
>> It was written with an eye towards serving MUDs, MUSHes, and
Shaun Bramley wrote at Wed, 25 Sep 2002 22:24:00 +0200:
> I'm just looking for some confirmation on my regx.
>
> I have a list ('1992', '1993 (summer)', '1995 fall') and what I want to do
> is keep only the first four characters. Will the regx work for me?
>
> @list =~ s/\s*//;
>
> Again will
John Almberg wrote at Wed, 25 Sep 2002 22:17:57 +0200:
> I'm trying to sort a SQL table that contains a character-type field that
> contains mostly numbers. This field always contains either a number or a
> number followed by a character. Like '57' or '57a'.
>
> I'd like to sort the table *numer
Shaun Bramley wrote:
> Hi all,
>
> I'm just looking for some confirmation on my regx.
>
> I have a list ('1992', '1993 (summer)', '1995 fall') and what I want to do
> is keep only the first four characters. Will the regx work for me?
>
> @list =~ s/\s*//;
>
> Again will that turn the list in
On Wed, Sep 25, 2002 at 03:34:26PM -0500, James Edward Gray II wrote:
> '2.1 Do similar modules already exist in some form?'
[snip]
> My newly coded module is a Multiplexed Non-blocking I/O Telnet Server.
> It was written with an eye towards serving MUDs, MUSHes, and similar
> games, because th
Here is how to do it in mysql
http://www.mysql.com/doc/en/Cast_Functions.html
- Original Message -
From: "John Almberg" <[EMAIL PROTECTED]>
To: "Beginners" <[EMAIL PROTECTED]>
Sent: Wednesday, September 25, 2002 5:21 PM
Subject: RE: How to sort a character-type field, numerically
> Well
On Wed, Sep 25, 2002 at 04:17:57PM -0400, John Almberg wrote:
> I'm trying to sort a SQL table that contains a character-type field that
> contains mostly numbers. This field always contains either a number or a
> number followed by a character. Like '57' or '57a'.
>
> I'd like to sort the table
Well, right now I'm doing the sort in SQL. That's the problem. Since its a
character-type field, I can't get MySQL to sort properly.
I guess I could use DBI::fetchall_arrayref to fetch all the data at once,
then sort the array of records the way I need them. However, what I'm hoping
for is some S
You should be able to sort it numerically if I understand where the
data is coming from. Could you provide a snippet of the code and from there
it should not be that hard to provide code to sort numerically.
Wags ;)
-Original Message-
From: John Almberg [mailto:[EMAIL P
Howdy:
(Warning: Questions require background, so this is a touch long.
Sorry about that.)
Okay, I've written, debugged, documented, etc a module. I think it
turned out well and might even be worth submitting to the CPAN. I'm
reading through the 'Guidelines for Module Creation' now, to se
> -Original Message-
> From: Shaun Bramley [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, September 25, 2002 4:24 PM
> To: [EMAIL PROTECTED]
> Subject: Help with regular expression
>
>
> Hi all,
>
> I'm just looking for some confirmation on my regx.
>
> I have a list ('1992', '1993 (sum
Nope..this won't work. Why don't you loop over the list and do a substring or pack as
you know that you need to keep only the first 4 characters of each element?
-Original Message-
From: Shaun Bramley [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, September 25, 2002 4:24 PM
To: [EMAIL PROTE
Hi all,
I'm just looking for some confirmation on my regx.
I have a list ('1992', '1993 (summer)', '1995 fall') and what I want to do
is keep only the first four characters. Will the regx work for me?
@list =~ s/\s*//;
Again will that turn the list into (1992, 1993, 1995)?
as always thank y
I'm trying to sort a SQL table that contains a character-type field that
contains mostly numbers. This field always contains either a number or a
number followed by a character. Like '57' or '57a'.
I'd like to sort the table *numerically* on this field, not *alphabetically*
on this field. That is
On Wed, Sep 25, 2002 at 11:17:18AM -0500, Wagner, David --- Senior Programmer Analyst
--- WGO wrote:
> Because the | is part of the regex which allows for (a|b|c| which
> says if a or b or c.
Also known as alternation.
> So what you have is basically I believe null or null which comes do
That works but I want to add some additional text at the bottom of
the image in the bottom margin area. And at times an overlay of text.
When I use the function I get "Not a GD::Image object"
-pete
-Original Message-
From: david [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, September 25,
On Wed, Sep 25, 2002 at 10:23:28AM +0700, Hengky wrote:
> i've already using a pop3 like Net::POP3 or even create a open port to
> listen.
Net::POP3 is for connecting to a POP3 daemon, and "create a open port"
sounds like you're trying to write a POP3 daemon. Which is it, are you the
client, or
On Tue, Sep 24, 2002 at 07:49:24PM -0300, Bruno Negrao wrote:
> #!/usr/bin/perl -w
Where's use strict?
> dbmopen(%a,"testdb",0666) || die "couldn't create/access the file $!";
> $a = $b = 0;
> until ($a < 20){# create items in the testdb.db file
This loop will never run. $a == 0, whic
I'm trying to write a perl script that creates a user name and password
for new users on a Solaris 8 box. I'm wondering if there's an easy way to
send a pregenerated password to the passwd command in a perl script.
Something like:
system("passwd",$uname,"< $generatedpassword");
Thanks.
--
Thanks for your help.
I rewrote it using a mix of your suggestions and it works fine now.
FYI: The 'chomp' statement was eliminating the '/n' so the pattern match
was not occuring. That's fixed now too.
Tom.
"Thomas 'Gakk' Summers" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[
Thomas 'Gakk' Summers wrote:
>
> Warning: Perl Novice Alert!
>
> I'm trying to:
> 1. read in a list of files,
> 2. test for text,
> 3. convert the text files from '\n' unix to '\r\n' dos
> 4. write them to a temporary location.
>
> The code below produces an error: 'Use of uninitialized value i
Dan wrote:
> I've managed to get SQL working now. Just one query. How can I get perl to
> create a new table? I have the table's name set in $acctab, this is what i
> have, but it doesn't work.. how so?
what's the error? any error message? perhaps you don't have permission?
>
> my $sth = $dbh
on Wed, 25 Sep 2002 17:16:19 GMT, Dan wrote:
> I've managed to get SQL working now. Just one query. How can I get
> perl to create a new table? I have the table's name set in $acctab,
> this is what i have, but it doesn't work.. how so?
Try
$dbh->do("CREATE ...");
--
felix
--
To uns
Sean Sugrue wrote:
>
> I am trying to create a hash that takes an xml input from a file retrieves
> all lines
> that has the word test_number in it, splits it to retrieve the actual test
> number and then
> when the hash is populated "while" through it and print out the keys and
> values. I don'
I've managed to get SQL working now. Just one query. How can I get perl to
create a new table? I have the table's name set in $acctab, this is what i
have, but it doesn't work.. how so?
my $sth = $dbh->prepare(" CREATE TABLE $acctab ( uid mediumint(10) NOT
NULL, nick varchar(30) NOT NULL, ulevel
Bob Showalter wrote:
> A more idiomatic way to write this is:
>
>for my $i (0 .. @files) {
>
you probably mean:
for my $i (0 .. $#files){
}
the range operator is inclusive.
david
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
There is a modeule XML::Parser ..something like this which you can look into.
You can also write your code as
open(XML, "x") || die("Cannot open file \n");
my $i = 1;
my %hash_try;
while() {
chomp;
if (/test_number/) {
/<(test_number)>(.*?)<\/(\1)>/;
if (defined $2) {
$hash_try{$i}
You have a number of things missing. The group will tell you to use
warnings and strict. This would have highlighted a number of items.
Here is the snippet of code using __DATA__ for the data:
my @test_number = ();
my $i= 0;
my %hast_try = ();
while() {
if ( /test_numbe
Pete Lancashire wrote:
> My brain is blocking something really simple here.
>
> What I want to do is add a block of text to
> a image created as
>
> my $graph = new GD::Graph::pie(1200, 1200);
>
> Could someone show me an example of adding a
> wrapbox of text to this image ?
>
have you tr
I am trying to create a hash that takes an xml input from a file retrieves all
lines
that has the word test_number in it, splits it to retrieve the actual test
number and then
when the hash is populated "while" through it and print out the keys and values.
I don't really have a good grasp of how
I see. Thanks!
Sean
-Original Message-
From: Rowe, Sean D. [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, September 25, 2002 10:53 AM
To: [EMAIL PROTECTED]
Subject: Problem with split
I have a string that is delimited by the '|' character. I pass this string
to a sub, and within the sub
Peter,
The openX() funcs are *nix based, and NT is very different in these
areas, so my code probably won't help much, and may take you down the
long and winding road 8-((.
All our automation is nix based for reliability and manageability
- you might consider a Linux box 8-)? but that is an ev
Because the | is part of the regex which allows for (a|b|c| which
says if a or b or c. So what you have is basically I believe null or null
which comes down to split(,$_[1]). What you want would be to escape the |
like \|, so you would have split(/\|/, $_[1]);
Wags ;) ps My terminology
I have a string that is delimited by the '|' character. I pass this string
to a sub, and within the sub I break it apart using split
my @Array = split(/|/, $_[1]);
When I print out the array, I find that split has broken the string apart
character by character, and not by the delimiter.
Thanks for your quick response.
> while () {
> chomp;
> s/\n/\r\n/g; # Need to see if this works. I think, it should work.
> print oFH;
> }
>> close oFH;
>> close iFH;
>> $files[$i] = "$tmpfile$i";
>Don't know why you are doing this ??
I was going to read
>If *nix, look at help for the open3 function. Attached as a text file is
>
>the little run class that I use to do this.
>
>Here is an example of how to use this class to encapsulate GPG, where
>the passphrase gets written to stdin of the child process, and the
>results are reaped from the child
-Original Message-
From: Thomas 'Gakk' Summers [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, September 25, 2002 8:34 AM
To: [EMAIL PROTECTED]
Subject: File testing
>Warning: Perl Novice Alert!
>I'm trying to:
>1. read in a list of files,
>2. test for text,
>3. convert the text files from
From: Ramprasad A Padmanabhan <[EMAIL PROTECTED]>
> Cant I tweak perldoc so that it allows me to run as root
> Everytime I want to refer to perldoc I have to su as some other user
> which is time wasting
>
> Ram
You should spend as little time as root as possible!
Besides ... you can't have tw
From: "William Martell" <[EMAIL PROTECTED]>
> I am trying to install this module for mysql and I am having trouble
> with it. I have included my makefile record and the error message I
> am receiving for your review.
>
> I would appreciate any help anyone can offer me. Thank y
> -Original Message-
> From: Thomas 'Gakk' Summers [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, September 25, 2002 8:34 AM
> To: [EMAIL PROTECTED]
> Subject: File testing
>
>
> Warning: Perl Novice Alert!
>
> I'm trying to:
> 1. read in a list of files,
> 2. test for text,
> 3. convert
On Sep 25, Adriano Allora said:
>use Text::ParseWords;
Why are you using this module if you're not ACTUALLY using it?
>$folder = "pathname";
>opendir(KART, $folder);
>foreach (readdir(KART)){
> if(grep /\.txt$/, $_){
You probably just want
if (/\.txt$/) { ... }
here. It's simpler.
> -Original Message-
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, September 25, 2002 8:52 AM
> To: [EMAIL PROTECTED]
> Subject: Programming pipes to and from another program
>
> ...
> Is there a simple (or even complex) way to open a two way
> pipe to another
>
Warning: Perl Novice Alert!
I'm trying to:
1. read in a list of files,
2. test for text,
3. convert the text files from '\n' unix to '\r\n' dos
4. write them to a temporary location.
The code below produces an error: 'Use of uninitialized value in -f at...'
in line 2.
I must misunderstand the u
If *nix, look at help for the open3 function. Attached as a text file is
the little run class that I use to do this.
Here is an example of how to use this class to encapsulate GPG, where
the passphrase gets written to stdin of the child process, and the
results are reaped from the childs stder
Hi there,
I hope this is a trivial newbie problem:
I know how to open a pipe to another program:
open (OUT, "|perl .\\bogus.pl") or warn "Unable to open pipe to
bogus.pl\n";
print OUT "Stuff\n";
And I know how to open a pipe from another program:
open (IN, "perl .\\bogus.pl|")
Hi, i have a web application and
i wonder if there is a way to get server date from à client with perl?
because i can't do it in javascript.
Thanks for your tips.
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
I dont know why but in my case also foreach ( readdir(...) ) didnt
work.
try
while( $eachfile = readdir( KART ){
.
}
This worked in my case.
-Rohit
Adriano Allora wrote:
> Hi to all,
> I need a script to open all the files in a directory and count all the
> words of them, but it do
on Wed, 25 Sep 2002 10:13:45 GMT, [EMAIL PROTECTED] (Adriano
Allora) wrote:
> Hi to all,
> I need a script to open all the files in a directory and count all
> the words of them, but it doesn't work:
> $folder = "pathname";
> opendir(KART, $folder);
> foreach (readdir(KART)){
> if(grep /\.
Adriano Allora wrote:
>
> Hi to all,
Hello,
> I need a script to open all the files in a directory and count all the
> words of them, but it doesn't work:
>
> use Text::ParseWords;
> $folder = "pathname";
> opendir(KART, $folder);
> foreach (readdir(KART)){
> if(grep /\.txt$/, $_){
> $
Arg!! Sorry, I really should have read the question more carefully.
while ($file = ) {
open FH, $file or die $!;
local $total;
while () {
$total += split /\S+/, $_ ; --$total;
}
print "In the file $file there are $total words\n";
}
--
print`$^Xdoc -qj`=~/"(.*)"/
--
On Wed, 25 Sep 2002 20:32:07 +1000
Robert Rendler <[EMAIL PROTECTED]> wrote:
> I don't know how accurate this may be:
Bit of testing and it seems kinda accurate, shortened it anyways.
while () {
open FH, $_ or die $!;
while () {
$total += scalar split /\S+/, $_; --$total
}
On Wed, 25 Sep 2002 12:13:45 +0200
Adriano Allora <[EMAIL PROTECTED]> wrote:
> Hi to all,
> I need a script to open all the files in a directory and count all the
> words of them, but it doesn't work:
>
>
> use Text::ParseWords;
> $folder = "pathname";
> opendir(KART, $folder);
> foreach (readd
on a linux / unix box:
alias perldoc='perldoc -U'
R
-Original Message-
From: Ramprasad A Padmanabhan [mailto:[EMAIL PROTECTED]]
Sent: 25 September 2002 11:01
To: [EMAIL PROTECTED]
Subject: perldoc as root
Cant I tweak perldoc so that it allows me to run as root Everytime I
want to r
Hi to all,
I need a script to open all the files in a directory and count all the
words of them, but it doesn't work:
use Text::ParseWords;
$folder = "pathname";
opendir(KART, $folder);
foreach (readdir(KART)){
if(grep /\.txt$/, $_){
$filename = "$_";
open(INPUT, $filename); this
Cant I tweak perldoc so that it allows me to run as root
Everytime I want to refer to perldoc I have to su as some other user
which is time wasting
Ram
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
On Tue, 24 Sep 2002, Josh wrote:
> The error message is as follows
> In string, @63 now must be written as \@63 at -e line 1, near "#foo-bar
> Target[789]:
> 1.3.6.1.2.1.10.32.2.1.7.57.789&1.3.6.1.2.1.10.32.2.1.9.57.789:SNMPSTRING@IP"
> Execution of -e aborted due to compilation errors.
>
> The
> -Original Message-
> From: Bruno Negrao [mailto:[EMAIL PROTECTED]]
> Sent: 24 September 2002 23:49
> To: [EMAIL PROTECTED]
> Subject: dbmopen doesn't work
>
>
> Hi all,
> Could someone say to me why this program doesn't run? (it
> doesn't print the database values)
>
> #!/usr/bin/p
The error message is as follows
In string, @63 now must be written as \@63 at -e line 1, near "#foo-bar
Target[789]:
1.3.6.1.2.1.10.32.2.1.7.57.789&1.3.6.1.2.1.10.32.2.1.9.57.789:SNMPSTRING@IP"
Execution of -e aborted due to compilation errors.
The code is as follows, but well, the @ is escaped s
Hi all,
Could someone say to me why this program doesn't run? (it doesn't print the database
values)
#!/usr/bin/perl -w
dbmopen(%a,"testdb",0666) || die "couldn't create/access the file $!";
$a = $b = 0;
until ($a < 20){# create items in the testdb.db file
$a{key$a} = $b;
$a = $b
Hello All,
I am trying to install this module for mysql and I am having trouble with
it. I have included my makefile record and the error message I am receiving
for your review.
I would appreciate any help anyone can offer me. Thank you very much for
your assistance. Have a great day.
Willia
Lots of good answers so far about using arrays, hashes etc, so
won't bother going there... look below to see an OOP that works
efficiently, using NAMEs rather than refs.
> -Original Message-
> From: Zielfelder, Robert
> [mailto:[EMAIL PROTECTED]]
> Sent: 24 September 2002 18:44
> To: '
81 matches
Mail list logo