Re: cascading menus in perl??

2004-12-14 Thread David Dorward
On Tue, 2004-12-14 at 11:41 +1100, Cat wrote:
 Been using a cascading menu written in javascript but would like to
 convert this to perl so that on mouseover it drops down further
 options to click through.

If you want something on the client to change in response to an action
then you either need to have the browser visit a new URL and send back a
different webpage or use client side scripting.

While you could do this in client side Perl, the number of users who are
using Internet Explorer AND have the PerlScript plugin installed are
minimal (and the subject is off topic for this mailing list anyway).


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



DBD::Oracle Instalation errors

2004-12-14 Thread perl_cova
I'm trying to install DBD:Oracle module (Itanium 64 bits) and when I execute 
make i get the following errors:

[EMAIL PROTECTED] DBD-Oracle-1.16]# make
gcc -c   -D_REENTRANT -D_GNU_SOURCE -DTHREADS_HAVE_PIDS -DDEBUGGING 
-fno-strict-aliasing -I/usr/local/include -D_LARGEFILE_SOURCE 
-D_FILE_OFFSET_BITS=64 -I/usr/include/gdbm -O2 -g -pipe   -DVERSION=\\ 
-DXS_VERSION=\\ -fPIC -I/usr/lib/perl5/5.8.0/ia64-linux-thread-multi/CORE   
Oracle.c
In file included from Oracle.h:18,
 from Oracle.xs:1:
/usr/lib/perl5/5.8.0/ia64-linux-thread-multi/CORE/DBIXS.h:31:22: dbipport.h: No 
such file or directory
/usr/lib/perl5/5.8.0/ia64-linux-thread-multi/CORE/DBIXS.h:34:21: dbi_sql.h: No 
such file or directory
In file included from Oracle.h:20,
 from Oracle.xs:1:
dbdimp.h:44:17: oci.h: No such file or directory
dbdimp.h:45:22: oratypes.h: No such file or directory
dbdimp.h:46:20: ocidfn.h: No such file or directory
In file included from Oracle.h:20,
 from Oracle.xs:1:
dbdimp.h:59: syntax error before OCIEnv
dbdimp.h:59: warning: no semicolon at end of struct or union
dbdimp.h:66: syntax error before '}' token
...
Someone help me?
Thanks.



-- 


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Perl Presentation Slides

2004-12-14 Thread Marcos Rebelo
Hy all

My next assignement is to do a presentation of Perl begginers (from
zero) in 4 days :'(

Actually I have already 71 slides and I would like to see other persons
work in this matter. Someone know where to find or can give some Slides
similar to the ones I'm doing.

Thanks
Marcos


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: DBD::Oracle Instalation errors

2004-12-14 Thread Lawrence Statton
 I'm trying to install DBD:Oracle module (Itanium 64 bits) and when I execute 
 make i get the following errors:
  from Oracle.xs:1:
 dbdimp.h:44:17: oci.h: No such file or directory
 dbdimp.h:45:22: oratypes.h: No such file or directory
 dbdimp.h:46:20: ocidfn.h: No such file or directory

Well -- find those files... maybe your sysadmin installed Oracle's
libraries in some non-standard place

find / -name oci.h

Then, fixup the incdir path, and try again.

-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
Lawrence Statton - [EMAIL PROTECTED] s/aba/c/g
Computer  software  consists of  only  two  components: ones  and
zeros, in roughly equal proportions.   All that is required is to
sort them into the correct order.



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




DBD::Oracle

2004-12-14 Thread perl_cova

