RE: Multiple filenames in form

2006-07-03 Thread Charles K. Clarkson
Peter Oram wrote:

: How can I get the IE behaviour to occur when a user has Firefox?

That's a JavaScript problem, not a perl problem.


HTH,

Charles K. Clarkson
-- 
Mobile Homes Specialist
Free Market Advocate
Web Programmer

254 968-8328

Don't tread on my bandwidth. Trim your posts.


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




modules maillist

2006-07-03 Thread Ken Perl

hi,

Is there a maillist talking about or seeking a module to a specific
requirement? For example, I want to write a module or application to
store all the glossary in my head, first, I search it on cpan.org but
and don't find any userful module, but I still want to confirm that no
one hasn't done that before, is this kind of maillist to ask?

--
perl -e 'print unpack(u,62V5N\FME;G\!EFQ`9VUA:6PN8V]M\[EMAIL PROTECTED]
)'

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




RE: modules maillist

2006-07-03 Thread Jeff Peng



Is there a maillist talking about or seeking a module to a specific
requirement?


There are some lists about CPAN,maybe that's you wanted.
For example:

cpan-discuss  A general, non-technical list for talking about any issue of 
CPAN.
cpan-interface  A list for people interested in developing a user-friendly 
web interface to CPAN.
cpan-metadata  A focused list for the discussion and implementation of 
Metadata for CPAN.
cpan-testers  This list is for those interested in the organised testing of 
CPAN modules.

cpan-update  An announce only list for new module update information.
cpan-workers  A closed list for people working on issues with CPAN, but 
lurkers may surf the archive.


Also pls see: http://lists.cpan.org/



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




how use Function

2006-07-03 Thread Umar Draz
hi dear members!

  i am new in Perl community i want to declare a function and try to pass some 
parameters same as i do in php. First i declare a function (umar).


sub umar ($width, $height) {
$area = $width * $height / 2;
return $area;
}

after that is I call function through a variable
$result = umar(10,40);
print $result\n;

But it did't work and i got a error

Illegal character in prototype for main::umar : $width,$height at ./test.pl 
line 7.
Malformed prototype for main::umar: $width,$height at ./test.pl line 12.

please help me what should i do?

Regards,

Umar Draz




-
Talk is cheap. Use Yahoo! Messenger to make PC-to-Phone calls.  Great rates 
starting at 1¢/min.

Re: how use Function

2006-07-03 Thread Beginner
On 3 Jul 2006 at 3:04, Umar Draz wrote:

 hi dear members!
 
   i am new in Perl community i want to declare a function and try to pass 
 some parameters same as i do in php. First i declare a function (umar).
 
 
 sub umar ($width, $height) {
 $area = $width * $height / 2;
 return $area;
 }

Generally when you create a function, you do not declare the variables in this 
way. The usual 
practise is like this:  

sub umar {
 my $width = shift; # First arg will be the width.
 my $height = shift;# Second arg will be the height.
 my $area = ($width * $height) / 2;
 return $area;
}

 after that is I call function through a variable
 $result = umar(10,40);
 print $result\n;
 
 But it did't work and i got a error
 
 Illegal character in prototype for main::umar : $width,$height at ./test.pl 
 line 7.
 Malformed prototype for main::umar: $width,$height at ./test.pl line 12.

HTH 
Dp.


Dermot Paikkos

[EMAIL PROTECTED]
Network Administrator @ Science Photo Library
Phone: 0207 432 1100 
Fax: 0207 286 8668


Re: how use Function

2006-07-03 Thread D. Bolliger
Umar Draz am Montag, 3. Juli 2006 12:04:
 hi dear members!

Hello Umar

   i am new in Perl community i want to declare a function and try to pass
 some parameters same as i do in php. First i declare a function (umar).


 sub umar ($width, $height) {
 $area = $width * $height / 2;
 return $area;
 }

 after that is I call function through a variable
 $result = umar(10,40);
 print $result\n;

 But it did't work and i got a error

 Illegal character in prototype for main::umar : $width,$height at ./test.pl
 line 7. Malformed prototype for main::umar: $width,$height at ./test.pl
 line 12.

 please help me what should i do?

As with any language, the best thing is to get an idea about the language 
syntax.

In Perl, the syntax of subroutines is described in 

perldoc perlsub
(type this in the commandline: perldoc ist the command to get perl 
documentation, and perlsub ist the part of the documentation you wish to 
open)

The list of the local documentation (manuals) is available with

perldoc perl

How to use perldoc in

perldoc perldoc

and every builtin function's documentation is available with

perldoc -f funktion_name_to_lookup

