Re: Sorting directory content using creation time
Hi, Does anybody know if there is an option in readdir to return the file list in the order of their creation time? Or know of a way to do that? Been reading the perldoc w/o much luck. Thanks! Doubtful, but it should be trivial using readdir in a list context and using 'sort' with 'stat'. perldoc -f sort perldoc -f stat perldoc -q sort The bigger question is are you sure you want to? the creation time on most OSes doesn't actually mean anything or exist at all. There is the 'ctime' which is an inode change time which means even less to most Perl programs. Are you positive your OS supports a creation time? What are you really trying to do? http://danconia.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: Sorting directory content using creation time
I have a directory tree in the following format: 20040202/ 20040202/file1 20040203/ 20040203/file1 20040203/file2 20040203/file3 20040204 20040204/file1 20040204/file2 First, I'd want to read in top level dirs in the order of 20040204, 20040203, then 20040202. Then the files in each dir in descending order w/ time of creation as well. I could read each handle, do a stat to sort them, then process. Thoughts? Thanks in advance! -Original Message- From: Wiggins d Anconia [mailto:[EMAIL PROTECTED] Sent: Wednesday, February 04, 2004 1:40 PM To: Li, William; [EMAIL PROTECTED] Subject: Re: Sorting directory content using creation time Hi, Does anybody know if there is an option in readdir to return the file list in the order of their creation time? Or know of a way to do that? Been reading the perldoc w/o much luck. Thanks! Doubtful, but it should be trivial using readdir in a list context and using 'sort' with 'stat'. perldoc -f sort perldoc -f stat perldoc -q sort The bigger question is are you sure you want to? the creation time on most OSes doesn't actually mean anything or exist at all. There is the 'ctime' which is an inode change time which means even less to most Perl programs. Are you positive your OS supports a creation time? What are you really trying to do? http://danconia.org -- This message is intended only for the personal and confidential use of the designated recipient(s) named above. If you are not the intended recipient of this message you are hereby notified that any review, dissemination, distribution or copying of this message is strictly prohibited. This communication is for information purposes only and should not be regarded as an offer to sell or as a solicitation of an offer to buy any financial product, an official confirmation of any transaction, or as an official statement of Lehman Brothers. Email transmission cannot be guaranteed to be secure or error-free. Therefore, we do not represent that this information is complete or accurate and it should not be relied upon as such. All information is subject to change without notice. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Sorting directory content using creation time
Also consider: perldoc File::Find On Wed, Feb 04, 2004 at 11:40:21AM -0700, Wiggins d Anconia wrote: Hi, Does anybody know if there is an option in readdir to return the file list in the order of their creation time? Or know of a way to do that? Been reading the perldoc w/o much luck. Thanks! Doubtful, but it should be trivial using readdir in a list context and using 'sort' with 'stat'. perldoc -f sort perldoc -f stat perldoc -q sort The bigger question is are you sure you want to? the creation time on most OSes doesn't actually mean anything or exist at all. There is the 'ctime' which is an inode change time which means even less to most Perl programs. Are you positive your OS supports a creation time? What are you really trying to do? http://danconia.org -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response -- Brad Lhotsky [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: db to HTML with checkboxes
Wiggins d Anconia wrote: Wiggins d'Anconia wrote: Andrew Gaffney wrote: Wiggins d'Anconia wrote: Andrew Gaffney wrote: I have a Perl CGI script that runs a query against a MySQL table. I have about 20 boolean values that I want shown as checkboxes in the produced HTML, but I don't want to have to do something like the below for every value. The key to this is contriving good names for the check boxes, usually such that they can be looped over... That's not an option. The values have been defined months and months ago and are hard-coded in a number of places. Ah the power of poor planning It was planned pretty well at first...about 2 years ago, but things change. The table has over doubled in number of fields since then. Right but at some point, aka around the fourth checkbox being added, someone should have realized that there would be more and added a loop just as you are doing now at around 20. In which case it was option 2 aka that refactoring wasn't being done as the system evolved, which just as they predict that means something major will have to be done to correct the situation at a later time, and that time has come [code] if($ref-{somevalue}) { print input type=checkbox name=somevalue value=1 checked; } else { print input type=checkbox name=somevalue value=1; } [/code] foreach my $index (1 .. 20) { print input type=checkbox name=somevalue$index . ($ref-{somevalue$index} ? ' checked=checked' : '') . ; } The (exp ? string : string) is called the ternary operator, perldoc perlop for more. Will this work in a here doc? Don't know... god I hate here docs... give it a shot but I doubt it. Apparently, that's a big fat NO. Although, there is something else that would probably work: [code] my $ref = $sth-execute; 'execute' (assuming we are talking DBI) returns a bool for success or failure, not a hashref. (Not sure if this was meant to be pseudo-code based on your statement below.) You will likely need a $ref = $sth-fetchrow_hashref; It was just pseudo-code. I used the correct $sth-execute and then $sth-fetchrow_hashref in the actual code. my $bools = {val1 = '', val2 = '', val3= '', ... }; foreach $bool (keys $bools) { $bools-{$bool} = checked if($ref-{$bool} eq '1'); } If these are truly 'bools' then it is cleaner to check true/false rather than string equals to 1, true may not always be represented by 1 and undef will produce a warning rather than just being false. By bool, I mean that the value will only ever be '1' or '0'. ... print EOF; input type=hidden name=val1 $bools-{val1} input type=hidden name=val2 $bools-{val2} EOF [/code] I suspect this isn't really all that is contained in your heredoc, otherwise why not put the input generation into the loop above? Just a simple example. Does this look like it might work? I think my syntax may be a bit off. Your syntax is a bit off (don't know if you wanted response on that), but your idea should work... It did end up working for me. Thanks. -- Andrew Gaffney Network Administrator Skyline Aeronautics, LLC. 636-357-1548 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: comparing array value...
Singh, Ajit p wrote: Hello there, could somebody let me know how do i compare the contents of an array that I have... To be specific. my array contains something like below Why? I see nothing uniform between the lines of the array tosuggest that they should be handled as array elements. What you show below looks like text, possibly a block. Is the whole block an array element? That might be a sensible arrangement, if you have a series of blocks of similar format. If not, then you probably need to rethink how you are loading your array. Array operations on heterogenous data like that shown below will be exceedinbly clumsy. If you start by defining your problem, what data you have available, and what information you want to generate from it, we can probably help you find more appropriate ways to process it. ... Building configuration... Current configuration : 130 bytes ! interface ATM2/0.10 multipoint description config vp thru program for slot2 range pvc 10/32 10/1023 class-range dbs ! end Joseph -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
DBI realted queries
Hi all, $sth-{LongReadLen} = 3; #what's the statement doing ? And from where to find out what all parameters are available to statement handle ? my ($id_prod); my $sqlstmt = EOM; SELECT id_prod FROM product EOM my $dbh = DBI-connect('DBI:Oracle:' . $SID, $USERNAME, $PASSWORD)|| die $DBI::errstr; my $sth = $dbh-prepare($sqlstmt); $sth-{LongReadLen} = 3; $sth-execute(); $sth-bind_columns(undef, \($id_prod)) ; #where do i find detials of function bind_columns OR what is bind_columns doing over here ? Thanks, Nilay -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
reference ?
Hi all, my $tmp_holder = find_file($VENTURA_BASEDIR . '/chapters', $title_code, ['pdf']); 1. What's the explanation of 3rd parameter ? 2. Is it declaring and passing a reference ? Is this the way to initialise a reference ? 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: reference ?
The third parameter is an anonymous array. What this means is that we are referring to an array by reference that we didn't name first. If you printed it out, Perl would display it as something like ARRAY(something). Just as an example, you could do something like this: ### my @array = (dog,cat,pig,Rush Limbaugh); my $ref1 = [dog,cat,pig,Rush Limbaugh]; my $ref2 = [EMAIL PROTECTED]; print $ref1-[2]; #Prints pig print $ref2-[2]; #Also prints pig ### $ref1 and $ref2 are both references to arrays, but $ref1 is a reference to an array that was created and initialized at the time $ref1 was created, while $ref2 is a reference to a named array that already existed. I hope that clears things up a bit. You can also declare references to anonymous hashes like this: my $hashref = {name = 'daffy', surname = 'duck'}; Finally, check out 'perldoc perlreftut'. -Original Message- From: Nilay Puri, Noida [mailto:[EMAIL PROTECTED] Sent: Wed 2/4/2004 12:35 AM To: Perl List (E-mail) Cc: Subject: reference ? Hi all, my $tmp_holder = find_file($VENTURA_BASEDIR . '/chapters', $title_code, ['pdf']); 1. What's the explanation of 3rd parameter ? 2. Is it declaring and passing a reference ? Is this the way to initialise a reference ?
Sending mails
Hello everybody, I have two radio buttons in a form. I want - When any one clicks on button A a mail will be sent to A when any one clicks on button B mail will be sent to button B. In both the cases whether someone clicks on A or B I will receive a mail. Can anyone help me with the coding pls? Thanks Nilanjana -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Fwd: Is it a perl Bug?
Tom Franklyn [EMAIL PROTECTED] wrote:From: Tom Franklyn Subject: Is it a perl Bug? Date: Wed, 04 Feb 2004 12:43:56 +0200 Dear all, I've following code : == #!/usr/bin/perl my $a = ab:cd:ef; my @b = split(/:/,$a); print (@b\n); my @c = ('/:/', $a); my @d = split(@c); print (@d\n); === Whats wrong with my code? why @b and @d give different output? Rgds, Tom Franklyn Jesus?? Not a God! http://www.geocities.com/abdlfth99/jesus_not_a_god.htm - Do you Yahoo!? Yahoo! SiteBuilder - Free web site building tool. Try it!
Re: Sending mails
Nilanjana Bhattacharya wrote: Hello everybody, I have two radio buttons in a form. I want - When any one clicks on button A a mail will be sent to A when any one clicks on button B mail will be sent to button B. In both the cases whether someone clicks on A or B I will receive a mail. Can anyone help me with the coding pls? Thanks Nilanjana never heard of any button that could recieve email, please be more specific, include code -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: FW: special vars
Nilay Puri wrote: -Original Message- From: Nilay Puri, Noida Sent: Wednesday, February 04, 2004 11:37 AM To: Perl (E-mail) Subject: FW: special vars -Original Message- From: Nilay Puri, Noida Sent: Wednesday, February 04, 2004 11:32 AM To: Perl (E-mail) Subject: special vars Hi all, Can any one help me understand the usage of special variable $| ? I know the description of this var. If set to nonzero, forces a flush after every write or print. But I am not able to understand its importance. If I am reading a file and writing the contents in a separat file after some processing. What will happen if I set $|=1 ? Thanks, NP if u use an OS like linux (which will not write things imediately to disc) this forces it to do so. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: How Am I?
Rob Dixon wrote: [stuff] Sorry guys. Just glad it wasn't anything too embarrassing :-/ /R -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Fwd: Is it a perl Bug?
On Wednesday 04 February 2004 10:48 am, nancy clark wrote: Tom Franklyn [EMAIL PROTECTED] wrote:From: Tom Franklyn Subject: Is it a perl Bug? Date: Wed, 04 Feb 2004 12:43:56 +0200 Dear all, I've following code : == #!/usr/bin/perl my $a = ab:cd:ef; my @b = split(/:/,$a); print (@b\n); my @c = ('/:/', $a); my @d = split(@c); What exactly are you wanting to happen here? What you're actualy doing is calling split(/ab/,'cd','ef'); which says use 'ab' as the pattern,'cd' as the expr, and 'ef' as the limit. split obviously can't handle this and thus returns undef. print (@d\n); === Whats wrong with my code? why @b and @d give different output? Rgds, Tom Franklyn Jesus?? Not a God! http://www.geocities.com/abdlfth99/jesus_not_a_god.htm - Do you Yahoo!? Yahoo! SiteBuilder - Free web site building tool. Try it! -- Gary Stainburn This email does not contain private or confidential material as it may be snooped on by interested government parties for unknown and undisclosed purposes - Regulation of Investigatory Powers Act, 2000 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Perl on WinCE
Hi, This is with regard to deploying Perl on Windows CE. My hardware setup consists of an Intel Celeron Processor, an i830M4 chipset Intel motherboard and I am running WindowsCE .Net 4.2 here. The board is targeted at Notebook devices. This is acting as my Windows CE device while I am using a WinXP machine with Microsoft Platform Builder 4.2 to build the WinCE .Net 4.2 and deploy it on the above device. Now I need to run Perl scripts on WinCE on this device. I tried with resources from the Internet which largely consists of links to 'PerlCE' developed by Rainer Keuchel for WinCE 2.11. But this is not working on my system. Various ways of trying to deploy it are failing. I even tried with another find 'Microperl' but with the same result. I need to know: 1. Are there any readily available Perl binaries for WinCE .Net 4.2 ? 2. Can anyone provide the essential guidelines to adapt 'PerlCE' or 'Microperl' to the above system? 3. Is there any way to make relevant changes in the original Perl source files to build the Perl package for my system? Any useful leads would be highly appreciated. Regards, Ayushman Ayushman Dutta Mailto: [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: DBI realted queries
Nilay Puri wrote: Hi all, $sth-{LongReadLen} = 3; #what's the statement doing ? And from where to find out what all parameters are available to statement handle ? my ($id_prod); my $sqlstmt = EOM; SELECT id_prod FROM product EOM my $dbh = DBI-connect('DBI:Oracle:' . $SID, $USERNAME, $PASSWORD)|| die $DBI::errstr; my $sth = $dbh-prepare($sqlstmt); $sth-{LongReadLen} = 3; $sth-execute(); $sth-bind_columns(undef, \($id_prod)) ; #where do i find detials of function bind_columns OR what is bind_columns doing over here ? Thanks, Nilay http://search.cpan.org/~timb/DBD-Oracle-1.15/Oracle.pm generally at 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
Re: Is it a perl Bug?
Nancy Clark wrote: Tom Franklyn [EMAIL PROTECTED] wrote:From: Tom Franklyn Subject: Is it a perl Bug? Date: Wed, 04 Feb 2004 12:43:56 +0200 Dear all, I've following code : == #!/usr/bin/perl my $a = ab:cd:ef; my @b = split(/:/,$a); print (@b\n); my @c = ('/:/', $a); my @d = split(@c); print (@d\n); === Whats wrong with my code? why @b and @d give different output? Hi Tom, Nancy. Two problems here. First of all my @c = ('/:/', $a) should be either my @c = (':', $a) or my @c = (qr/:/, $a) otherwise the regex would match the three characters slash, colon, slash. Secondly, 'split' is prototyped, so it forces its first parameter into scalar context. Array @c has two elements so your call my @d = split(@c) is equivalent to my @d = split(2) which will try to split $_ on the regex '2'. Look at this code: $_ = ab2cd2ef; my @c = (1, 2); my @d = split(@c); print (@d\n); **OUTPUT ab cd ef HTH, Rob -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Uploading a CSV file to a Database Table
I'm pulling my hair out trying to find out how to upload this data. My files can vary in numbers of rows and columns but the x and y axis always contain the same type of metadata - in my case cost centre and cost item. A sample of the data would look like : cost_centre,stationery,postage,furniture,training,advertising 1001,£10.56,£8,£500.99,£1500,£300.99 1002,£40.50,£12.35,£0,£0,£450 My database table is preloaded with a transposed version of the metadata and is waiting for the expenditure values : cost_centre | cost_item | spend 1001 | stationery | ...(would be populated with 10.56) 1002 | stationery | ...(would be populated with 40.50) 1001 | postage| ..(would be populated with 8) 1002 | stationery | ...(would be populated with 12) ..etc. So I need to parse through the csv file regardless of how many rows or columns and insert into my table in the form : UPDATE EXPENDITURE SET SPEND = 10.56 WHERE cost_centre = 1001 AND cost_item = stationery My attempts so far have been pretty retarded, if you can help at all I'd really appreciate it. Regards,Mark
RE: Dump Excel File to Database table
Paul, Thanks for your response. I'm open to any suggestion as I'm pulling my hair out trying to find out how to upload this data. My files can vary in numbers of rows and columns but the x and y axis always contain the same type of metadata - in my case cost centre and cost item. A sample of the data converted to csv would look like : cost_centre,stationery,postage,furniture,training,advertising 1001,£10.56,£8,£500.99,£1500,£300.99 1002,£40.50,£12.35,£0,£0,£450 My database table is preloaded with a transposed version of the metadata and is waiting for the expenditure values : cost_centre | cost_item | spend 1001 | stationery | ...(would be populated with 10.56) 1002 | stationery | ...(would be populated with 40.50) 1001 | postage| ..(would be populated with 8) 1002 | stationery | ...(would be populated with 12) ..etc. So I need to parse through the csv file regardless of how many rows or columns and insert into my table in the form : UPDATE EXPENDITURE SET SPEND = 10.56 WHERE cost_centre = 1001 AND cost_item = stationery My attempts so far have been pretty retarded, if you can help at all I'd really appreciate it. Send a copy of the code that you have tried. It easier to help fix your code then it is to write the code for you. Plus you will learn more. Also direct all perl mail to the beginners list so that everyone can benefit. I have copied your message to the list. Paul -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
AW: FW: special vars
It is important believe me. Especialy if you are writting to logfiles, databases and unix named pipes. If in this context buffered io is on it will happen that if you prints something to a file or anywhere not the whole line is dumped only the stuff what was in the buffer when the buffer was flushed because of its size the last time. if you give out the line: Hello, I am here./n Buffered it could look like this at the destination: Hello, I a Unbuffered it will look like this: Hello, I am here./n Beware THERE IS A DIFFERENCE OF PRINTING TO A FILE, PIPE, PROGRAM and a TTY / COMMANDLINE. See Fcntl, File::Handle, Io::Handle at cpan for more. -Ursprungliche Nachricht- Von: Eternius [mailto:[EMAIL PROTECTED] Gesendet: Mittwoch, 4. Februar 2004 12:00 An: [EMAIL PROTECTED] Betreff: Re: FW: special vars Nilay Puri wrote: -Original Message- From: Nilay Puri, Noida Sent: Wednesday, February 04, 2004 11:37 AM To: Perl (E-mail) Subject: FW: special vars -Original Message- From: Nilay Puri, Noida Sent: Wednesday, February 04, 2004 11:32 AM To: Perl (E-mail) Subject: special vars Hi all, Can any one help me understand the usage of special variable $| ? I know the description of this var. If set to nonzero, forces a flush after every write or print. But I am not able to understand its importance. If I am reading a file and writing the contents in a separat file after some processing. What will happen if I set $|=1 ? Thanks, NP if u use an OS like linux (which will not write things imediately to disc) this forces it to do so. -- 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: Sending mails
Nilanjana Bhattacharya wrote: Hello everybody, I have two radio buttons in a form. I want - When any one clicks on button A a mail will be sent to A when any one clicks on button B mail will be sent to button B. In both the cases whether someone clicks on A or B I will receive a mail. Can anyone help me with the coding pls? Yes, but we generally want to see what you have so far. Is this a web form? If so, you'll need to write a CGI program to handle the form. Use Perl's CGI module for this. For sending mail, I recommend the Mail::Send module, available from CPAN. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Uploading a CSV file to a Database Table
On Feb 4, 2004, at 6:50 AM, Mark Martin wrote: I'm pulling my hair out trying to find out how to upload this data. My files can vary in numbers of rows and columns but the x and y axis always contain the same type of metadata - in my case cost centre and cost item. A sample of the data would look like : cost_centre,stationery,postage,furniture,training,advertising 1001,£10.56,£8,£500.99,£1500,£300.99 1002,£40.50,£12.35,£0,£0,£450 Generally, when I have data like this, my favorite thing to do is to build a hash out of each row, then use whatever I want by name. Like this: my $header = ; my @cols = split /,/, $header; # store column names for later use while () { my @fields = split /,/; # next we load our hash my %record = map { ($cols[$_], $fields[$_]) } 0..$#fields; # and here we can use it print $record{cost_centre} $record{stationery}\n; # or whatever } From there you're problem is simply building an SQL statement and feeding it to the DBI. Is that enough to get you going? James -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: FW: special vars
Nilay Puri wrote: if u use an OS like linux (which will not write things imediately to disc) this forces it to do so. That is misleading and not necessarily true. It tells Perl to unbuffer the I/O but not the OS. The OS decides what will and won't get written to disc, based on kernel settings, harddrive settings, etc. Don't confuse the two... http://danconia.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: DBI realted queries
Hi all, $sth-{LongReadLen} = 3; #what's the statement doing ? And from where to find out what all parameters are available to statement handle ? my ($id_prod); my $sqlstmt = EOM; SELECT id_prod FROM product EOM my $dbh = DBI-connect('DBI:Oracle:' . $SID, $USERNAME, $PASSWORD)|| die $DBI::errstr; my $sth = $dbh-prepare($sqlstmt); $sth-{LongReadLen} = 3; $sth-execute(); $sth-bind_columns(undef, \($id_prod)) ; #where do i find detials of function bind_columns OR what is bind_columns doing over here ? perldoc DBI that should explain everything. Alternatively you can look on http://search.cpan.org for the DBI docs in web form. There is also a [EMAIL PROTECTED] list, but don't post there until you have read the docs several times and haven't found what you are looking for as they are very thorough. http://danconia.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: Uploading a CSV file to a Database Table
On Feb 4, 2004, at 6:50 AM, Mark Martin wrote: I'm pulling my hair out trying to find out how to upload this data. My files can vary in numbers of rows and columns but the x and y axis always contain the same type of metadata - in my case cost centre and cost item. A sample of the data would look like : cost_centre,stationery,postage,furniture,training,advertising 1001,£10.56,£8,£500.99,£1500,£300.99 1002,£40.50,£12.35,£0,£0,£450 Generally, when I have data like this, my favorite thing to do is to build a hash out of each row, then use whatever I want by name. Like this: my $header = ; my @cols = split /,/, $header;# store column names for later use while () { my @fields = split /,/; # next we load our hash my %record = map { ($cols[$_], $fields[$_]) } 0..$#fields; # and here we can use it print $record{cost_centre} $record{stationery}\n;# or whatever } From there you're problem is simply building an SQL statement and feeding it to the DBI. Is that enough to get you going? James If your CSV is at all complex (read: can have other delimiters or quoted strings, etc.) I would suggest investing in, especially since its free, Text::CSV_XS: http://search.cpan.org/~jwied/Text-CSV_XS-0.23/CSV_XS.pm http://danconia.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: Is it a perl Bug?
Tom Franklyn [EMAIL PROTECTED] wrote:From: Tom Franklyn Subject: Is it a perl Bug? Date: Wed, 04 Feb 2004 12:43:56 +0200 Dear all, I've following code : == #!/usr/bin/perl my $a = ab:cd:ef; my @b = split(/:/,$a); print (@b\n); my @c = ('/:/', $a); my @d = split(@c); print (@d\n); === Whats wrong with my code? why @b and @d give different output? Never use $a and $b as variables in Perl outside of a sort subroutine. They are used by the sort function. Secondly, study perldoc -f split, especially the arguments: split /PATTERN/,EXPR,LIMIT split /PATTERN/,EXPR split /PATTERN/ split It's not a perl bug. Luke -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: How Am I?
Any of us could have written an email like that. No big deal. Now THIS is embarrassing: I once had an employee who had a girlfriend named Jane. We had a client named Janet. (You can see where this is going.) Yup, turned out he like to write highly intimate emails involving fantasy scenarios with himself and his girl. One day he moved his mouse two pixels the wrong way on the send-to drop-down. It turned out our client was highly unreceptive to that kind of email, and who can blame her. Now THAT is embarrassing. At 12:18 PM 2/4/04 -, Rob Dixon wrote: Rob Dixon wrote: [stuff] Sorry guys. Just glad it wasn't anything too embarrassing :-/ /R -- 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
How to use the arguments to use() in the package being used
Howdy, The subject says it all believe it or not :) What I'm trying to figure out is how to pass an argument (pragma I believe is the proper term) to use() and do sonethign in the package based on it. I've looked at CGI.pm source but can't seem to track it down. (Similar idea as to CGIs -oldstyle_urls -newstyel_urls) http://search.cpan.org/~lds/CGI.pm-3.04/CGI.pm#PRAGMAS What I'd like to do is something like this: # for old time's sake we'll just use our favorite module use Foo::Monkey qw(:Foo :Bar -doamazingthings); #then in Foo::Monkey: package Foo::Monkey; [mandatory module goodies snipped] if(?) { # IE if -doamazingthings was specified in the use statement # do some amazing things here } [mandatory module goodies snipped] How do I do that?? Are those arguments stored in a special array somewhere?? TIA DMuey -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
In what order does a program run..??
I'm new to PERL and am trying to learn by reading some PERL programs. My question is this - does PERL execute sequentially and skip around embedded subroutines or Does it execute them inline? For example, if the program has the following set of code lines Line1 Line2 Line3 Sub1 Subcode1 Subcode2 Endsub1 Line4 Line5 Line6 calls sub1 Line7 Does the execution sequence go like this: Line1, line2, line3 line 4 line5, line6, sub1, subcode1, subcode2, endsub1 line7 Or does it go like this: Line1, Line2, Line3, Sub1, Subcode1, Subcode2, Endsub1, Line4, Line5, Line6, Sub1, Subcode1, Subcode2, Endsub1, Line7 Thanks. Portions of this message may be confidential under an exemption to Ohio's public records law or under a legal privilege. If you have received this message in error or due to an unauthorized transmission or interception, please delete all copies from your system without disclosing, copying, or transmitting this message.
Re: In what order does a program run..??
On Feb 4, [EMAIL PROTECTED] said: My question is this - does PERL execute sequentially and skip around embedded subroutines or Does it execute them inline? Perl *compiles* subroutines when it sees them, but does NOT run them UNLESS you call them. Line1 Line2 Line3 Sub1 Subcode1 Subcode2 Endsub1 Line4 Line5 Line6 calls sub1 Line7 Does the execution sequence go like this: Line1, line2, line3 line 4 line5, line6, sub1, subcode1, subcode2, endsub1 line7 Yes. -- Jeff japhy Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/ stu what does y/// stand for? tenderpuss why, yansliterate of course. [ I'm looking for programming work. If you like my work, let me know. ] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: How Am I?
Any of us could have written an email like that. No big deal. Now THIS, however, is embarrassing: I once had an employee who had a girlfriend named Jane. We had a client named Janet. (You can see where this is going.) Yup, turned out he like to write intimate emails involving fantasy scenarios with himself and his girl. One day he moved his mouse two pixels the wrong way on the send-to drop-down. It turned out our client was highly unreceptive to that kind of email, and who can blame her. Now THAT is embarrassing. Sorry, yours doesn't even come close; nice try though! -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: In what order does a program run..??
I'm new to PERL and am trying to learn by reading some PERL programs. Perl or perl, never PERL. perldoc -q 'Perl' Sometimes that is good, sometimes bad depending on who wrote the Perl you are reading, it is one way to pick up very bad habits. Does the code you are reading have: use strict; use warnings; At the top? If not you may be better off walking away slowly and then checking out a book (see suggestion below) or one of the free online resources first, then come back to the code. http://learn.perl.org My question is this - does PERL execute sequentially and skip around embedded subroutines or Does it execute them inline? It skips them as they are definitions For example, if the program has the following set of code lines Line1 Line2 Line3 Sub1 Subcode1 Subcode2 Endsub1 Line4 Line5 Line6 calls sub1 Line7 Does the execution sequence go like this: Line1, line2, line3 line 4 line5, line6, sub1, subcode1, subcode2, endsub1 line7 Correct (if I am understanding your 'sub1' correctly). Or does it go like this: Line1, Line2, Line3, Sub1, Subcode1, Subcode2, Endsub1, Line4, Line5, Line6, Sub1, Subcode1, Subcode2, Endsub1, Line7 Thanks. You may want to look at, perldoc perl and review some of the basics. An excellent resource is also Learning Perl from O'Reilly and will get you all of the basics you will need and give you familarity with how to do things in a Perlish way. Good luck and welcome, http://danconia.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: In what order does a program run..??
On Feb 4, 2004, at 9:52 AM, [EMAIL PROTECTED] wrote: I'm new to PERL and am trying to learn by reading some PERL programs. Welcome then. Look's like you already got your answer, but here's a tip: perl refers to the program that compiles and runs programs written in the Perl programming language, but we don't know what PERL is. ;) James -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: How Am I?
Rob Dixon wrote: [stuff] Sorry guys. Just glad it wasn't anything too embarrassing :-/ /R I thought I just missed the beginning to the best thread we have had in months ;-)... http://danconia.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: How to use the arguments to use() in the package being used
On Feb 4, Dan Muey said: # for old time's sake we'll just use our favorite module use Foo::Monkey qw(:Foo :Bar -doamazingthings); Well, depending on what you want to do with the arguments, you might want to use the Exporter module to handle exporting functions, variables, etc. perldoc perlmod (look for Perl Modules) perldoc Exporter When you say use Module qw( args go here ); this is translated into BEGIN { require Module; Module-import(qw( args go here )); } Thus, you need an 'import' method in Module::. package Module; sub import { my $class = shift; print You gave me (@_)\n; } It's up to you to do something with @_. -- Jeff japhy Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/ stu what does y/// stand for? tenderpuss why, yansliterate of course. [ I'm looking for programming work. If you like my work, let me know. ] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: How to use the arguments to use() in the package being used
Dan == Dan Muey [EMAIL PROTECTED] writes: Dan What I'm trying to figure out is how to pass an argument Dan (pragma I believe is the proper term) to use() and do Dan sonethign in the package based on it. $ perldoc -f use [...] Imports some semantics into the current package from the named module, generally by aliasing certain subroutine or variable names into your package. It is exactly equivalent to BEGIN { require Module; import Module LIST; } except that Module *must* be a bareword. Therefore, it's calling a class method in your module called import. Create your own import method, instead of inheriting Exporter's import, and you're all set. -- Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095 [EMAIL PROTECTED] URL:http://www.stonehenge.com/merlyn/ Perl/Unix/security consulting, Technical writing, Comedy, etc. etc. See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training! -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: How Am I?
Another reason you don't send personal emails form work place or work accounts... So I assume he lost his job. Poor chap Thanks, Kevin Holcomb W2K System Administrator/Database Administrator Bank of America E-Commerce: Interactive Information Management -Original Message- From: Michael C. Davis [mailto:[EMAIL PROTECTED] Sent: Wednesday, February 04, 2004 10:41 AM To: Rob Dixon Cc: [EMAIL PROTECTED] Subject: Re: How Am I? Any of us could have written an email like that. No big deal. Now THIS is embarrassing: I once had an employee who had a girlfriend named Jane. We had a client named Janet. (You can see where this is going.) Yup, turned out he like to write highly intimate emails involving fantasy scenarios with himself and his girl. One day he moved his mouse two pixels the wrong way on the send-to drop-down. It turned out our client was highly unreceptive to that kind of email, and who can blame her. Now THAT is embarrassing. At 12:18 PM 2/4/04 -, Rob Dixon wrote: Rob Dixon wrote: [stuff] Sorry guys. Just glad it wasn't anything too embarrassing :-/ /R -- 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 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Module for Country/Country Codes Lists
Hi! My name is Shlomi Fish and I am a co-developer of the WWW::Form module: http://search.cpan.org/~bschmau/WWW-Form-1.13/ Benjamin Schmaus (WWW::Form's main developer) and I decided it would be a good idea for the module or an extension of it to provide common form controls like a country list or a U.S. states list. To do so we need a module that returns a country list. Ideally what we would like is for it to return a refernece to a hash of country codes (US, IL, UK, RU, etc.) that each map to a contry name (United States, Israel, United Kingdom, Russia). Or alternatively, a similar interface with similar capabilites. We enumberated our needs here: http://benschmaus.com/cgi-bin/twiki/view/Main/WwwFormCountryList So, is there a good module for doing that on CPAN that is also actively maintained and updated? Regards, Shlomi Fish -- Shlomi Fish[EMAIL PROTECTED] Home Page: http://t2.technion.ac.il/~shlomif/ You are banished! You are banished! You are banished! Hey? I'm just kidding! -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Module for Country/Country Codes Lists
Look at Net::Domain::TLD on CPAN It has a fairly comprehensive list of country codes as well as top-level domain names. I noticed that it did not include entries that would validate '.co.uk' or '.co.jp', which echoes your concern about how actively this module is maintained. I would imagine that somewhere is a web-published list of cc's and you could code a script to check it daily for changes. At 06:36 PM 2/4/04 +0200, Shlomi Fish wrote: Hi! My name is Shlomi Fish and I am a co-developer of the WWW::Form module: http://search.cpan.org/~bschmau/WWW-Form-1.13/ Benjamin Schmaus (WWW::Form's main developer) and I decided it would be a good idea for the module or an extension of it to provide common form controls like a country list or a U.S. states list. To do so we need a module that returns a country list. Ideally what we would like is for it to return a refernece to a hash of country codes (US, IL, UK, RU, etc.) that each map to a contry name (United States, Israel, United Kingdom, Russia). Or alternatively, a similar interface with similar capabilites. We enumberated our needs here: http://benschmaus.com/cgi-bin/twiki/view/Main/WwwFormCountryList So, is there a good module for doing that on CPAN that is also actively maintained and updated? Regards, Shlomi Fish -- Shlomi Fish[EMAIL PROTECTED] Home Page: http://t2.technion.ac.il/~shlomif/ You are banished! You are banished! You are banished! Hey? I'm just kidding! -- 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: How to use the arguments to use() in the package being used
On Feb 4, Dan Muey said: # for old time's sake we'll just use our favorite module use Foo::Monkey qw(:Foo :Bar -doamazingthings); Well, depending on what you want to do with the arguments, you might want to use the Exporter module to handle exporting functions, variables, etc. perldoc perlmod (look for Perl Modules) perldoc Exporter I do use Exporter actually should've mentioned that sorry, I'll check out your perldocs to. Thanks When you say use Module qw( args go here ); this is translated into BEGIN { require Module; Module-import(qw( args go here )); } Thus, you need an 'import' method in Module::. package Module; sub import { my $class = shift; print You gave me (@_)\n; } Perfect! Exactly what I needed. It's up to you to do something with @_. Thanks Jeff -- Jeff japhy Pinyan -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
formatting and syntax
Hi I am all still to new to PERL and I am having trouble playing with formatting my data into a new format. So here is my problem: I have data (DNA sequence) in a file that looks like this: # Infile bob AGTGATGCCGACG fred ACGCATATCGCAT jon CAGTACGATTTATC and I need it converted to: # Outfile R 1 20 A G U G A T G C C G A C G - - - - - - - bob A C G C A U A U C G C A U - - - - - - - fred C A G U A C G A U U U A U C - - - - - - jon The R 1 is static and should always appear. The 20 at the top of the new file should be a number defined by the user, that is they should be prompted for the length they wish the sequence to be. That is the total length of the sequence plus the added dashes could be 20 or 3000 or whatever. So, if they type 20 and there is only 10 letters in that row then the script should add 10 dashes to bring that total up to the 20 chosen by the user. Note that there should be a space between all letters and dashes - including a space at the beginning. Then there are supposed to be 7 spaces after the sequence string followed by the name as shown in the example output file above. Also, of note is the fact that all of the T's are changed to U's. For those of you that know biology I am not only switching formats of the data but also changing DNA to RNA. I hope I am explaining this clear enough, but here (see below) is as far as I can get with the code. I just do not know how to structure the loop/code to do this. I always have trouble with manipulating data the way I want when it comes to a loop. I would prefer an easier to understand code rather than an efficient code. This way I can learn the simple stuff first and learn the short-cuts later. Thanks to anyone who can help. - Cheers! - Mike ## #!/usr/bin/perl use warnings; use strict; print Enter the path of the INFILE to be processed:\n; # For example rotifer.txt or ../Desktop/Folder/rotifer.txt chomp (my $infile = STDIN); open(INFILE, $infile) or die Can't open INFILE for input: $!; print Enter in the path of the OUTFILE:\n; # For example rotifer_out.txt or ../Desktop/Folder/rotifer_out.txt chomp (my $outfile = STDIN); open(OUTFILE, $outfile) or die Can't open OUTFILE for input: $!; print Enter in the LENGTH you want the sequence to be:\n; my ( $len ) = STDIN =~ /(\d+)/ or die Invalid length parameter; print OUTFILE R 1 $len\n\n\n\n; # The top of the file is supposed # type of loop or structure to follow ? # -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: Module for Country/Country Codes Lists
We enumberated our needs here: http://benschmaus.com/cgi-bin/twiki/view/Main/WwwFormCountryList So, is there a good module for doing that on CPAN that is also actively maintained and updated? If not I'll include it my upcoming module perhaps (no not Foo::monkey ;p) -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Uploading a CSV file to a Database Table
hmmm..bit over my head I'm afraid. I've tried a different tack that maybe you can help me with. It's quite possible that I will be forced to take the data in MS Excel format (like attachment) so using the example that comes with the Spreadsheet::ParseExcel pm I can parse thru the worksheet and load the cell reference and value into a hash as you've suggested : #!/usr/bin/perl -w use strict; use Spreadsheet::ParseExcel; my $oExcel = new Spreadsheet::ParseExcel; my %hash = (); die You must provide a filename to $0 to be parsed as an Excel file unless @ARGV; my $oBook = $oExcel-Parse($ARGV[0]); my($iR, $iC, $oWkS, $oWkC,$cell,$ref,$value); print FILE :, $oBook-{File} , \n; print COUNT :, $oBook-{SheetCount} , \n; print AUTHOR:, $oBook-{Author} , \n if defined $oBook-{Author}; for(my $iSheet=0; $iSheet $oBook-{SheetCount} ; $iSheet++) { $oWkS = $oBook-{Worksheet}[$iSheet]; print - SHEET:, $oWkS-{Name}, \n; for(my $iR = $oWkS-{MinRow} ; defined $oWkS-{MaxRow} $iR = $oWkS-{MaxRow} ; $iR++) { for(my $iC = $oWkS-{MinCol} ; defined $oWkS-{MaxCol} $iC = $oWkS-{MaxCol} ; $iC++) { $oWkC = $oWkS-{Cells}[$iR][$iC]; #print ( $iR , $iC ) =, $oWkC-Value, \n if($oWkC); $value = $oWkC-Value; $cell = $iR.,.$iC; $hash{$cell}=$value; } } } foreach $ref(2,1) { if (exists $hash{$ref}) { print \n\n\n\n$ref spent $hash{$ref}\n\n\n; } } but I'm still left with problem of isolating the column and row headers so that I can load it to the DB correctly i.e. update record with value from cell blahblah where cost_centre (column 0 values) = blahblah and cost_item (row 0 values) = blahblah Mark - Original Message - From: James Edward Gray II [EMAIL PROTECTED] To: Mark Martin [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Wednesday, February 04, 2004 2:34 PM Subject: Re: Uploading a CSV file to a Database Table On Feb 4, 2004, at 6:50 AM, Mark Martin wrote: I'm pulling my hair out trying to find out how to upload this data. My files can vary in numbers of rows and columns but the x and y axis always contain the same type of metadata - in my case cost centre and cost item. A sample of the data would look like : cost_centre,stationery,postage,furniture,training,advertising 1001,£10.56,£8,£500.99,£1500,£300.99 1002,£40.50,£12.35,£0,£0,£450 Generally, when I have data like this, my favorite thing to do is to build a hash out of each row, then use whatever I want by name. Like this: my $header = ; my @cols = split /,/, $header; # store column names for later use while () { my @fields = split /,/; # next we load our hash my %record = map { ($cols[$_], $fields[$_]) } 0..$#fields; # and here we can use it print $record{cost_centre} $record{stationery}\n; # or whatever } From there you're problem is simply building an SQL statement and feeding it to the DBI. Is that enough to get you going? James costings.xls Description: MS-Excel spreadsheet -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: FW: special vars
then I guess, I didn't understand it myself Wiggins D Anconia wrote: Nilay Puri wrote: if u use an OS like linux (which will not write things imediately to disc) this forces it to do so. That is misleading and not necessarily true. It tells Perl to unbuffer the I/O but not the OS. The OS decides what will and won't get written to disc, based on kernel settings, harddrive settings, etc. Don't confuse the two... http://danconia.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: In what order does a program run..??
Wiggins D Anconia wrote: I'm new to PERL and am trying to learn by reading some PERL programs. Perl or perl, never PERL. perldoc -q 'Perl' Only on Unix: perldoc What's the difference will work. Rob -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: How Am I?
Wiggins D Anconia wrote: Rob Dixon wrote: [stuff] Sorry guys. Just glad it wasn't anything too embarrassing :-/ /R I thought I just missed the beginning to the best thread we have had in months ;-)... Within my rouge, er, thanks for bottom-posting :) /R -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: FW: special vars
Eternius wrote: Wiggins D Anconia wrote: Nilay Puri wrote: if u use an OS like linux (which will not write things imediately to disc) this forces it to do so. That is misleading and not necessarily true. It tells Perl to unbuffer the I/O but not the OS. The OS decides what will and won't get written to disc, based on kernel settings, harddrive settings, etc. Don't confuse the two... http://danconia.org Then I guess, I didn't understand it myself. Disk drives have their own cache. CPUs now have their own first, second and third level memory caching. The file system is likely to have two caches of its own per file, and the language at least one more in RAM. Disabling output buffering in Perl should be seen as a nicety that helps debugging, but not much else. Only a hardware solution can guard against losing power at the wrong time. Rob -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: Program to reformat Perl code?
On Wed, 4 Feb 2004, Toby Stuart wrote: http://perltidy.sourceforge.net/ Got it! Works! Thanks much! -- Maranatha! John McKown -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: How to use the arguments to use() in the package being used
Jeff 'Japhy' Pinyan wrote: When you say use Module qw( args go here ); this is translated into BEGIN { require Module; Module-import(qw( args go here )); } That's an interesting point Jeff. You're right that it's Module-import() instead of Module::import() as 'import' will be inherited in the (common) case that Module ISA Exporter. Rob -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: In what order does a program run..??
On Feb 4, 2004, at 12:11 PM, Rob Dixon wrote: Wiggins D Anconia wrote: I'm new to PERL and am trying to learn by reading some PERL programs. Perl or perl, never PERL. perldoc -q 'Perl' Only on Unix: perldoc What's the difference I believe you missed a -q in there: perldoc -q What's the difference James -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Delimiter for string..
Friends, I am running a perl script as below which is working perfectly and want to replace the hardcoded values with variables. (the script accepts space as the delimiter) @respon = $placesock-print(./test.pl \7741266\ \DEM EXPO\ \255.255.255.255\ \n); and i am doing this @respon = $placesock-print(./test.pl. .$param1. .$param2. .$param3 \n); Whats the mistake i am commiting. i m getting the following error message... String found where operator expected at mybly.pl line 263, near ./test.pl . . $param1. (Missing operator before . $param1.?) panic: realloc at mybly.pl line 263. regards, Ajitpal Singh, -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: formatting and syntax
Michael S. Robeson II wrote: Hi I am all still to new to PERL and I am having trouble playing with formatting my data into a new format. So here is my problem: I have data (DNA sequence) in a file that looks like this: [snip] Please don't talk about interesting stuff like DNA sequences on a Perl group. We need less distraction. Rob -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Uploading a CSV file to a Database Table
On Feb 4, 2004, at 11:24 AM, Mark Martin wrote: hmmm..bit over my head I'm afraid. What was over you head? What I showed, or building an SQL statement and feeding it to the DBI? I've tried a different tack that maybe you can help me with. It's quite possible that I will be forced to take the data in MS Excel format (like attachment) so using the example that comes with the Spreadsheet::ParseExcel pm I can parse thru the worksheet and load the cell reference and value into a hash as you've suggested : I would much prefer we sort it out in CSV first, if possible, before we complicate it with the reading of Excel spreadsheets. James -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: formatting and syntax
Michael S. Robeson II wrote: I have data (DNA sequence) in a file that looks like this: # Infile bob AGTGATGCCGACG fred ACGCATATCGCAT jon CAGTACGATTTATC and I need it converted to: # Outfile R 1 20 A G U G A T G C C G A C G - - - - - - - bob A C G C A U A U C G C A U - - - - - - - fred C A G U A C G A U U U A U C - - - - - - jon there are many ways of doing that. here is one: #!/usr/bin/perl -w use strict; #-- #-- discard the first 3 header lines #-- DATA for 1..3; #-- #-- read each ' ' #-- $/ = ' '; while(DATA){ next unless(my($n,$s) = /(.+)\n(.+)/); #-- #-- pad dna sequence to 20 bytes and translate T to U #-- here, you will prompt the user to enter a number instead #-- ($s .= '-'x(20-length($s))) =~ y/T/U/; #-- #-- put space after each character #-- $s =~ s/./$ /g; print $s\t$n\n; } __DATA__ # Infile bob AGTGATGCCGACG fred ACGCATATCGCAT jon CAGTACGATTTATC __END__ prints: A G U G A U G C C G A C G - - - - - - - bob A C G C A U A U C G C A U - - - - - - - fred C A G U A C G A U U U A U C - - - - - - jon david -- sub'_{print@_ ;* \ = * __ ,\ \} sub'__{print@_ ;* \ = * ___ ,\ \} sub'___{print@_ ;* \ = * ,\ \} sub'{print@_,\n}{_+Just}(another)-(Perl)-(Hacker) -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
$PATH/expect_scripts/script.exp | $PATH/perl/script.pl
the subject describes my wishes. what i really want to do is parse the screens of an expect script through a perl script... now, what i would like to do is understand how to catch a pipe in perl, and how my program will end up being different. I looked up pipe in 'perldoc -q pipe' and 'perldoc -f pipe' i'm having trouble parsing the information, so i'm looking forward to a little bit of extra enlightenment :) thanks, willy -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: $PATH/expect_scripts/script.exp | $PATH/perl/script.pl
i feel silly. with regard to pipe catching:: while (STDIN) { print $_, is a lovely string\n; } well, there's a simple answer to a simple question... willy :) -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Delimiter for string..
Ajitpal, [EMAIL PROTECTED] wrote: Friends, I am running a perl script as below which is working perfectly and want to replace the hardcoded values with variables. (the script accepts space as the delimiter) @respon = $placesock-print(./test.pl \7741266\ \DEM EXPO\ \255.255.255.255\ \n); and i am doing this @respon = $placesock-print(./test.pl. .$param1. .$param2. .$param3 \n); Try doing this instead: (untested) @respon = $placesock-print(./test.pl \$param1\ \$param2\ \$param3\\n); Whats the mistake i am commiting. i m getting the following error message... String found where operator expected at mybly.pl line 263, near ./test.pl . . $param1. (Missing operator before . $param1.?) panic: realloc at mybly.pl line 263. regards, Ajitpal Singh, HTH, Chuck -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
symbolic references
Greetings, Im trying to generate a tree of nested hashes [of an arbitrary size]. Perhaps you could suggest a better solution. Currently I'm trying to use symbolic references according to the literature but without much luck. Best regards, David My script is as follows (for now, Ive tried to keep the tree as simple as possible): #!perl #use strict; # Currently commented-out because of warning: Can't use string (1) as a SCALAR ref. use warnings; use Data::Dumper; my ($href, %Tree, $cluster_id, $split_val, $num_child, $i, $j, $k); $href = \%Tree; $cluster_id = 698; $split_val = 1; $num_child = 2; # For now, the above values are arbitrary place-holders. $i = 0; $j = 1; while ($i4) { $$i = { ClusterNum = $cluster_id, SplitValue = $split_val, NumChildren= $num_child, Child = $$j, # Child value should be a reference to the subsequent hash. }; if ($i==0) { $Tree{Root} = \$$i; next; } $k = ($i - 1); $$k = \$$i; $i = ($i + 2); $j = ($j + 2); } print Dumper($href).\n; __ Do you Yahoo!? Yahoo! SiteBuilder - Free web site building tool. Try it! http://webhosting.yahoo.com/ps/sb/ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: Delimiter for string..
I am running a perl script as below which is working perfectly and want to replace the hardcoded values with variables. (the script accepts space as the delimiter) @respon = $placesock-print(./test.pl \7741266\ \DEM EXPO\ \255.255.255.255\ \n); and i am doing this @respon = $placesock-print(./test.pl. .$param1. .$param2. .$param3 \n); Whats the mistake i am commiting. The simple answer is that you are forgetting to escape Really, I think you're getting confused about when you are in the s and when you aren't. The more complicated answer is how to get what you want. I'll give it a try: @respon = $placesock-print(./test.pl \.$param1.\ \.$param2.\ \.$param3.\ \n); but that is way more complicated than it needs to be, since will replace $var with it's value, so you should be able to do: @respon = $placesock-print(./test.pl \$param1\ \$param2\ \$param3\ \n); for me, that's a little hard to read, but others may prefer it. Another option, if you don't put anything in s that needs to be replaced would be: @respon = $placesock-print('./test.pl '.$param1.' '.$param2.' '.$param3.' '.\n); All three of these produce the same output as the hardcoded version that you gave us when given proper values for $params i m getting the following error message... String found where operator expected at mybly.pl line 263, near ./test.pl . . $param1. (Missing operator before . $param1.?) panic: realloc at mybly.pl line 263. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
How to reinstall CPAN?
Hi folks, For some reason, when running CPAN I get to many problems (I installed Perl v. 5.8.3 this morning, don't know if it has an effect) cpan install HTML::Mason CPAN: Storable loaded ok LWP not available CPAN: Net::FTP loaded ok Fetching with Net::FTP: ftp://cpan.chebucto.ns.ca/pub/CPAN/authors/01mailrc.txt.gz Going to read /usr/local/cpan/sources/authors/01mailrc.txt.gz Can't exec ./gzip: No such file or directory at /usr/local/lib/perl5/5.8.3/aix/IO/File.pm line 176, FIN line 1. Could not pipe[./gzip --decompress --stdout /usr/local/cpan/sources/authors/01mailrc.txt.gz |]: No such file or directory at /usr/local/lib/perl5/5.8.3/CPAN.pm line 5727, FIN line 1. Is there any way I can reinstall CPAN from scratch? Thanks! Steve Hemond Programmeur Analyste / Analyst Programmer Smurfit-Stone, Ressources Forestieres La Tuque, P.Q. Tel.: (819) 676-8100 X2833 [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: How to reinstall CPAN?
cpan o conf init On Feb 4, 2004, at 8:36 PM, Hemond, Steve wrote: Hi folks, For some reason, when running CPAN I get to many problems (I installed Perl v. 5.8.3 this morning, don't know if it has an effect) cpan install HTML::Mason CPAN: Storable loaded ok LWP not available CPAN: Net::FTP loaded ok Fetching with Net::FTP: ftp://cpan.chebucto.ns.ca/pub/CPAN/authors/01mailrc.txt.gz Going to read /usr/local/cpan/sources/authors/01mailrc.txt.gz Can't exec ./gzip: No such file or directory at /usr/local/lib/perl5/5.8.3/aix/IO/File.pm line 176, FIN line 1. Could not pipe[./gzip --decompress --stdout /usr/local/cpan/sources/authors/01mailrc.txt.gz |]: No such file or directory at /usr/local/lib/perl5/5.8.3/CPAN.pm line 5727, FIN line 1. Is there any way I can reinstall CPAN from scratch? Thanks! Steve Hemond Programmeur Analyste / Analyst Programmer Smurfit-Stone, Ressources Forestieres La Tuque, P.Q. Tel.: (819) 676-8100 X2833 [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 -- 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-beginners] How to reinstall CPAN?
That's what I did, but it didn't fix anything. I thought by removing the cpan directory it would then asks me the startup questions but it didn't. I'm still confused... Steve Hemond Programmeur Analyste / Analyst Programmer Smurfit-Stone, Ressources Forestières La Tuque, P.Q. Tel.: (819) 676-8100 X2833 [EMAIL PROTECTED] -Original Message- From: Remko Lodder [mailto:[EMAIL PROTECTED] Sent: Wednesday, February 04, 2004 3:15 PM To: Hemond, Steve; [EMAIL PROTECTED] Subject: RE: [Perl-beginners] How to reinstall CPAN? your config resides in ~/.cpan perhaps you can delete that directory, and reconfigure it? cheers -- Kind regards, Remko Lodder Elvandar.org/DSINet.org www.mostly-harmless.nl Dutch community for helping newcomers on the hackerscene -Oorspronkelijk bericht- Van: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Hemond, Steve Verzonden: woensdag 4 februari 2004 20:37 Aan: [EMAIL PROTECTED] Onderwerp: [Perl-beginners] How to reinstall CPAN? Hi folks, For some reason, when running CPAN I get to many problems (I installed Perl v. 5.8.3 this morning, don't know if it has an effect) cpan install HTML::Mason CPAN: Storable loaded ok LWP not available CPAN: Net::FTP loaded ok Fetching with Net::FTP: ftp://cpan.chebucto.ns.ca/pub/CPAN/authors/01mailrc.txt.gz Going to read /usr/local/cpan/sources/authors/01mailrc.txt.gz Can't exec ./gzip: No such file or directory at /usr/local/lib/perl5/5.8.3/aix/IO/File.pm line 176, FIN line 1. Could not pipe[./gzip --decompress --stdout /usr/local/cpan/sources/authors/01mailrc.txt.gz |]: No such file or directory at /usr/local/lib/perl5/5.8.3/CPAN.pm line 5727, FIN line 1. Is there any way I can reinstall CPAN from scratch? Thanks! Steve Hemond Programmeur Analyste / Analyst Programmer Smurfit-Stone, Ressources Forestieres La Tuque, P.Q. Tel.: (819) 676-8100 X2833 [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 ___ Perl-beginners mailing list [EMAIL PROTECTED] http://lists.elvandar.org/mailman/listinfo/perl-beginners -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE : How to reinstall CPAN?
/usr/local# cpan o conf init CPAN: Storable loaded ok LWP not available CPAN: Net::FTP loaded ok Fetching with Net::FTP: ftp://cpan.chebucto.ns.ca/pub/CPAN/authors/01mailrc.txt.gz Going to read /usr/local/cpan/sources/authors/01mailrc.txt.gz Could not pipe[./gzip --decompress --stdout /usr/local/cpan/sources/authors/01mailrc.txt.gz |]: A file or directory in the path name does not exist. at /usr/local/lib/perl5/5.8.3/CPAN.pm line 5727. Same problems ... like every CPAN linked command (gzip, ftp, wget, etc) can't be found by CPAN... but WHY? Any clues? Thanks again, Regards, Steve Hemond Programmeur Analyste / Analyst Programmer Smurfit-Stone, Ressources Forestières La Tuque, P.Q. Tel.: (819) 676-8100 X2833 [EMAIL PROTECTED] -Original Message- From: Remo Sanges [mailto:[EMAIL PROTECTED] Sent: Wednesday, February 04, 2004 3:18 PM To: Hemond, Steve Cc: [EMAIL PROTECTED] Subject: Re: How to reinstall CPAN? cpan o conf init On Feb 4, 2004, at 8:36 PM, Hemond, Steve wrote: Hi folks, For some reason, when running CPAN I get to many problems (I installed Perl v. 5.8.3 this morning, don't know if it has an effect) cpan install HTML::Mason CPAN: Storable loaded ok LWP not available CPAN: Net::FTP loaded ok Fetching with Net::FTP: ftp://cpan.chebucto.ns.ca/pub/CPAN/authors/01mailrc.txt.gz Going to read /usr/local/cpan/sources/authors/01mailrc.txt.gz Can't exec ./gzip: No such file or directory at /usr/local/lib/perl5/5.8.3/aix/IO/File.pm line 176, FIN line 1. Could not pipe[./gzip --decompress --stdout /usr/local/cpan/sources/authors/01mailrc.txt.gz |]: No such file or directory at /usr/local/lib/perl5/5.8.3/CPAN.pm line 5727, FIN line 1. Is there any way I can reinstall CPAN from scratch? Thanks! Steve Hemond Programmeur Analyste / Analyst Programmer Smurfit-Stone, Ressources Forestieres La Tuque, P.Q. Tel.: (819) 676-8100 X2833 [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 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: How to use the arguments to use() in the package being used
On Feb 4, Rob Dixon said: That's an interesting point Jeff. You're right that it's Module-import() instead of Module::import() as 'import' will be inherited in the (common) case that Module ISA Exporter. And also, 'Module' is sent as the first arg to import(). -- Jeff japhy Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/ stu what does y/// stand for? tenderpuss why, yansliterate of course. [ I'm looking for programming work. If you like my work, let me know. ] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE : How to reinstall CPAN?
Ok I have figured something out. The initial configurations are held in /path/to/perl/lib/CPAN/Config.pm I have corrected the gzip, ftp, tar, etc.. lines so it points to the right absolute path to the binaries. It works now. Thanks a lot. Best regards, Steve Hemond Programmeur Analyste / Analyst Programmer Smurfit-Stone, Ressources Forestières La Tuque, P.Q. Tel.: (819) 676-8100 X2833 [EMAIL PROTECTED] -Original Message- From: Remo Sanges [mailto:[EMAIL PROTECTED] Sent: Wednesday, February 04, 2004 3:18 PM To: Hemond, Steve Cc: [EMAIL PROTECTED] Subject: Re: How to reinstall CPAN? cpan o conf init On Feb 4, 2004, at 8:36 PM, Hemond, Steve wrote: Hi folks, For some reason, when running CPAN I get to many problems (I installed Perl v. 5.8.3 this morning, don't know if it has an effect) cpan install HTML::Mason CPAN: Storable loaded ok LWP not available CPAN: Net::FTP loaded ok Fetching with Net::FTP: ftp://cpan.chebucto.ns.ca/pub/CPAN/authors/01mailrc.txt.gz Going to read /usr/local/cpan/sources/authors/01mailrc.txt.gz Can't exec ./gzip: No such file or directory at /usr/local/lib/perl5/5.8.3/aix/IO/File.pm line 176, FIN line 1. Could not pipe[./gzip --decompress --stdout /usr/local/cpan/sources/authors/01mailrc.txt.gz |]: No such file or directory at /usr/local/lib/perl5/5.8.3/CPAN.pm line 5727, FIN line 1. Is there any way I can reinstall CPAN from scratch? Thanks! Steve Hemond Programmeur Analyste / Analyst Programmer Smurfit-Stone, Ressources Forestieres La Tuque, P.Q. Tel.: (819) 676-8100 X2833 [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 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: formatting and syntax
On Feb 4, Michael S. Robeson II said: bob AGTGATGCCGACG fred ACGCATATCGCAT jon CAGTACGATTTATC R 1 20 A G U G A T G C C G A C G - - - - - - - bob A C G C A U A U C G C A U - - - - - - - fred C A G U A C G A U U U A U C - - - - - - jon The R 1 is static and should always appear. The 20 at the top of the new file should be a number defined by the user, that is they should be prompted for the length they wish the sequence to be. That is the total length of the sequence plus the added dashes could be 20 or 3000 or whatever. So, if they type 20 and there is only 10 letters in that row then the script should add 10 dashes to bring that total up to the 20 chosen by the user. I'll provide one way to do this: # assuming $size has the number entered by the user while (FILE) { my ($name) = / (.+)/;# get the line name chomp(my $DNA = FILE); # get the next line (the DNA) # add $size - length() dashes to the end of $DNA $DNA .= - x ($size - length $DNA); # print the DNA with spaces, then a tab, then the name print join( , split //, $DNA), \t$name\n; } -- Jeff japhy Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/ stu what does y/// stand for? tenderpuss why, yansliterate of course. [ I'm looking for programming work. If you like my work, let me know. ] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: symbolic references
On Feb 4, 2004, at 1:38 PM, David Byrne wrote: Greetings, Hello. Im trying to generate a tree of nested hashes [of an arbitrary size]. I'm trying to run the code you posted, so I can see what the heck is going on. That's not going well for me either. laughs My processor usage spikes through the roof, but it doesn't seem to get anywhere. Does this run for you? Perhaps you could suggest a better solution. Perhaps. I know you're building some sort of hash tree, but I have no idea why. Can you tell us what you're aiming for? Currently I'm trying to use symbolic references according to the literature but without much luck. My opinion is that we can do better than symbolic references, yes. Unfortunately, I don't understand what we're trying to do. Take a step back and explain the problem to us, if you would, not the problem with the implementation. James -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
FYI: 2 perl courses for additional guidance
Hi all, A few months ago before I started studying for the LSAT, I was trying to learn perl using Beginning Perl, and the expertise of users on this list. Well, that test prep put my perl learning on hold, and now that it's done, I'm back to working on my project. Anyway, the point of this email is to alert those out there that want to learn perl, and find that learning from a course is much easier than a from a book, or at least a syllabus or book styled as a course, I proffer two websites I stumbled on last night: Summer Perl course for HS students at Brown U. http://www.cs.brown.edu/people/dg/summer04/ I browsed this site and thought it was great. It is by a Ph.D. student that wants to be a prof, and he is teaching a summer course at Brown. Though I am not sure it is meant to be free (however, I presume that he wouldn't publish it without password protection if he really wanted to limit access to his paying students), but it is there, and seems to be pretty good. I like it at least. Perl for Text Processing http://www.ccl.umist.ac.uk/staff/paul/perlcourse.html This is another one that I think is by a prof in the UK. It has a text processing focus, hence the title, and is really what I want out of perl anyway, so I'd certainly use it. The caveat emptor here is that in the 12 lessons, I don't think he advise use strict; until lesson 10. The caveat emptor for both is that, while I like to think I'm smart and educated, I'm not trained in computer science, but rather the science of the political kind, and therefore, can't say, with just a browsing of the offerings, that they teach good programming practices. I can say that I'm going to look at them more closely and possibly utilize them in the coming weeks. Apologies for the loquaciousness, but I prefer to make easy things hard, and hard things harder. :-D I hope this helps someone. -stu __ Do you Yahoo!? Yahoo! SiteBuilder - Free web site building tool. Try it! http://webhosting.yahoo.com/ps/sb/ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: sort -- following question: How to rearrange columns
Hello, With this sample data set, I have a different question. How can I rearrange columns such as this: before: col1col4col5col2col6col3 Abc 12.88 left1 15.7 Def 13.89 top 0 19.7 gef 14.89 left0 19.7 Dgf 12.39 right 4 99.6 cef 16.84 right 0 89.7 baf 32.87 bottom 5 79.8 efg 16.85 right 0 56.7 etg 12.82 left7 34.7 after: col1col2col3col4col5col6 Abc left15.712.88 1 Def top 19.713.89 0 gef left19.714.89 0 Dgf right 99.612.39 4 cef right 89.716.84 0 baf bottom 79.832.87 5 efg right 56.716.85 0 etg left34.712.82 7 I thought one way to do it is to transpose the array, sort _ColumnName_, then transpose it back. Is this right way to do it? Thanks, Shiping At 07:50 PM 1/29/2004 -0500, Hanson, Rob wrote: I have to run, otherwise I would elaborate a bit. The code is below. Check out the perldoc perlreftut for what the [EMAIL PROTECTED], @{$row}, and $a-[2] means. Check out perldoc -f sort for what the sort {...} @rows means. And of course ask questions if you get stuck (but take a look at the docs first). THE CODE my @rows; while (my $line = DATA) { chomp($line); my @cols = split(/\s+/, $line); push @rows, [EMAIL PROTECTED]; } print Sorted on 5th column:\n; @rows = sort {$a-[4] = $b-[4]} @rows; foreach my $row (@rows) { print @{$row}\n; } print Sorted on 3rd column:\n; @rows = sort {$a-[2] = $b-[2]} @rows; foreach my $row (@rows) { print @{$row}\n; } __DATA__ Abc 12.8 8 left 1 15.7 Def 13.8 9 top 0 19.7 gef 14.8 9 left 0 19.7 Dgf 12.3 9 right 4 99.6 cef 16.8 4 right 0 89.7 baf 32.8 7 bottom 5 79.8 efg 16.8 5 right 0 56.7 etg 12.8 2 left 7 34.7 THE OUTPUT $ perl sort.pl Sorted on 5th column: efg 16.8 5 right 0 56.7 Def 13.8 9 top 0 19.7 gef 14.8 9 left 0 19.7 cef 16.8 4 right 0 89.7 Abc 12.8 8 left 1 15.7 Dgf 12.3 9 right 4 99.6 baf 32.8 7 bottom 5 79.8 etg 12.8 2 left 7 34.7 Sorted on 3rd column: etg 12.8 2 left 7 34.7 cef 16.8 4 right 0 89.7 efg 16.8 5 right 0 56.7 baf 32.8 7 bottom 5 79.8 Abc 12.8 8 left 1 15.7 Dgf 12.3 9 right 4 99.6 Def 13.8 9 top 0 19.7 gef 14.8 9 left 0 19.7 -Original Message- From: Boon Chong Ang [mailto:[EMAIL PROTECTED] Sent: Thursday, January 29, 2004 7:38 PM To: [EMAIL PROTECTED] Subject: sort Hi, I want to write a perl script to do something like this Abc 12.8 8 left 1 15.7 Def 13.8 9 top 0 19.7 gef 14.8 9 left 0 19.7 Dgf 12.3 9 right 4 99.6 cef 16.8 4 right 0 89.7 baf 32.8 7 bottom 5 79.8 efg 16.8 5 right 0 56.7 etg 12.8 2 left 7 34.7 Just say I want to sort the row based on the value on fifth or third column, any advice how to do so? Thank you best regards, ABC -- 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: RE : How to reinstall CPAN?
/usr/local# cpan o conf init CPAN: Storable loaded ok LWP not available CPAN: Net::FTP loaded ok Fetching with Net::FTP: ftp://cpan.chebucto.ns.ca/pub/CPAN/authors/01mailrc.txt.gz Going to read /usr/local/cpan/sources/authors/01mailrc.txt.gz Could not pipe[./gzip --decompress --stdout /usr/local/cpan/sources/authors/01mailrc.txt.gz |]: A file or directory in the path name does not exist. at /usr/local/lib/perl5/5.8.3/CPAN.pm line 5727. Same problems ... like every CPAN linked command (gzip, ftp, wget, etc) can't be found by CPAN... but WHY? Any clues? Have you tried entering full paths for the commands? CPAN may be messing up the cwd for some reason before reaching the commands. I thought CPAN provided the full paths as the defaults when calling 'o conf init'?? http://danconia.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: symbolic references
Okay, sorry to be somewhat unclear with my question. Heres some sample input data that may help to clear things up: ### node_id = 0 parent_node_id = N/A child_node_ids = 1, 2 node_id = 1 parent_node_id = 0 child_node_ids = 3, 4 node_id = 2 parent_node_id = 0 child_node_ids = 5, 6, 7 node_id = 3 parent_node_id = 1 child_node_ids = N/A node_id = 4 parent_node_id = 1 child_node_ids = 8, 9 node_id = 5 parent_node_id = 2 child_node_ids = N/A node_id = 6 parent_node_id = 2 child_node_ids = 10 node_id = 7 parent_node_id = 2 child_node_ids = N/A node_id = 8 parent_node_id = 4 child_node_ids = N/A node_id = 9 parent_node_id = 4 child_node_ids = 11, 12 #...and so on # Notes: - node_id = 0 is the root node. - N/A means no further relationships exist. - Only one parent exists for each child. - The 'child_node_id' is redundant data. There will be similar descriptive data for each node, but it isnt important for the structure of the tree. Question: How can I create a tree (i.e. a hash of hashes) given the above relationships? --- James Edward Gray II [EMAIL PROTECTED] wrote: On Feb 4, 2004, at 1:38 PM, David Byrne wrote: Greetings, Hello. Im trying to generate a tree of nested hashes [of an arbitrary size]. I'm trying to run the code you posted, so I can see what the heck is going on. That's not going well for me either. laughs My processor usage spikes through the roof, but it doesn't seem to get anywhere. Does this run for you? Perhaps you could suggest a better solution. Perhaps. I know you're building some sort of hash tree, but I have no idea why. Can you tell us what you're aiming for? Currently I'm trying to use symbolic references according to the literature but without much luck. My opinion is that we can do better than symbolic references, yes. Unfortunately, I don't understand what we're trying to do. Take a step back and explain the problem to us, if you would, not the problem with the implementation. James -- 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!? Yahoo! SiteBuilder - Free web site building tool. Try it! http://webhosting.yahoo.com/ps/sb/ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
(U) What are the best Perl books out there ... More than 1 is fin e ... list as many as you like
CLASSIFICATION: UNCLASSIFIED Classification: UNCLASSIFIED -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: How Am I?
On Wed, Feb 04, 2004 at 12:18:49PM -, Rob Dixon ([EMAIL PROTECTED]) wrote: Rob Dixon wrote: [stuff] Sorry guys. Just glad it wasn't anything too embarrassing :-/ /R I posted an intimate message to a lady friend of mine once to the Debian users list. I know how you feel, hehe. I got over it but it has taken 4 years and a lot of counseling ;) Kent -- Efficiency is intelligent laziness. -David Dunham -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: symbolic references
On Feb 4, 2004, at 4:19 PM, David Byrne wrote: Okay, sorry to be somewhat unclear with my question. Heres some sample input data that may help to clear things up: See if this gets you going. It's one possible answer. James #!/usr/bin/perl use strict; use warnings; use Data::Dumper; my $tree = data_to_hash_tree(); # build tree print Dumper($tree);# print tree sub data_to_hash_tree { my @nodes; # to store nodes during reading local $/ = ''; # use paragraph read mode while (DATA) { my %node = map { split /\s*=\s*/ } split /\n/; # build node from data $nodes[$node{node_id}] = \%node;# add to list } foreach (@nodes) { # cross reference and clean up nodes if ($_-{child_node_ids} eq 'N/A') { $_-{child_node_ids} = [ ]; } else { $_-{child_node_ids} = [ map { $nodes[$_] } split /,\s*/, $_-{child_node_ids} ]; } $_-{parent_node_id} = undef if $_-{parent_node_id} eq 'N/A'; } return $nodes[0]; # return root } __DATA__ node_id = 0 parent_node_id = N/A child_node_ids = 1, 2 node_id = 1 parent_node_id = 0 child_node_ids = 3, 4 node_id = 2 parent_node_id = 0 child_node_ids = 5, 6, 7 node_id = 3 parent_node_id = 1 child_node_ids = N/A node_id = 4 parent_node_id = 1 child_node_ids = 8, 9 node_id = 5 parent_node_id = 2 child_node_ids = N/A node_id = 6 parent_node_id = 2 child_node_ids = 10 node_id = 7 parent_node_id = 2 child_node_ids = N/A node_id = 8 parent_node_id = 4 child_node_ids = N/A node_id = 9 parent_node_id = 4 child_node_ids = 11, 12 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Make this into a script to parse?
I'm back to dealing with the main issue of a badly formatted file being brought down from an archaic system and needing to be cleaned up before being passed to another user or a database table. I have the code below, which pulls the whole file in and parse it line by line. That problem is still that when the stuff is done parsing the file, the file still has a ton of white spaces left in it. What I would like to do is when I first open the file (another piece of this massive script) is tell it to just run a sub program on each piece that does the same thing as the stuff below, unfortunately I am not sure of the way to do this. This piece I DO have: sub cleanup{ use strict; my $file = info/bad.sql; my $newfile = info/inventory.sql; my $line; open (OLDFILE, $file); open (NEWFILE, $newfile); while ($line = OLDFILE) { $line =~ s/^ //mg; $line =~ s/ $//mg; $line =~ s/\t/|/mg; $line =~ s/\s+/ /mg; $line =~ s/^\s*//mg; $line =~ s/\s*$//mg; $line =~ s/\s*$//mg; ### The following lines mod the files to reflect inches and feet $line =~ s/(?=\d)/in. /mg; $line =~ s/(?=\d)'/ft. /mg; $line =~ s/^\s+//mg; $line =~ s/\s+$//mg; # $line =~ s/\s*\|\s*//mg; ### $line =~ s/ |/|/mg; ### $line =~ s/| /|/mg; print NEWFILE $line\n; } close OLDFILE; close NEWFILE; print $newfile has now been created\n; } The first pass of the code which piece of the array of data into another location further back in the file: sub MySQL_id_data { $database_file = info/salesa1; open(INF,$database_file) or dienice(Can't open $database_file: $! \n); @grok = INF; close(INF); $file1 = info/salesa1-data; open (FILE, $file1) || die Can't write to $file1 : error $!\n; $inv = 1; foreach $i (@grok) { chomp($i); ($item_num,$item_desc,$b1,$b2,$b3,$b4,$cc,$vn,$qoh,$qc,$qor,$bc,$sc,$yp) = split(/\|/,$i); print FILE $inv|$item_num|$item_desc|$b1|$b2|$b3|$b4|$cc|$vn|$qoh|$qc|$qor|$bc|$it em_num|$sc|$yp\n; $inv++; } close FILE; } HELP!! Thanks, Robert -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: special vars
On Feb 4, 2004, at 10:23 AM, Rob Dixon wrote: [..] Disabling output buffering in Perl should be seen as a nicety that helps debugging, but not much else. Only a hardware solution can guard against losing power at the wrong time. Minor Nit, yes I know that the thread has been about disk and/or filesystem I/O - but the need to disable output buffering becomes very important when one is doing client-server code over a socket and/or pipe. Nothing like having one side waiting for the otherside to do something - but the message did not get sent because it is sitting in a buffer waiting to be flushed... ciao drieux --- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Make this into a script to parse?
For Quality purpouses, Lone Wolf 's mail on Thursday 05 February 2004 00:52 may have been monitored or recorded as: I'm back to dealing with the main issue of a badly formatted file being brought down from an archaic system and needing to be cleaned up before being passed to another user or a database table. I have the code I assume by saying you are back that you are talking ofyour thread from 12/17: get rid of whitesace around pipes??. below, which pulls the whole file in and parse it line by line. That problem is still that when the stuff is done parsing the file, the file still has a ton of white spaces left in it. did you try something like my @fields = split /\s*\|\s*/, $line; as suggested by James, Jeff and Randy? Why didnt it work - the problem looks still pretty much the same, does it? What I would like to do is when I first open the file (another piece of this massive script) is tell it to just run a sub program on each piece that does the same thing as the stuff below, unfortunately I am not sure of the way to do this. Frankly, after a while of looking at your code Im still not sure what you want do - that might be due to my ignorance, but you would really help me (and I guess others too) understand, if you could post some sample data before they go into your program and a line of how you expect thme to look like after they were processed by your code - I guess that would make it easier to figure out, where what goes how (or so). Wolf -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Module for Country/Country Codes Lists
On 2/4/2004 11:36 AM, Shlomi Fish wrote: Hi! My name is Shlomi Fish and I am a co-developer of the WWW::Form module: http://search.cpan.org/~bschmau/WWW-Form-1.13/ Benjamin Schmaus (WWW::Form's main developer) and I decided it would be a good idea for the module or an extension of it to provide common form controls like a country list or a U.S. states list. To do so we need a module that returns a country list. Ideally what we would like is for it to return a refernece to a hash of country codes (US, IL, UK, RU, etc.) that each map to a contry name (United States, Israel, United Kingdom, Russia). Or alternatively, a similar interface with similar capabilites. We enumberated our needs here: http://benschmaus.com/cgi-bin/twiki/view/Main/WwwFormCountryList So, is there a good module for doing that on CPAN that is also actively maintained and updated? You should be able to build on Locale::Country Locale::SubCountry. Regards, Randy. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Make this into a script to parse?
On Feb 4, Lone Wolf said: I'm back to dealing with the main issue of a badly formatted file being brought down from an archaic system and needing to be cleaned up before being passed to another user or a database table. I have the code below, which pulls the whole file in and parse it line by line. That problem is still that when the stuff is done parsing the file, the file still has a ton of white spaces left in it. open (OLDFILE, $file); open (NEWFILE, $newfile); while ($line = OLDFILE) { $line =~ s/^ //mg; $line =~ s/ $//mg; $line =~ s/\t/|/mg; $line =~ s/\s+/ /mg; $line =~ s/^\s*//mg; $line =~ s/\s*$//mg; $line =~ s/\s*$//mg; These regexes (above and below) have NO need for the /m modifier, and only a few of them have any need for the /g modifier. $line =~ s/^\s+//; # remove leading spaces $line =~ s/\s+$/; # remove trailing spaces $line =~ tr/\t/|/; # change all \t's to |'s $line =~ tr/ //s; # squash multiple spaces on one space Those four lines (two regexes, two transliterations) do what the seven lines above them do. $line =~ s/(?=\d)/in. /mg; $line =~ s/(?=\d)'/ft. /mg; Still don't need the /m modifier. $line =~ s/^\s+//mg; $line =~ s/\s+$//mg; The first one is totally useless, and the second is only needed because it's possible $line now ends in in. , which means the trailing space should be removed. The solution, then, is to do the two \d regexes FIRST, and THEN do the other regexes. # $line =~ s/\s*\|\s*//mg; ###$line =~ s/ |/|/mg; ###$line =~ s/| /|/mg; Are those not needed, or commented out because they're not working properly? print NEWFILE $line\n; } close OLDFILE; close NEWFILE; print $newfile has now been created\n; } sub MySQL_id_data { $database_file = info/salesa1; open(INF,$database_file) or dienice(Can't open $database_file: $!\n); @grok = INF; close(INF); There's no reason to slurp a file into an array. Just loop over the lines of the file like you have with the while loop above. $file1 = info/salesa1-data; open (FILE, $file1) || die Can't write to $file1 : error $!\n; $inv = 1; foreach $i (@grok) { chomp($i); ($item_num,$item_desc,$b1,$b2,$b3,$b4,$cc,$vn,$qoh,$qc,$qor,$bc,$sc,$yp) = split(/\|/,$i); print FILE $inv|$item_num|$item_desc|$b1|$b2|$b3|$b4|$cc|$vn|$qoh|$qc|$qor|$bc|$it em_num|$sc|$yp\n; $inv++; } Oh good God. Do you know what that for loop is DOING? for each element in @grok: remove the newline split it on pipes into some variables print $inv, those variables with pipes in between, and add a newline That is terribly insane. close FILE; } Here's my rewrite: sub MySQL_id_data { my $db_file = info/salesa1; my $info_file = $db_file-data; open DB, $db_file or dienice(can't open $db_file: $!); open INFO, $info_file or dience(can't write $info_file: $!); print INFO $.|$_ while DB; close INFO; close DB; } -- Jeff japhy Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/ stu what does y/// stand for? tenderpuss why, yansliterate of course. [ I'm looking for programming work. If you like my work, let me know. ] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: (U) What are the best Perl books out there ... More than 1 is fin e ... list as many as you like
Hi, I like: Learning Perl by Randal Schwartz Tom Phoenix as a good introduction with tons of further references Programing Perl by Larry Wall, Tom Christiansen and Jon Orwant as the ultimate refernce and pillow Mastering Perl/Tk by Steve Lidie and Nancy Walsh for times when I dont have access to this mailing list and zentaras hints The Perl Cookbook by Tom Christiansen and Nathan Torkington for when I was to lasy to think for myself (or wanted to get depressed by how much better one could solve the problem Ive been working on in hunderts of lines) And even though I never read it in the linear way: Mastering regular expressions by Jeffrey Friedl Not to forget: perldoc perltoc or www.perldoc.com and The Hitchhickers Guide to the Galaxy and Last Chance to see by Douglas Adams. I guess others would recomend The Lord of the rings too. Good night:-) Wolf -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: (U) What are the best Perl books out there ... More than 1 is fin e ... list as many as you like
On Feb 4, 2004, at 2:36 PM, Johnson, Michael wrote: CLASSIFICATION: UNCLASSIFIED Classification: UNCLASSIFIED I guess a part of the question is at what level. My general documentation is at: http://www.wetware.com/drieux/CS/Proj/TPFH/gen_doc.html if you feel at home reading just Perl Doc's, the the simpler fix is to read it from http://www.perldoc.com/ so are you looking at reading or teaching? ciao drieux --- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: In what order does a program run..??
On 2/4/2004 10:52 AM, [EMAIL PROTECTED] wrote: I'm new to PERL and am trying to learn by reading some PERL programs. My question is this - does PERL execute sequentially and skip around embedded subroutines or Does it execute them inline? In depth answer: perl reads in your source file and parses the code from top to bottom. If it sees a 'use module;' statement it stops parsing your file, reads and parses the used module, and then resumes parsing your source. If it encounters any 'BEGIN' subs (there can be more than one), it executes the code in that sub as soon as the complete sub has been completely parsed, but before parsing the remainder of your source. After the source has been parsed, perl executes any 'CHECK' subs (there can be more than one) beginning with the last, continuing in the *reverse* order of definition. If you specify the '-c' (compile-only) switch, the process ends here. Otherwise perl continues execution at the top first with the execution of any 'INIT' subs in the order they are defined. Then perl begins executing any code at file scope, executing code in subroutines only when (or if) they are called. Afterwards, perl executes any 'END' subs in reverse order of definition. Randy. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: Make this into a script to parse?
I tried the my @fields and I did not get it to work, probably because my coding skills have not improved enough lately to be worthy of perl. Thank goodness I never said I had perfect code, because I would definitely be lying. I attached 2 files, one the beginning data, the other the .sql file that I load into MySQL database. The files are about 3000 lines before and after so I cut out the first 30 lines and put them in the files to the list. What I need to figure out is how to make a sub call that when I pull in the file will remove all extraneous white space. Something I can copy into another Perl program to parse another set of files (ARGH!). I've learned not to tell the bosses I can write a script to handle the errors of the salesmen. I currently use a back piece of PHP coding to handle the extra spaces in the pages that use the data, but for another project I can't use that work-around. I know I can do something along the lines of: (from an HTML generating page with a sort) foreach $i (sort ByName @grok) { chomp($i); ($type,$description,$parts,$numb) = split(/\|/,$i); print INFO2; trtd$type/tdtd$description/tdtd$parts/tdtd$numb/td/tr INFO2 } The sub program: sub ByName { @a = split(/\|/,$a); @b = split(/\|/,$b); $a[1] cmp $b[1]; } But I am still not sure how to make the $i go through, and it is probably something simple I am missing. Thanks!! Robert 1|AA-1202|12in. X10.75 FOIL SHEETS 12/200|70.96|46.40|45.24|44.13|246|3|55.000|.000|.000|A|AA-1202 2|AA-1205|12in. x10in. FOIL POPUP SHEETS 6/500|96.61|63.17|61.59|60.09|246|3|19.000|.000|.000|B|AA-1205 3|AA-1215RO|12in. X1000ft. ROYALE FOIL STD 1|25.16|15.84|15.46|15.09|245|3|56.000|5.000|.000|B|AA-1215RO 4|AA-1217SE|12in. X1000 ALUMINUM FOIL STD 1|30.18|19.73|19.24|18.77|245|3|36.000|.000|.000|B|AA-1217SE 5|AA-1251|12in. X500 ALUMINUM FOIL (HVY) EA|26.25|17.17|16.74|16.33|245|3|34.000|.000|.000|B|AA-1251 6|AA-1255RO|12in. X500ft. ROYALE FOIL STD 1/CS|15.96|10.05|9.81|9.58|245|3|30.000|.000|.000|C|AA-1255RO 7|AA-1817SE|18in. X1000 STD.DUTY FOIL-RL 1|42.82|28.00|27.30|26.63|245|3|17.000|.000|.000|C|AA-1817SE 8|AA-1825|18in. X25ft. HEAVY DUTY-RL 12|28.29|27.27|26.79|26.17|245|3|6.000|.000|.000|C|AA-1825 9|AA-1851SE|18in. X500 ALUMINUM FOIL (HVY) 1|32.67|21.36|20.83|20.32|245|3|116.000|4.000|.000|A|AA-1851SE 10|AA-1857SE|18in. X500in. ALUMINUM FOIL STD 1|24.41|15.96|15.56|15.18|245|3|67.000|.000|.000|B|AA-1857SE 11|AA-455-44|1/2 AL.STEAM T/PAN-MEDIUM 100|40.59|27.24|26.54|25.88|212|3|22.000|.000|.000|B|AA-455-44 12|AA-456-44|1/2 AL.STEAM T/PAN-DEEP 100|34.16|24.54|23.86|23.38|212|3|97.000|1.000|.000|A|AA-456-44 13|AA-457-70|FULL AL.STEAM T/PAN-MEDIUM 50|53.57|36.92|35.95|35.03|212|3|9.000|.000|.000|B|AA-457-70 14|AA-458-40|1/2 AL.STEAM T/PAN-SHALLOW 100|34.49|22.99|22.41|21.85|212|3|11.000|.000|.000|C|AA-458-40 15|AA-459-70|FULL AL.STEAM T/PAN-SHALLOW 50|53.02|36.30|35.35|34.45|212|3|8.000|1.000|.000|C|AA-459-70 16|AA-460-70|FULL AL.STEAM T/PAN-DEEP 50|44.49|30.25|29.47|28.72|212|3|116.000|2.000|.000|A|AA-460-70 17|AA-516430WLR|***9ft. RND CONT W/FOIL BD LD 250|57.80|49.13|45.35|42.11|77|3|8.000|.000|.000|D|AA-516430WLR 18|AA-552-40|ASHTRAY ROUND SILVER 1000|77.65|50.77|49.50|48.29|2|3|15.000|.000|.000|B|AA-552-40 19|AA-554-40|FULL AL.STEAM T/PAN-FOIL COV50|27.45|17.95|17.50|17.07|212|3|42.000|2.000|.000|A|AA-554-40 20|AA-555-30|1/2 AL.STEAM T/PAN-FOIL COV100|14.44|13.75|13.42|12.94|212|3|23.000|1.000|.000|B|AA-555-30 21|AA-688-64A|19in. AL.ROAST.PAN-OVAL-GIANTG50|51.24|51.24|51.24|51.24|212|3|15.000|.000|.000|C|AA-688-64A 22|AA-9102|9X10.75 FOIL SHEETS 12/200|51.71|33.81|32.96|32.16|246|3|17.000|.000|.000|B|AA-9102 23|AA-9105|9X10.75 FOIL SHEETS 6/500|59.47|38.88|37.91|36.99|246|3|94.000|5.000|.000|A|AA-9105 24|AA-A12DL|12in. DOME CLEAR LID-A13A16 25|13.73|9.72|9.46|9.21|41|3|3.000|.000|.000|C|AA-A12DL 25|AA-A12FT|12in. ALUMINUM FLAT TRAY 25|15.51|10.99|10.69|10.41|41|3|5.000|.000|.000|C|AA-A12FT 26|AA-A12LS|12in. ALUMINUM 5-CMPT.TRAY 25|15.51|10.99|10.69|10.41|41|3|15.000|.000|.000|C|AA-A12LS 27|AA-A16DL|16in. DOME CLEAR LID 25|20.76|14.71|14.31|13.93|41|3|11.000|1.000|.000|B|AA-A16DL 28|AA-A16FT|16in. ALUMINUM FLAT TRAY 25|25.69|18.19|17.70|17.24|41|3|10.000|1.000|.000|B|AA-A16FT 29|AA-A16LS|16in. ALUMINUM 5-CMPT.TRAY 25|25.69|18.19|17.70|17.24|41|3|8.000|.000|.000|C|AA-A16LS 30|AA-A18DL|18in. DOME CLEAR LID 25|29.84|21.14|20.57|20.03|41|3|7.000|1.000|.000|C|AA-A18DL AA-1202 |12X10.75 FOIL SHEETS 12/200| 70.96 | 46.40 | 45.24 | 44.13 |UF|ALCAN |55.000 | .000 | .000 |A AA-1205 |12x10FOIL POPUP SHEETS 6/500| 96.61 | 63.17 | 61.59 | 60.09 |UF|ALCAN |19.000 | .000 | .000 |B AA-1215RO |12X1000' ROYALE FOIL STD1| 25.16 | 15.84 | 15.46 | 15.09 |U5|ALCAN |56.000 | 5.000 | .000 |B AA-1217SE |12X1000 ALUMINUM FOIL STD 1| 30.18 | 19.73 |
Re: Make this into a script to parse?
On Wed, 4 Feb 2004, Jeff 'japhy' Pinyan wrote: snip foreach $i (@grok) { chomp($i); ($item_num,$item_desc,$b1,$b2,$b3,$b4,$cc,$vn,$qoh,$qc,$qor,$bc,$sc,$yp) = split(/\|/,$i); print FILE $inv|$item_num|$item_desc|$b1|$b2|$b3|$b4|$cc|$vn|$qoh|$qc|$qor|$bc|$it em_num|$sc|$yp\n; $inv++; } Oh good God. Do you know what that for loop is DOING? for each element in @grok: remove the newline split it on pipes into some variables print $inv, those variables with pipes in between, and add a newline That is terribly insane. Jeff, The input and output lines are not identical. The output line prefixes $inv at the front and inserts $item_num between $bc and $sc. I don't know why $item_num is repeated. Granted that I think a more efficient construct might be: my ($item_num,$a,$b) = $i =~ /(.*?|)((?:.*?|){11})(.*)/; print LINE $inv|$item_num|$a|$item_num|$b\n; I think that I have that right. Well, assuming that the original is correct. -- Maranatha! John McKown -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
removing all elements in an array
How can I simply remove all elements in an array, given that the array is global and a procedure defines the elements to where the total number of elements in this array could be very well be less. I have tried @array = (); but this seems to affect the arrary in that it wont take any element assignments afterwards. Do I need to iterate through each element and blank the out? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: (U) What are the best Perl books out there ... More than 1 is fin e ... list as many as you like
On 2/4/2004 10:17 PM, wolf blaum wrote: Hi, I like: Learning Perl by Randal Schwartz Tom Phoenix as a good introduction with tons of further references Programing Perl by Larry Wall, Tom Christiansen and Jon Orwant as the ultimate refernce and pillow Mastering Perl/Tk by Steve Lidie and Nancy Walsh for times when I dont have access to this mailing list and zentaras hints The Perl Cookbook by Tom Christiansen and Nathan Torkington for when I was to lasy to think for myself (or wanted to get depressed by how much better one could solve the problem Ive been working on in hunderts of lines) And even though I never read it in the linear way: Mastering regular expressions by Jeffrey Friedl Not to forget: perldoc perltoc or www.perldoc.com and The Hitchhickers Guide to the Galaxy and Last Chance to see by Douglas Adams. I guess others would recomend The Lord of the rings too. Good night:-) Wolf Since there was no mention what kind of perl books (beginner, etc.): I'd add: Object Oriented Perl by Damian Conway, I've also been wanting to check out Learning Perl Objects, References, Modules by Randall Schwartz. Advanced Perl Programming by Sriram Srinivasan (getting slightly out of date; seems I heard of updated edition coming ???). Effective Perl Programming by Joseph Hall is not bad. Writing Perl Modules for CPAN by Sam Tregar is pretty good if your going to write modules for CPAN. Extending Embedding Perl by Tim Jenness Simon Cozens is good if your going to get into Perl/XS. You'll definately want the Perl Cookbook mentioned above. It's the Perl equivelant of the Effective C++ books. Regards, Randy. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: removing all elements in an array
On Feb 4, Markham, Richard said: How can I simply remove all elements in an array, given that the array is global and a procedure defines the elements to where the total number of elements in this array could be very well be less. I have tried @array = (); but this seems to affect the arrary in that it wont take any element assignments afterwards. Then you're doing something wrong. @array = (); is the proper way to do it. Show us your code. -- Jeff japhy Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/ stu what does y/// stand for? tenderpuss why, yansliterate of course. [ I'm looking for programming work. If you like my work, let me know. ] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Make this into a script to parse?
On Feb 4, John McKown said: On Wed, 4 Feb 2004, Jeff 'japhy' Pinyan wrote: foreach $i (@grok) { chomp($i); ($item_num,$item_desc,$b1,$b2,$b3,$b4,$cc,$vn,$qoh,$qc,$qor,$bc,$sc,$yp) = split(/\|/,$i); print FILE $inv|$item_num|$item_desc|$b1|$b2|$b3|$b4|$cc|$vn|$qoh|$qc|$qor|$bc|$it em_num|$sc|$yp\n; $inv++; } Oh good God. Do you know what that for loop is DOING? That is terribly insane. Jeff, The input and output lines are not identical. The output line prefixes $inv at the front and inserts $item_num between $bc and $sc. I don't know why $item_num is repeated. Granted that I think a more efficient construct might be: Bah, I missed that. Then I'd use split(), but just use an array. while (IN) { local $ = |; my @fields = split /\|/; print OUT $.|@fields[0..11,0,12..13]; } But this begs the question, WHY does item_num have to be used TWICE in the SAME line of data. This smells of poor coding on the other side. It's still ugly. -- Jeff japhy Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/ stu what does y/// stand for? tenderpuss why, yansliterate of course. [ I'm looking for programming work. If you like my work, let me know. ] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: removing all elements in an array
On 2/4/2004 10:27 PM, Markham, Richard wrote: How can I simply remove all elements in an array, given that the array is global and a procedure defines the elements to where the total number of elements in this array could be very well be less. I have tried @array = (); but this seems to affect the arrary in that it wont take any element assignments afterwards. Do I need to iterate through each element and blank the out? @array = (); is what you want. What kind of assignments are producing errors, and what errors are you getting? Randy. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: removing all elements in an array
For Quality purpouses, Markham, Richard 's mail on Thursday 05 February 2004 04:27 may have been monitored or recorded as: How can I simply remove all elements in an array, given that the array is global and a procedure defines the elements to where the total number of elements in this array could be very well be less. I have tried @array = (); but this seems to affect the arrary in that it wont take any element assignments afterwards. well ---snip--- #!/usr/bin/perl use strict; use warnings; my @array=qw/1 2 3 4 5 6 a s d f g/; print Length for blank: , scalar @array,\n; print $_ foreach (@array); @array=(); print \nLength after blank: , scalar @array,\n; ---snap--- does it. @array=(); is the way to go: I guess your proble is somewhere else. Do I need to iterate through each element and blank the out? ...making easy thigs easy and hard things possible - heavans no! wolf -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Make this into a script to parse?
For Quality purpouses, Lone Wolf 's mail on Thursday 05 February 2004 04:23 may have been monitored or recorded as: Hi Thank goodness I never said I had perfect code, because I would definitely be lying. no worries - I post code to get feedback. Thats the whole ideaof learning it. I attached 2 files, one the beginning data, the other the .sql file that I load into MySQL database. The files are about 3000 lines before and after so I cut out the first 30 lines and put them in the files to the list. Ok - then, again: Do not read these files into mem at once unless you really have to (which should be close to never). here is a script that uses your given data: ---snip--- #!/usr/bin/perl use strict; use warnings; my (@fields, $lng); opendir INDIR , ./sql or die Can't open dir with before files:$!; foreach my $infile (grep {!/^\./} readdir INDIR) { #read all the files in your home/sql dir #read only files that do not start with a . my ($i,$rec); open INFILE, ./sql//$infile or die Can't open $infile: $!; open OUTFILE, ./${infile}.out or die Can't open ${infile}.out at home: $!; while (INFILE) { $rec++; chomp; @fields = split /\s*\|\s*/, $_; $fields[0] =~ s/^\s+//; #there is probably a way to get rid of the trailing spaces in the first entry using split,I just couldnt think of any. $lng = @fields unless $lng; #set $lng for first record print The following record: $i has , scalar @fields, fields as compared to $lng fields in the first record! Skip. : $_\n and next unless $lng == @fields; #poor quality control of your input data: check if all reords have the same number of fields or skip and print record otherwise. $i++; print OUTFILE $i; print OUTFILE |$_ foreach (@fields); print OUTFILE |$fields[0]\n; #your trailing ID } close INFILE; close OUTFILE; print Read $rec records from ./sql/$infile and printed $i into ./ ${infile}.out\n; } closedir INDIR; ---snap--- A couple of hints: The script reads all files in the sql subdir of your home dir and produces the corrosponding filname.out in your homedir. the split splits as written by Jeff et al. I coulndt think of a better way to substtute the leading spaces for the first field. Anyone better suggestions? you end up with a final \n in each outfile. You rewrite it into a sub by substititing the line foreach my $infile (grep {!/^\./} readdir INDIR) { with sub whatever{ ... foreach my $infile (@_) { and call th sub with whatever (file1, file2, ...); of course you may want to change the open statements to, if you dont have your infiles in ./sql Hope that gets you started, Wolf -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Make this into a script to parse?
For Quality purpouses, wolf blaum 's mail on Thursday 05 February 2004 06:07 may have been monitored or recorded as: The script reads all files in the sql subdir of your home dir and produces the corrosponding filname.out in your homedir. shame on me: of course it reads all the files in the sub dir sql of the CURRENT DIR, not the home dir. use ~/ if you want your homedir... Well, if been here a while... Something else i forgot: why do you need the count on the beginning of the line? I hope not as a unique (primary) key for the dbtable you feed that into.There should be an AUTO_INCREMENT in your DB for that. And talking about DBs: According to te 3rd rule of Normalisation as outlined by e.f.codd of ibm in the 1970s: (to that i was arround at this time...) An Entity is said to be in 3rd normal form if it is allready in 2nd normal form and no nonidentifying attributs are dependent on any other nonidentifying attributs. The repeat of a value like $fields[0] clearly violates this rule. See www.databasejournal.com/sqletc/article.php/1428511 on Db Design. Good night, wolf -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Remote script execution
Hello Friends, I would be really grateful if someone could help me out with this. I want to write a script that when executed will get lots of details from 10 different Unix(AIX) and Windows(XP) boxes and generate a report. The details to be gathered about the machines include : 1) Names and versions of all the softwares on the machines. 2) Disk space usage. Etc... Please guide me how I could go about it... I am not aware of how a script running on 1 machine take data from commands that are to be run on other...(like rsh) Thanks in advance -aman
RE: Remote script execution
Thind, Aman [EMAIL PROTECTED] wrote: : : Hello Friends, : : I would be really grateful if someone could help me out with : this. : : I want to write a script that when executed will get lots of : details from 10 different Unix(AIX) and Windows(XP) boxes and : generate a report. : : The details to be gathered about the machines include : [snip] How are the machines connected? Charles K. Clarkson -- Head Bottle Washer, Clarkson Energy Homes, Inc. Mobile Home Specialists 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
RE: Remote script execution
Hello Charles, We have a 100 mbps LAN running tcp\ip...typical to company networks. Thanks Aman Thind -Original Message- From: Charles K. Clarkson [mailto:[EMAIL PROTECTED] Sent: 05 February 2004 11:31 To: [EMAIL PROTECTED] Subject: RE: Remote script execution Thind, Aman [EMAIL PROTECTED] wrote: : : Hello Friends, : : I would be really grateful if someone could help me out with : this. : : I want to write a script that when executed will get lots of : details from 10 different Unix(AIX) and Windows(XP) boxes and : generate a report. : : The details to be gathered about the machines include : [snip] How are the machines connected? Charles K. Clarkson -- Head Bottle Washer, Clarkson Energy Homes, Inc. Mobile Home Specialists 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 -- 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 script execution
Thind, Aman [EMAIL PROTECTED] wrote: : : We have a 100 mbps LAN running tcp\ip...typical to company networks. : : -Original Message- : From: Charles K. Clarkson [mailto:[EMAIL PROTECTED] : Sent: 05 February 2004 11:31 : To: [EMAIL PROTECTED] : Subject: RE: Remote script execution : : : Thind, Aman [EMAIL PROTECTED] wrote: : : : : Hello Friends, : : : : I would be really grateful if someone could help me out with : : this. : : : : I want to write a script that when executed will get lots of : : details from 10 different Unix(AIX) and Windows(XP) boxes and : : generate a report. : : : : The details to be gathered about the machines include : : [snip] : : How are the machines connected? : You might try the Operating System Interfaces section of CPAN: http://search.cpan.org/modlist/Operating_System_Interfaces The Quota module seems to do much of what you want. I don't have experience with your problem. Perhaps someone else will come on later and suggest a better module to start with. HTH, Charles K. Clarkson -- Head Bottle Washer, Clarkson Energy Homes, Inc. Mobile Home Specialists 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