Now when I execute make I get the following error:
[EMAIL PROTECTED] DBD-Oracle-1.16]# make
gcc -c   -D_REENTRANT -D_GNU_SOURCE -DTHREADS_HAVE_PIDS -DDEBUGGING 
-fno-strict-aliasing -I/usr/local/include -D_LARGEFILE_SOURCE 
-D_FILE_OFFSET_BITS=64 -I/usr/include/gdbm -O2 -g -pipe   -DVERSION=\\ 
-DXS_VERSION=\\ -fPIC -I/usr/lib/perl5/5.8.0/ia64-linux-thread-multi/CORE   
Oracle.c
Oracle.xs: In function `XS_DBD__Oracle_ORA_OCI':
Oracle.xs:43: `ORA_OCI_VERSION' undeclared (first use in this function)
Oracle.xs:43: (Each undeclared identifier is reported only once
Oracle.xs:43: for each function it appears in.)
make: *** [Oracle.o] Error 1
Thanks...


-- 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




RE: Perl Presentation Slides

2004-12-14 Thread Charles K. Clarkson
Marcos Rebelo [EMAIL PROTECTED] wrote:

: Hy all
: 
: My next assignement is to do a presentation of Perl begginers
: (from zero) in 4 days :'( 
: 
: Actually I have already 71 slides and I would like to see
: other persons
: work in this matter. Someone know where to find or can give
: some Slides
: similar to the ones I'm doing.

Mark Jason Dominus has quite a few slide presentations online.

http://perl.plover.com/

HTH,

Charles K. Clarkson
-- 
Mobile Homes Specialist
254 968-8328


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




asking for y or n

2004-12-14 Thread Christopher Spears
I'm writing a Perl script where I ask the user a
question similar to:

Would you like to remove this file?
Type y or n.

How do I get Perl to receive the answer and act on it?
 I've been looking in some of my books and noticed 
two ways of receiving input STDIN and .  What is
the difference between the two?

=
I'm the last person to pretend that I'm a radio.  I'd rather go out and be a 
color television set.
-David Bowie

Who dares wins
-British military motto

The freak is the norm. - The Infernal Desire Machines of Dr. Hoffman by 
Angela Carter

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: asking for y or n

2004-12-14 Thread Kirk Bauer
On Tue, 14 Dec 2004, Christopher Spears wrote:

 I'm writing a Perl script where I ask the user a
 question similar to:

 Would you like to remove this file?
 Type y or n.

 How do I get Perl to receive the answer and act on it?
  I've been looking in some of my books and noticed
 two ways of receiving input STDIN and .  What is
 the difference between the two?

 will read from the files specified as arguments I believe.  I do
this:

print Would you like to remove this file? (Y/N) ;
my $input = STDIN;
if ($input =~ /^[yY]$/) {
   unlink($filename)  print File '$filename' has been deleted.\n;
}

This requires the user to hit y or Y and then ENTER.  It is possible to
do this without the enter but it takes more work.

-- 
Kirk Bauer [EMAIL PROTECTED]
http://linux.kaybee.org | www.autorpm.org | www.logwatch.org

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: asking for y or n

2004-12-14 Thread Christopher Spears
Thanks for the answer Chris!  Now my question is how
do I find out if it is actually on my machine!  I
don't want to have to download anything because I am
writing this script on one machine and then I am going
to send it to another to be used.  perl -v yields:

This is perl, v5.8.1-RC3 built for
darwin-thread-multi-2level
(with 1 registered patch, see perl -V for more detail)

I am using Darwin on Mac OS X.

=
I'm the last person to pretend that I'm a radio.  I'd rather go out and be a 
color television set.
-David Bowie

Who dares wins
-British military motto

The freak is the norm. - The Infernal Desire Machines of Dr. Hoffman by 
Angela Carter

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




receiving input from different sources

2004-12-14 Thread Christopher Spears
I need to be able to receive input from the keyboard,
but STDIN is being used to process a file and  is
not appropiate for this purpose.  What can I do?  I
was told there was a way to do this with exec.

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: receiving input from different sources

2004-12-14 Thread Edward WIJAYA

On Tue, 14 Dec 2004 20:19:23 -0800 (PST), Christopher Spears  
[EMAIL PROTECTED] wrote:

I need to be able to receive input from the keyboard,
but STDIN is being used to process a file and  is
not appropiate for this purpose.

