Matching text
Hi I have a really simple problem that I could solve easily with a strstr() call in c but cannot get my head around in perl. I have have the following input. Active Accounted actions on tty57, User fred Priv 1 Task ID 35176, Network Accounting record, 02:04:00 Elapsed what I want to do is for $data (@raw_data){ if $data contains "User" $username = [the word after User]; } The length of this string can vary so I cannot rely on "User" being at n charcters from beginning or end of string. I am sure it is a RegEx problem but any help/pointers appreciated. Thanks Kevin -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Matching text
Kevin wrote: > > Hi > > I have a really simple problem that I could solve easily with a strstr() call > in c but cannot get my head around in perl. > > I have have the following input. > > Active Accounted actions on tty57, User fred Priv 1 > Task ID 35176, Network Accounting record, 02:04:00 Elapsed > > what I want to do is > >for $data (@raw_data){ > if $data contains "User" something like if ($data =~ /User ([^ ]*)/) { $username = $1; } what happends there is that it checks for the occurance of User then a space followed by 0-* nonspace chars. it puts the nonspace cars, ie the username in $1 since we hve the () around that part. you should read the documentation at 'perldoc perlre' and/or read books about perl. My guess is that it'd take you 5 mins of reading in learning perl to solve this problem. /Jon > $username = [the word after User]; >} > > The length of this string can vary so I cannot rely on "User" being at n > charcters from beginning or end of string. > > I am sure it is a RegEx problem but any help/pointers appreciated. > > Thanks > > Kevin > > -- > 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: perl database access
I'm not sure i follow you but if you use localhost or leave the host blank it'll try localhost... /Jon Jefferson Ryan Lee wrote: > > Hi, > > Are there any way to access a database (SQL Server) not using the ODBC? > It is possible for a perl script to query a database not on a local > machine instead on a different location through tcp-ip/internet? Please > advise. Thanks. > > Regards, > > Jeff > > -- > 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: Matching text
- Original Message - From: "Kevin" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Thursday, January 31, 2002 10:15 PM Subject: Matching text > I have have the following input. > > Active Accounted actions on tty57, User fred Priv 1 > Task ID 35176, Network Accounting record, 02:04:00 Elapsed > > what I want to do is > >for $data (@raw_data){ > if $data contains "User" > $username = [the word after User]; >} > > The length of this string can vary so I cannot rely on "User" being at n > charcters from beginning or end of string. > > I am sure it is a RegEx problem but any help/pointers appreciated. How about this :- foreach $data (@raw_data){ if ($data =~/User (\b\w+\b)/){ $username = $1; }; }; a shortcut would be foreach (@raw_data){ if (/User (\b\w+\b)/){ $username = $1; }; }; or do {$username = $1 if (/User (\b\w+\b)/)} foreach (@raw_data); _ 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]
fastCGI Perl & memory
that is full script. it is fastCGI and problem is memory used by this script. after yester run is used memory by script bigger and bigger :( i ned absolute flushing memory from added "modul" (sorry for my english) #!/usr/bin/perl use FCGI; use Mysql; require "default.conf"; require "default.def"; require "_cookie.mdl"; # RELOAD sub fcgi_exit { my $request = FCGI::Request(); $request->Finish(); exit(0); } # CREATE LOG sub save_log { my($uroven,$text) = @_; if ($uroven<=$log) { open (HND, ">>_logs/$Wyear$Wmom$Wmday-$$-$Whour.fastlog"); print HND "\\$$\\$fastcount\\[$uroven]\\ $text\n"; close HND; if ($superlog){$superlog_tmp="$superlog_tmp\\[$uroven]\\ $text ";} } } # ADD MODULE ### sub add_module { my($tempposition,$name,@variables) = @_; my $mdl_output; do "$name.mdl"; if ($mdl_output=&ModulAdd(@variables)) { $html_write{$tempposition}="$html_write{$tempposition}$mdl_output"; } undef &ModulAdd; my $length=length($mdl_output); &save_log(2,"+\"$name.mdl\" [$tempposition][$length]"); } ### # ### my $req=FCGI::Request(); local $fastcount; while ($req->Accept() >= 0) { $fastcount++; &StartScript_new; } sub StartScript_new { my $time_start=(times)[0]; # START COUNTING TIME # RELATIVE my $html_temp=$HTML_TEMP; # TIME local $current_time=time; local ($Tsec, $Tmin, $Thour, $Tmday, $Tmom, $Tyear, $Twday, $Tyday, $Tisdst)=localtime($current_time); local $Wsec=$Tsec;local $Wmin=$Tmin;local $Whour=$Thour;local $Wmday=$Tmday;local $Wmom=$Tmom+1; local $Wyear=$Tyear+1900; if ($Wsec<10){$Wsec="0$Wsec"} if ($Wmin<10){$Wmin="0$Wmin"} if ($Whour<10){$Whour="0$Whour"} if ($Wmday<10){$Wmday="0$Wmday"} if ($Wmom<10){$Wmom="0$Wmom"} # LOCAL local $superlog_tmp; local %form; local %cookie; local %html_write; local $dbh = Mysql->Connect($db_host,$db_name,$db_user,$db_pass); # MY my $key; my $length; &save_log(0,"START [$$][$fastcount/$max_count]"); &GetQueryString; if(!$form{type}){$form{type}="first";} &GetCookie;foreach $key (keys %cookie){&save_log(3,"get_cookie '$key'=\"$cookie{$key}\"");} # START BASE MODULE'S &add_module('00-01',"_check_online"); if ($superlog){&add_module('99-99',"_superlog")}; do "type_$form{type}.mdl"; &BaseModul;undef &BaseModul; # All others modules is in &BaseModul {&add_module...,&add_module... etc...} # CREATE HTML foreach $key (sort keys %html_write) { if (not $html_temp=~s|<%TMP$key%>|$html_write{$key}|g) { $length=length($html_write{$key});&save_log(0,"! insert ok '$key' [$length chars]"); } else { $length=length($html_write{$key});&save_log(4,"-> bad insert! '$key' [$length chars]"); } } # SEND COOKIE $cookie{name}="i-laskanie"; &SetCookie("-1","$host","/","0"); foreach $key (keys %cookie){&save_log(3,"set_cookie '$key'=\"$cookie{$key}\"");} # COUNT END, LOG END my $time_end=(times)[0]-$time_start; # END COUNTING TIME my $memory_end=`ps -p $$ -o vsz=`;$memory_end=~s|[\n\r ]||g; $length=length($html_temp); &save_log(0,"END [$$][$current_time][$time_end][$length chars][$memory_end/$max_memory]\n\n"); # SEND HTML if ($superlog){$html_temp=~s|<%SUPERLOG%>|$superlog_tmp|g;} &PrintHeader; print $html_temp; # UNDEF undef %form; undef %cookie; undef $dbh; # RELOAD if (($fastcount>$max_count)||($memory_end>$max_memory)) {&save_log(0,"RELOAD [$current_time][$$-$memory_end/$max_memory]\n\n");&fcgi_exit;} } > and this is "base_clanky_big.mdl" linket by sub > &add_module(x,'base_clanky_big'); sub ModulAdd { ## # LOCAL VARIABLES FOR MODULE ## my $mdl_temp; my $mdl_temp_line=<<"HEADER"; HEADER my $db_micro; my $db_micro1; my %db_micro_line; my %db_micro1_line; my $nullid; my %ref; ### # START VARIABLES MANIPULATION ### $db_micro = $dbh->Query("SELECT ID,starttime,author,tiny,title,image FROM clanky WHERE starttime<$current_time AND active='Y' AND typeview='B' ORDER BY starttime DESC LIMIT 1"); if (@db_micro_line=$db_micro->FetchRow()) { $mdl_clanok_big_no=$db_micro_line[0]; $mdl_temp="$mdl_temp$mdl_temp_line"; $mdl_temp=~s||$db_micro_line[4]|g; $mdl_temp=~s||$db_micro_line[3]|g; $mdl_temp=~s||$db_micro_line[0]|g; $nullid=$db_micro_line[0]; if ($nullid<10){$nullid="0$nullid"}; if ($nullid<100){$nullid="0$nullid"}; if ($nullid<1000){$nullid="0$nullid"}; if ($nullid<1){$nullid="0$nullid"}; if ($nullid<10){$nullid="0$nullid"}; $mdl_temp=~s||$nullid|g; @ref=
Re: More Economic Use of Hash
Do you want a lexical sort or a numeric sort? foreach my $key ( sort keys %freq ) # lexical foreach my $key ( sort ($a<=>$b) keys %freq ) # numeric - Roger - - Original Message - From: "Balint, Jess" <[EMAIL PROTECTED]> To: "'Roger C Haslock'" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]> Sent: Thursday, January 31, 2002 9:37 PM Subject: RE: More Economic Use of Hash > Thanks. Works great. Any ideas how I might sort the output hash for output > to a file in key order? > > -Original Message- > From: Roger C Haslock [mailto:[EMAIL PROTECTED]] > Sent: Thursday, January 31, 2002 2:23 PM > To: Balint, Jess; [EMAIL PROTECTED] > Subject: Re: More Economic Use of Hash > > > # Why not ... > while( ) > { > @tmp = split( /\|/ ); > if (exists $freq{$tmp[$table]}) > { > $freq{$tmp[$table]}++ > } > else > { > $freq{$tmp[$table]}=1 > } > $tot ++ > } > > - Original Message - > From: "Balint, Jess" <[EMAIL PROTECTED]> > To: <[EMAIL PROTECTED]> > Sent: Thursday, January 31, 2002 6:45 PM > Subject: More Economic Use of Hash > > > > I am attemping to create a frequency chart based on a pipe delimited > > database output. Following is what I have come up with. The hash create > from > > this is then output to another file. It seems to be very slow on files in > > excess of ~1 lines. This will be used on ~50 line files and needs > to > > be a proficient as possible. If anyone knows a better way to do this, it > > would be extremely helpful. Thank you. -Jess > > > > $table is the number of the field which the frequency will be calculated > on. > > ex. a|b|c|d| if $table = 3 then c will be used > > @tmp is the split array of the line input > > %freqidx is the hash with fields values as keys and frequency counts > > $tot is for percentage calculation after this loop. this is basically an > > INFILE line count > > > > while( ) { > > @tmp = split( /\|/ ); > > $x = 0; > > foreach( keys( %freqidx ) ) { > > if( $tmp[$table] ne $_ ) { > > $x = 1; > > } else { > > $x = 0; > > last; > > } > > } > > if( $x == 1 ) { > > $freqidx{$tmp[$table]} = 0; > > } > > $freqidx{$tmp[$table]}++; > > $tot++; > > } > > > > -- > > 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] > > > > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
translation of logical operators
Dear perl mongers. I need to know if I can translate symbols in a text file into logical operators like AND|OR|NOT and so forth. The thing is that I'm trying to build a simulator for digital cuircuts, with input files in 3DML style (ascii graphix style) like this: =A-N> =O> >A- Hrm, a little explanation might be handy. A dual input AND gate inputs signal to a NOT gate. Dual input OR gate. Result of AND+NOT, and OR gates enters AND gate and out comes result. I know it's a mouthfull or two, since I just got the Lhama, but if you could kick me in the right direction... filson
PERL and XML Parser
Hi list. I'm currently doing a perl project involving XML parser. given this xml snippet: Percy Alice in Chains The Pixies Bob Marley Peter Tosh how can i get the PCDATA for the element "owner"? i want to get just the "owner" elements and the content of the "owner." i've created a code that will trap for the start and end tags of the element "owner" as well as the handlers for the characters that were part of the markup but no particular handlers. please help. thanks. percy _ 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: PERL and XML Parser
On Fri, 1 Feb 2002 21:04:54 +0800 P0R0NG <[EMAIL PROTECTED]> wrote: |how can i get the PCDATA for the element "owner"? i want to get just |the "owner" elements and the content of the "owner." | |i've created a code that will trap for the start and end tags of |the element "owner" as well as the handlers for the characters |that were part of the markup but no particular handlers. i forgot, my code was getting all the contents with no particular handlers. (ie contents of "rock", "reggae", "owner" elements were trapped. all i want is the content of the "owner" elements. thanks again. percy _ 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: [ma-linux] Just when you thought you are done, the - is there - appears
Thanks to all who responded to my mail, especially Geoff. The best solution, I think, will be for me to throw in a login screen, but this has been ruled out. The IP range solution has lots of question marks, including what Geoff pointed out. I am basically stuck and will need any suggestion (of course, with minimal "question marks") so I can put this big monster to sleep. Thanks again. __ William Ampeh (x3939) Federal Reserve Board -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: html entity conversion... one liner?
Just because tmtowtdi (even if it is not very efficient): $item = join '', map { s//>/; $_ } split //, $item; On Thu, 2002-01-31 at 09:51, Chas Owens wrote: > On Thu, 2002-01-31 at 09:39, John Edwards wrote: > > Why *must* it be a one liner. I think my suggestion is easier to understand > > for someone having to maintain your code. If there is no other reason than > > "I want a one liner" to do this on one line, then why not do it on two?? > > Just because it is possible in one line, doesn't mean it's the best > > approach. > > > > To me this: > > > > $item = ""; > > > > $item =~ s/ > $item =~ s/>/>/g; > > > > Seems far easier to understand than either this: > > > > $item = ""; > > > > $item =~ s/([<>])/'&'. ($1 eq'<' ? 'l':'g') . 't;'/eg; > > > > or this: > > > > my %entity = ( > > '<' => '<', > > '>' => '>', > > '&' => '&', > > ); > > > > $item = ""; > > > > $item =~ s/([<>&])/$entity{$1}/ge; > > > > which isn't even a one liner as you have to define a lookup hash to begin > > with. > > True it is not a one liner, but it does look nicer and is easier to > extend than individual regexs if you are defining a lot of entities > (that is why my example had an & in it). Of course you should probably > not be doing any of this yourself; I am sure a module exists out there > to handle this sort of case. > > > > All IMHO ;) > > > > John > > > > -Original Message- > > From: Briac Pilpré [mailto:[EMAIL PROTECTED]] > > Sent: 31 January 2002 14:35 > > To: [EMAIL PROTECTED] > > Subject: Re: html entity conversion... one liner? > > > > > > On Thu, 31 Jan 2002 14:06:06 -, Michael Kavanagh > > <[EMAIL PROTECTED]> wrote: > > > I thought it would be good to be able to do this: > > > > > > $item = ""; > > > $item =~ tr/<>/(<)(>)/; > > > > > > to convert those <> symbols to their entity references. however, the > > > tr operator doesn't seem to like using () to group... any comments on > > > how to make this operation in to a one-liner? > > > > Here's a possible suboptimal one-liner approach: > > > > > > #!/usr/bin/perl -w > > use strict; > > > > my $item = "buh zoh"; > > > > $item =~ s/([<>])/'&'. ($1 eq'<' ? 'l':'g') . 't;'/eg; > > > > print $item; > > > > > > __END__ > > > > > > > > -- > > briac > > << dynamic .sig on strike, we apologize for the inconvenience >> > > > > > > -- > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > --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] > -- > Today is Sweetmorn the 31st day of Chaos in the YOLD 3168 > Umlaut Zebra über alles! > > Missle Address: 33:48:3.521N 84:23:34.786W > > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] -- Today is Boomtime the 32nd day of Chaos in the YOLD 3168 Hail Eris! Missle Address: 33:48:3.521N 84:23:34.786W -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [ma-linux] Just when you thought you are done, the - is there - appears
I guess geoff is in the ma-linux list, not in here since the only things i can find in this thread is 3 posts by you. Kinda hard to offer better(tm) sollutions when you don't know what's been suggested before...Perhaps you should try NOT cross-posting? /Jon [EMAIL PROTECTED] wrote: > > Thanks to all who responded to my mail, especially Geoff. The best > solution, I think, will be for > me to throw in a login screen, but this has been ruled out. The IP range > solution has lots of > question marks, including what Geoff pointed out. I am basically stuck and > will need any > suggestion (of course, with minimal "question marks") so I can put this big > monster to sleep. > > Thanks again. > > __ > > William Ampeh (x3939) > Federal Reserve Board > > -- > 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]
testing for a dir
What is the best way, using rsh, to test if a directory exists on another server? _ MSN Photos is the easiest way to share and print your photos: http://photos.msn.com/support/worldwide.aspx -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
change all files in directory
Hello, I am trying to change all files in a directory that contain the strings Satellite satellite and SATELLITE that I need to change to target, Target and TARGET. Because many of these are C++ source files I need to preserve the case. I was thinking of the following script: #!/usr/bin/perl -w #UNTESTED @FilesInDirectory = <*.cpp *.hpp *.asc>; foreach $FileName (@FilesInDirectory) { open(IN, $FileName); while { $_ =~ s/satellite/target/; $_ =~ s/Satellite/Target/; $_ =~ s/SATELLITE/TARGET/;} } but this just doesn't seem as efficient as it can be. I was trying to think of regex that could do it all in one line but it seemed so much simpler to do it in three. Any thoughts, Tim
RE: PERL and XML Parser
There are tons of XML modules, many of which make that sort of thing easy... but it depends on exactly what you want to do. Here are some snippets: use XML::EasyOBJ; my $obj = new XML::EasyOBJ('killme.xml'); foreach ( $obj->albums ) { print $_->owner->getString . "\n"; } -- OR -- use XML::RAX; my $rax = new XML::RAX; $rax->openfile('killme.xml'); $rax->setRecord('albums'); while ( my $rec = $rax->readRecord ) { print $rec->getField('owner') . "\n"; } And there are *LOTS* more. It all depends on what you need to do. BTW - The current version of XML::EasyOBJ on CPAN is a bit old. I have a newer version that includes read and write capabilities but I haven't written up the new docs for it yet. I can send it if you wanted. Rob -Original Message- From: P0R0NG [mailto:[EMAIL PROTECTED]] Sent: Friday, February 01, 2002 8:10 AM To: [EMAIL PROTECTED] Subject: Re: PERL and XML Parser On Fri, 1 Feb 2002 21:04:54 +0800 P0R0NG <[EMAIL PROTECTED]> wrote: |how can i get the PCDATA for the element "owner"? i want to get just |the "owner" elements and the content of the "owner." | |i've created a code that will trap for the start and end tags of |the element "owner" as well as the handlers for the characters |that were part of the markup but no particular handlers. i forgot, my code was getting all the contents with no particular handlers. (ie contents of "rock", "reggae", "owner" elements were trapped. all i want is the content of the "owner" elements. thanks again. percy -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: testing for a dir
Well, I'm not sure about rsh, but with ssh: ssh www.journalistic.com "perl -e 'print ( (-d \"data\") ? \"DIR\n\" : \"Not DIR\n\" );'" Change "data" to whatever your dirname is... Jason If memory serves me right, on Friday 01 February 2002 10:18, Alex Harris wrote: > What is the best way, using rsh, to test if a directory exists on another > server? > > _ > MSN Photos is the easiest way to share and print your photos: > http://photos.msn.com/support/worldwide.aspx -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: change all files in directory
From: Booher Timothy B 1stLt AFRL/MNAC <[EMAIL PROTECTED]> > Hello, I am trying to change all files in a directory that contain the > strings Satellite satellite and SATELLITE that I need to change to > target, Target and TARGET. Because many of these are C++ source files > I need to preserve the case. I was thinking of the following script: > > #!/usr/bin/perl -w > #UNTESTED > > @FilesInDirectory = <*.cpp *.hpp *.asc>; > foreach $FileName (@FilesInDirectory) { > open(IN, $FileName); > while { > $_ =~ s/satellite/target/; > $_ =~ s/Satellite/Target/; > $_ =~ s/SATELLITE/TARGET/;} > } %replace = ( satellite => 'target', Satellite => 'Target', SATELLITE => 'TARGET', ); $re = join('|',keys %replace); while () { s/($re)/$replace{$1}/go; } Not sure if it'll be any quicker. If you keep your code do not forget to add the /g option, otherwise you'd only replace the first occurence on each line. 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: change all files in directory
Yeah, here is an easy solution, run it right at the command line... (Make a backup of the files first!!) perl -pi -e 's|satellite|target|' *.cpp *.hpp *.asc perl -pi -e 's|Satellite|Target|' *.cpp *.hpp *.asc perl -pi -e 's|SATELLITE|TARGET|' *.cpp *.hpp *.asc Rob -Original Message- From: Booher Timothy B 1stLt AFRL/MNAC [mailto:[EMAIL PROTECTED]] Sent: Friday, February 01, 2002 10:22 AM To: [EMAIL PROTECTED] Subject: change all files in directory Hello, I am trying to change all files in a directory that contain the strings Satellite satellite and SATELLITE that I need to change to target, Target and TARGET. Because many of these are C++ source files I need to preserve the case. I was thinking of the following script: #!/usr/bin/perl -w #UNTESTED @FilesInDirectory = <*.cpp *.hpp *.asc>; foreach $FileName (@FilesInDirectory) { open(IN, $FileName); while { $_ =~ s/satellite/target/; $_ =~ s/Satellite/Target/; $_ =~ s/SATELLITE/TARGET/;} } but this just doesn't seem as efficient as it can be. I was trying to think of regex that could do it all in one line but it seemed so much simpler to do it in three. Any thoughts, Tim -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
difference between MSI and AS package
One more while I am at it . . . what is the difference between the MSI and the AS package distribution of ActivePerl 5.6.1 on the active state web-site? I don't know which one to download . . . Tim
RE: change all files in directory
From: Jenda Krynicky [mailto:[EMAIL PROTECTED]] > If you keep your code do not forget to add the /g option Oops! perl -pi -e 's|satellite|target|g' *.cpp *.hpp *.asc perl -pi -e 's|Satellite|Target|g' *.cpp *.hpp *.asc perl -pi -e 's|SATELLITE|TARGET|g' *.cpp *.hpp *.asc Rob -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: difference between MSI and AS package
The MSI uses the Microsoft installer, which means you can uninstall it. Use that one if you can. The AS package does not include an installer (well maybe a batch script, but I'm not sure). Rob -Original Message- From: Booher Timothy B 1stLt AFRL/MNAC [mailto:[EMAIL PROTECTED]] Sent: Friday, February 01, 2002 10:31 AM To: [EMAIL PROTECTED] Subject: difference between MSI and AS package One more while I am at it . . . what is the difference between the MSI and the AS package distribution of ActivePerl 5.6.1 on the active state web-site? I don't know which one to download . . . Tim -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: change all files in directory
On Feb 1, Booher Timothy B 1stLt AFRL/MNAC said: >Hello, I am trying to change all files in a directory that contain the >strings Satellite satellite and SATELLITE that I need to change to target, >Target and TARGET. Because many of these are C++ source files I need to >preserve the case. I was thinking of the following script: There's an entry in the Perl FAQ for preserving case, but there's a much simpler way: sub case { my ($s, $d) = @_; $s = substr($s, 0, length($d)) if length($d) < length($s); $d ^ (~$s & (" " x length $s)); } Try it out: for (qw( satellite Satellite SATELLITE )) { print case($_ => "target"), "\n"; } The output is target Target TARGET Its usage in a s/// is: s/(word to change)/case($1, "word to become")/eg; -- Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/ ** Look for "Regular Expressions in Perl" published by Manning, in 2002 ** what does y/// stand for? why, yansliterate of course. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: change all files in directory
Somewhat related question: I want to ADD a file extension (there currently none)to all files that start with "FOO" so they will be named FOO.txt Is there a one liner that can accomplish this? -Original Message- From: Hanson, Robert [mailto:[EMAIL PROTECTED]] Sent: Friday, February 01, 2002 9:30 AM To: 'Booher Timothy B 1stLt AFRL/MNAC'; [EMAIL PROTECTED] Subject: RE: change all files in directory Yeah, here is an easy solution, run it right at the command line... (Make a backup of the files first!!) perl -pi -e 's|satellite|target|' *.cpp *.hpp *.asc perl -pi -e 's|Satellite|Target|' *.cpp *.hpp *.asc perl -pi -e 's|SATELLITE|TARGET|' *.cpp *.hpp *.asc Rob -Original Message- From: Booher Timothy B 1stLt AFRL/MNAC [mailto:[EMAIL PROTECTED]] Sent: Friday, February 01, 2002 10:22 AM To: [EMAIL PROTECTED] Subject: change all files in directory Hello, I am trying to change all files in a directory that contain the strings Satellite satellite and SATELLITE that I need to change to target, Target and TARGET. Because many of these are C++ source files I need to preserve the case. I was thinking of the following script: #!/usr/bin/perl -w #UNTESTED @FilesInDirectory = <*.cpp *.hpp *.asc>; foreach $FileName (@FilesInDirectory) { open(IN, $FileName); while { $_ =~ s/satellite/target/; $_ =~ s/Satellite/Target/; $_ =~ s/SATELLITE/TARGET/;} } but this just doesn't seem as efficient as it can be. I was trying to think of regex that could do it all in one line but it seemed so much simpler to do it in three. Any thoughts, Tim -- 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: change all files in directory
On Fri, 1 Feb 2002, Booher Timothy B 1stLt AFRL/MNAC wrote: > Hello, I am trying to change all files in a directory that contain the > strings Satellite satellite and SATELLITE that I need to change to target, > Target and TARGET. Because many of these are C++ source files I need to > preserve the case. I was thinking of the following script: > > #!/usr/bin/perl -w > #UNTESTED > > @FilesInDirectory = <*.cpp *.hpp *.asc>; > foreach $FileName (@FilesInDirectory) { > open(IN, $FileName); > while { > $_ =~ s/satellite/target/; > $_ =~ s/Satellite/Target/; > $_ =~ s/SATELLITE/TARGET/;} > } > > but this just doesn't seem as efficient as it can be. I was trying to think > of regex that could do it all in one line but it seemed so much simpler to > do it in three. This can actually be done on the command-line: perl -pi.bak -e 's/satellite/target/g' *.cpp *.hpp. *.asc There's nothing wrong with doing it in three steps. -- Brett http://www.chapelperilous.net/ "Trust me": Translation of the Latin "caveat emptor." -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
UFO (Unidentified Formatting Observation) on the web....
I have a very beginner's question. I've just been looking at the code for a library file and noticed some, to me, very peculiar things. First, there is text that is not commented, it is just typed in place. Why does this not interfere with the script? Second, there are expressions like "=pod" and "=cut" and "=head1". What do these mean? Third, there is a "1;" at the very end of the file. I've seen that before, but what is the purpose? Fourth, there is text like "I blah blah" and "B" (I assume that this last is a comment on text decoration). Can anyone tell me what these mean? Is there a difference in a library file and a regular script file that allows for this? Is there some tutorial or documentation about the differences in writing a library/module versus a normal script file? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: change all files in directory
When I try to run the one-liners I get: Can't open *.cpp: Invalid argument. Can't open *.hpp: Invalid argument. But when I do a dir command I get: target_functions.cpptarget_modules.cpp global_constants.hpp global_header.hpp class_functions.cpp S2b_4.opt Clearly these files are there . . . or am I just doing something silly . . . tim -Original Message- From: Brett W. McCoy [mailto:[EMAIL PROTECTED]] Sent: Friday, February 01, 2002 9:47 AM To: Booher Timothy B 1stLt AFRL/MNAC Cc: [EMAIL PROTECTED] Subject: Re: change all files in directory On Fri, 1 Feb 2002, Booher Timothy B 1stLt AFRL/MNAC wrote: > Hello, I am trying to change all files in a directory that contain the > strings Satellite satellite and SATELLITE that I need to change to target, > Target and TARGET. Because many of these are C++ source files I need to > preserve the case. I was thinking of the following script: > > #!/usr/bin/perl -w > #UNTESTED > > @FilesInDirectory = <*.cpp *.hpp *.asc>; > foreach $FileName (@FilesInDirectory) { > open(IN, $FileName); > while { > $_ =~ s/satellite/target/; > $_ =~ s/Satellite/Target/; > $_ =~ s/SATELLITE/TARGET/;} > } > > but this just doesn't seem as efficient as it can be. I was trying to think > of regex that could do it all in one line but it seemed so much simpler to > do it in three. This can actually be done on the command-line: perl -pi.bak -e 's/satellite/target/g' *.cpp *.hpp. *.asc There's nothing wrong with doing it in three steps. -- Brett http://www.chapelperilous.net/ "Trust me": Translation of the Latin "caveat emptor."
Re: UFO (Unidentified Formatting Observation) on the web....
On Feb 1, Ron Goral said: >I have a very beginner's question. I've just been looking at the code for a >library file and noticed some, to me, very peculiar things. First, there is >text that is not commented, it is just typed in place. Why does this not >interfere with the script? Second, there are expressions like "=pod" and >"=cut" and "=head1". What do these mean? Third, there is a "1;" at the >very end of the file. I've seen that before, but what is the purpose? >Fourth, there is text like "I blah blah" and "B" (I >assume that this last is a comment on text decoration). Can anyone tell me >what these mean? Is there a difference in a library file and a regular >script file that allows for this? Is there some tutorial or documentation >about the differences in writing a library/module versus a normal script >file? The text that "is not commented", you will find, is placed inbetween the =XYZ statements. The =XYZ statements are called Pod directives, and the I<...> and B<...> statements are Pod markup. Pod is "Plain Old Documentation", a very simple markup language for documenting Perl programs. Read 'perldoc perlpod' for information on Pod. The '1;' at the end of the file is there so that the file returns a true value when Perl require()s it. See 'perldoc -f require'. As for how a library or module differs from a "normal" program, it's basically how an encyclopedia differs from your term paper. You READ your term paper, and it makes references to places in the encyclopedia -- you wouldn't use the entire encyclopedia as your term paper. -- Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/ ** Look for "Regular Expressions in Perl" published by Manning, in 2002 ** what does y/// stand for? why, yansliterate of course. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: UFO (Unidentified Formatting Observation) on the web....
it's pod, do 'perldoc module' and 'perldoc perldoc' /jon Ron Goral wrote: > > I have a very beginner's question. I've just been looking at the code for a > library file and noticed some, to me, very peculiar things. First, there is > text that is not commented, it is just typed in place. Why does this not > interfere with the script? Second, there are expressions like "=pod" and > "=cut" and "=head1". What do these mean? Third, there is a "1;" at the > very end of the file. I've seen that before, but what is the purpose? > Fourth, there is text like "I blah blah" and "B" (I > assume that this last is a comment on text decoration). Can anyone tell me > what these mean? Is there a difference in a library file and a regular > script file that allows for this? Is there some tutorial or documentation > about the differences in writing a library/module versus a normal script > file? > > -- > 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: UFO (Unidentified Formatting Observation) on the web....
On Fri, 2002-02-01 at 10:44, Ron Goral wrote: > I have a very beginner's question. I've just been looking at the code for a > library file and noticed some, to me, very peculiar things. First, there is > text that is not commented, it is just typed in place. Why does this not > interfere with the script? Second, there are expressions like "=pod" and > "=cut" and "=head1". What do these mean? Third, there is a "1;" at the > very end of the file. I've seen that before, but what is the purpose? > Fourth, there is text like "I blah blah" and "B" (I > assume that this last is a comment on text decoration). Can anyone tell me > what these mean? Is there a difference in a library file and a regular > script file that allows for this? Is there some tutorial or documentation > about the differences in writing a library/module versus a normal script > file? > That is POD (Plain Old Documentation). POD is a method of documenting Perl code be it a script or a library. See "perldoc perlpod" for more information. The 1; at the end of the file is necessary for libraries only. See "perldoc perlmod" for more information. -- Today is Boomtime the 32nd day of Chaos in the YOLD 3168 All Hail Discordia! Missle Address: 33:48:3.521N 84:23:34.786W -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Access Transmitted Data On "Server" Side Of A TCP Socket
Received an off-list reply that solved the problem. Replaced $client->recv with: $dataIn = <$client>); There's no way I would have figured that out on my own. Hew Hewlett M. Pickens BIM -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: change all files in directory
Oh, you're on Windows, it may not work because of the shell ("cmd"). In Windows the single quotes around the code usually need to be double quotes, and it doesn't seem to be expanding *.cpp when on Unix (types) it will expand that to all of the individual file names. I guess you need to write a script then like you were originally planning to do. ...Or if you want to be bold, install Cygwin (http://www.cygwin.com/) which includes tons of Unix utilities that will run on Win95/98/ME/NT/2K. Among the utilities is "bash", and command shell which you can use instead of "cmd" on NT/2K and "command" on Win95/98/ME. After using bash for a while you will wonder why you ever wanted to use "cmd" to begin with (I know I do). Rob -Original Message- From: Booher Timothy B 1stLt AFRL/MNAC [mailto:[EMAIL PROTECTED]] Sent: Friday, February 01, 2002 10:46 AM To: Brett W. McCoy; Booher Timothy B 1stLt AFRL/MNAC Cc: [EMAIL PROTECTED] Subject: RE: change all files in directory When I try to run the one-liners I get: Can't open *.cpp: Invalid argument. Can't open *.hpp: Invalid argument. But when I do a dir command I get: target_functions.cpptarget_modules.cpp global_constants.hpp global_header.hpp class_functions.cpp S2b_4.opt Clearly these files are there . . . or am I just doing something silly . . . tim -Original Message- From: Brett W. McCoy [mailto:[EMAIL PROTECTED]] Sent: Friday, February 01, 2002 9:47 AM To: Booher Timothy B 1stLt AFRL/MNAC Cc: [EMAIL PROTECTED] Subject: Re: change all files in directory On Fri, 1 Feb 2002, Booher Timothy B 1stLt AFRL/MNAC wrote: > Hello, I am trying to change all files in a directory that contain the > strings Satellite satellite and SATELLITE that I need to change to target, > Target and TARGET. Because many of these are C++ source files I need to > preserve the case. I was thinking of the following script: > > #!/usr/bin/perl -w > #UNTESTED > > @FilesInDirectory = <*.cpp *.hpp *.asc>; > foreach $FileName (@FilesInDirectory) { > open(IN, $FileName); > while { > $_ =~ s/satellite/target/; > $_ =~ s/Satellite/Target/; > $_ =~ s/SATELLITE/TARGET/;} > } > > but this just doesn't seem as efficient as it can be. I was trying to think > of regex that could do it all in one line but it seemed so much simpler to > do it in three. This can actually be done on the command-line: perl -pi.bak -e 's/satellite/target/g' *.cpp *.hpp. *.asc There's nothing wrong with doing it in three steps. -- Brett http://www.chapelperilous.net/ "Trust me": Translation of the Latin "caveat emptor." -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
simple commenting question ...
Can I comment an entire block of code with comments at just the beginning and end of the block instead of having to put a # at the beginning of each line? If so, what is the symbol? Thank You! -Richard -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
why doesn't this error
First, I read perldoc -f exec() and did as follows: exec "rsh $plant /u1/bin/forkit 'work.pl'" or print STDERR "Couldn't fork it.\n $!\n"; BUT, even though the file it should be exec - ing 'work.pl' does NOT exist on the remote system, the error doesn't get kicked off. The only error I've gotten it to register is if $plant is invalid. Any ideas? _ MSN Photos is the easiest way to share and print your photos: http://photos.msn.com/support/worldwide.aspx -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: simple commenting question ...
Here is what you do =pod code block . =cut -Original Message- From: Pfeiffer, Richard [mailto:[EMAIL PROTECTED]] Sent: Friday, February 01, 2002 11:02 AM To: '[EMAIL PROTECTED]' Subject: simple commenting question ... Can I comment an entire block of code with comments at just the beginning and end of the block instead of having to put a # at the beginning of each line? If so, what is the symbol? Thank You! -Richard -- 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: simple commenting question ...
Yes. ...Sort of. =pod $x = 1; ... $y = 2; =cut The =pod and =cut are usually used for documentation but works for commenting out chunks of code as well. Currently there are no other mechanisms (unless you want to put it all in a if(0){} block :). Rob -Original Message- From: Pfeiffer, Richard [mailto:[EMAIL PROTECTED]] Sent: Friday, February 01, 2002 11:02 AM To: '[EMAIL PROTECTED]' Subject: simple commenting question ... Can I comment an entire block of code with comments at just the beginning and end of the block instead of having to put a # at the beginning of each line? If so, what is the symbol? Thank You! -Richard -- 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: PERL and XML Parser
oh yes thanks for that! thanks. i overlooked that. my big... anyways, here's the correct xml version: Percy Alice in Chains The Pixies Percy and the Test Tube Babies Bob Marley Peter Tosh Percy Gone Jazz in using xml parser, how can i get the content of element 'owner'? i created the code but every content between the xml elements we parsed. here's my code: #! /usr/local/bin/perl use XML::Parser; my $parser = new XML::Parser (); $parser->setHandlers (Start => \&Start_handler, End => \&End_handler, Default => \&Default_handler ); my $filename = shift; die "Can't find '$filename': $!\n" unless -f $filename; $parser->parsefile ($filename); sub Start_handler { my $p = shift; my $el = shift; if ($el =~ m/owner/g) {print "<$el>"}; } sub End_handler { my ($p,$el) = @_; if ($el =~ m/owner/g) { print "\n"; }; } sub Default_handler { my ($p,$str) = @_; # my $p = shift; # my $str = shift; if (($str =~m/Percy/g) or ($str =~m/Percy/g)){ print "\n$str\n"; } } On Fri, 1 Feb 2002 10:27:37 -0500 "Hanson, Robert" <[EMAIL PROTECTED]> wrote: |By the way, there were a lot of XML errors in that example. | | | |You need an attribute name, this is not legal. | |Alice in Chains | |The closing tag does not match the opening tag. | | | |You need an attribute name, this is not legal. | |Rob | | |-Original Message- |From: P0R0NG [mailto:[EMAIL PROTECTED]] |Sent: Friday, February 01, 2002 8:05 AM |To: [EMAIL PROTECTED] |Subject: PERL and XML Parser | | |Hi list. | |I'm currently doing a perl project involving XML parser. | |given this xml snippet: | | | Percy | |Alice in Chains |The Pixies | | |Bob Marley |Peter Tosh | | _ 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]
Writing to Multiple Files
Does anyone know the best way to write a really long form into two seperate flat files, which then can be polled using a generated ID# into HTML? Thanks Guys... -- /_/_/ Aaron K. White _/ _/ _/ _/ _/ GeSE Program Office _/_/_/ _/ _/ _/_/ _/ Web Development & Solutions _/ _/ _/ _/ _/_/(303)272-9974 EX.79974 _/_/_/ _/_/_/ _/ _/ 500 Eldorado Blvd. Broomfield CO 80021 M I C R O S Y S T E M S[EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Include file
I have a set of program to do which is using always same var. So I would like to defined a small file where I defined my var (like $database="toto" $host="localhost" etc..) and then include it in my other program, but How to do that ? I try "use" but it's seems that is for complete module. "require" seems to be for version behavior and include seems not be supported... I browse doc but I found nothing..
Re: why doesn't this error
Alex Harris wrote: > > First, I read perldoc -f exec() and did as follows: > > exec "rsh $plant /u1/bin/forkit 'work.pl'" or >print STDERR "Couldn't fork it.\n $!\n"; > > BUT, even though the file it should be exec - ing 'work.pl' does NOT exist > on the remote system, the error doesn't get kicked off. The only error I've > gotten it to register is if $plant is invalid. Any ideas? > I think that instead of 'print', you should try 'warn' or 'die. Bompa -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: why doesn't this error
> -Original Message- > From: Alex Harris [mailto:[EMAIL PROTECTED]] > Sent: Friday, February 01, 2002 11:06 AM > To: [EMAIL PROTECTED] > Subject: why doesn't this error > > > First, I read perldoc -f exec() and did as follows: > > exec "rsh $plant /u1/bin/forkit 'work.pl'" or >print STDERR "Couldn't fork it.\n $!\n"; > > BUT, even though the file it should be exec - ing 'work.pl' > does NOT exist > on the remote system, the error doesn't get kicked off. The > only error I've > gotten it to register is if $plant is invalid. Any ideas? The exec will only fail if rsh doesn't exist. Assuming rsh exists, rsh *completely replaces* your perl script. Any problems encountered by rsh will be apparent only after your perl script is gone. You need to use system() instead of exec() if you need to determine whether rsh had any problems. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Get IP address from ifconfig
Richard, the bash shell script I used to do that was the following: /sbin/ifconfig eth0 |grep inet |cut -d ' ' -f12 | cut -d ':' -f2 This may not be generic, and you may have to fine-tune it to work for you, but it should give you the basic premise... Chris Weyn, Austin TX -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
still not catching error
I took out the exec and placed system. But even though work.pl doesn't exist on the remote system, still getting no error. Help! if (system("rsh $plant /u1/bin/forkit '/u1/bin/work.pl'") > 0) { excep(" $!\n"); } _ Send and receive Hotmail on your mobile device: http://mobile.msn.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Win32::GUI - Getting rid of console Window?
Is there anyway to get a Win3::GUI app to not display the DOS console when running, so it runs just like any other GUI app? Agustin Rivera Webmaster, Pollstar.com http://www.pollstar.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: still not catching error
Try $result = `rsh $plant /u1/bin/forkit '/u1/bin/work.pl'`; print $result; You are storing the output of the rsh... command into the variable. You can now run a regex on that to check for success/failure. I don't know what the output should be but as an example... $result = `rsh $plant /u1/bin/forkit '/u1/bin/work.pl'`; if ($result =~ /worked/i) { print "Yep, that worked\n"; } else { print "Ooops. Something went wrong: $result"; } HTH John -Original Message- From: Alex Harris [mailto:[EMAIL PROTECTED]] Sent: 01 February 2002 16:52 To: [EMAIL PROTECTED] Subject: still not catching error I took out the exec and placed system. But even though work.pl doesn't exist on the remote system, still getting no error. Help! if (system("rsh $plant /u1/bin/forkit '/u1/bin/work.pl'") > 0) { excep(" $!\n"); } _ Send and receive Hotmail on your mobile device: http://mobile.msn.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --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]
Re: Win32::GUI - Getting rid of console Window?
>Is there anyway to get a Win3::GUI app to not display the DOS console when >running, so it runs just like any other GUI app? Yuppers. use Win32::GUI; # hwnd is a handle to a window - basically, window's # way of keeping track of it's program windows... $hwnd = GUI::GetPerlWindow(); # comment this to see error messages in a dos window # otherwise, this will hide the blasted thing... GUI::Hide($hwnd); -- Morbus Iff ( softcore vulcan pr0n rulez ) http://www.disobey.com/ && http://www.gamegrene.com/ please me: http://www.amazon.com/exec/obidos/wishlist/25USVJDH68554 icq: 2927491 / aim: akaMorbus / yahoo: morbus_iff / jabber.org: morbus -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Perl DBI - using parameters
Hi, This is my first effort at perl scripting so forgive my innocence. What I am trying to do is extract schema and data info from a proprietary database into flat files, format those files and import the data and schema into an Oracle database. The initial part of this is capturing the table names into an array and then using that array to query the database and dump the results to flat files. Where I'm having trouble is in using a bound parameter in the sql statement. If I use a table name directly it works without a problem but when I parameterise it I get a Parse Error. foreach $i (@table_arr){ $content = $i; # print ("table name is: $i \n"); open( CONTENT, ">$content" ) || die "Can't open file $content"; my $sth = $dbh->prepare("select * from ?"); $sth->bind_param(1, $i); my $row; $sth->execute or die "Can't execute SQL statement: ", $sth->errstr(), "\n"; $row = $sth->dump_results(80, "\n", ':',\*CONTENT); } Any ideas where I could be going wrong? Cheers Shane -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Get IP address from ifconfig
Hi Chris, Thanks for the tip. My script works like a charm now! Cheers, Richard On Fri, 1 Feb 2002, Chris Weyn wrote: > Richard, > > the bash shell script I used to do that was the following: > > /sbin/ifconfig eth0 |grep inet |cut -d ' ' -f12 | cut -d ':' -f2 > > This may not be generic, and you may have to fine-tune it to work for you, but > it should give you the basic premise... > > Chris Weyn, Austin TX > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: PERL and XML Parser
I not sure how more experienced Perl developers feel but in addition to XML::Parser, I found XML::SimpleObject a great way to start parsing XML. Here's a link: http://www.xml.com/pub/a/2001/04/18/perlxmlqstart1.html Additionally, you can model the data anyway you want, but here's a little twist on what you have that may be worth pondering: Alice in Chains Percy Rock The Pixies Percy Rock Percy and the Test Tube Babies Percy Rock Bob Marley Percy Reggae Peter Tosh Percy Reggae Percy Gone Jazz Percy Reggae Yes Percy (owner) is repeated and so is the category, but it makes it a little easier to add another album to your file: Napalm Death Joel Ballads Hope this helps. Joel > -Original Message- > From: P0R0NG [mailto:[EMAIL PROTECTED]] > Sent: Friday, February 01, 2002 8:29 AM > To: [EMAIL PROTECTED] > Cc: Hanson, Robert > Subject: Re: PERL and XML Parser > > > oh yes thanks for that! thanks. i overlooked that. my big... > > anyways, here's the correct xml version: > > > > Percy > > Alice in Chains > The Pixies > Percy and the Test Tube Babies > > > Bob Marley > Peter Tosh > Percy Gone Jazz > > > > in using xml parser, how can i get the content of element 'owner'? i > created the code but every content between the xml elements we parsed. > here's my code: > > #! /usr/local/bin/perl > > use XML::Parser; > my $parser = new XML::Parser (); > > $parser->setHandlers (Start => \&Start_handler, > End => \&End_handler, > Default => \&Default_handler > ); > > my $filename = shift; > die "Can't find '$filename': $!\n" unless -f $filename; > > $parser->parsefile ($filename); > > sub Start_handler { > my $p = shift; > my $el = shift; > > if ($el =~ m/owner/g) {print "<$el>"}; > } > > sub End_handler { > my ($p,$el) = @_; > if ($el =~ m/owner/g) { print "\n"; }; > } > > sub Default_handler { > my ($p,$str) = @_; > # my $p = shift; > # my $str = shift; > if (($str =~m/Percy/g) or ($str =~m/Percy/g)){ print "\n$str\n"; } > } > > On Fri, 1 Feb 2002 10:27:37 -0500 > "Hanson, Robert" <[EMAIL PROTECTED]> wrote: > > |By the way, there were a lot of XML errors in that example. > | > | > | > |You need an attribute name, this is not legal. > | > |Alice in Chains > | > |The closing tag does not match the opening tag. > | > | > | > |You need an attribute name, this is not legal. > | > |Rob > | > | > |-Original Message- > |From: P0R0NG [mailto:[EMAIL PROTECTED]] > |Sent: Friday, February 01, 2002 8:05 AM > |To: [EMAIL PROTECTED] > |Subject: PERL and XML Parser > | > | > |Hi list. > | > |I'm currently doing a perl project involving XML parser. > | > |given this xml snippet: > | > | > | Percy > | > |Alice in Chains > |The Pixies > | > | > |Bob Marley > |Peter Tosh > | > | > > _ > 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] > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Hash Question
Since this is a beginners list, I thought I would be allowed to ask this question. Can there be multiple values for hash keys, or just one? The reason I am asking is that I am working on a statistical program and would need to use multiple hashes as values of another hash. If this is possible, please let me know. Thank you. -Jess -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Perl DBI - using parameters
On Fri, Feb 01, 2002 at 12:13:41PM -0500, McElwee, Shane wrote: > foreach $i (@table_arr){ > $content = $i; > # print ("table name is: $i \n"); > open( CONTENT, ">$content" ) || die "Can't open file $content"; > my $sth = $dbh->prepare("select * from ?"); > $sth->bind_param(1, $i); > > my $row; > > $sth->execute or die "Can't execute SQL statement: ", $sth->errstr(), > "\n"; > $row = $sth->dump_results(80, "\n", ':',\*CONTENT); > } Placeholders are for data, not SQL syntax. A placeholder doesn't just insert the text as is, it quotes it. In your case, the quoting is preventing the database from being able to parse it. Instead of using a placeholder just use Perl to interpolate: my $sth = $dbh->prepare("select * from $i"); Also, if $i is input from a user make sure to check it; I'd suggest not allowing anything except [A-Za-z0-9_]. 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: Hash Question
Just one unless you use references. Here is an example with references... %hash = ( one => 1, two => 2 ); $hash{oneagain} = \$hash{one}; foreach my $key ( keys %hash ) { my $value = (ref $hash{$key}) ? ${$hash{$key}} : $hash{$key}; print "$key => $value\n"; } And when you change the value of either key (directly or by reference) both values will be changed because they point to the same piece of data. And if you delete one of the keys the other will still remain. You can change it by setting up a sub like this (or directly but that would be messy)... setVal(\%hash, 'one', 'ONE'); setVal(\%hash, 'oneagain', 'ONE'); sub setVal { my $hash = shift; my $key = shift; my $value = shift; if (ref $hash->{$key}) { ${$hash->{$key}} = $value; } else { $hash->{$key} = $value; } } Rob -Original Message- From: Balint, Jess [mailto:[EMAIL PROTECTED]] Sent: Friday, February 01, 2002 12:43 PM To: '[EMAIL PROTECTED]' Subject: Hash Question Since this is a beginners list, I thought I would be allowed to ask this question. Can there be multiple values for hash keys, or just one? The reason I am asking is that I am working on a statistical program and would need to use multiple hashes as values of another hash. If this is possible, please let me know. Thank you. -Jess -- 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: Hash Question
Hashes cannot store multiple values (to the best of my knowledge), although they can store arrays or additional hashes which can of course, contain more values. "Balint, Jess" wrote > > Since this is a beginners list, I thought I would be allowed to ask this > question. Can there be multiple values for hash keys, or just one? The > reason I am asking is that I am working on a statistical program and would > need to use multiple hashes as values of another hash. If this is possible, > please let me know. Thank you. > > -Jess > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] -- Terry Dignon <[EMAIL PROTECTED]> "I stand by all the misstatements I have ever said" -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Hash Question
Keys are unique in a hash; what you put in them is up to you. the new value will overwrite the old value, unless you append it during assignment, using the . operator. Yes, you can store a hash in a hash in a hash... :) try perldoc perldsc for stuff on data structures. deen On Fri, 1 Feb 2002, Balint, Jess wrote: > Since this is a beginners list, I thought I would be allowed to ask this > question. Can there be multiple values for hash keys, or just one? The > reason I am asking is that I am working on a statistical program and would > need to use multiple hashes as values of another hash. If this is possible, > please let me know. Thank you. > > -Jess > > -- Deen Hameed - [EMAIL PROTECTED] One OS to rule them all, One OS to find them, One OS to bring them all, and in the darkness bind them. -- Bilga -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Hash Question
The example I gave could also be expanded to include a subroutine to simplify getting a hash value... %hash = ( one => 1, two => 2 ); $hash{oneagain} = \$hash{one}; foreach my $key ( keys %hash ) { # Either will work, but I prefer the second print "$key => ".getVal(\%hash, $key)."\n"; print "$key => @{[getVal(\%hash, $key)]}\n"; } sub getVal { my $hash = shift; my $key = shift; if (ref $hash->{$key}) { return ${$hash->{$key}}; } else { return $hash->{$key}; } } Rob -Original Message- From: Hanson, Robert Sent: Friday, February 01, 2002 1:04 PM To: 'Balint, Jess'; '[EMAIL PROTECTED]' Subject: RE: Hash Question Just one unless you use references. Here is an example with references... %hash = ( one => 1, two => 2 ); $hash{oneagain} = \$hash{one}; foreach my $key ( keys %hash ) { my $value = (ref $hash{$key}) ? ${$hash{$key}} : $hash{$key}; print "$key => $value\n"; } .And when you change the value of either key (directly or by reference) both values will be changed because they point to the same piece of data. And if you delete one of the keys the other will still remain. You can change it by setting up a sub like this (or directly but that would be messy)... setVal(\%hash, 'one', 'ONE'); setVal(\%hash, 'oneagain', 'ONE'); sub setVal { my $hash = shift; my $key = shift; my $value = shift; if (ref $hash->{$key}) { ${$hash->{$key}} = $value; } else { $hash->{$key} = $value; } } Rob -Original Message- From: Balint, Jess [mailto:[EMAIL PROTECTED]] Sent: Friday, February 01, 2002 12:43 PM To: '[EMAIL PROTECTED]' Subject: Hash Question Since this is a beginners list, I thought I would be allowed to ask this question. Can there be multiple values for hash keys, or just one? The reason I am asking is that I am working on a statistical program and would need to use multiple hashes as values of another hash. If this is possible, please let me know. Thank you. -Jess -- 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] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
soft reference
Hi, I need help about soft referencing or extract value of array var. Can some one get a look to code bellow : Have a good week-end. asma. foreach(@articles) { ##($code,$article,$codeFamil,$uniteVent,$idDepot,$quantite) my @row1; push(@row1, $q -> td({align => 'center'},$article), $q -> td({align => 'center'},$code), $q -> td({align => 'center'},$quantite), $q -> td ( {align => 'center'}, $q->popup_menu({ name=>'intitF', values=>[@listeFamilles], default=>@listeFamille[0], linebreak=>'true', }) ), $q -> td ( {align => 'center'}, $q->popup_menu({ name=>'Uvente', values=>[1,2,3,4,5,6,7,8,9,10,11,12,"autre"], default=>"autre", linebreak=>'true', }) ), $q -> td ( {align => 'center'}, $q -> submit ({ name => 'entreeArt', value => "GO", class => 'submit', onFocus => "javascript:document.$form_name.action = document.url ;'", onMouseOver => "this.style.color = '$red'", onMouseOut => "this.style.color = '$text_color'" }) ) ); >the pb reside on that I have tree times the same array ele of ListeRang --du to the hard ref I done on @row1 push(@ListeRang,@row1); $idRang ++; }
Formats
Why does the following not work for me? format NAME = TEST @<<< $test .. $test = "asdfjkl;"; select(NAME); write(); __END__ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
FW: Formats
-Original Message- From: Anthony Bhagwandin Sent: Friday, February 01, 2002 1:11 PM To: [EMAIL PROTECTED] Subject: Formats Why does the following not work for me? format NAME = TEST @<<< $test $test = "asdfjkl;"; select(NAME); write(); __END__ -- 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: Formats
On Feb 1, [EMAIL PROTECTED] said: >Why does the following not work for me? > >format NAME = >TEST > >@<<< >$test >.. > >$test = "asdfjkl;"; > >select(NAME); >write(); That tries writing to the filehandle NAME, too. Instead of select(NAME), do: $~ = "NAME"; That will set STDOUT's default format name to "NAME". -- Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/ ** Look for "Regular Expressions in Perl" published by Manning, in 2002 ** what does y/// stand for? why, yansliterate of course. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Tr: soft reference
-Message d'origine- De : mb <[EMAIL PROTECTED]> À : [EMAIL PROTECTED] <[EMAIL PROTECTED]> Date : vendredi 1 février 2002 19:13 Objet : soft reference Hi, I need help about soft referencing or extract value of array var. Can some one get a look to code bellow : Have a good week-end. asma. foreach(@articles) { ##($code,$article,$codeFamil,$uniteVent,$idDepot,$quantite) my @row1; push(@row1, $q -> td({align => 'center'},$article), $q -> td({align => 'center'},$code), $q -> td({align => 'center'},$quantite), $q -> td ( {align => 'center'}, $q->popup_menu({ name=>'intitF', values=>[@listeFamilles], default=>@listeFamille[0], linebreak=>'true', }) ), $q -> td ( {align => 'center'}, $q->popup_menu({ name=>'Uvente', values=>[1,2,3,4,5,6,7,8,9,10,11,12,"autre"], default=>"autre", linebreak=>'true', }) ), $q -> td ( {align => 'center'}, $q -> submit ({ name => 'entreeArt', value => "GO", class => 'submit', onFocus => "javascript:document.$form_name.action = document.url ;'", onMouseOver => "this.style.color = '$red'", onMouseOut => "this.style.color = '$text_color'" }) ) ); >the pb reside on that I have tree times the same array ele of ListeRang --du to the hard ref I done on @row1 push(@ListeRang,@row1); $idRang ++; } -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Formats
thanks a lot! -Original Message- From: Jeff 'japhy' Pinyan [mailto:[EMAIL PROTECTED]] Sent: Friday, February 01, 2002 1:19 PM To: [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Subject: Re: Formats On Feb 1, [EMAIL PROTECTED] said: >Why does the following not work for me? > >format NAME = >TEST > >@<<< >$test >.. > >$test = "asdfjkl;"; > >select(NAME); >write(); That tries writing to the filehandle NAME, too. Instead of select(NAME), do: $~ = "NAME"; That will set STDOUT's default format name to "NAME". -- Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/ ** Look for "Regular Expressions in Perl" published by Manning, in 2002 ** what does y/// stand for? why, yansliterate of course. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Hash Question
On Fri, 2002-02-01 at 12:42, Balint, Jess wrote: > Since this is a beginners list, I thought I would be allowed to ask this > question. Can there be multiple values for hash keys, or just one? The > reason I am asking is that I am working on a statistical program and would > need to use multiple hashes as values of another hash. If this is possible, > please let me know. Thank you. > > -Jess > I assume you mean a multi-dimensional hash. Perl allows infinite (assuming you have the resources) nesting of data structures. This is accomplished by using a reference to the structure to be nested. So for a three dimension hash you would first have a hash whose values were hash references. Then those hashes would have values that were also references to hashes. You could then access the data like this: print $hash{'key1'}->{'key2'}->{'key3'}, "\n"; but Perl being what it is provides a little syntatic suger and lets you just write this: print $hash{'key1'}{'key2'}{'key3'}, "\n"; #!/usr/bin/perl -w use strict; my %hash; while (<>) { my ($key1, $key2, $key3, $data) = split; $hash{$key1}{$key2}{$key3} = $data if $key1 and $key2 and $key3; } foreach my $key1 (sort keys %hash) { foreach my $key2 (sort keys %{$hash{$key1}}) { foreach my $key3 (sort keys %{$hash{$key1}{$key2}}) { print "($key1)+($key2)+($key3) returns ", $hash{$key1}{$key2}{$key3}, "\n"; } } } -- Today is Boomtime the 32nd day of Chaos in the YOLD 3168 Or is it? Missle Address: 33:48:3.521N 84:23:34.786W -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Hash Question
Better yet you could use 'tie' and create your own hash implementation like the code below. You will be able to set and retreive values normally except for the fact that if you want a single value to be linked to two keys you will need to store the value in one key and reference that key in another key (i.e. $hash{foo} = 1; $hash{bar} = \$hash{foo}). Rob package MyHash; require Tie::Hash; @ISA = (Tie::StdHash); sub FETCH { my $hash = shift; my $key = shift; if (ref $hash->{$key}) { return ${$hash->{$key}}; } else { return $hash->{$key}; } } sub STORE { my $hash = shift; my $key = shift; my $value = shift; if (ref $hash->{$key}) { ${$hash->{$key}} = $value; } else { $hash->{$key} = $value; } } package main; tie %hash, 'MyHash'; %hash = ( one => 1, two => 2 ); $hash{oneagain} = \$hash{one}; $hash{three} = 3; $hash{oneagain} = 'ONE'; foreach my $key ( keys %hash ) { print "$key => $hash{$key}\n"; } -Original Message- From: Balint, Jess [mailto:[EMAIL PROTECTED]] Sent: Friday, February 01, 2002 12:43 PM To: '[EMAIL PROTECTED]' Subject: Hash Question Since this is a beginners list, I thought I would be allowed to ask this question. Can there be multiple values for hash keys, or just one? The reason I am asking is that I am working on a statistical program and would need to use multiple hashes as values of another hash. If this is possible, please let me know. Thank you. -Jess -- 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] -- 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]
directory file rename
I have a directory full of mp3s with various names, but I want to convert each mp3 to the file name 1.mp3 and continuing up to the last file in the directory - I would also like it to generate a text file that is setup like ->
Re: directory file rename
Hmmm ... seems pretty simple ... here's my baby-talk approach: # note: I would tar up your directory b4 running this program, just # in case it doesn't work (not in the mood to test this w/ my mp3's ;)) # backup backup backup! :) use File::Copy; # first, read in the dir/files opendir (DIR, "/path/to/mp3s"); my @files = readdir(DIR); closedir (DIR); # now go through each file, rename/move to new file # and append change to logfile # opening log file open (LOG, ">>/path/to/logfile"); # set the first number my $filenum = 1; foreach (@files) { my $newfile = "/path/to/newmp3s/" . $filenum++ . ".mp3"; # you may need to preface $_ with the full path, such as # move( "/path/to/mp3s/$_", $newfile ); # you may also want to use copy() instead of move() to test # before actually making the move move( $_, $newfile ); print LOG "$_ -> $newfile\n"; } close (LOG); __END__ Jason If memory serves me right, on Friday 01 February 2002 16:38, Eric Plowe wrote: > I have a directory full of mp3s with various names, but I want to > convert each mp3 to the file name 1.mp3 and continuing up to the last file > in the directory - I would also like it to generate a text file that is > setup like > > -> > any ideas or suggestions? thanks > > ~Ericv -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Perl DBI - using parameters
I misunderstood the example from the book. Thanks for clearing that up. @table_arr is reading from a file now but I can use your suggestion if I have to make the process more interactive. Thanks Shane -Original Message- From: Michael Fowler [mailto:[EMAIL PROTECTED]] Sent: Friday, February 01, 2002 12:53 PM To: McElwee, Shane Cc: '[EMAIL PROTECTED]' Subject: Re: Perl DBI - using parameters On Fri, Feb 01, 2002 at 12:13:41PM -0500, McElwee, Shane wrote: > foreach $i (@table_arr){ > $content = $i; > # print ("table name is: $i \n"); > open( CONTENT, ">$content" ) || die "Can't open file $content"; > my $sth = $dbh->prepare("select * from ?"); > $sth->bind_param(1, $i); > > my $row; > > $sth->execute or die "Can't execute SQL statement: ", $sth->errstr(), > "\n"; > $row = $sth->dump_results(80, "\n", ':',\*CONTENT); > } Placeholders are for data, not SQL syntax. A placeholder doesn't just insert the text as is, it quotes it. In your case, the quoting is preventing the database from being able to parse it. Instead of using a placeholder just use Perl to interpolate: my $sth = $dbh->prepare("select * from $i"); Also, if $i is input from a user make sure to check it; I'd suggest not allowing anything except [A-Za-z0-9_]. Michael -- Administrator www.shoebox.net Programmer, System Administrator www.gallanttech.com -- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Formats, cont'd
I have two arrays, @array_a and @array_b, that contain info I want formatted. I would like to have the output look something like: dataset A dataset B -- a1 b1 a2 b2 a3 b3 a(n)b(n) where a1 is the first element of @array_a, b1 is the first element of @array_b. Every time I try something, I get a runaway format, so nothing gets printed to screen. Any ideas -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Include file
You could use the module that I am trying to use but having problems: "AppConfig" or you could use this (it works but is to limited for what I need): #/usr/bin/perl my $file = "/dir/somefile.txt"; open (CONFIG, "< $file") or die "Can't open $file"; while () { chomp; #no newline s/#.*//;#no comments s/^\s+//; #no leading white s/\s+$//; #no trailing white next unless length; #anything left? my ($var, $value) = split(/\s*=\s*/, $_, 2); $config{$var} = $value; } close(CONFIG); #then print everything or a specific $var exit; That should do the trick for you, if you have any luck see my positing on AppConfig. AppConfig is used to do the same thing plus it has a lot more features in it, I just can't get the damn thing to work. If this works for you and you have a spare minute I would appreciate any help that I could get on the AppConfig (two brains are better than one). If you don't have time, don't worry about it. jeffl On Fri, 2002-02-01 at 09:13, gross, cedric wrote: > I have a set of program to do which is using always same var. > > So I would like to defined a small file where I defined my var (like > $database="toto" $host="localhost" etc..) and then include it in my > other program, but > How to do that ? > > I try "use" but it's seems that is for complete module. > "require" seems to be for version behavior > and include seems not be supported... > > I browse doc but I found nothing.. > > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Tr: soft reference
-Message d'origine- De : mb <[EMAIL PROTECTED]> À : [EMAIL PROTECTED] <[EMAIL PROTECTED]> Date : vendredi 1 février 2002 19:01 Objet : soft reference Hi, I need help about soft referencing or extract value of array var. Can some one get a look to code bellow : Have a good week-end. asma. foreach(@articles) { ##($code,$article,$codeFamil,$uniteVent,$idDepot,$quantite) my @row1; push(@row1, $q -> td({align => 'center'},$article), $q -> td({align => 'center'},$code), $q -> td({align => 'center'},$quantite), $q -> td .. ( onMouseOut => "this.style.color = '$text_color'" }) ) ); >the pb reside on that I have tree times the same array ele of ListeRang --du to the hard ref I done on @row1 push(@ListeRang,@row1); $idRang ++; }
Tr: soft reference
-Message d'origine- De : mb <[EMAIL PROTECTED]> À : [EMAIL PROTECTED] <[EMAIL PROTECTED]> Date : vendredi 1 février 2002 19:01 Objet : soft reference Hi, I need help about soft referencing or extract value of array var. Can some one get a look to code bellow : Have a good week-end. asma. foreach(@articles) { ##($code,$article,$codeFamil,$uniteVent,$idDepot,$quantite) my @row1; push(@row1, $q -> td({align => 'center'},$article), $q -> td({align => 'center'},$code), ... ( onMouseOut => "this.style.color = '$text_color'" }) ) ); >the pb reside on that I have tree times the same array ele of ListeRang --du to the hard ref I done on @row1 push(@ListeRang,@row1); $idRang ++; }
Tr: soft reference sorry I think that there is a pb of transmit
Hi, I need help about soft referencing or extract value of array var. Can some one get a look to code bellow : Have a good week-end. asma. foreach(@articles) { ##($code,$article,$codeFamil,$uniteVent,$idDepot,$quantite) my @row1; push(@row1, $q -> td({align => 'center'},$article), ... ( onMouseOut => "this.style.color = '$text_color'" }) ) ); >the pb reside on that I have tree times the same array ele of ListeRang --du to the hard ref I done on @row1 push(@ListeRang,@row1); }
RE: change all files in directory
On Fri, 1 Feb 2002, Booher Timothy B 1stLt AFRL/MNAC wrote: > When I try to run the one-liners I get: > > Can't open *.cpp: Invalid argument. > Can't open *.hpp: Invalid argument. > > But when I do a dir command I get: > target_functions.cpptarget_modules.cpp global_constants.hpp > global_header.hpp class_functions.cpp S2b_4.opt > > Clearly these files are there . . . or am I just doing something silly . . . Oh, you didn't say you were using Winders. It doesn't like the single quotes, so you will need to use double quotes, or do it as a script after all. Or install CygWin, which has it's own build of Perl (and gcc, and bash, and lots of other goodies that are sorely missed in the glorified DOS shell). -- Brett http://www.chapelperilous.net/ Lady Nancy Astor: "Winston, if you were my husband, I'd put poison in your coffee." Winston Churchill: "Nancy, if you were my wife, I'd drink it." -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: pulling file name into perl
I don't think this is the right way to approach this. I suggest you look at opendir, readdir in perlfunc. opendir DIR, '/' or die "$0: no top level directory $!"; my @dirlist = readdir DIR; - Roger - - Original Message - From: "Russell Boyd" <[EMAIL PROTECTED]> To: ">" < <[EMAIL PROTECTED]> Sent: Thursday, January 31, 2002 8:16 PM Subject: pulling file name into perl I am wanting to get a unix directory file listing and put it into a Perl array. I attempted $date = system "ls -al | grep filename.txt"; However all this did was send it to . What am I missing? Thanks, Russell -- 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: Formats, cont'd
Maybe one of the guru's can help us, but here is one way: #!perl -w use strict; my @a1 = ();# leaving out $a1[1] so undefined and can use the check of undefined in loop $a1[0] = 1; $a1[2] = 3; $a1[3] = 4; $a1[4] = 5; $a1[5] = 6; my @b1 = (2,3,4,5,6,7); my $Mya1; my $Myb1; my $MyId; format HEADER = Id Test1Test2 --- .. format NAME = @>> @<<< @<<< $MyId, $Mya1 , $Myb1 .. $~ = "HEADER"; write(); $~ = "NAME"; #select(STDOUT); my $MyMax = scalar(@a1); $MyMax = scalar(@b1) if ( scalar(@b1) > $MyMax); for($MyId=0;$MyId<$MyMax;$MyId++) { $Mya1 = 'n'; $Myb1 = 'n'; $Mya1 = $a1[$MyId] if ( defined $a1[$MyId] and $a1[$MyId] gt '' ); $Myb1 = $b1[$MyId] if ( defined $b1[$MyId] and $b1[$MyId] gt '' ); write; } __END__ Output: Id Test1Test2 --- 0 12 1 n3 2 34 3 45 4 56 5 67 Wags ;) -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Friday, February 01, 2002 10:46 To: [EMAIL PROTECTED] Subject: Formats, cont'd I have two arrays, @array_a and @array_b, that contain info I want formatted. I would like to have the output look something like: dataset A dataset B -- a1 b1 a2 b2 a3 b3 . a(n)b(n) where a1 is the first element of @array_a, b1 is the first element of @array_b. Every time I try something, I get a runaway format, so nothing gets printed to screen. Any ideas -- 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: Please point me to a language (perl I hope)
Please stop making life difficult for yourself. If you need just a small part of a large image to animate, chop up the large image so the animated part can be isolated, place all the parts in a table to unite them and animate the needed part. As for the person walking, either use the above technique or if the file sizes become unwieldy, use DHTML. Perl can do server side animation for you, but it's a bigger headache than what I've described. As a caveat, please be aware that most people find gratuitous animation annoying. If you can get away with not animating something, don't. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Thursday, January 31, 2002 8:25 PM To: [EMAIL PROTECTED] Subject: Please point me to a language (perl I hope) Sorry if this is off topic, but I really don't know who else to ask. Heres what I want to do.. maybe you would be so kind as to tell me what language this can best be done in. I'm just learning perl and know HTML. within frames (or a table)... I would like to put a large gif in the backround and then place a smaller gif over it. The smaller gif is where the movement or animation would happen, Like a mouth moving over a picture of a person. Could this be done with 2 or 3 small moving gifs at the same time? Like a candle flame and a mouth of a person? If I had a picture of a forest, I'd like to have a person walk from left to right. would this mean individual gifs or one multi-gif animation in a frame that moves over the backround? I have looked into Java, Javascript, CSS and DHTML and all look promising, but I have yet to find an example in a book that answers my question. Help? Please? L Hernsen -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
help with script
> can you review this script and see if you can spot any errors? > no errors appear in the log, but the lines in red do not process correctly > > see example 57 for the code that I got most of these problem spots from > > Chris > -Original Message- > From: Chris klein [mailto:[EMAIL PROTECTED]] > Sent: Friday, February 01, 2002 10:07 AM > To: Klein, Christopher > Subject: > > > #! /usr/bin/perl > > print "Content-type: text/html\n\n"; > print "Decoding the query string"; > > $minobs=0; > $file="/usr/local/www/cgi-bin/wva/testing"; > open(SUBMISSION, ">$file") || die "Can't open newfile: $! \n"; > $webpage="/usr/local/www/data/upload/page2a.html"; > open(PAGE2, ">$webpage") || die "Can't open newfile: $! \n"; > #open(NAMES, "/usr/local/www/data/upload/wvahosps.txt") || die "can't open > data file"; > #while () { > # ( $num, $name )= split(' ', $_, 2); > # $realid($num) = $name; > #} > #close NAMES; > open(INPIPE, "date |"); > $today = ; > close(INPIPE); > > #Getting the input > if ( $ENV{REQUEST_METHOD} eq 'GET' ){ > $inputstring=$ENV{QUERY_STRING}; > } > else { > read(STDIN, $inputstring, $ENV{'CONTENT_LENGTH'}); > } > > #print "Before decoding:"; > #print "$inputstring"; > > # Replace + signs with spaces > $inputstring =~ tr/+/ /; > > #Decoding the hexadecimal characters > $inputstring =~ s/%(..)/pack("C", hex($1))/ge; > > # After decoding %xy > #print "-" x 80, ""; > #print "After decoding %xy:"; > #print "$inputstring"; > > # Extracting the & and = to create key/value pairs > @key_value=split(/&/, $inputstring); > foreach $pair ( @key_value){ > ($key, $value) = split(/=/, $pair); > $input{$key} = $value; # Creating a hash to save the data > } > > > if ($inputstring{numobs} < $minobs ) { > print 'https://wva.s-3.net/upload/error1.html";>there was an > error, click here for details '; > } > > #elsif ($inputstring{provid} ne $num) {print ' CONTENT="7; url=https://wva.s-3.net/upload/error1.html";>';} > else { > > # After decoding > #print "-" x 80, ""; > #print "After decoding + and &:"; > while(($key, $value) = each(%input) ){ > # Printing the contents of the hash > print SUBMISSION "$key: $value \n"; > } > while(){ > chomp($num=$provid); > last unless $num; > print SUBMISSION $realid{$num}, "\n"; > } > print SUBMISSION $today ; > > #creating dynamic web page > print PAGE2 "\n\nresults\n"; > print PAGE2 ''; > print PAGE2 "\n\n"; > print PAGE2 '', "\n"; > > while(($key, $value) = each(%input) ){ > # Printing the contents of the hash > print PAGE2 "$key: $value \n "; > } > while(){ > chomp($num=$provid); > last unless $num; > print PAGE2 $realid{$num}, "\n"; > } > print PAGE2 $today ; > > print PAGE2 "\n\n\n\n" ; > print PAGE2 ' action="https://wva.s-3.net/cgi-bin/fupload.cgi"; method="post">'; > print PAGE2 "\n"; > print PAGE2 'is this information correct?'; > print PAGE2 "\n"; > print PAGE2 ' '; > print PAGE2 "\n"; > print PAGE2 ''; > print PAGE2 "\n"; > print PAGE2 ''; > #print "Now what do we want to do with this information?"; > #print 'https://wva.s-3.net/upload/page2.html";>'; > > print 'https://wva.s-3.net/upload/page2a.html";>done, click here > to continue '; > } -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Wade through a file and grab titles
I have a bunch of files in the form below and I want to go through the list and extract only the file name. The only way I can consistently see this is to take the next line after the ")." ahmad73 __ exist: 0 K. Ahmad and I. J. Smalley, Powder Technol. 8, 69 (1973). Observation of particle segregation in vibrated granular systems . keywords: segregation vibration ahn91 __ exist: 0 H. Ahn, C. E. Brennen, and R. H. Sabersky, J. Appl. Mech. 58, 792 (1991). Observation of particle segregation in vibrated granular systems . ahn92 __ exist: 0 H. Ahn, C. E. Brennen, and R. H. Sabersky, J. Appl. Mech. 59, 109 (1992). Analysis of the fully developed chute flow of granular materials . I tried the following: # NOT WORKING open(LL,$ARGV[0]) || die "can't open $ARGV for reading: $!"; # input file open(LOGFILE,">$ARGV[1]") || die "can't open output file $ARGV[1]"; #output file while(my $line = ) { next if $line =~ /^\s*$/; if ($line =~ /\)\.\s*$/) { # attempt to match on .) at end of line $myTitle = <>; print LOGFILE $myTitle; } } This is returning all files as if the regex were continually true . . . any body with a sharp eye
Dates
this statement ($sec,$min,$hour,$mon,$year,$wday,$yday,$isdst) = localtime(); i obtain the date of today, but i need the $day,$mon,$year of yesterday How? Thank you Argenis Perez -- Nunca creas feliz a nadie que esté pendiente de la felicidad. Se apoya en una base frágil quien pone su alegría en lo adventicio. El goce que viene de afuera, afuera se irá. Por el contrario, aquel que nace de uno mismo es fiel y firme, y crece, y nos acompaña hasta el fin. - Lucio Anneo Séneca - Saludos Argenis Perez __ Your favorite stores, helpful shopping tools and great gift ideas. Experience the convenience of buying online with Shop@Netscape! http://shopnow.netscape.com/ Get your own FREE, personal Netscape Mail account today at http://webmail.netscape.com/ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Hash Question
"Balint, Jess" wrote: > > Since this is a beginners list, I thought I would be allowed to ask this > question. Can there be multiple values for hash keys, or just one? The > reason I am asking is that I am working on a statistical program and would > need to use multiple hashes as values of another hash. If this is possible, > please let me know. Thank you. > > -Jess > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] If, by chance, you're not confused enough yet, you could take a look at a "tutorial", (and I use that term loosely), that I wrote ONLY to help myself understand nested hashes. (Although I think what you want is really called a hash of lists, examples of which should be in any good Perl book). Bompa PS: Keep in mind said "tutorial" is not authoritative as I was leaning more towards illustrating the concept rather than coding accuracy. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Please point me to a language (perl I hope)
The rule of thumb for animated images: Flashing, blinking, rotating, jumpy-bumpy effects are distracting. If you must use animated images, keep it small, tasteful, and to a bare minimum. Studies have found that users have actually gone so far as to 'cover' annoying animations and blinking text with their hands when viewing a site containing these 'features'. -Original Message- From: Camilo Gonzalez [mailto:[EMAIL PROTECTED]] Sent: Friday, February 01, 2002 8:32 AM To: 'Luinrandir Hernsen'; [EMAIL PROTECTED] Subject: RE: Please point me to a language (perl I hope) Please stop making life difficult for yourself. If you need just a small part of a large image to animate, chop up the large image so the animated part can be isolated, place all the parts in a table to unite them and animate the needed part. As for the person walking, either use the above technique or if the file sizes become unwieldy, use DHTML. Perl can do server side animation for you, but it's a bigger headache than what I've described. As a caveat, please be aware that most people find gratuitous animation annoying. If you can get away with not animating something, don't. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Thursday, January 31, 2002 8:25 PM To: [EMAIL PROTECTED] Subject: Please point me to a language (perl I hope) Sorry if this is off topic, but I really don't know who else to ask. Heres what I want to do.. maybe you would be so kind as to tell me what language this can best be done in. I'm just learning perl and know HTML. within frames (or a table)... I would like to put a large gif in the backround and then place a smaller gif over it. The smaller gif is where the movement or animation would happen, Like a mouth moving over a picture of a person. Could this be done with 2 or 3 small moving gifs at the same time? Like a candle flame and a mouth of a person? If I had a picture of a forest, I'd like to have a person walk from left to right. would this mean individual gifs or one multi-gif animation in a frame that moves over the backround? I have looked into Java, Javascript, CSS and DHTML and all look promising, but I have yet to find an example in a book that answers my question. Help? Please? L Hernsen -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] The views and opinions expressed in this email message are the sender's own, and do not necessarily represent the views and opinions of Summit Systems Inc. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Please point me to a language (perl I hope)
On Fri, 1 Feb 2002, Nikola Janceski wrote: > The rule of thumb for animated images: > Flashing, blinking, rotating, jumpy-bumpy effects are distracting. If you > must use animated images, keep it small, tasteful, and to a bare minimum. > Studies have found that users have actually gone so far as to 'cover' > annoying animations and blinking text with their hands when viewing a site > containing these 'features'. Some newer browsers (Mozilla, Galeon) even have the options of only allowing an animation to run once, or not at all. -- Brett http://www.chapelperilous.net/ BOFH excuse #98: The vendor put the bug there. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Dates
use Date::Calc module; man Date::Calc (if it's installed). -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Friday, February 01, 2002 2:35 PM To: [EMAIL PROTECTED] Subject: Dates this statement ($sec,$min,$hour,$mon,$year,$wday,$yday,$isdst) = localtime(); i obtain the date of today, but i need the $day,$mon,$year of yesterday How? Thank you Argenis Perez -- Nunca creas feliz a nadie que esté pendiente de la felicidad. Se apoya en una base frágil quien pone su alegría en lo adventicio. El goce que viene de afuera, afuera se irá. Por el contrario, aquel que nace de uno mismo es fiel y firme, y crece, y nos acompaña hasta el fin. - Lucio Anneo Séneca - Saludos Argenis Perez __ Your favorite stores, helpful shopping tools and great gift ideas. Experience the convenience of buying online with Shop@Netscape! http://shopnow.netscape.com/ Get your own FREE, personal Netscape Mail account today at http://webmail.netscape.com/ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] The views and opinions expressed in this email message are the sender's own, and do not necessarily represent the views and opinions of Summit Systems Inc. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Hash Question
I think I will go ahead and use something like the multi-dimensional hash example below. What I need to do is create hashes dynamically based on how many are needed for this particular instance of the program. Any ideas on dynamic hash creation multi-dimensionally? Thanks -jess -Original Message- On Fri, 2002-02-01 at 12:42, Balint, Jess wrote: > Since this is a beginners list, I thought I would be allowed to ask this > question. Can there be multiple values for hash keys, or just one? The > reason I am asking is that I am working on a statistical program and would > need to use multiple hashes as values of another hash. If this is possible, > please let me know. Thank you. > > -Jess > I assume you mean a multi-dimensional hash. Perl allows infinite (assuming you have the resources) nesting of data structures. This is accomplished by using a reference to the structure to be nested. So for a three dimension hash you would first have a hash whose values were hash references. Then those hashes would have values that were also references to hashes. You could then access the data like this: print $hash{'key1'}->{'key2'}->{'key3'}, "\n"; but Perl being what it is provides a little syntatic suger and lets you just write this: print $hash{'key1'}{'key2'}{'key3'}, "\n"; #!/usr/bin/perl -w use strict; my %hash; while (<>) { my ($key1, $key2, $key3, $data) = split; $hash{$key1}{$key2}{$key3} = $data if $key1 and $key2 and $key3; } foreach my $key1 (sort keys %hash) { foreach my $key2 (sort keys %{$hash{$key1}}) { foreach my $key3 (sort keys %{$hash{$key1}{$key2}}) { print "($key1)+($key2)+($key3) returns ", $hash{$key1}{$key2}{$key3}, "\n"; } } } -- Today is Boomtime the 32nd day of Chaos in the YOLD 3168 Or is it? Missle Address: 33:48:3.521N 84:23:34.786W -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Checking an existing instance of a process
What is the most cautious way to see if I am already running an instance of a program and kill that said process? I'm setting up a shell that will be launched from a cronjob and want to make sure that if there was an instance of the same process running, that it was killed up front, before continuing on through the program. in Bourne shell, I would use the following code: exec > /dev/null 2>&1 Progname='basename $0' PIDfile=/var/tmp/$Progname.pid OLDPID=`cat $PIDfile 2>/dev/null` test -n $OLDPID && kill -9 $OLDPID Thanks in advance for any help, Dan Taylor. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Dates
Try this: ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time -86400); #86400 seconds in a day print join "-",(($mon + 1),$mday,($year + 1900)); BTW, that's an interesting quote. If you don't mind my asking, who is Lucio Anneo Séneca? -Original Message- From: Argenis Perez [mailto:[EMAIL PROTECTED]] Sent: Friday, February 01, 2002 11:35 AM To: [EMAIL PROTECTED] Subject: Dates this statement ($sec,$min,$hour,$mon,$year,$wday,$yday,$isdst) = localtime(); i obtain the date of today, but i need the $day,$mon,$year of yesterday How? Thank you Argenis Perez -- Nunca creas feliz a nadie que esté pendiente de la felicidad. Se apoya en una base frágil quien pone su alegría en lo adventicio. El goce que viene de afuera, afuera se irá. Por el contrario, aquel que nace de uno mismo es fiel y firme, y crece, y nos acompaña hasta el fin. - Lucio Anneo Séneca - Saludos Argenis Perez __ Your favorite stores, helpful shopping tools and great gift ideas. Experience the convenience of buying online with Shop@Netscape! http://shopnow.netscape.com/ Get your own FREE, personal Netscape Mail account today at http://webmail.netscape.com/ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] This email may contain confidential and privileged material for the sole use of the intended recipient. If you are not the intended recipient, please contact the sender and delete all copies. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Hash Question
Where might one find this 'tutorial'? -Original Message- From: Dave Benware [mailto:[EMAIL PROTECTED]] Sent: Friday, February 01, 2002 2:44 PM To: Beginners perl Subject: Re: Hash Question "Balint, Jess" wrote: > > Since this is a beginners list, I thought I would be allowed to ask this > question. Can there be multiple values for hash keys, or just one? The > reason I am asking is that I am working on a statistical program and would > need to use multiple hashes as values of another hash. If this is possible, > please let me know. Thank you. > > -Jess > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] If, by chance, you're not confused enough yet, you could take a look at a "tutorial", (and I use that term loosely), that I wrote ONLY to help myself understand nested hashes. (Although I think what you want is really called a hash of lists, examples of which should be in any good Perl book). Bompa PS: Keep in mind said "tutorial" is not authoritative as I was leaning more towards illustrating the concept rather than coding accuracy. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] _ IMPORTANT NOTICES: This message is intended only for the addressee. Please notify the sender by e-mail if you are not the intended recipient. If you are not the intended recipient, you may not copy, disclose, or distribute this message or its contents to any other person and any such actions may be unlawful. Banc of America Securities LLC("BAS") does not accept time sensitive, action-oriented messages or transaction orders, including orders to purchase or sell securities, via e-mail. BAS reserves the right to monitor and review the content of all messages sent to or from this e-mail address. Messages sent to or from this e-mail address may be stored on the BAS e-mail system. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Win32::GUI - Getting rid of console Window?
The only downside to this method is that an errant Perl Window can linger around long after you think it's been closed (i.e. it won't show anywhere expect under Task Manager). I prefer making a copy of perl.exe (in C:\Perl\bin) and call it something like perlw.exe. Then register perlw.exe as a Windows app, instead of a DOS app. My Windows perl scripts get an extention of .plw which gets associated with perlw.exe Russell J Foster Subject, Wills, & Company e. [EMAIL PROTECTED] v. 630-572-0240 > -Original Message- > From: Morbus Iff [mailto:[EMAIL PROTECTED]] > Sent: Friday, February 01, 2002 11:01 AM > To: Agustin Rivera; [EMAIL PROTECTED] > Subject: Re: Win32::GUI - Getting rid of console Window? > > > >Is there anyway to get a Win3::GUI app to not display the > DOS console when >running, so it runs just like any other GUI app? > > Yuppers. > > use Win32::GUI; > > # hwnd is a handle to a window - basically, window's > # way of keeping track of it's program windows... > $hwnd = GUI::GetPerlWindow(); > > # comment this to see error messages in a dos window > # otherwise, this will hide the blasted thing... > GUI::Hide($hwnd); > > > -- > Morbus Iff ( softcore vulcan pr0n rulez ) > http://www.disobey.com/ && > http://www.gamegrene.com/ please > me: > http://www.amazon.com/exec/obidos/wishlist/25USVJDH68554 > icq: 2927491 / aim: akaMorbus / yahoo: morbus_iff / jabber.org: morbus > > > -- > 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: Hash Question
how will you know how many keys are needed? On Fri, 2002-02-01 at 14:42, Balint, Jess wrote: > I think I will go ahead and use something like the multi-dimensional hash > example below. What I need to do is create hashes dynamically based on how > many are needed for this particular instance of the program. Any ideas on > dynamic hash creation multi-dimensionally? Thanks -jess > > -Original Message- > > On Fri, 2002-02-01 at 12:42, Balint, Jess wrote: > > Since this is a beginners list, I thought I would be allowed to ask this > > question. Can there be multiple values for hash keys, or just one? The > > reason I am asking is that I am working on a statistical program and would > > need to use multiple hashes as values of another hash. If this is > possible, > > please let me know. Thank you. > > > > -Jess > > > > I assume you mean a multi-dimensional hash. Perl allows infinite > (assuming you have the resources) nesting of data structures. This is > accomplished by using a reference to the structure to be nested. So for > a three dimension hash you would first have a hash whose values were > hash references. Then those hashes would have values that were also > references to hashes. You could then access the data like this: > > print $hash{'key1'}->{'key2'}->{'key3'}, "\n"; > > but Perl being what it is provides a little syntatic suger and lets you > just write this: > > print $hash{'key1'}{'key2'}{'key3'}, "\n"; > > > > #!/usr/bin/perl -w > > use strict; > > my %hash; > > while (<>) { > my ($key1, $key2, $key3, $data) = split; > > $hash{$key1}{$key2}{$key3} = $data if $key1 and $key2 and $key3; > } > > foreach my $key1 (sort keys %hash) { > foreach my $key2 (sort keys %{$hash{$key1}}) { > foreach my $key3 (sort keys %{$hash{$key1}{$key2}}) { > print "($key1)+($key2)+($key3) returns ", > $hash{$key1}{$key2}{$key3}, "\n"; > } > } > } > > > -- > Today is Boomtime the 32nd day of Chaos in the YOLD 3168 > Or is it? > > Missle Address: 33:48:3.521N 84:23:34.786W -- Today is Boomtime the 32nd day of Chaos in the YOLD 3168 Fnord. Missle Address: 33:48:3.521N 84:23:34.786W -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Win32::GUI - Getting rid of console Window?
>The only downside to this method is that an errant Perl Window can linger >around long after you think it's been closed (i.e. it won't show anywhere >expect under Task Manager). Russ, I had noticed that a while too. Somehow or another, with the Windows.pl file in the AmphetaDesk [1] source, I've stopped that. Not sure how, but check it out... [1] http://www.disobey.com/amphetadesk/ -- Morbus Iff ( softcore vulcan pr0n rulez ) http://www.disobey.com/ && http://www.gamegrene.com/ please me: http://www.amazon.com/exec/obidos/wishlist/25USVJDH68554 icq: 2927491 / aim: akaMorbus / yahoo: morbus_iff / jabber.org: morbus -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Hash Question
On Fri, 2002-02-01 at 15:23, Balint, Jess wrote: > A scalar value based on the number of command line arguments put into an > array. > > if( $ARGV[$_] =~ /^-f/ ) { > # PARSE TABULATION VALUES > if( $table ) { > $table = $ARGV[$_]; > $table =~ s/-f//; > $table = $ARGV[$_+1] if( length( $table ) == 0 ); > $tables[$tblcnt] = $table; > $tblcnt++; > } else { > $table = $ARGV[$_]; > $table =~ s/-f//; > $table = $ARGV[$_+1] if( length( $table ) == 0 ); > $tables[0] = $table; > $tblcnt++; > } > First off, you don't need $tblcnt. @tables in a scalar context will return the number of elements and you can simply push the value onto the array (see perldoc -f push). This also gets rid of the if $table business. Second off, I assume that you are trying to treat -f table and -ftable the same. In which case shouldn't you increment $_ if you grab the next arg? if ( $ARGV[$_] =~ /^-f(.*)/ ) { # PARSE TABULATION VALUES if (defined($1)) { #if there was something after -f push @tables, $1; } else { #otherwise use next arg $_++; push @tables, $ARGV[$_]; } } print "There were ", scalar(@tables), "tables on the cmdline.\n"; Thirdly, where are the keys for the hashes going to come from? And how are you going to know at which level in the hash you want to store the data? To clarify: In my example I read the keys from the first three words of a line where the first word was the first key, the second word was the second key, and the third word was the the third key and then treated the fourth word as the data. -- Today is Boomtime the 32nd day of Chaos in the YOLD 3168 Hail Eris! Missle Address: 33:48:3.521N 84:23:34.786W -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Problem with format command
Ok, Did I ask a dumb question? or is there just no answer? -Original Message- From: Michael Eggleton [mailto:[EMAIL PROTECTED]] Sent: Thursday, January 31, 2002 8:33 PM To: [EMAIL PROTECTED] Subject: Problem with format command Hello All, Here is the code for the format command: use Win32::Service; push( @ARGV, Win32::NodeName() ) unless( scalar @ARGV ); foreach my $Machine ( @ARGV ) { local %List; print "Available services on $Machine:\n"; if( Win32::Service::GetServices( $Machine, \%List ) ) { $~ = FormatHeader; write; $~ = FormatData; foreach $Service ( sort( keys( %List ) ) ) { write; } print "\n" x 3; } else { print Win32::FormatMessage( Win32::GetLastError() ), "\n"; } } format FormatHeader = @< @< "Service Name","Service Display Name" -- -- . format FormatData = @< @< $List{$Service}, $Service . And here is the error. Missing right curly or square bracket at example_8_1.pl line 38, at end of linesyntax error at example_8_1.pl line 38, at EOF Execution of example_8_1.pl aborted due to compilation errors. And if I replace < with | or > it works just fine. Michael D. Eggleton http://www.gorealnetworks.com mailto:[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: Hash Question
The way I have the argument parsing set up is for ( 0..$#ARGV ) { . . . When a -f n is presented on the command line, n will be the field number for the first hash. So if I use -f 1 -f 2 -f 3, there will be three levels of hashes. The top level will contain all unique values in the first field of the file. The second level will contain all unique values unique to the top level, and the third level will be unique to the first and second level. The value of the third level key will be a count of the occurance of all the values together in the same line. -Original Message- On Fri, 2002-02-01 at 15:23, Balint, Jess wrote: > A scalar value based on the number of command line arguments put into an > array. > > if( $ARGV[$_] =~ /^-f/ ) { > # PARSE TABULATION VALUES > if( $table ) { > $table = $ARGV[$_]; > $table =~ s/-f//; > $table = $ARGV[$_+1] if( length( $table ) == 0 ); > $tables[$tblcnt] = $table; > $tblcnt++; > } else { > $table = $ARGV[$_]; > $table =~ s/-f//; > $table = $ARGV[$_+1] if( length( $table ) == 0 ); > $tables[0] = $table; > $tblcnt++; > } > First off, you don't need $tblcnt. @tables in a scalar context will return the number of elements and you can simply push the value onto the array (see perldoc -f push). This also gets rid of the if $table business. Second off, I assume that you are trying to treat -f table and -ftable the same. In which case shouldn't you increment $_ if you grab the next arg? if ( $ARGV[$_] =~ /^-f(.*)/ ) { # PARSE TABULATION VALUES if (defined($1)) { #if there was something after -f push @tables, $1; } else { #otherwise use next arg $_++; push @tables, $ARGV[$_]; } } print "There were ", scalar(@tables), "tables on the cmdline.\n"; Thirdly, where are the keys for the hashes going to come from? And how are you going to know at which level in the hash you want to store the data? To clarify: In my example I read the keys from the first three words of a line where the first word was the first key, the second word was the second key, and the third word was the the third key and then treated the fourth word as the data. -- Today is Boomtime the 32nd day of Chaos in the YOLD 3168 Hail Eris! Missle Address: 33:48:3.521N 84:23:34.786W -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
generate variable names
Hi all, I 'm asking if there a dynamic way to generate variable names. $id; foreach(@_){ my($var1 > in the second time my($var2 -> my($varn Thanks a lot in advance, asma
Re: generate variable names
On Feb 1, mb said: >I 'm asking if there a dynamic way to generate variable names. Yes, and you don't want it. >foreach(@_){ >my($var1 > in the second time my($var2 -> my($varn Why not use an array? my $i = 0; my @data; foreach (@_) { # work with $data[$i] # and when you're done... $i++; } or some other array-oriented approach. -- Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/ ** Look for "Regular Expressions in Perl" published by Manning, in 2002 ** what does y/// stand for? why, yansliterate of course. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: generate variable names
If you need something like that, you would be better off using a hash to hold the information vs a number of unknown variable names. I believe that this will be confirmed by the list helpers. Wags ;) -Original Message- From: mb [mailto:[EMAIL PROTECTED]] Sent: Friday, February 01, 2002 13:37 To: [EMAIL PROTECTED] Subject: generate variable names Hi all, I 'm asking if there a dynamic way to generate variable names. $id; foreach(@_){ my($var1 > in the second time my($var2 -> my($varn Thanks a lot in advance, asma -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: still not catching error
> -Original Message- > From: Alex Harris [mailto:[EMAIL PROTECTED]] > Sent: Friday, February 01, 2002 11:52 AM > To: [EMAIL PROTECTED] > Subject: still not catching error > > > I took out the exec and placed system. But even though > work.pl doesn't > exist on the remote system, still getting no error. Help! > > if (system("rsh $plant /u1/bin/forkit '/u1/bin/work.pl'") > 0) > { > excep(" $!\n"); > } The exit status of rsh is 0 if it was able to connect to the remote system. It doesn't return the exit status of the command being run. Try this search for some suggestions on handling this issue: http://groups.google.com/groups?hl=en&q=rsh+exit+status HTH -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: generate variable names
On Fri, 1 Feb 2002, mb wrote: > I 'm asking if there a dynamic way to generate variable names. There are easier ways that what you are thinking of. > $id; > foreach(@_){ > my($var1 > in the second time my($var2 -> my($varn > > Thanks a lot in advance, I'd just create an array or a hash -- that's the simplest and safest way of doing what you want. -- Brett http://www.chapelperilous.net/ LILO, you've got me on my knees! -- David Black, [EMAIL PROTECTED], with apologies to Derek and the Dominos, and Werner Almsberger -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Wade through a file and grab titles
> -Original Message- > From: Booher Timothy B 1stLt AFRL/MNAC > [mailto:[EMAIL PROTECTED]] > Sent: Friday, February 01, 2002 2:35 PM > To: [EMAIL PROTECTED] > Subject: Wade through a file and grab titles > > > I have a bunch of files in the form below and I want to go > through the list > and extract only the file name. The only way I can > consistently see this is > to take the next line after the ")." > > ahmad73 __ exist: 0 > K. Ahmad and I. J. Smalley, Powder Technol. 8, 69 (1973). > Observation of particle segregation in vibrated granular systems . > keywords: segregation vibration > ahn91 __ exist: 0 > H. Ahn, C. E. Brennen, and R. H. Sabersky, J. Appl. Mech. 58, > 792 (1991). > Observation of particle segregation in vibrated granular systems . > ahn92 __ exist: 0 > H. Ahn, C. E. Brennen, and R. H. Sabersky, J. Appl. Mech. 59, > 109 (1992). > Analysis of the fully developed chute flow of granular materials . > > I tried the following: > > # NOT WORKING > open(LL,$ARGV[0]) || die "can't open $ARGV for reading: $!"; > # input file > open(LOGFILE,">$ARGV[1]") || die "can't open output file > $ARGV[1]"; #output > file > > while(my $line = ) { > next if $line =~ /^\s*$/; > if ($line =~ /\)\.\s*$/) { # attempt to match on .) at end of line > $myTitle = <>; ^^ This should be . If I make that change, the script runs fine for me. > print LOGFILE $myTitle; } > } > > This is returning all files as if the regex were continually > true . . . any > body with a sharp eye > > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: generate variable names
> -Original Message- > From: mb [mailto:[EMAIL PROTECTED]] > Sent: Friday, February 01, 2002 4:37 PM > To: [EMAIL PROTECTED] > Subject: generate variable names > > > Hi all, > I 'm asking if there a dynamic way to generate variable names. Man, this question comes up a lot! :) -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Wade through a file and grab titles
You can shorten this down using $_. while(my $line = ) { next if $line =~ /^\s*$/; if ($line =~ /\)\.\s*$/) { # attempt to match on .) at end of line $myTitle = <>; print LOGFILE $myTitle; } } can be written as: while() { if ($_ =~ /\)\.\s*$/) { # attempt to match on .) at end of line my $mytitle = ; print LOGFILE $mytitle; } } It doesn't seem like much in this example, but the $_ variable can be very useful and save you a lot of time. -Original Message- From: Booher Timothy B 1stLt AFRL/MNAC [mailto:[EMAIL PROTECTED]] Sent: Friday, February 01, 2002 11:35 AM To: [EMAIL PROTECTED] Subject: Wade through a file and grab titles I have a bunch of files in the form below and I want to go through the list and extract only the file name. The only way I can consistently see this is to take the next line after the ")." ahmad73 __ exist: 0 K. Ahmad and I. J. Smalley, Powder Technol. 8, 69 (1973). Observation of particle segregation in vibrated granular systems . keywords: segregation vibration ahn91 __ exist: 0 H. Ahn, C. E. Brennen, and R. H. Sabersky, J. Appl. Mech. 58, 792 (1991). Observation of particle segregation in vibrated granular systems . ahn92 __ exist: 0 H. Ahn, C. E. Brennen, and R. H. Sabersky, J. Appl. Mech. 59, 109 (1992). Analysis of the fully developed chute flow of granular materials . I tried the following: # NOT WORKING open(LL,$ARGV[0]) || die "can't open $ARGV for reading: $!"; # input file open(LOGFILE,">$ARGV[1]") || die "can't open output file $ARGV[1]"; #output file while(my $line = ) { next if $line =~ /^\s*$/; if ($line =~ /\)\.\s*$/) { # attempt to match on .) at end of line $myTitle = <>; print LOGFILE $myTitle; } } This is returning all files as if the regex were continually true . . . any body with a sharp eye This email may contain confidential and privileged material for the sole use of the intended recipient. If you are not the intended recipient, please contact the sender and delete all copies. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: generate variable names
> > I 'm asking if there a dynamic way to generate variable names. > Man, this question comes up a lot! :) I was thinking the same, maybe it should be put in the FAQ... -rjf -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]