Re: close (...) or die "$!"

2004-12-04 Thread Peter Scott
In article <[EMAIL PROTECTED]>, [EMAIL PROTECTED] (Felix Li) writes: >It's fairly well known that one should use "open" with an "or die". Is = >there really any condition where "close" fails, making the "or die" = >necessary? Sure. For example, when writing buffered data to a file and the filesy

Re: a warning which i can't understand

2004-12-04 Thread Lawrence Statton
> [EMAIL PROTECTED] ./backwards.pl > print (...) interpreted as function at ./backwards.pl line 14. > December > December > It's not a serious warning -- the program is doing what you coded it to do, and you can supress it by explicitly mentioning the filehandle in the print print STDOUT (('Ja

close or die() semantics

2004-12-04 Thread Lawrence Statton
I just remembered a program I wrote ten years ago where close() could (and often did) fail: Writing to an file residing on an NFS mount, where the NFS server had recently become unavailable - such that the flush accompanied with close() would generate an error. -- -- -- -- -- -- -- -- -- -- -- -

Re: a warning which i can't understand

2004-12-04 Thread Hameed U. Khan
HI, I really didn't understand. can you give some more details. On Sun, 5 Dec 2004 01:01:07 -0500, Felix Li <[EMAIL PROTECTED]> wrote: > Note the ''. in front of the list > > print ''.('January', 'February, 'March', 'April', 'May ', 'June','July', > > > 'August', 'September','October, 'Novemb

Re: close (...) or die "$!"

2004-12-04 Thread Lawrence Statton
> On Sat, 4 Dec 2004, Felix Li wrote: > > > It's fairly well known that one should use "open" with an "or die". Is > > there really any condition where "close" fails, making the "or die" > > necessary? > > Of course! > > Off the top of my head, there are two obvious possibilities: > > * The

Re: Tabulate data in a sequential file

2004-12-04 Thread Lawrence Statton
> Lawrence, > > Thanks for your explanation and pointers to perldoc, I can now manage > it basically. > > To print them out, now I use > > for ($i=0; $i<=$max_records; $i++) { >foreach $key (@keys) { > print $data{$key}[$i]; >} > } > > A little bit clumsy,

Re: a warning which i can't understand

2004-12-04 Thread Felix Li
Note the ''. in front of the list print ''.('January', 'February, 'March', 'April', 'May ', 'June','July', 'August', 'September','October, 'November', 'December')[-1]; - Original Message - From: "Hameed U. Khan" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Sunday, December 05, 2004

a warning which i can't understand