Consider using Getopt module.
perldoc Getopt::Long
perldoc Getopt::Std
Show us some script, so we can see the problem in more
concrete ways.
--
Regards,
Edward WIJAYA
Singapore
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Edit properties for MS-Office files

2004-12-14 Thread Bee
Hi, 

I now have some thousands of ms-word and power point files .
And they are required to make some clone like properties data filling. 
Now, I have to modify them one by one, is there any module 
would help to do this ?  so I can just simply get a file list and clone
data with a loop Is that possible ?

Thanks in advise,
Bee

any perl project ideas

2004-12-14 Thread Harbhajan Julka
Hey all,
Need some pointers to perl projects that use all the
major functionalities of perl. Please pass your ideas
as soon as you can. I've been working on perl in
theory and tried some small programs to practice, but
need something bigger that would help understand perl
and learn it too.

Thanks in Advance.



__ 
Do you Yahoo!? 
Yahoo! Mail - Find what you need with new enhanced search.
http://info.mail.yahoo.com/mail_250

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: any perl project ideas

2004-12-14 Thread Tor Hildrum
On Tue, 14 Dec 2004 23:10:48 -0800 (PST), Harbhajan Julka
[EMAIL PROTECTED] wrote:
 Hey all,
 Need some pointers to perl projects that use all the
 major functionalities of perl. Please pass your ideas
 as soon as you can. I've been working on perl in
 theory and tried some small programs to practice, but
 need something bigger that would help understand perl
 and learn it too.

Write a spam-filter.

Tor

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: control loop question

2004-12-14 Thread Tor Hildrum
On Mon, 13 Dec 2004 14:46:13 -0800 (PST), Christopher Spears
[EMAIL PROTECTED] wrote:
 Hi!
 
 Let's say I have a text file filled with:
 
 stuff
 stuff
 stuff
   Users sometext
   tom
   dick
   harry
   Users more sometext
larry
curly
moe
moe
 stuff
 stuff
 etc.
 
 I need to write a Perl script that will go through the
 file and find the lines with Users, process that line,
 and then start looking for moe (who may occur more
 than once).  Upon finding another line with Users, the
 code should loop and process the line and then start
 looking for moe again.  How should I proceed?  

You text example leaves something to the  imagination. 
From the text above, and your requirements, it seems like
you can just search the whole file for 'moe'. When does
a 'Users'-part end? I'm guessing occurences of 'moe' outside
a Users-part shouldn't be handled?

Not really sure if this a valid way to do it, I've never nested reads on 
the same filehandle myself. 

## loop over file
while( FH ) {

   ## Check for users part
   if ( /Users/i ) {

  ## Loop over users part (Is this considered bad form?)
  while( FH ) {

 ## Check for end of Users
 last if /endofUserspart/;

 ## Check for moe
 if ( /moe/i ) {
## We have moe inside users
 }

  }
  
   }

}

Tor

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: remote database access in perl

2004-12-14 Thread Adam Saeed
Thanks It works now.



On Mon, 13 Dec 2004 23:43:06 -0800, Todd Lewis [EMAIL PROTECTED] wrote:
 usually you have to log in as a local user before executing your
 script.
 
 
 
  I have written a simple program that should get data from a remote
  database, but it is not working giving error:
  DBI-connect(sugs:192.168.14.2) failed: Host 'www.sample.com' is not
  allowed to connect to this MySQL server at testbug.pl line 12
 
  code is below:
  *
  #! /usr/bin/perl -w
 
  use DBI;
  use strict;
 
  my ($driver = 'mysql',$user = 'root',$pass = ,$database = 'sugs');
 
  my $dsn = DBI:$driver:$dbname:192.168.14.2;
  my $dbh = DBI-connect($dsn,$user,$pass);
 
  my $strsql=select * from products where product='L2';
  my $sth = ($dbh-prepare($strsql) || die Query could not be executed
   . $dbh-errstr());
  i$sth-execute();
  while (my $row = $sth-fetchrow_arrayref){
  print join(\t, @$row), \n;
  }
  $sth-finish();
  $dbh-disconnect();
 
  Script is working fine on the host machine(192.168.14.2) but give
  error when run from remote machine...
  any suggestion?
 
  Thanks
  Adam
  
  --
 
 
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
  http://learn.perl.org/ http://learn.perl.org/first-response
 
 
 
 


