stat function
Hi! I have the following code: #!/usr/bin/perl -w open(FIC,">/home/collineau/Perl/Programmes/01_informatique/sauve/c0111_05.htm ") || die "Impossible d'ouvrir $!\n";; @tab = stat (FIC); print scalar localtime($tab[10]); The date of c0111_05.htm is november 5th 2001. But the print is now ! What is the problem ? Thanks Franck --- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE:disable a frame
Hi, How can I do to disable a frame which contains some widget in it in Perl TK? Thanks. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: CGI.pm problems continued
In article <56313003.1006216242@[10.0.0.140]>, [EMAIL PROTECTED] (Birgit Kellner) wrote: > I have tried the following code to read a query-string from a CGI request > into a hash, taking into account (a) multiple select fields without knowing > the field name, (b) getting rid of names without values, and thereby, > hopefully, (c) allowing for user input alternately through a text field or > a select list, (d) getting rid of select fields where no selection was > made, in which case the value will be "---". > > This is the code I used: > > #!/usr/bin/perl > use CGI qw(:standard); > use CGI qw(:cgi-lib); > my $q = new CGI; > my %in = &parse_form; #!/usr/bin/perl -w use strict; use CGI 2.78 qw(:standard :cgi-lib -no_xhtml); # if this errors, remove the 2.78 # what version of CGI.pm does your server have? print $CGI::VERSION, " CGI.pm installed\n"; my $q = new CGI; my $in = $q->Vars;# reference to hash print "Param 'foo' is ", $in->{'foo'}, "\n"; print "Multivalued param 'bar' contains "; my @bar = split("\0", $in->{'bar'}); print join "\n\t", @bar; print "\n"; print "Param 'baz' ", defined(param('baz')) ? " is ", $in->{'baz'}, "\n" : " is undefined\n"; -- Scott R. Godin| e-mail : [EMAIL PROTECTED] Laughing Dragon Services |web : http://www.webdragon.net/ It is not necessary to cc: me via e-mail unless you mean to speak off-group. I read these via nntp.perl.org, so as to get the stuff OUT of my mailbox. :-) -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Stat function
Hi! I have the following code: #!/usr/bin/perl -w open(FIC,">/home/collineau/Perl/Programmes/01_informatique/sauve/c0111_05.ht m") || die "Impossible d'ouvrir $!\n";; @tab = stat (FIC); print scalar localtime($tab[10]); The date of c0111_05.htm is november 5th 2001. But the print is now ! What is the problem ? Thanks Franck -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Regex: Why [^>]* and not .*?
Hi Again, I have a doubt, why do people use if($html =~ /(<[^>]*>)/) { } instead of simple to use and understand if($html =~ /(<.*?>)/) { } To extract HTML tags. Regards, Girish -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: using perl-command line not working
you must escape " this will work: perl -e "print \"@inc\";" by martin Moulas, Lionel wrote: > Hi. > First post here, simple question. > > Trying, under the msdos command line (WinNT, "cmd"), > perl -e ' print "@INC"' > > I get the message > Can't find string terminator "'" anywhere before EOF at -e line 1. > > I`m using Win NT, ActivePerl 5.6.1.629. > I haven`t used Perl for months, I feel I have a lot to cover again...Time to > put back my Perl cap. > Any suggestions welcome! > PS: yeah, I know about the Oreilly books. Got some. About 800 miles from my > current home, one of my problems. A bit late with my readings.. > > Have a good day! > > > > * > The information in this internet E-mail is confidential and is intended > solely for the addressee. Access, copying or re-use of information in it > by anyone else is unauthorized. Any views or opinions presented are > solely those of the author and do not necessarily represent those of > Credit Lyonnais or any of its affiliates. The information contained herein > is recorded for business purposes and use of services is monitored to > protect both the company and its individual users. If you are not the > intended recipient please contact [EMAIL PROTECTED] > * > > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
how do tell a program to skip
I've got a program running and extracting minimum values from the data base, but if there is no data available for the day on the data base, the value -999.9 is reflected. so how do I tell my program to skip the -999.9 and then select the minimum value out of the data base. "Your life is not a coincidence, its a reflection of You." ** Movalo R.S Prediction Research South African Weather Service Pretoria, 0001 Tel: 012 309 3807 E-mail: [EMAIL PROTECTED] Call our Weather line at 082 162 Visit our website at : www.weathersa.co.za ** -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Sorting a list of links by the linked text
Hellew, I have an include file for my weblog that looks like this: http://www.ocf.berkeley.edu/";>nutz0 http://mundissa.com/";>cronópios http://feralliving.blogspot.com";>feral living http://underwatergirl.blogspot.com";>so blue it's black http://genehack.org/index.html";>genehack Etc, just a big list of links. I'd like to sort it by the contained text (i.e., by 'nutzO', 'cronópios', 'feral living', etc.), so that the links appear in alphabetical order. Any pointers to where I can learn how to do this, or off-the-top-of-your-ever-so-knowledgeable-heads code? Thanks! -Pat http://www.fieldmethods.net __ Do You Yahoo!? Yahoo! GeoCities - quick and easy web site hosting, just $8.95/month. http://geocities.yahoo.com/ps/info1 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
HTML::Templ - Error in Doc
hi to all! I found a error in documentation of HTML::Template my $filter = sub { my $text_ref = shift; $$text_ref =~ s/!!!ZAP_(.*?)!!!//g; } replace } with }; HERE IS ERROR after } semicolon missing! # open zap.tmpl using the above filter my $template = HTML::Template->new(filename => 'zap.tmpl', filter => $filter); Without semicolon it doesnt work martin -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: HTML::Templ - Error in Doc
thx a lot. Nafiseh Saberi Iran. - Original Message - From: "Martin Pfeffer" <[EMAIL PROTECTED]> To: "perllist" <[EMAIL PROTECTED]> Sent: Tuesday, November 20, 2001 13:51 PM Subject: HTML::Templ - Error in Doc > hi to all! > I found a error in documentation of HTML::Template > > my $filter = sub { > my $text_ref = shift; > $$text_ref =~ s/!!!ZAP_(.*?)!!!//g; > } > replace } with }; > HERE IS ERROR after } semicolon missing! > > > # open zap.tmpl using the above filter > my $template = HTML::Template->new(filename => 'zap.tmpl', >filter => $filter); > > > Without semicolon it doesnt work > > martin > > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: CGI.pm problems continued
--On Montag, 19. November 2001 21:09 -0500 "Scott R. Godin" <[EMAIL PROTECTED]> wrote: ># !/usr/bin/perl -w > use strict; > use CGI 2.78 qw(:standard :cgi-lib -no_xhtml); ># if this errors, remove the 2.78 ># what version of CGI.pm does your server have? > print $CGI::VERSION, " CGI.pm installed\n"; > my $q = new CGI; > my $in = $q->Vars;# reference to hash > > print "Param 'foo' is ", $in->{'foo'}, "\n"; > print "Multivalued param 'bar' contains "; > my @bar = split("\0", $in->{'bar'}); > print join "\n\t", @bar; > print "\n"; > print "Param 'baz' ", defined(param('baz')) >? " is ", $in->{'baz'}, "\n" >: " is undefined\n"; > Sorry for being stubborn, but I' like to decode multivalued parameters *without* identifying them by name. That's precisely why reading multiple values into an array is not applicable. Is it possible that, when I do "my %in = $q->Vars" (should be "%in", not "$in", shouldn't it?), %in contains not the actual names and values, but only references, and that that's why any subsequent attempts at deleting key/value-paris are unsuccessful? Birgit Kellner -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
calling perlscript from html
problem goes like this- what i want is to call a perl script from html document or image...onload what tags ..code should i need to write in html Thanks, Rahul
RE: calling perlscript from html
It depends what you want the script to do. If it's returning html and you want that inserted in your page, use SSI (server side includes). If it's doing background work that doesn't return output to the browser, you can use an image tag with the source set to the script you want to run. The server will execute the script and return the results (nothing) to the browser. The beauty of using the image way is that the client doesn't wait for the script to complete before continuing to load the rest of the page. Set the image size to 1x1 and hide it away somewhere and people will never know it's there. John -Original Message- From: Rahul Garg [mailto:[EMAIL PROTECTED]] Sent: 20 November 2001 11:12 To: [EMAIL PROTECTED] Subject: calling perlscript from html problem goes like this- what i want is to call a perl script from html document or image...onload what tags ..code should i need to write in html Thanks, Rahul --Confidentiality--. This E-mail is confidential. It should not be read, copied, disclosed or used by any person other than the intended recipient. Unauthorised use, disclosure or copying by whatever medium is strictly prohibited and may be unlawful. If you have received this E-mail in error please contact the sender immediately and delete the E-mail from your system. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Command Line arguments.
Hi guys, Can anyone tell me how can I take the command line arguments in a perl script . I forgot how to do it . Thanks for your support . Regards, Nick -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Command Line arguments.
The command-line arguments are stored in the built-in @ARGV array. Therefore, if you say something like : perl sample.pl argument1 argument2 argument3 then in your program you can access each of the command-line arguments as follows print $ARGV[0]; #prints argument1 print $ARGV[1]; #prints argument2 etc -- Rex > -Original Message- > From: Nicolae Popovici [mailto:[EMAIL PROTECTED]] > Sent: Tuesday, November 20, 2001 6:13 AM > To: [EMAIL PROTECTED] > Subject: Command Line arguments. > > > Hi guys, > > Can anyone tell me how can I take the command line arguments > in a perl > script . I forgot how to do it . > Thanks for your support . > > Regards, > Nick > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Regex: Why [^>]* and not .*?
You should not extract html tags with this... check out http://www.perl.com/CPAN/authors/Tom_Christiansen/scripts/striphtml.gz The above can still be tricked out I think when having but for sure is way better. It's in fact 3 regexes. Also read http://www.perldoc.com/perl5.6.1/pod/perlfaq9.html#How-do-I-remove-HTML-from-a-string- on how to use HTML::Parser from CPAN to do even a better job (I think). As for your specific question, I don't have a clue at all:-) The gurus will answer promptly Etienne Girish wrote: > > Hi Again, > > I have a doubt, why do people use > > if($html =~ /(<[^>]*>)/) { > > } > > instead of simple to use and understand > if($html =~ /(<.*?>)/) { > > } > To extract HTML tags. > > Regards, > Girish > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] -- Etienne Marcotte Specifications Management - Quality Control Imperial Tobacco Ltd. - Montreal (Qc) Canada 514.932.6161 x.4001 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Stat function
> -Original Message- > From: COLLINEAU Franck FTRD/DMI/TAM > [mailto:[EMAIL PROTECTED]] > Sent: Tuesday, November 20, 2001 3:31 AM > To: [EMAIL PROTECTED] > Subject: Stat function > > > Hi! > > I have the following code: > > #!/usr/bin/perl -w > open(FIC,">/home/collineau/Perl/Programmes/01_informatique/sau > ve/c0111_05.ht > m") || die "Impossible d'ouvrir $!\n";; > > @tab = stat (FIC); > > print scalar localtime($tab[10]); > > > The date of c0111_05.htm is november 5th 2001. > > But the print is now ! > > What is the problem ? You are opening the file for output, which is overwriting any previous contents. Also, you probably want mtime (9) and not ctime (10). -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Regex: Why [^>]* and not .*?
> -Original Message- > From: Girish [mailto:[EMAIL PROTECTED]] > Sent: Tuesday, November 20, 2001 3:42 AM > To: [EMAIL PROTECTED] > Subject: Regex: Why [^>]* and not .*? > > > Hi Again, > > I have a doubt, why do people use > > if($html =~ /(<[^>]*>)/) { > > } > > > instead of simple to use and understand > if($html =~ /(<.*?>)/) { > > } > To extract HTML tags. I think the non-greedy qualifiers were added to Perl relatively recently (but before 5.6 I think). -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
writting in a file
Hi! I have the follwing code: #!/usr/bin/perl -w open(FIC,"/home/collineau/Perl/Programmes/01_informatique/sauve/c0111_05.htm") || die "Impossible d'ouvrir $!\n"; open (TEMP,">/home/collineau/Perl/Programmes/01_informatique/sauve/temp.htm") || die "Impossible d'ouvrir $!\n"; while () { print (TEMP $_); } The temp.htm file is empty !! Can anybody help me ? Franck -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: writting in a file
Should be print TEMP $_; On Tue, Nov 20, 2001 at 02:57:25PM +0100, Franck Collineau shaped the electrons to read: > Hi! > > I have the follwing code: > > #!/usr/bin/perl -w > open(FIC,"/home/collineau/Perl/Programmes/01_informatique/sauve/c0111_05.htm") > || die "Impossible d'ouvrir $!\n"; > open (TEMP,">/home/collineau/Perl/Programmes/01_informatique/sauve/temp.htm") > || die "Impossible d'ouvrir $!\n"; > while () > { > print (TEMP $_); > > } > > > > The temp.htm file is empty !! > > Can anybody help me ? > > > Franck > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: writting in a file
I'm sorry, I've found Thank you -Message d'origine- De : [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Envoyé : mardi 20 novembre 2001 15:18 À : COLLINEAU Franck FTRD/DMI Cc : [EMAIL PROTECTED] Objet : Re: writting in a file Should be print TEMP $_; On Tue, Nov 20, 2001 at 02:57:25PM +0100, Franck Collineau shaped the electrons to read: > Hi! > > I have the follwing code: > > #!/usr/bin/perl -w > open(FIC,"/home/collineau/Perl/Programmes/01_informatique/sauve/c0111_05..htm ") > || die "Impossible d'ouvrir $!\n"; > open (TEMP,">/home/collineau/Perl/Programmes/01_informatique/sauve/temp.htm") > || die "Impossible d'ouvrir $!\n"; > while () > { > print (TEMP $_); > > } > > > > The temp.htm file is empty !! > > Can anybody help me ? > > > Franck > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: writting in a file
The filehandle should be outside the parentheses, like print TEMP $_; Also, you didn't close your files close FIC; close TEMP; Franck Collineau wrote: > Hi! > > I have the follwing code: > > #!/usr/bin/perl -w > open(FIC,"/home/collineau/Perl/Programmes/01_informatique/sauve/c0111_05.htm") > || die "Impossible d'ouvrir $!\n"; > open (TEMP,">/home/collineau/Perl/Programmes/01_informatique/sauve/temp.htm") > || die "Impossible d'ouvrir $!\n"; > while () > { > print (TEMP $_); > > } > > > > The temp.htm file is empty !! > > Can anybody help me ? > > > Franck > > -- Thomas S. Dixon Applications Analyst II Pediatric Cardiology Medical University of South Carolina -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Profiler for Windows
Does dprof work on Windows? Does any profiler? How do you know from CPAN if a module is windows compatible or not? ___ Stephan Gross Loral Skynet 908-470-2388 [EMAIL PROTECTED]
Re: Profiler for Windows
sometimes you can see this in the readme file martin Gross, Stephan wrote: > Does dprof work on Windows? Does any profiler? How do you know from CPAN > if a module is windows compatible or not? > > ___ > Stephan Gross Loral Skynet 908-470-2388 [EMAIL PROTECTED] > > > > > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Little pb with sort ...
Here is a little code : -- my @trav= ( 1, 12, 5, 3); @trav=sort { $b cmp $a } @trav; foreach (@trav) { print " $_ "; } -- After exec, we have : 5 3 12 1 But I expected : 12 5 3 1 How can I do ? I mean easily (without developping some code) ... Franck. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Little pb with sort ...
@trav=sort { $b <=> $a } @trav; <=> instead of cmp for numerical descending http://www.perldoc.com/perl5.6.1/pod/func/sort.html Etienne Franck FASANO wrote: > > Here is a little code : > > -- > my @trav= ( 1, 12, 5, 3); > @trav=sort { $b cmp $a } @trav; > > foreach (@trav) { > print " $_ "; > } > -- > > After exec, we have : > 5 3 12 1 > > But I expected : > 12 5 3 1 > > How can I do ? > I mean easily (without developping some code) ... > > Franck. > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] -- Etienne Marcotte Specifications Management - Quality Control Imperial Tobacco Ltd. - Montreal (Qc) Canada 514.932.6161 x.4001 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Little pb with sort ...
On Tue, 20 Nov 2001, Franck FASANO wrote: > Here is a little code : > > -- > my @trav= ( 1, 12, 5, 3); > @trav=sort { $b cmp $a } @trav; > > foreach (@trav) { > print " $_ "; > } > -- > > After exec, we have : > 5 3 12 1 You're using the wrong operator. You want { $b <=> $a} for your comparison. -- Brett http://www.chapelperilous.net/ Everybody has something to conceal. -- Humphrey Bogart -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re[2]: Little pb with sort ...
Tuesday, November 20, 2001, 6:27:44 PM, Brett W. McCoy wrote: BWM> On Tue, 20 Nov 2001, Franck FASANO wrote: >> Here is a little code : >> >> -- >> my @trav= ( 1, 12, 5, 3); >> @trav=sort { $b cmp $a } @trav; >> >> foreach (@trav) { >> print " $_ "; >> } >> -- >> >> After exec, we have : >> 5 3 12 1 BWM> You're using the wrong operator. You want { $b <=> $a} for your BWM> comparison. because <=> will do a numeric comparison, whereas cmp will do a string comparison... as strings "12" is less that "5", but as numbers 5 is obviously less than 12. -- Best regards, Daniel -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Off-Topic (200%) - Where are you from?
From: "Etienne Marcotte" <[EMAIL PROTECTED]> > By reading the messages everyday I can guess most of us are from United > States right? And since there are not a lot of messages in (my) morning > time, probably means most are from the west coast (different timezone). > > Am I right? > > I'm from Quebec, Canada.. and you? Prague, Czech Republic, Central Europe Jenda === [EMAIL PROTECTED] == http://Jenda.Krynicky.cz == There is a reason for living. There must be. I've seen it somewhere. It's just that in the mess on my table ... and in my brain. I can't find it. --- me -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: -onChange
From: Jeff 'japhy' Pinyan <[EMAIL PROTECTED]> > On Nov 19, Jerry Preston said: > > >Trying to learn how to "-onChange", where can I find some good doc and > >examples? > > You're barking up the wrong tree. onChange is a javascript event. Well ... such a handler may exist in other event based "systems". Tk comes to mind (though I did not find onChange there). Maybe Jerry meant wxPerl, gTk or something. Also notice the dash : -onChange. That looks Perlish, not JavaScriptish. Jenda === [EMAIL PROTECTED] == http://Jenda.Krynicky.cz == There is a reason for living. There must be. I've seen it somewhere. It's just that in the mess on my table ... and in my brain. I can't find it. --- me -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: highlight words.
From: "Houda Araj" <[EMAIL PROTECTED]> > The script > #!/usr/bin/perl > use strict; > use diagnostics; > use CGI qw/:standard/; > use CGI::Carp 'fatalsToBrowser'; > > ... > Can't use an undefined value as a symbol reference at highlight2.pl > line 10. Try to add use FileHandle; Jenda === [EMAIL PROTECTED] == http://Jenda.Krynicky.cz == There is a reason for living. There must be. I've seen it somewhere. It's just that in the mess on my table ... and in my brain. I can't find it. --- me -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: open filehandle in lowercase produce warning, why?
From: Jeff 'japhy' Pinyan <[EMAIL PROTECTED]> > On Nov 15, EternalLifeThereAfter said: > > >Whilst playing with filehandles, I noted that if the > >unquoted-open-filehandles is in lower case it produces the following > >warnings => "Unquoted string "justaname" may clash with future reserved > >word at misc.pl line 3." > > >(Q1) I just wonder what's the reasons for having warnings on lower-case > >filehandles as uppercase-open-handles does not produce warnings. > > What about the hundreds of people who open their logfiles with the > filehandle "log"? (Hint: 'log' is a reserved word.) And the UPPERCASE cannot trigger a warning because of backwards compatibility. Everybody's using that. > >(Q2) However, if I put single or double quotes on the filehandles, > >everything seems fine. Am I therefore right to say that it is better to > >put quotes on filehandles, irregardless of uppercase-open-handles or > >lowercase-open-handles. > > Well, quoting a word makes it NOT a bareword, and so it can't be a > reserved word. But quoting filehandles is a bad idea -- it makes things > symbol when they needn't be, and I don't think strict appreciates it. > > (I might be wrong with that last one.) I think you are right. IMHO it's best to use normal scalars fro filehandles: use FileHandle; my $fh; open $fh, "<$filename" or die "..."; that way the filehandles may be lexical and thus safe! (No I don't do this always, especialy in older scripts or modules.) Jenda === [EMAIL PROTECTED] == http://Jenda.Krynicky.cz == There is a reason for living. There must be. I've seen it somewhere. It's just that in the mess on my table ... and in my brain. I can't find it. --- me -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Error management
Hello, I'm new to perl but not to programming, and I have been searching (without any success up to now) how perl handles errors. Does perl offer a system of error management ? Where can I find information (faq, URL or any other ...) about perl error management ? For example I'm using the following Time::Local call timelocal. This function takes as input 6 numeric fields and I would like to call this function. If this function returns an error (because parameters are not numeric ...), then I should be able to sort of get this error and do some processing of mine. If anyone has some info to share with me, that would be great ... Teggy P Veerapen -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Sorting a list of links by the linked text
Here is a start: Script starts on next line: #!perl -w printf "%-20s - %-s\n", "SortField", "Url"; foreach my $MyData (sort {$a->[2] cmp $b->[2]} map{ [$_,/="([^"]+).+\>([^<]+)\<\/a/i ] } ) { printf "%-20s - %-s\n", $MyData->[2], $MyData->[1]; } __DATA__ http://www.ocf.berkeley.edu/";>nutz0 http://mundissa.com/";>cronópios http://feralliving.blogspot.com";>feralliving http://underwatergirl.blogspot.com";>soblue it's black http://genehack.org/index.html";>genehack ^ ENd of script output: SortField- Url cronópios - http://mundissa.com/ feralliving - http://feralliving.blogspot.com genehack - http://genehack.org/index.html nutz0- http://www.ocf.berkeley.edu/ soblue it's black - http://underwatergirl.blogspot.com -Original Message- From: patrick hall [mailto:[EMAIL PROTECTED]] Sent: Tuesday, November 20, 2001 02:05 To: [EMAIL PROTECTED] Subject: Sorting a list of links by the linked text Hellew, I have an include file for my weblog that looks like this: http://www.ocf.berkeley.edu/";>nutz0 http://mundissa.com/";>cronópios http://feralliving.blogspot.com";>feral living http://underwatergirl.blogspot.com";>so blue it's black http://genehack.org/index.html";>genehack Etc, just a big list of links. I'd like to sort it by the contained text (i.e., by 'nutzO', 'cronópios', 'feral living', etc.), so that the links appear in alphabetical order. Any pointers to where I can learn how to do this, or off-the-top-of-your-ever-so-knowledgeable-heads code? Thanks! -Pat http://www.fieldmethods.net __ Do You Yahoo!? Yahoo! GeoCities - quick and easy web site hosting, just $8.95/month. http://geocities.yahoo.com/ps/info1 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
flock problem on AIX 4.3.3
Hello, A colleague is experiencing some problems using user_manage v1.53 by Lincoln Stein with Apache Stronghold 3 on AIX 4.3.3. Seems as though the entire password file is getting corrupted when there are a lot of people changing passwords. The file seems to be blanked out and/or with only a few entries. We are using flat files and not a database. We wrote to Lincoln and he provided us with a script which pointed us to a problem with our version of flock, so we rebuilt Perl with the -Ud_flock option to configure which, according to the doco, causes perl to not use flock and instead use fcntl. However the problem persists. We re-ran the test script and again "obtained lock and shouldn't have". Can anyone point us in the right direction? Please let me know if I need to provide more details. Thanks! --Rich The test script by L. Stein is quoted below: #!/usr/bin/perl use Fcntl qw(:flock); open FOO,(">./foo.lock") or die "Can't open for writing"; flock(FOO,LOCK_EX) or die "Can't flock for writing"; print FOO "locked\n"; open BAR,"./foo.lock" or die "Can't open for reading"; eval { local $SIG{ALRM} = sub { die "timed out\n" }; alarm(5); flock(BAR,LOCK_SH) or die "Can't flock for reading"; }; alarm(0); if ($@ =~ /timed out/) { print "timed out as expected\n"; } else { print "obtained lock and shouldn't have\n"; } -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Error management
At 02:37 PM 11/20/01 +0100, Teggy P Veerapen wrote: >Hello, > > I'm new to perl but not to programming, and I have been searching >(without any success up to now) how perl handles errors. Does perl offer a >system of error management ? Kind of. You sound like you're looking for something like the Java interface where everything advertises which exception classes it can throw. Perl doesn't do that (although I and others proposed something close to it for Perl 6). But it isn't far off; after all, you have to read the documentation for any function that you call anyway to see what they'll do. The vast majority of Perl builtins and third-party module functions will return some value to signify error. You have to check the documentation to find out what. Some will signify error via another variable which you have to check. A few will throw exceptions instead; in Perl this is done with "die", and they are caught with "eval". >Where can I find information (faq, URL or any >other ...) about perl error management ? perldoc -f die perldoc -f eval That may not be enough for you though. Shameless plug though it may be, I expended a chapter (#9) on this topic in my book (URL below). > For example I'm using the following Time::Local call timelocal. This >function takes as input 6 numeric fields and I would like to call this >function. If this function returns an error (because parameters are not >numeric ...), then I should be able to sort of get this error and do some >processing of mine. This is a good question. The Time::Local documentation doesn't say. It also says that by default it does range checking on arguments but doesn't say what happens if they fail. You have to try it and see (or read the source): % perl -Mstrict -MTime::Local -wle 'print timelocal(0,0,0,35,0,99)' Day '35' out of range 1..31 at -e line 1 Ah; it dies. And with non-numeric data: % perl -Mstrict -MTime::Local -wle 'print timelocal(0,0,0,"foo",0,99)' Argument "foo" isn't numeric in numeric gt (>) at /afs/jpl/rep/f/fil/uai/perl/lib/5.6.1/Time/Local.pm line 90. Day 'foo' out of range 1..31 at -e line 1 So it still died (because "foo" numericizes to zero), but you got a warning first with -w or use warnings. A block eval could catch the die(). As for ensuring that you're passing numeric data, well, you have to decide what you want to happen. Perhaps you'd like to turn all warn() calls into die()s via this statement: local $SIG{__WARN__} = sub {die $_[0]}; -- Peter Scott Pacific Systems Design Technologies http://www.perldebugged.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Error management
On Tue, 20 Nov 2001, Teggy P Veerapen wrote: > I'm new to perl but not to programming, and I have been searching > (without any success up to now) how perl handles errors. Does perl offer a > system of error management ? Where can I find information (faq, URL or any > other ...) about perl error management ? It depends on how the function calls themselves handle errors. And for this, you will need to consult the appropriate documentation for the various function calls. Many system calls will return undef on an error and put a message into $!: open FILE, "file" or die "Can't open file: $!\n"; If you are familiar with C, this way of handling errors is similar to: FILE *fh; if((fh = fopen("file", "r") == NULL) { perror("Can't open file"); } die will end the program unless you catch it as an exception. Which brings me to the next point, exceptions. In Perl, you can also do exception handling with the use of eval and the $@ variable. To use the above example: eval { open FILE, "file" or die "Can't open file: $!\n"; }; print "ERROR: $@" if $@; I think there is a Throw module that lets you do exception handling in the C++/Java style with throwing and catching. There are also other modules that let you maniuplate warning messgaes and handle errors for CGI programs. A good book on Perl (like the Camel) will give you more guidance on error handling. -- Brett http://www.chapelperilous.net/ He that teaches himself has a fool for a master. -- Benjamin Franklin -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
"Shorthand"
Is there a quicker way to write this..just curious.. $count=&SomeFunctionWitchReturnsaNumber; $count=$count+1; Thanks, Agustin -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: "Shorthand"
On Tue, Nov 20, 2001 at 11:04:15AM -0800, A. Rivera wrote: > Is there a quicker way to write this..just curious.. > > $count=&SomeFunctionWitchReturnsaNumber; > $count=$count+1; $count = SomeFunctionWhichReturnsANumber() + 1; Z. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re[2]: Sorting a list of links by the linked text
Tuesday, November 20, 2001, 7:11:34 PM, Wagner-David wrote: WD> Here is a start: WD> Script starts on next line: WD> #!perl -w WD> printf "%-20s - %-s\n", "SortField", "Url"; WD> foreach my $MyData (sort {$a->[2] cmp $b->[2]} map{ [$_,/="([^"]+).+\>([^<]+)\<\/a/i ] } ) { WD>printf "%-20s - %-s\n", $MyData->[2], $MyData->[1]; WD> } for those who won't have any clues whatsoever about that hunk of line noise, i've expanded it out a bit and added some commentary. 1: my @links; 2: foreach my $line () { 3: my ($link, $desc) = $line =~ /="([^"]+).+\>([^<]+)\<\/a/i; 4: push @links, [ $link, $desc ]; 5: } 6: 7: my @sorted_links = sort { $a->[2] cmp $b->[2] } @links; 8: 9: foreach my $line (@sorted_links) { 10:printf "%-20s - %-s\n", $line->[2], $line->[1]; 11: } the overall aim is to read each line from the data file (what's under __DATA__ [1]), find the interesting parts of each line, sort them, and then print them. using angle brackets around a file descriptor ("DATA" in this case) will read a line in scalar context and the whole file in array context. so our foreach line will read a line from the file, store it in the "$line" variable and then execute the code within the loop. that scary looking line 3 is, in fact, scary. it will pattern match on $line, returning the right bits. / =" # match an = then a " (like in href=" ([^"]+) # then go find everything that's not a # quote and remember it .+ # find something, one or more time \> # then a literal > ([^<]+) # everything that's not a < and remember it \<\/a # then the string "[1] cmp $b->[1] } @links; we need to sort the data, so we use the "sort" function [3]. this function allows us to specify how we'd like the sorting to happen, and in this case we want to sort on the anchor text. if you remember from line 4 it's stored in the second element of our anonymous array. because the first element is indexed at 0, the second is at position 1. that'll give us all of the links sorted properly, so now we need to print them out: 9: foreach my $line (@sorted_links) { 10:printf "%-20s - %-s\n", $line->[1], $line->[0]; printf is like doing a print and an sprintf [4]. that funny string with the %'s in it is a template which says that we'd like the data formatted please and how we'd like it formatted. in this case, we'd like the first field left-justified within 20 spaces and the second field just left-justified. [4] has good info about it. hope that helps someone! -- Best regards, Daniel [1] http://www.perldoc.com/perl5.6.1/lib/SelfLoader.html#The-__DATA__-token [2] http://www.perldoc.com/perl5.6.1/pod/perlreftut.html [3] http://www.perldoc.com/perl5.6.1/pod/func/sort.html [4] http://www.perldoc.com/perl5.6.1/pod/func/sprintf.html [5] http://www.perldoc.com/perl5.6.1/pod/perlretut.html -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: "Shorthand"
On Tue, 20 Nov 2001, A. Rivera wrote: > Is there a quicker way to write this..just curious.. > > $count=&SomeFunctionWitchReturnsaNumber; $count = func(); (I really hope you are not creating subs with names that long) > $count=$count+1; $count++; -- Brett http://www.chapelperilous.net/ Everything might be different in the present if only one thing had been different in the past. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
How to delete hash element
Hi, If I know the key and offset of the element, how can I delete that hash element, please? Your help will be appreciated. Ahmed -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How to delete hash element
On Tue, 20 Nov 2001, Ahmed Moustafa Ibrahim Ahmed wrote: > If I know the key and offset of the element, how can I delete that hash > element, please? perldoc -f delete -- Brett http://www.chapelperilous.net/ A bird in the hand is worth what it will bring. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How to delete hash element
Tuesday, November 20, 2001, 8:41:03 PM, Ahmed Moustafa Ibrahim Ahmed wrote: AMIA> If I know the key and offset of the element, how can I delete that hash AMIA> element, please? you can delete a hash element like: delete $hash{ the_key }; but i'm not sure what you mean by "the offset of the element" -- Best regards, Danielmailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: How to delete hash element
Say you've got a hash called %myhash and it's got a key called "foo". delete $myhash{foo}; will get rid of the "foo" key. Chris Spurgeon Senior Design Technologist [EMAIL PROTECTED] ELECTRONIC INK One South Broad Street 19th Floor Philadelphia, PA 19107 www.electronicink.com t 215.922.3800 x(233) f 215.922.3880 -Original Message- From: Ahmed Moustafa Ibrahim Ahmed [mailto:[EMAIL PROTECTED]] Sent: Tuesday, November 20, 2001 3:41 PM To: [EMAIL PROTECTED] Subject: How to delete hash element Hi, If I know the key and offset of the element, how can I delete that hash element, please? Your help will be appreciated. Ahmed -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] This e-mail is intended solely for the above-mentioned recipient and it may contain confidential or privileged information. If you have received it in error, please notify us immediately and delete the e-mail. You must not copy, distribute, disclose or take any action in reliance on it. In addition, the contents of an attachment to this e-mail may contain software viruses which could damage your own computer system. While Electronic Ink, Inc. and E Ink Ltd have taken every reasonable precaution to minimize this risk, we cannot accept liability for any damage which you sustain as a result of software viruses. You should perform your own virus checks before opening the attachment. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: How to delete hash element
is it possible to delete a "key" along with the element?? -Original Message- From: Daniel Gardner [mailto:[EMAIL PROTECTED]] Sent: Tuesday, November 20, 2001 3:50 PM To: Ahmed Moustafa Ibrahim Ahmed Cc: [EMAIL PROTECTED] Subject: Re: How to delete hash element Tuesday, November 20, 2001, 8:41:03 PM, Ahmed Moustafa Ibrahim Ahmed wrote: AMIA> If I know the key and offset of the element, how can I delete that hash AMIA> element, please? you can delete a hash element like: delete $hash{ the_key }; but i'm not sure what you mean by "the offset of the element" -- Best regards, Danielmailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: How to delete hash element
That is what delete function does. It deletes both the key and the element it posits to. -- Rex > -Original Message- > From: Mike Rapuano [mailto:[EMAIL PROTECTED]] > Sent: Tuesday, November 20, 2001 3:57 PM > To: Daniel Gardner; Ahmed Moustafa Ibrahim Ahmed > Cc: [EMAIL PROTECTED] > Subject: RE: How to delete hash element > > > is it possible to delete a "key" along with the element?? > > > > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: How to delete hash element
Yeah, that gets rid of the key as well. Chris Spurgeon Senior Design Technologist [EMAIL PROTECTED] ELECTRONIC INK One South Broad Street 19th Floor Philadelphia, PA 19107 www.electronicink.com t 215.922.3800 x(233) f 215.922.3880 -Original Message- From: Mike Rapuano [mailto:[EMAIL PROTECTED]] Sent: Tuesday, November 20, 2001 3:57 PM To: Daniel Gardner; Ahmed Moustafa Ibrahim Ahmed Cc: [EMAIL PROTECTED] Subject: RE: How to delete hash element is it possible to delete a "key" along with the element?? -Original Message- From: Daniel Gardner [mailto:[EMAIL PROTECTED]] Sent: Tuesday, November 20, 2001 3:50 PM To: Ahmed Moustafa Ibrahim Ahmed Cc: [EMAIL PROTECTED] Subject: Re: How to delete hash element Tuesday, November 20, 2001, 8:41:03 PM, Ahmed Moustafa Ibrahim Ahmed wrote: AMIA> If I know the key and offset of the element, how can I delete that hash AMIA> element, please? you can delete a hash element like: delete $hash{ the_key }; but i'm not sure what you mean by "the offset of the element" -- Best regards, Danielmailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] This e-mail is intended solely for the above-mentioned recipient and it may contain confidential or privileged information. If you have received it in error, please notify us immediately and delete the e-mail. You must not copy, distribute, disclose or take any action in reliance on it. In addition, the contents of an attachment to this e-mail may contain software viruses which could damage your own computer system. While Electronic Ink, Inc. and E Ink Ltd have taken every reasonable precaution to minimize this risk, we cannot accept liability for any damage which you sustain as a result of software viruses. You should perform your own virus checks before opening the attachment. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Perl on AIX
Hi, I'm new to Perl and I'm looking for a contact that uses Perl on AIX version 4.3+. Thanks, Maurice Newton "MMS " made the following annotations on 11/20/01 16:20:22 -- This message is for the named person's use only. It may contain confidential, proprietary, or legally privileged information. No confidentiality or privilege is waived or lost by any mistransmission. If you receive this message in error, please immediately delete it and all copies of it from your system, destroy any hard copies of it, and notify the sender. You must not, directly or indirectly, use, disclose, distribute, print, or copy any part of this message if you are not the intended recipient. Health First reserves the right to monitor all e-mail communications through its networks. Any views or opinions expressed in this message are solely those of the individual sender, except (1) where the message states such views or opinions are on behalf of a particular entity; and (2) the sender is authorized by the entity to give such views or opinions. == -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: how do tell a program to skip
On Tue, 20 Nov 2001, shirley wrote: > I've got a program running and extracting minimum values from the data > base, but if there is no data available for the day on the data base, the > value -999.9 is reflected. so how do I tell my program to skip the -999.9 > and then select the minimum value out of the data base. To skip while looping: next if ($value == -999.9); To keep the min value of $value: my $min; $min = $value < $min ? $value : $min; > "Your life is not a coincidence, its a reflection of You." > ** > Movalo R.S > Prediction Research > South African Weather Service > Pretoria, 0001 > Tel: 012 309 3807 > E-mail: [EMAIL PROTECTED] > Call our Weather line at 082 162 > Visit our website at : www.weathersa.co.za > > ** > > > > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: flock problem on AIX 4.3.3
> -Original Message- > From: Rich Fernandez [mailto:[EMAIL PROTECTED]] > Sent: Tuesday, November 20, 2001 2:23 PM > To: [EMAIL PROTECTED] > Cc: [EMAIL PROTECTED] > Subject: flock problem on AIX 4.3.3 > > > Hello, > > A colleague is experiencing some problems using user_manage > v1.53 by Lincoln > Stein with > Apache Stronghold 3 on AIX 4.3.3. Seems as though the entire > password file > is getting > corrupted when there are a lot of people changing passwords. > The file seems > to be blanked > out and/or with only a few entries. We are using flat files and not a > database. > > We wrote to Lincoln and he provided us with a script which > pointed us to a > problem with our > version of flock, so we rebuilt Perl with the -Ud_flock > option to configure > which, > according to the doco, causes perl to not use flock and > instead use fcntl. > > However the problem persists. We re-ran the test script and > again "obtained > lock and > shouldn't have". > > Can anyone point us in the right direction? > Please let me know if I need to provide more details. > Thanks! > > --Rich > > The test script by L. Stein is quoted below: > > #!/usr/bin/perl > > use Fcntl qw(:flock); > open FOO,(">./foo.lock") or die "Can't open for writing"; > flock(FOO,LOCK_EX) or die "Can't flock for writing"; > print FOO "locked\n"; > > open BAR,"./foo.lock" or die "Can't open for reading"; > eval { > local $SIG{ALRM} = sub { die "timed out\n" }; > alarm(5); > flock(BAR,LOCK_SH) or die "Can't flock for reading"; > }; > alarm(0); > > if ($@ =~ /timed out/) { > print "timed out as expected\n"; > } else { > print "obtained lock and shouldn't have\n"; > } This program prints "obtained lock and shouldn't have" on my HP-UX 11.0 system as well. I think the problem is with POSIX lock semantics. On my system, flock is implemented using fcntl(2). A section from my fcntl(2) manpage says: "Locking a segment already locked by the calling process causes the old lock type to be removed and the new lock type to take effect. All locks associated with a file for a given process are removed when a file descriptor for that file is closed by that process or the process holding that file descriptor terminates." I ran into a simlar (though not identical) problem trying to get the module Tie::DB_FileLock to work. This module would dup the dbm handle, lock the dup'ed handle, then close and reopen the other handle to get changes to the buffers, assuming the lock still held. This simply would not work on a POSIX system, due to the semantics above. HTH. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How to delete hash element
The value of each key is an array. And, I want to delete an element of this array. I don't want to delete the whole key. Is it possible? - Original Message - From: Daniel Gardner To: Ahmed Moustafa Ibrahim Ahmed Cc: [EMAIL PROTECTED] Sent: Tuesday, November 20, 2001 12:50 PM Subject: Re: How to delete hash element Tuesday, November 20, 2001, 8:41:03 PM, Ahmed Moustafa Ibrahim Ahmed wrote: AMIA> If I know the key and offset of the element, how can I delete that hash AMIA> element, please? you can delete a hash element like: delete $hash{ the_key }; but i'm not sure what you mean by "the offset of the element" -- Best regards, Danielmailto:[EMAIL PROTECTED]
RE: How to delete hash element
Still you should be able to handle it. Study the output: use strict; my(%hash) = ('name1'=>['Joe','Doe'], 'name2'=>['Ahmed', 'Basha']); while(my($key,$val) = each %hash){ print ("$key ==> @$val\n"); } delete(${$hash{'name2'}}[0]); while(my($key,$val) = each %hash){ print ("$key ==> @$val\n"); } --Rex > -Original Message- > From: Ahmed Moustafa Ibrahim Ahmed [mailto:[EMAIL PROTECTED]] > Sent: Tuesday, November 20, 2001 3:54 PM > To: Daniel Gardner > Cc: [EMAIL PROTECTED] > Subject: Re: How to delete hash element > > > The value of each key is an array. And, I want to delete an > element of this array. I don't want to delete the whole key. > Is it possible? > - Original Message - > From: Daniel Gardner > To: Ahmed Moustafa Ibrahim Ahmed > Cc: [EMAIL PROTECTED] > Sent: Tuesday, November 20, 2001 12:50 PM > Subject: Re: How to delete hash element > > > Tuesday, November 20, 2001, 8:41:03 PM, Ahmed Moustafa > Ibrahim Ahmed wrote: > > AMIA> If I know the key and offset of the element, how can > I delete that hash > AMIA> element, please? > > you can delete a hash element like: > > delete $hash{ the_key }; > > but i'm not sure what you mean by "the offset of the element" > > > -- > Best regards, >Danielmailto:[EMAIL PROTECTED] > > > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re[2]: How to delete hash element
Tuesday, November 20, 2001, 8:54:26 PM, Ahmed Moustafa Ibrahim Ahmed wrote: AMIA> The value of each key is an array. And, I want to delete an AMIA> element of this array. I don't want to delete the whole key. Is AMIA> it possible? delete $hash{ key }->[0]; like brett said, perldoc -f delete AMIA> - Original Message - AMIA> From: Daniel Gardner AMIA> To: Ahmed Moustafa Ibrahim Ahmed AMIA> Cc: [EMAIL PROTECTED] AMIA> Sent: Tuesday, November 20, 2001 12:50 PM AMIA> Subject: Re: How to delete hash element AMIA> Tuesday, November 20, 2001, 8:41:03 PM, Ahmed Moustafa Ibrahim Ahmed wrote: AMIA> AMIA> If I know the key and offset of the element, how can I delete that hash AMIA> AMIA> element, please? AMIA> you can delete a hash element like: AMIA> delete $hash{ the_key }; AMIA> but i'm not sure what you mean by "the offset of the element" -- Best regards, Daniel -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How to delete hash element
On Tue, Nov 20, 2001 at 12:41:03PM -0800, Ahmed Moustafa Ibrahim Ahmed wrote: > If I know the key and offset of the element, how can I delete that hash > element, please? As far as I understand the followup clarification, what you really want to do is delete an element in an array, which just happens to be in a hash. So, you have a data structure something like: %hash = ( key1=> ['key1, element1', 'key1, element 2'], key2=> ['key2, element1', 'key2, element2', 'key2, element3'], ); And you want to delete the first element in the $hash{'key2'} array. That'd be accomplished like so: unshift @{ $hash{'key2'} }; Or, say you want to delete the second element in the $hash{'key1'} array: splice(@{ $hash{'key1'} }, 1, 1) See perldoc perldata for more information on dealing with arrays, perldoc perldsc for information on dealing with complex data structures, and perldoc -f unshift and perldoc -f splice for information on the unshift and splice, respectively. I'm really surprised at some of the people suggesting you use delete for this. Most of them should know better. Using delete on an array element will remove that element, but only if it's on the end. If it's in the middle, or at the beginning of the array, it'll simply cause the exists operator to return false for that element. I doubt that's what you wanted. Michael -- Administrator www.shoebox.net Programmer, System Administrator www.gallanttech.com -- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How to delete hash element
Michael, Thanks a lot. Ahmed - Original Message - From: Michael Fowler To: Ahmed Moustafa Ibrahim Ahmed Cc: [EMAIL PROTECTED] Sent: Tuesday, November 20, 2001 2:14 PM Subject: Re: How to delete hash element On Tue, Nov 20, 2001 at 12:41:03PM -0800, Ahmed Moustafa Ibrahim Ahmed wrote: > If I know the key and offset of the element, how can I delete that hash > element, please? As far as I understand the followup clarification, what you really want to do is delete an element in an array, which just happens to be in a hash. So, you have a data structure something like: %hash = ( key1=> ['key1, element1', 'key1, element 2'], key2=> ['key2, element1', 'key2, element2', 'key2, element3'], ); And you want to delete the first element in the $hash{'key2'} array. That'd be accomplished like so: unshift @{ $hash{'key2'} }; Or, say you want to delete the second element in the $hash{'key1'} array: splice(@{ $hash{'key1'} }, 1, 1) See perldoc perldata for more information on dealing with arrays, perldoc perldsc for information on dealing with complex data structures, and perldoc -f unshift and perldoc -f splice for information on the unshift and splice, respectively. I'm really surprised at some of the people suggesting you use delete for this. Most of them should know better. Using delete on an array element will remove that element, but only if it's on the end. If it's in the middle, or at the beginning of the array, it'll simply cause the exists operator to return false for that element. I doubt that's what you wanted. Michael -- Administrator www.shoebox.net Programmer, System Administrator www.gallanttech.com --
symlinking a file to every homedir
Hello, I'm trying to get a file to copy to all users home directories. When I run it as root below, it does not produce any error, but it does not copy /etc/sofficerc to .sofficerc in each directory in /home, as I expected. What am I missing here? Thanks, Gabe #!/usr/bin/perl -w # simple script by GG to make sure .sofficerc is in user home directories # 9/20/2001 my $dirname = "/home"; my $name; my $symlink = "/etc/sofficerc"; opendir HOME, $dirname or die "Cannot open $dirname: $!"; while (my $name = readdir HOME) { print "$name "; next if $name =~ /^\./; # skip over dotfiles next unless -d $name; $name = "$dirname/$name"; symlink $symlink, "$name/.sofficerc"; closedir HOME; } -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Little pb with sort ...
or you can use the reverse sort like this ... @trav= reverse sort { $a <=> $b } @trav; _ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: writting in a file
- Original Message - From: "Thomas S. Dixon" <[EMAIL PROTECTED]> To: "Franck Collineau" <[EMAIL PROTECTED]> Cc: <[EMAIL PROTECTED]> Sent: Tuesday, November 20, 2001 10:30 PM Subject: Re: writting in a file > The filehandle should be outside the parentheses, like > print TEMP $_; Therefore am I right to interprete the above as:- print into-the-filehandle-TEMP (all the things here. ); which can also be written as this :- print TEMP ($_); ## and if there's no filehandles then it will be :- print ("This is just a print without any handles and I know that parenthesis is not requited !\n"); Thanks. _ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
what is this called $/
I know of the following :- $" = '|interpolation-seperator|'; $, = '|seperator|'; $\ = '\n endOfLine'; my @a = qw (hi how are you); print "@a\n"; My question is what is this called ==> $/ and where can I do some reading on $/ . Thanks _ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: what is this called $/
At 01:54 PM 11/21/01 +0800, Leon wrote: >I know of the following :- > >$" = '|interpolation-seperator|'; >$, = '|seperator|'; >$\ = '\n endOfLine'; >my @a = qw (hi how are you); >print "@a\n"; > >My question is what is this called ==> $/ $INPUT_RECORD_SEPARATOR $RS $/ The input record separator, newline by default. This influences Perl's idea of what a "line" is. >and where can I do some reading on $/ . perldoc perlvar -- Peter Scott Pacific Systems Design Technologies http://www.perldebugged.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: what is this called $/
hi. it is for The input record separator, newline by default. May be multicharacter. see it. http://burks.bton.ac.uk/burks/language/perl/perlref.htm#contents it is very good with all of special characters. Nafiseh Saberi Iran. - Original Message - From: "Leon" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Wednesday, November 21, 2001 09:24 AM Subject: what is this called $/ > I know of the following :- > > $" = '|interpolation-seperator|'; > $, = '|seperator|'; > $\ = '\n endOfLine'; > my @a = qw (hi how are you); > print "@a\n"; > > My question is what is this called ==> $/ > and where can I do some reading on $/ . >
please help out guys
I've got a program running and extracting minimum values from the data base, but if there is no data available for the day on the data base, the value -999.9 is reflected. so how do I tell my program to skip the -999.9 when reading the data and then select the minimum value out of the data base. pls check the program below: !/usr/bin/perl-w open(FH,"fort.4") || die " cannot open $list for reading : $!"; open(OUT,">mm") || die "cannot create mm: $!"; $tx_min = ; $tx_max = -; $tn_min = 999; $tn_max = -; while ($list = ){ ($tn,$tx) = split (" ",$list); print " $tn\t $tx\n"; if ($tn < $tn_min) { $tn_min = $tn } if ( $tn > $tn_max) { $tn_max = $tn } if ($tx < $tx_min) { $tx_min = $tx } if ( $tx > $tx_max) { $tx_max = $tx } $sum= $sum + $list ; $chan = abs($tn - $tn_min); } $mean = $sum/9; $change = abs($tn_min -$mean) *2 ; $pp = abs($tn_max -$tn_min) ; #$norm = $chan/$pp ; #print OUT " $norm\n"; print OUT " $tn_min\n"; #print OUT " $tn_min\t$tn_max\n"; $name = "train"; if (-e $name) { print " the file is already there $name\n"; } else { print "perhaps you need make a new file $name\n"; } close (train); close(OUT) || die "cant close mm: $!"; "Your life is not a coincidence, its a reflection of You." ** Movalo R.S Prediction Research South African Weather Service Pretoria, 0001 Tel: 012 309 3807 E-mail: [EMAIL PROTECTED] Call our Weather line at 082 162 Visit our website at : www.weathersa.co.za ** -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Regex: Why [^>]* and not .*?
> "Girish" == Girish <[EMAIL PROTECTED]> writes: Girish> Hi Again, Girish> I have a doubt, why do people use Girish> if($html =~ /(<[^>]*>)/) { Girish> Girish> } Girish> instead of simple to use and understand Girish> if($html =~ /(<.*?>)/) { Girish> Girish> } Girish> To extract HTML tags. Well, the latter fails when \n appears within the tag, and the former is easier to understand when coming from another regex language. It's probably also slightly faster. Also, consider: "dh" =~ /<[^>]*>h/ matches "h", while "dh" =~ /<.*?>h/ ends up matching the entire string! So ".*?" is not synonymous with "this contains no instances of the closing delimiter", and I bet the people that use the charclass version have gotten bitten by this before and are now gunshy. :) -- Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095 <[EMAIL PROTECTED]> 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]
Re: registry Security permissions.
> Is there any way to controll registry security permissions as we can do it > from REGEDT32.exe in NT. This is very Urgent. Please respond if any. > > Thank you very much. > > With Regards > Raju Install Win32::Perms (should be instalable via PPM) Jenda === [EMAIL PROTECTED] == http://Jenda.Krynicky.cz == There is a reason for living. There must be. I've seen it somewhere. It's just that in the mess on my table ... and in my brain. I can't find it. --- me -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]