If you intend to use perl on a regular basis, a good idea might be to buy a 
perl book, which gives, besides details, an overview of perl. A good start is 
the Camel Book, Programming Perl from O'Reilly.

There are also websites dedicated to perl (as perlmonks.org, perl.org for 
example), and from cpan.org you can get a lot of perl modules for certain 
tasks.

Dani

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




Re: using MS Excel generated .xml files

2006-07-03 Thread Jay Savage

On 6/30/06, Mr. Shawn H. Corey [EMAIL PROTECTED] wrote:

On Fri, 2006-30-06 at 17:07 +0100, Gary Stainburn wrote:
 Hi folks

 I'm just about to look into writing a perl prog to read in an excel
 spreadsheet and us that to populate a SQL database.

 The idea is to save the spreadsheet as a .xml file (using Office XP), use a
 perl module to read in the file, and using the parsed data update the
 database.

 Would anyone like to pass on any experiences / recommendations before I dive
 headlong in.



[snip]


You may also want to consider exporting your data as a CSV or DSV file.
There are modules in CPAN that can read these formats and other modules
that can read an Excel file directly.



I just want to second that. XML is a long, slow, complicated,
error-prone way to get already structured data from a speadsheet to a
database, especially with large files. Save it at tab or CSV. Most
databases can read those formats natively; you may not even need a
perl script at all. If you do (e.g. to do a little manipulation or
handle the connection) the scripting will be lightweight, and the
modules are speedy and reliable. And by speedy, I'm talking orders of
magnitude. YMMV depending on the number of rows and columns in your
dataset as well as the makeup of individual records, but I've found
that parsing 10,000+ row address lists in CSV is anywhere from 10 to
1,000+ times faster than parsing equivalent datasets in XML. Don't
forget that XML export adds a great deal of metadata used only by the
XML engine that must be parsed and stored in memory. For spreadsheet
exports--at least when you're using it a spreadsheet to store numbers,
and not as a poor man's database to store quantities of text--the
size of the XML markup is often far larger than the size of the actual
data.

When moving data from spreadsheets to databases, split() and Text::CSV
are your best friends.

Just my $.02

-- jay
--
This email and attachment(s): [  ] blogable; [ x ] ask first; [  ]
private and confidential

daggerquill [at] gmail [dot] com
http://www.tuaw.com  http://www.dpguru.com  http://www.engatiki.org

values of β will give rise to dom!


Parse XMP file -- foreach problem

2006-07-03 Thread Andrej Kastrin

Dear Perl community

I have to parse ID, TITLE and SYMBOL fields from the file below. In this 
manner I wrote (modify actually) simple script to do that for me.


?xml version='1.0'?
entries
 entry
   id001/id
   titleFIRST TITLE/title
   symbolSYMBOL AAA/symbol
   symbolSECOND CCC/symbol
 /entry
 entry
   id002/id
   titleSECOND TITLE/title
   symbolSYMBOL HHH/symbol
 /entry
/entries

Script below work well, if there is only one symbol field in each 
entry. I have some troubles to implement second foreach structure to 
loop through each symbol field and print it.


Thanks in advance for any help,

Andrej

-
#!/usr/bin/perl
# use module
use XML::Simple;
# create object
$xml = new XML::Simple (KeyAttr=[]);
# read XML file
$data = $xml-XMLin(example.xml);
# access XML data
foreach $e (@{$data-{entry}}){
$id=$e-{id};
$title=$e-{title};
$symbol=$e-{symbol};
print $id|$title|$symbol\n;
}


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




Re: [OT] Can't redirect before fork().

2006-07-03 Thread Danijel Tasov
Mumia W. wrote:
 In the parent, I want to redirect STDOUT to 'logfile' then fork. In the
   ^^^  ^^

 Here is my code:
 
 use strict;
 use warnings;
 use constant EXIT_OK = 0;
 
 $SIG{CHLD} = IGNORE;
 my $child = fork();

Where is the redirection code? 

-DaTa
Danijel Tasov
[EMAIL PROTECTED]
-- 
Maybe I'm a little bit crazy, but I can't decide if it's psychotic or
neurotic. You know the difference, don't you? A psychotic thinks that
2 + 2 = 5. A neurotic knows that 2 + 2 = 4, but it makes him nervous.
 -- Larry Wall, 8th State of the Onion

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




Re: Parse XMP file -- foreach problem

2006-07-03 Thread D. Bolliger
Andrej Kastrin am Montag, 3. Juli 2006 21:08:
 Dear Perl community