2004-12-04 Thread Hameed U. Khan
Hi, i am new to perl and to this mailing list. My name is Hameed and I am 20 years old. I am doing BCS from Biztek (http://biztek.edu.pk). i have joined this mailing list because i am learning perl. i am getting a warinig which i can't understand so i am mailing you people. following is my progra

a warning which i can't understand

2004-12-04 Thread Hameed U. Khan
Hi, i am new to perl and to this mailing list. My name is Hameed and I am 20 years old. I am doing BCS from Biztek (http://biztek.edu.pk). i have joined this mailing list because i am learning perl. i am getting a warinig which i can't understand so i am mailing you people. following is my progr

Re: close (...) or die "$!"

2004-12-04 Thread Felix Li
That was my intent of my query. close ... or die "$!" - Original Message - From: "Kevin Lee Phair II" <[EMAIL PROTECTED]> To: "Perl Beginners List" <[EMAIL PROTECTED]> Sent: Sunday, December 05, 2004 12:35 AM Subject: Re: close (...) or die "$!" > Chris Devers wrote: > > >On Sat, 4

Re: close (...) or die "$!"

2004-12-04 Thread Kevin Lee Phair II
Chris Devers wrote: On Sat, 4 Dec 2004, Felix Li wrote: It's fairly well known that one should use "open" with an "or die". Is there really any condition where "close" fails, making the "or die" necessary? Of course! The 'open ... or die ...' idiom makes debugging *much* easier. I rea

Re: close (...) or die "$!"

2004-12-04 Thread Chris Devers
On Sat, 4 Dec 2004, Felix Li wrote: > It's fairly well known that one should use "open" with an "or die". Is > there really any condition where "close" fails, making the "or die" > necessary? Of course! Off the top of my head, there are two obvious possibilities: * The file might not exist;

How's a simpler way to do this? (pattern)

2004-12-04 Thread pablo wablo
Hello, I'm new to perl. I'm trying a regular expression that accepts register format for assembly. (r0 - r31) I have this regexp $in =~ /\b[rR] ( ([0-9]) | ( [12][0-9] ) | ( 3[01] ))\b/x; it works fine but I'm not satisfied with it.. (too long!) I have something in mind but I dont know th

Re: Tabulate data in a sequential file

2004-12-04 Thread Chan YW
Lawrence, Thanks for your explanation and pointers to perldoc, I can now manage it basically. To print them out, now I use for ($i=0; $i<=$max_records; $i++) { foreach $key (@keys) { print $data{$key}[$i]; } } A little bit clumsy, but it can do my work and I

close (...) or die "$!"

2004-12-04 Thread Felix Li
Greetings, It's fairly well known that one should use "open" with an "or die". Is there really any condition where "close" fails, making the "or die" necessary? felix

RE: Building Network Redundancy into a Perl Client

2004-12-04 Thread Jim
> I am trying to implement redundancy in a client application > that I am writing so that I can have a primary server and a > backup server. The client is tailing a logfile and sends > results to a server for processing, at the end of the tail > loop it sends data to a function that tries to e

Re: Getting the dir structure

2004-12-04 Thread John W. Krahn
Dan Jones wrote: On Thu, 2004-12-02 at 00:13 -0800, Mr M senthil kumar wrote: I have a file with thousands of line like : /abc/def/ijk/test.txt /pqr/lmn/test1.t I want to get the directory where the files test.txt and test1.txt are lying. Hi, You can try the following: #!/usr/bin/perl open (IN,"

Re: Perl module question

2004-12-04 Thread PerlDiscuss - Perl Newsgroups and mailing lists
Stephen Liu wrote: > Further to my last posting > $ perl wget_window.pl > Can't locate Tk.pm in @INC (@INC contains: > Tk.pm module still could not be found It can't be found because it didn't install: > t/zzScrolled.FAILED tests 66, 94 ... > /usr/bin/make test -- NOT OK >

Re: Portable safe directpry seperator

2004-12-04 Thread John W. Krahn
JupiterHost.Net wrote: To do this portably you should use the File::Spec module. perldoc File::Spec Ah perfect! File::Spec->catfile() is exactly what I need A new little jem every single day ;p Also, to understand some of the portability issues read the perlport document. perldoc perlport John --

Re: Getting the dir structure

2004-12-04 Thread Octavian Rasnita
All the files are automaticly closed when the perl program ends. Teddy - Original Message - From: "Dan Jones" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Sunday, December 05, 2004 1:25 AM Subject: Re: Getting the dir structure On Thu, 2004-12-02 at 00:13 -0800, Mr M senthil kumar

Re: Portable safe directpry seperator

2004-12-04 Thread JupiterHost.Net
To do this portably you should use the File::Spec module. perldoc File::Spec Ah perfect! File::Spec->catfile() is exactly what I need A new little jem every single day ;p Thanks John -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Re: Portable safe directpry seperator

2004-12-04 Thread John W. Krahn
JupiterHost.Net wrote: Hello again, Hello, I need to make sure a given path has an ending path separator: my $file = 'joemama'; my $path = '/foo/bar/wiz'; $path .= '/' if $path !~ m/\/$/; So I can then do "$path$file" and ensure its /foo/bar/wiz/joemama and not /foo/bar/wizjoemama The question is,

Re: Getting the dir structure

2004-12-04 Thread Dan Jones
On Thu, 2004-12-02 at 00:13 -0800, Mr M senthil kumar wrote: > > > > I have a file with thousands of line like : > > /abc/def/ijk/test.txt > > /pqr/lmn/test1.t > > I want to get the directory where the files test.txt and test1.txt are > > lying. > > > Hi, > You can try the following: > > #!/u

RE : Is try-catch a better method for handling errors ?

2004-12-04 Thread Jose Nyimi
> -Message d'origine- > De : Jonathan Paton [mailto:[EMAIL PROTECTED] > Envoyé : samedi 4 décembre 2004 20:08 > À : Nilay Puri, Noida; [EMAIL PROTECTED] > Objet : Re: Is try-catch a better method for handling errors ? > > Dear Nilay, > > I strongly recommend using exceptions (what you c

Re: Is try-catch a better method for handling errors ?

2004-12-04 Thread Jonathan Paton
Dear Nilay, I strongly recommend using exceptions (what you call "try-catch"), since you need to do something more complicated upon failure. You can implement exceptions using eval, die and checking the return value of eval. This is a rather ugly way to implement exceptions, but commonly used.

Re: stat and chmod safety and prtability

2004-12-04 Thread JupiterHost.Net
Lawrence Statton wrote: Hello group: In attempting to set $file2 to the same mode as $file1 I do this: my $mode = (stat($file1))[2]; chmod $mode, $file2; That code does the trick but I just want to make sure of: 1) I see in perldoc -f chmod it talks about oct() but if I'm using stat's mode it

Re: Portable safe directpry seperator

2004-12-04 Thread JupiterHost.Net
JupiterHost.Net wrote: Hello again, I need to make sure a given path has an ending path separator: my $file = 'joemama'; my $path = '/foo/bar/wiz'; $path .= '/' if $path !~ m/\/$/; So I can then do "$path$file" and ensure its /foo/bar/wiz/joemama and not /foo/bar/wizjoemama The question is, DIffe

Portable safe directpry seperator

2004-12-04 Thread JupiterHost.Net
Hello again, I need to make sure a given path has an ending path separator: my $file = 'joemama'; my $path = '/foo/bar/wiz'; $path .= '/' if $path !~ m/\/$/; So I can then do "$path$file" and ensure its /foo/bar/wiz/joemama and not /foo/bar/wizjoemama The question is, DIfferent systems use differe

Re: stat and chmod safety and prtability

2004-12-04 Thread Lawrence Statton
> Hello group: > > In attempting to set $file2 to the same mode as $file1 I do this: > >my $mode = (stat($file1))[2]; >chmod $mode, $file2; > > That code does the trick but I just want to make sure of: > > 1) > I see in perldoc -f chmod it talks about oct() but if I'm using stat's > mo