-- 
Allah Hafiz
O! God Thy sea is so great and my boat is so small.
Adam

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: SFTP problem...Please help me !.....

2004-12-14 Thread roime puniran
no..there is more than 100 file in my
directory...actually it's a flow files...


--- Ing. Branislav Gerzo [EMAIL PROTECTED] wrote:

 roime puniran [rp], on Tuesday, December 14, 2004 at
 01:27 (-0800
 (PST)) typed the following:
 
 rp transfered and remove successfull ..Below is my
 rp script...
 
 it works, if you have in your source directory only
 1 file, for
 example data.dat ?
 
 -- 
 
  ...m8s, cu l8r, Brano.
 
 [He's mostly dead Jim. Get Miracle Max!]
 
 
 
 -- 
 To unsubscribe, e-mail:
 [EMAIL PROTECTED]
 For additional commands, e-mail:
 [EMAIL PROTECTED]
 http://learn.perl.org/
 http://learn.perl.org/first-response
 
 
 




__ 
Do you Yahoo!? 
Dress up your holiday email, Hollywood style. Learn more. 
http://celebrity.mail.yahoo.com

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



RE: Deleting the records from a table

2004-12-14 Thread Mallik
Hi Jose,

Thanks for your prompt reply.

I too thought of same solution, but we don't want to delete the original
table. Any other solution is greatly appreciated.

Thanks  Regards,
Mallik.

-Original Message-
From: José Pedro Silva Pinto [mailto:[EMAIL PROTECTED]
Sent: Tuesday, December 14, 2004 5:02 PM
To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Subject: RE: Deleting the records from a table


Hi,

It songs a funny solutions but...

Create a TEMP table and insert latest 5 days data

After delete the table and rename temp table


José Pinto


-Original Message-
From: Mallik [mailto:[EMAIL PROTECTED]
Sent: terça-feira, 14 de Dezembro de 2004 11:31
To: [EMAIL PROTECTED]
Subject: Deleting the records from a table


Hi Friends,

I need a help from you in implementation of purging functionality.
I am given a hash of table(s), each having millions of records. i need to
delete those records keeping latest 5 days records in the tables.

I know the delete query like: delete from $tableName where adddtm  today ?
$numDays ; where $numDays is the variable having number of days latest data
to be retained. if i give the direct query like above it takes a lot of time
to delete records from that set of tables.

Do you have any idea to implement this purging that can be done in time for
any number of tables containing millions of records in a loop. i need to
implement this in perl, with DBI-informix interface.

Thanks in advance,
Mallik.

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



RE: Deleting the records from a table

2004-12-14 Thread Bob Showalter
Mallik wrote:
 Hi Friends,
 
 I need a help from you in implementation of purging functionality.
 I am given a hash of table(s), each having millions of records. i
 need to delete those records keeping latest 5 days records in the
 tables. 
 
 I know the delete query like: delete from $tableName where adddtm 
 today ? $numDays ; where $numDays is the variable having number of
 days latest data to be retained. if i give the direct query like
 above it takes a lot of time to delete records from that set of
 tables. 
 
 Do you have any idea to implement this purging that can be done in
 time for any number of tables containing millions of records in a
 loop. i need to implement this in perl, with DBI-informix interface.

This isn't really a Perl question. The first thing I would ask is what
percentage of the table's rows are you deleting? 1 percent? 50 percent? 90
percent? If the percentage is low, you can improve performance by creating
an index on the date column and using a properly optimizable WHERE clause.
If the percentage is very high, you might offload the rows to keep to a temp
table, truncate the big table (which is usually fast), and reload the rows
to keep.

There isn't going to be a Perl approach that is faster than a simple DELETE
FROM foo WHERE date  ? to delete a bunch of rows from the table.

This is a database question, not a Perl question. Have you pursued this on
Informix lists?

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: Assigning a match to a varible without an IF

2004-12-14 Thread Ing. Branislav Gerzo
S.A. Birl [SAB], on Tuesday, December 14, 2004 at 09:58 (-0500 (EST))
contributed this to our collective wisdom:

SAB Problem is:
SAB   $from_ = $From =~ /@/;
SAB returns 1.

you should use this:
($from_ = $From) =~ /@/;

but your regexp isn't right.
maybe this will work:
($from_ = $From) =~ /[EMAIL PROTECTED]/;

you should look on google for right email regexp, there are some on
the web...

-- 

 ...m8s, cu l8r, Brano.

[That's how bold the stuff is, you little priss-ant! -- Crow]



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: Assigning a match to a varible without an IF

2004-12-14 Thread Jenda Krynicky
From: S.A. Birl [EMAIL PROTECTED]
 I realized that, out of all of the PERL code Ive written, Ive only
 been able to assign to a variable from a pattern match within an IF
 statement:
 
 if ( /^From:(.*)$/ )
 {
 $From = $1;
 }
 
 Simple enough.  But now I wanted to go deeper and capture only the
 email address.
 
 Problem is:
   $from_ = $From =~ /@/;
 returns 1.
 
 I didnt want the return status.  In this example I wanted @
 And I didnt want to use another IF statement
   if ( $From =~ /(@)/ )
   {
  $from_ = $1;
   }

($from_) = $From =~ /(@)/;

Both pairs of brackets are needed.

Jenda

= [EMAIL PROTECTED] === http://Jenda.Krynicky.cz =
When it comes to wine, women and song, wizards are allowed 
to get drunk and croon as much as they like.
-- Terry Pratchett in Sourcery


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



RE: MySQL and flock

2004-12-14 Thread Ron Goral


 -Original Message-
 From: Octavian Rasnita [mailto:[EMAIL PROTECTED]
 Sent: Tuesday, December 14, 2004 6:57 AM
 To: [EMAIL PROTECTED]
 Subject: MySQL and flock


 Hi all,

 Does anyone know if MySQL uses flock when it modifies the data from a
 database for locking the files in which are kept the modified tables?
 I want to make a perl program which gets the file and store a
 back-up but I
 don't want to get the files while they are modified.

 Thank you.

 Teddy

Howdy -

Check out http://dev.mysql.com/doc/mysql/en/LOCK_TABLES.html for information
about MySQLs method of locking tables.

HTH -
Ron



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: MySQL and flock

2004-12-14 Thread Octavian Rasnita
Thanks but I don't have access to MySQL nor to the client that makes the
update. I don't even know if it locks the tables or not.

I would like to just copy some files in order to create a backup but I don't
want to copy them while they are locked.
However, I don't know if this is possible, because now I am thinking that if
my program starts copying the files, they might start beeing updated just
after I have started the copy process...

Teddy

- Original Message - 
From: Ron Goral [EMAIL PROTECTED]
To: Octavian Rasnita [EMAIL PROTECTED]; [EMAIL PROTECTED]
Sent: Tuesday, December 14, 2004 4:32 PM
Subject: RE: MySQL and flock




 -Original Message-
 From: Octavian Rasnita [mailto:[EMAIL PROTECTED]
 Sent: Tuesday, December 14, 2004 6:57 AM
 To: [EMAIL PROTECTED]
 Subject: MySQL and flock


 Hi all,


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



RE: Trouble with format

2004-12-14 Thread Moon, John
This is my code (something very simple):

$variable = Ordenes\nServicios\nGarantias;
  format ORDENES =
  Text: ^*
$variable
  ~~^*
$variable
  .

But I don't know how can I see or print the output of this, and send it bye
email. I tried with write(), but does not work.


[jwm] Here is something I do... maybe this will give you some ideas...

snip
format EXCEPTIONS_TOP =
@|||

|
Daily Report of Oracle Account Exceptions

Prepared: @
$date
Account #  SchemaOS User  Instance
Platform Collected
-- - 
-
 ---
.
format EXCEPTIONS =
@@ @
@
@ @
$item{account},
$item{schema},$item{os_user},$item{instance},$item{platform},$it
em{je_date}
.
/snip
...
snip
open EXCEPTIONS, | MAIL $to
or die Open Failed;
...
write EXCEPTIONS;
...
close EXCEPTIONS;
/snip

Please note that this reply wrapped some of the formats...

You may wish to try something like this before first write...

snip
print EXCEPTIONS Subject: ...\n;
print EXCEPTIONS From: \n;
/snip
hope this helps...

jwm

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: control loop question

2004-12-14 Thread Dave Gray
 Let's say I have a text file filled with:
 
 stuff
 stuff
 stuff
   Users sometext
   tom
   dick
   harry
   Users more sometext
larry
curly
moe
moe
 stuff
 stuff
 etc.

First of all, can this be XML instead? Then you can pass off the
parsing to XML::Simple or something similar.

If not, it looks like you want to organize by whitespace. (Like Tor
said, a group end token would help.) It also looks like you want to
end up with something like:

$VAR1 = {
  'sometext' = {
'tom' = 1,
'dick' = 1,
'harry' = 1,
'more sometext' = {
  'larry' = 1,
  'curly' = 1,
  'moe' = 1
}
  }
};

But possibly not using hashrefs (because you have duplicates) and
possibly not nesting references. Can you be more specific (in a
general way) about your secret requirements?

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: regexp for a blank line

2004-12-14 Thread Dave Gray
Christopher Spears [mailto:[EMAIL PROTECTED] wrote:
 I have to write a script that processes text in a
 file.  The text includes lots of blank lines.  How can
 I tell Perl to skip the lines?

On Tue, 14 Dec 2004 11:22:54 +0530, Mallik [EMAIL PROTECTED] wrote:
 next if ($line =~ /^\s*$/);

+1 - this will match \n,   \n, \t\n, \t \n, etc

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: asking for y or n

2004-12-14 Thread Prasanna Kothari
#Warningt untested
my $answer = STDIN;
chomp($answer);
if($answer =~ m/^[y|Y]es$/) {
   print Yes;
}elsif ( $answer =~m/^[n|N]o$/ {
print no;
}else {
print undefined value;
}
Christopher Spears wrote:
I'm writing a Perl script where I ask the user a
question similar to:
Would you like to remove this file?
Type y or n.
How do I get Perl to receive the answer and act on it?
I've been looking in some of my books and noticed 
two ways of receiving input STDIN and .  What is
the difference between the two?

=
I'm the last person to pretend that I'm a radio.  I'd rather go out and be a color 
television set.
-David Bowie
Who dares wins
-British military motto
The freak is the norm. - The Infernal Desire Machines of Dr. Hoffman by 
Angela Carter
 


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response


Re: asking for y or n

2004-12-14 Thread Chris Devers
On Tue, 14 Dec 2004, Christopher Spears wrote:

 I'm writing a Perl script where I ask the user a
 question similar to:
 
 Would you like to remove this file?
 Type y or n.

Try Damian Conway's IO::Prompt:

http://search.cpan.org/~autrijus/IO-Prompt-0.02/lib/IO/Prompt.pm

Use it like this:

use IO::Prompt;
while( prompt next:  ) {
print You said '$_'\n;
}

Or maybe in your case like this:

$user_input = prompt(
  qq[Would you like to remove this file?\nType y or n. ], 
  -tty, -yes, -no, -onechar, -speed=0.2
);
 
You can write this by hand, but once Damian has attacked a problem, 
there's little point in trying to out-clever him :-)
 

-- 
Chris Devers

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response