Hi Andrej

 I have to parse ID, TITLE and SYMBOL fields from the file below. In this
 manner I wrote (modify actually) simple script to do that for me.

 ?xml version='1.0'?
 entries
   entry
 id001/id
 titleFIRST TITLE/title
 symbolSYMBOL AAA/symbol
 symbolSECOND CCC/symbol
   /entry
   entry
 id002/id
 titleSECOND TITLE/title
 symbolSYMBOL HHH/symbol
   /entry
 /entries

 Script below work well, if there is only one symbol field in each
 entry. I have some troubles to implement second foreach structure to
 loop through each symbol field and print it.

 Thanks in advance for any help,
 -

 #!/usr/bin/perl

use strict;
use warnings; 

# and declare your variables with my,...

 # use module
 use XML::Simple;
 # create object
 $xml = new XML::Simple (KeyAttr=[]);

# ...for example here:

my $xml = new XML::Simple (KeyAttr=[]);

 # read XML file
 $data = $xml-XMLin(example.xml);
 # access XML data
 foreach $e (@{$data-{entry}}){
 $id=$e-{id};
 $title=$e-{title};
 $symbol=$e-{symbol};
 print $id|$title|$symbol\n;
 }

The script generates following output:

001|FIRST TITLE|ARRAY(0x84ee214)
002|SECOND TITLE|SYMBOL HHH

The 'ARRAY(0x84ee214)' part indicates that in the $symbol variable you're 
printing out is not a string, but an arrayref - containing multiple symbol 
entries. (you can check that, and inspect any nested data structure,  with 
the Data::Dumper module).

So, $symbol can contain a scalar (string) or an arrayref containing (string) 
scalars, depending of the number of symbol tags in the xml-document.

You get what you want by modifying the print line, for example:

print $id|$title|, 
  ref($symbol) # or (ref($symbol) eq 'ARRAY')
 ? join ',', @$symbol # arrayref in $symbol
 : $symbol,# scalar in $symbol
  \n;

You may need another format for multiple value entries than a comma separated 
list. 

Hm, or do you need to repeat the parent tag path in such a case? Like:
001|FIRST TITLE|SYMBOL AAA
001|FIRST TITLE|SECOND CCC
Then forget my modified print statement :-)
(Your question is not clear to me in that respect)

Hope this helps,

Dani

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




Re: Parse XMP file -- foreach problem

2006-07-03 Thread Mumia W.

Andrej Kastrin wrote:

[...]
$symbol=$e-{symbol};
print $id|$title|$symbol\n;
}



Use the 'ref' command to find out if $symbol is an 'ARRAY' reference. If 
it is, use 'join' to join all the elements into a string and put it back 
into $symbol before you print.



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




Re: Detecting line terminators in a CSV file

2006-07-03 Thread Daniel Kasak
John W. Krahn wrote:
 Daniel Kasak wrote:
   
 John W. Krahn wrote:
 
 perldoc -f binmode
   
 binmode is what I was after - thanks :)
 

 Then don't forget to use the correct characters for this: \015 for Carriage
 Return and \012 for Line Feed; as using \n may get translated to something
 other than just \012.
   

Thanks for that tip. I'll do that.

 That depends on what your definition of working is.  Precedence means that:

 open SOURCE, $options-{source} || die message ...;

 will only die if $options-{source} contains the string '' or '0' or the
 number 0 or the value 'undef'.  You need to either add parentheses:

 open( SOURCE, $options-{source} ) || die message ...;

 or use the low precedence 'or' operator:

 open SOURCE, $options-{source} or die message ...;
   

Ah. Yes I see what you're saying now. Thanks.

 You should also include the $! or the $^E variable in the error message so you
 will know *why* the file could not be opened.

 The point I should have made originally and that I will make now is that you
 shouldn't use eval() to print an error message from a built-in function.  When
 open() fails it returns undef and puts the error message in $!.  eval() will
 not catch this or the error message.  eval() will only catch the die() and its
 message but since it won't die when open fails...  But since you don't
 actually want the program to die, why use die in the first place?
   

I'm reading up on the $! and $^E thing now. I'm still relatively new to
this :)

 You don't have to call the length() function, you can just use a negative 
 number:

 if ( substr( $fieldnames, -2, 2 ) eq \r\n ) {
   
 Now *that* is useful. Thanks :)
 

 And since the offset -2 can only be two characters long you can omit the
 length argument as well:

 if ( substr( $fieldnames, -2 ) eq \r\n ) {
   

Thanks for your tips John. You've pointed me in the right direction on a
number of issues :)

Dan

-- 
Daniel Kasak
IT Developer
NUS Consulting Group
Level 5, 77 Pacific Highway
North Sydney, NSW, Australia 2060
T: (+61) 2 9922-7676 / F: (+61) 2 9922 7989
email: [EMAIL PROTECTED]
website: http://www.nusconsulting.com.au

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