Re: Tabulate data in a sequential file

2004-12-04 Thread Lawrence Statton
> Hi, > > I'm just learning Perl and hit a wall when I don't really understand > how associative array works, could you kindly give me a guidance? > > I want to tabulate a file as follow? > > -- source --- > key1: data1a > key2: data2a > key3: data3a > key1: data1b > key2: data2b > key3: data3b

stat and chmod safety and prtability

2004-12-04 Thread JupiterHost.Net
Hello group: In attempting to set $file2 to the same mode as $file1 I do this: my $mode = (stat($file1))[2]; chmod $mode, $file2; That code does the trick but I just want to make sure of: 1) I see in perldoc -f chmod it talks about oct() but if I'm using stat's mode it should be safe not to us

Re: perl questions.

2004-12-04 Thread Lawrence Statton
That's a really difficult (and somewhat pointless) question -- because Perl is so many things to so many people, what questions you ask a candidate are going to be based on the kind of programming you do. If your primary application for Perl is lots of little scripts, then you'll probably conce

Tabulate data in a sequential file

2004-12-04 Thread Chan YW
Hi, I'm just learning Perl and hit a wall when I don't really understand how associative array works, could you kindly give me a guidance? I want to tabulate a file as follow? -- source --- key1: data1a key2: data2a key3: data3a key1: data1b key2: data2b key3: data3b ... --- to --- key1ke

perl questions.

2004-12-04 Thread Harbhajan Julka
Hi everybody, What are the most often asked perl questions for an interview? If you know them, kindly forward them. Thanx a bunch. __ Do you Yahoo!? Yahoo! Mail - now with 250MB free storage. Learn more. http://info.mail.yahoo.com/mail_250 --

Re: Regex question (once again)

2004-12-04 Thread John W. Krahn
Jan Eden wrote: Hi, Hello, sorry! Overlooked the g switch, so the first parentheses captures either nothing or the initial \\begin{letter}. Correct. Another way to write it (so you only have one alternation) would be: / (?: \\begin{letter}{ | \\+\s* ) ( [^\\}]+ ) /xg I got it now. Thanks again,

Re: Perl module question

2004-12-04 Thread Stephen Liu
Hi Chris, Further to my last posting $ perl wget_window.pl Can't locate Tk.pm in @INC (@INC contains: /usr/lib/perl5/5.8.3/i386-linux-threa d-multi /usr/lib/perl5/5.8.3 /usr/lib/perl5/site_perl/5.8.3/i386-linux-thread-mu lti /usr/lib/perl5/site_perl/5.8.2/i386-linux-thread-multi /

Re: Perl module question

2004-12-04 Thread Stephen Liu
Hi Chris, Tks for your advice. > > # perl -MCPAN -e 'install Tk.pm' > > The .pm suffix isn't necessary in this situation: > > $ sudo perl -MCPAN -e 'install Tk' $ sudo perl -MCPAN -e 'install Tk' . .. 6# Test 66 got: '589x341+0+32' (t/zzScrolled.t at line 104 fail #2)

Re: Perl module question

2004-12-04 Thread Chris Devers
On Sat, 4 Dec 2004, Stephen Liu wrote: > # perl -MCPAN -e 'install Tk.pm' The .pm suffix isn't necessary in this situation: $ sudo perl -MCPAN -e 'install Tk' (Root isn't necessary either, if you have sudo access.) -- Chris Devers -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additi

Transport endpoint is not connected,

2004-12-04 Thread D. Scott
Hi Have anyone comes across the above error. When trying to create a socket? Dan -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Perl module question

2004-12-04 Thread Stephen Liu
Hi folks, Running $ perl wget_window.pl Can't locate Tk.pm in @INC (@INC contains: /usr/lib/perl5/5.8.3/i386-linux-thread-multi /usr/lib/perl5/5.8.3 /usr/lib/perl5/site_perl/5.8.3/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.2/i386-linux-thread-multi # perl -MCPAN -e 'install Tk.