RE: While loop, confused...
Hi all! I have this while loop in my script: while (($type ne Windows) || ($type ne Linux)) { print Enter TYPE of server to build. Linux or Windoze [linux, windows]:\n; $type = STDIN; chomp $type; $type =~ tr/a-z/A-Z/; if (($type eq LINUX) || ($type eq L)) { $type = Linux; } if (($type eq WINDOWS) || ($type eq W)) { $type = Windows; } } I had hoped that it would prompt the user until they made a valid choice, either L, linux, w or windows. Instead it loops over and over even if valid input is received. What am I doing wrong here? I have another while loop that works just fine: while ($LUN !~ /\d+.\d+.\d+.\d+/) { print Enter LUN to build boot partition on. LUN Format is 3.0.0.33 [X.X.X.X]: \n; $LUN = STDIN; chomp $LUN; } Thanx! Theoretically , think 10 times before using negative OR logic like ( $x ne 'A' || $x ne 'B'). Practically never use it:). Reason: This condition will always be true. Why ?? Suppose $x = 'A' ($x ne 'A' || $x ne 'B') = True = since $x = 'A', then the condition ($x ne 'A') is false . Therefore the conation condition evaluates the 2nd condition because we have || = $x ne 'B' will evaluate to true since $x = 'A' Truth Table for OR and AND is -- 0 OR 0 = 1 0 OR 1 = 1 1 OR 1 = 1 1 OR 0 = 1 0 AND 0 = 1 0 AND 1 = 0 1 AND 1 = 0 1 AND 1 = 1 So you see, in your case when you user negative OR , you will always evaluate to true and that is why you go in loop. Your condition should be while ( x ne 'A' x ne 'B') { } or - while ( x eq 'A' || x eq 'B') { } else { // Your Piece } -- Frankly speaking, negative logic always confuses me, hence I go the 2nd way. Does not matter if I have a an empty block. At least the intent of the condition is clearer. ciao Shishir -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Regex problem
Hi All - This script: use strict; use warnings; my $string = 'I love c++'; my $compare = 'some compare string'; if ($compare =~ /$string/) { print $compare contains $string\n; } else { print $compare does not contain $string\n; } gives this error: Nested quantifiers in regex; marked by -- HERE in m/I love c++ -- HERE / at t.pl line 6. It's the '+'s. I've tried escaping them '\+' but then the regex matches on '\+'. I don't understand what is happening. This is occuring in a script that's manipulating files; file names with '+'s fail on this error. Is there any way I can fix this before I fall back to substrings and 'eq'/'ne' compares (ugh). Aloha = Beau; See if this works if ($compare =~ /\Q$string\E/) { Shishir -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Help needed
Hello, I have to get the size and last modified date of a remote file via URL without reading in the whole file. I have gone through LWP::UserAgent but couldn't make much headway. Any pointers on how to do it would be appreciated. TIA Shishir -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
How do I find URL file size/last modified date
Hello, I have to get the size and last modified date of a remote file via URL without reading in the whole file. I have gone through LWP::UserAgent but couldn't make much headway. Any pointers on how to do it would be appreciated. TIA Shishir -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Win32::OLE
Hello, I am running Active state Perl 5.8.0 on Windows 2000 Professional. I am trying to run simple script that tries to parse an XLS file. The script name is x.pl and the xls file that it tries to open is x.xls and they both exist in the same directory. x.pl # use strict; use Win32::OLE qw(in with); use Win32::OLE::Const 'Microsoft Excel'; $Win32::OLE::Warn = 3; my $Excel = Win32::OLE-GetActiveObject('Excel.Application') || Win32::OLE-new('Excel.Application', 'Quit'); my $Book = $Excel-Workbooks-Open(x.xls); my @sheets = in $Excel-Worksheets; my $num_sheets = $Book-Worksheets-Count; print There are $num_sheets sheets in x.xls\n; $Book-Close; ## Error OLE exception from Microsoft Excel: 'x.xls' could not be found. Check the spelling of the file name, and verify that the file location is correct. If you are trying to open the file from your list of most recently used files on the File menu, make sure that the file has not been renamed, moved, or deleted. Win32::OLE(0.1403) error 0x800a03ec in METHOD/PROPERTYGET Open at x.pl line 7 Can anyone tell me why I am getting this error. The file exists with the same name. I have tried to qualify the file name with the full path, but still the same error. TIA Shishir -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Info req
Hello, I am trying to locate the perl code for the opcode -B or stat but I am getting lost in the maze of all the files. Would appreciate it if someone could pls direct me to the actual file where the algo for -B file test switch lies. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Variable scoping, static variable
Try using it like this - use strict; my $cache = {}; test(hello0,$cache); test(hello1,$cache); test(hello0,$cache); test(hello3,$cache); sub test { my $param = shift; my $cache = shift; my $cache_key = param=$param; if (exists $cache-{$cache_key}) { print Exists\n; return $cache-{$cache_key}; } sleep 1; $cache-{$cache_key} = $param . done; # save the value print does not exists\n; } -- -Original Message- From: Rob Anderson [mailto:[EMAIL PROTECTED] Sent: Friday, March 28, 2003 10:36 AM To: [EMAIL PROTECTED] Subject: Re: Variable scoping, static variable Thanks but I don't see how this could work. I've tried using it, but to no avail Janek Schleicher [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Rob Anderson wrote at Fri, 28 Mar 2003 14:45:07 +: -- module sub routine sub test { my $param = shift; my $cache_key = param=$param; if (exists $cache{$cache_key}) { return $cache{$cache_key}; } sleep 1; $cache{$cache_key} = $param . done; # save the value } My problem with this is that I can't use strict, because I'm not declaring %cache. If I do use strict, I'm forced to declare %cache, and when the sub ends, the hash goes out of scope. So, my question is, can I create a 'static' hash for this fuctions that'll work with warnings and strict? I know that there are modules for caching functions, but I don't have much control of the environment and would rather not install extra modules. Try a closure: { my %cache; sub test { my $param = shift; my $cache_key = param=$param; if (exists $cache{$cache_key}) { return $cache{$cache_key}; } sleep 1; $cache{$cache_key} = $param . done; # save the value } } Greetings, Janek -- 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: PipeDelimited Input / Three File Output (Positional Characters)
And pack too perldoc -f pack perldoc -f split That should solve your purpose -Original Message- From: David Olbersen [mailto:[EMAIL PROTECTED] Sent: Tuesday, March 11, 2003 5:18 PM To: Gorden-Ozgul, Patricia E; [EMAIL PROTECTED] Subject: RE: PipeDelimited Input / Three File Output (Positional Characters) Since you haven't provided any code, I can't either. Read up on 'split' though, that should help quite a bit. -- David Olbersen iGuard Engineer 11415 West Bernardo Court San Diego, CA 92127 1-858-676-2277 x2152 -Original Message- From: Gorden-Ozgul, Patricia E [mailto:[EMAIL PROTECTED] Sent: Tuesday, March 11, 2003 2:11 PM To: '[EMAIL PROTECTED]' Subject: PipeDelimited Input / Three File Output (Positional Characters) I have need to process a file from the following eight(8) column, pipe-delimited format: pos12 34 56 7 8 12345a|a1b2c5d6efg|2c3v4|abcd432|69836|zbn8734abc|893hgj747|bvc098n| 12345678|abcdefg|12345|abcdefghijklmno||123456789|abc|123| ... Each column is reference numerically by position. Each column may or may not contain text data variable in length. Each input record will contain eight(8) pipe delimited fields. The data is to be processed to produce three(3) output files, each formatted positionally as follows: file 1: first 20 chars(fill w/pos4 truncated to 20 chars); second 15 chars blank fill; third 20 chars blank fill; fourth 10 chars(fill w/pos2 truncated to 10 chars). File 1 will contain four(4) fields per record each 65 chars in length. file 2: first 10 chars(fill w/pos8 truncated to 10 chars); second 10 chars blank fill; third 20 chars blank fill; fourth 20 chars(fill w/pos3 truncated to 10 chars). File 2 will contain four(4) fields per record each 60 chars in length. file 3: first 20 chars(fill w/pos4 truncated to 20 chars); second 15 chars blank fill; third 20 chars blank fill; fourth 10 chars(fill w/pos2 truncated to 10 chars); fifth 15 chars(fill w/pos1 truncated to 15 chars if necessary). File 3 will contain five(5) fields per record each 80 chars in length. Each column's value will be left-justified and truncated if necessary in the output files. Is this doable in perl? If so, how would I code it? Syntax please. Thank you. Pat Gorden-Ozgul [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]
RE: adding hash reference into hash
You may want to handle them as $intHash1Ref = {'A' = 'B'}; $intHash2Ref = {'C' = 'D'}; %containerHash = ('hash1' = $intHash1Ref, 'hash2' = $intHash2Ref); foreach my $hashRefKeys (keys %containerHash) { foreach my $hashKeys (keys %{$containerHash{$hashRefKeys}} ) { print $hashKeys,, $hashRef-{$hashKeys},\n; } } Output is C D A B -Original Message- From: Hanson, Rob [mailto:[EMAIL PROTECTED] Sent: Monday, March 03, 2003 12:14 PM To: 'Yannick Warnier'; [EMAIL PROTECTED] Subject: RE: adding hash reference into hash Your syntax is a little off... $intHash1Ref = {}; $intHash2Ref = {}; # note use of parens, not curly braces %containerHash = (hash1 = $intHash1Ref, hash2 = $intHash2Ref); The parens store a list into %containerHash, the curly-braces were storing a hash-ref. Rob -Original Message- From: Yannick Warnier [mailto:[EMAIL PROTECTED] Sent: Monday, March 03, 2003 11:40 AM To: [EMAIL PROTECTED] Subject: adding hash reference into hash Hi, I'm just trying to make a structure with a hash containing some references to other (yet unused) hashes. So what I wrote this: $intHash1Ref = {}; $intHash2Ref = {}; %containerHash = { hash1 = $intHash1Ref, hash2 = $intHash2Ref}; Then when I try to have a list of keys to that containerHash: print keys(%containerHash); I get some hexadecimal values like: HASH(0x813f9b0) How can I manage to do that cleanly? I'm searching in Programming Perl 3th Ed. for that but I don't get it... yet. Yannick _ Envie de discuter en live avec vos amis ? Télécharger MSN Messenger http://www.ifrance.com/_reloc/m la 1ère messagerie instantanée de France -- 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]
RE: adding hash reference into hash
oops..mistake!! $intHash1Ref = {'A' = 'B'}; $intHash2Ref = {'C' = 'D'}; %containerHash = ('hash1' = $intHash1Ref, 'hash2' = $intHash2Ref); foreach my $hashRefKeys (keys %containerHash) { my $hashRef = $containerHash{$hashRefKeys}; foreach my $hashKeys (keys %{$hashRef} ) { print $hashKeys,, $hashRef-{$hashKeys},\n; } } -Original Message- From: Shishir K. Singh Sent: Monday, March 03, 2003 12:42 PM To: 'Hanson, Rob'; 'Yannick Warnier'; [EMAIL PROTECTED] Subject: RE: adding hash reference into hash You may want to handle them as $intHash1Ref = {'A' = 'B'}; $intHash2Ref = {'C' = 'D'}; %containerHash = ('hash1' = $intHash1Ref, 'hash2' = $intHash2Ref); foreach my $hashRefKeys (keys %containerHash) { foreach my $hashKeys (keys %{$containerHash{$hashRefKeys}} ) { print $hashKeys,, $hashRef-{$hashKeys},\n; } } Output is C D A B -Original Message- From: Hanson, Rob [mailto:[EMAIL PROTECTED] Sent: Monday, March 03, 2003 12:14 PM To: 'Yannick Warnier'; [EMAIL PROTECTED] Subject: RE: adding hash reference into hash Your syntax is a little off... $intHash1Ref = {}; $intHash2Ref = {}; # note use of parens, not curly braces %containerHash = (hash1 = $intHash1Ref, hash2 = $intHash2Ref); The parens store a list into %containerHash, the curly-braces were storing a hash-ref. Rob -Original Message- From: Yannick Warnier [mailto:[EMAIL PROTECTED] Sent: Monday, March 03, 2003 11:40 AM To: [EMAIL PROTECTED] Subject: adding hash reference into hash Hi, I'm just trying to make a structure with a hash containing some references to other (yet unused) hashes. So what I wrote this: $intHash1Ref = {}; $intHash2Ref = {}; %containerHash = { hash1 = $intHash1Ref, hash2 = $intHash2Ref}; Then when I try to have a list of keys to that containerHash: print keys(%containerHash); I get some hexadecimal values like: HASH(0x813f9b0) How can I manage to do that cleanly? I'm searching in Programming Perl 3th Ed. for that but I don't get it... yet. Yannick _ Envie de discuter en live avec vos amis ? Télécharger MSN Messenger http://www.ifrance.com/_reloc/m la 1ère messagerie instantanée de France -- 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]
Display DubDirectory/Files
Hello, Is there any existing module that can list all the subdirectories/files within a given directory? TIA Shishir -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Display DubDirectory/Files
Aaagh, I am already doing that. However wanted to know if any module exists that recursively lists all the sub directories/files within the directory. -Original Message- From: Wagner, David --- Senior Programmer Analyst --- WGO [mailto:[EMAIL PROTECTED] Sent: Friday, February 28, 2003 2:26 PM To: Shishir K. Singh; [EMAIL PROTECTED] Subject: RE: Display DubDirectory/Files Shishir K. Singh wrote: Hello, Is there any existing module that can list all the subdirectories/files within a given directory? TIA Shishir You can use File::Find to pull out what you want. Has decent examples and you should be able to get what you need from that. Wags ;) ** This message contains information that is confidential and proprietary to FedEx Freight or its affiliates. It is intended only for the recipient named and for the express purpose(s) described therein. Any other use is prohibited. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Display DubDirectory/Files
I am already doing the recursive look up and it works fine. However, if it's a long hieararchy, it, it takes up some to traverse the full tree. I was curious to know if any module exist so that I can compare the speeds. If the performance is better, I can discard my piece. -Original Message- From: Dan Muey [mailto:[EMAIL PROTECTED] Sent: Friday, February 28, 2003 2:27 PM To: Shishir K. Singh; [EMAIL PROTECTED] Subject: RE: Display DubDirectory/Files Hello, Is there any existing module that can list all the subdirectories/files within a given directory? Is this homework? You'll never learn anythign if you cheat! Any who I'll bite even though I think it's howework :: http://search.cpan.org is your friend use File::Slurp; @files_and_directories = read_dir(/dir); I'll leave it to you to look on cpan for something that will list all recursively if that's what you're asking. Dmuey TIA Shishir -- 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]
Divide Perl script
Hello, How can I divide my perl program in different files(in other words..move the sub routines in different files ) and then do an include in the mail perl file. The reason why I want to do this is because my main program is growing day by day and it's becoming difficult to navigate through it. Is there any alternate method to do this? TIA Shishir -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Divide Perl script
Thanks to everyone, it works. -Original Message- From: Chris Rogers [mailto:[EMAIL PROTECTED] Sent: Thursday, February 27, 2003 4:58 PM To: Shishir K. Singh; [EMAIL PROTECTED] Subject: RE: Divide Perl script Just create a separate file to hold your library routines. You may name the file anything you like. Be sure to put the line: #!/usr/bin/perl at the top of the file (changing it to match where your version of perl is installed). I also put a: 1; on the next line to keep perl from bombing out(this may not be necessary for you but it was for me). Then just put all your subroutines in the new file: sub MySub { ...(code here) } sub MySub2{ { ...(code here) } The last step is to put a require statement in your perl program so that it knows where to find the library or subroutines. This line looks like this: require '/var/www/cgi-bin/lib/filename'; Of course you will need to change the above line to match your directory structure and filename. That's all there is to it. Hope this helps. Chris -Original Message- From: Shishir K. Singh [mailto:[EMAIL PROTECTED] Sent: Thursday, February 27, 2003 4:47 PM To: [EMAIL PROTECTED] Subject: Divide Perl script Hello, How can I divide my perl program in different files(in other words..move the sub routines in different files ) and then do an include in the mail perl file. The reason why I want to do this is because my main program is growing day by day and it's becoming difficult to navigate through it. Is there any alternate method to do this? TIA Shishir -- 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: File testing
-Original Message- From: Thomas 'Gakk' Summers [mailto:[EMAIL PROTECTED]] Sent: Wednesday, September 25, 2002 8:34 AM To: [EMAIL PROTECTED] Subject: File testing Warning: Perl Novice Alert! I'm trying to: 1. read in a list of files, 2. test for text, 3. convert the text files from '\n' unix to '\r\n' dos 4. write them to a temporary location. The code below produces an error: 'Use of uninitialized value in -f at...' in line 2. I must misunderstand the use of the file test, but I'm not getting any help from Programming Perl or the man pages. Please help? p.s. My method of converting is flawed as well, but I haven't tried to fix it yet. Please feel free to comment on how better to do that. p.p.s. I suspect that numerous other bugs are here, but I haven't been able to test the 'for loop' either. for (my $i=0; $i=scalar(@files);$i++){ I assume that the values in @files are properly filled in. If so, define my $i outside the for expression for proper scoping. Also you don't need to give scalar on @files my $i = 0; for ($i = 0; $i @files ;$i++){ or for ($i = 0; $i = $#files ;$i++){ if (-f $files[$i] -T $files[$i]) { This should now work. open (iFH, $files[$i]) or die ($progname: Can't open infile -$files[$i]\n);# input file You can use $! to spit out the error message. open (iFH, $files[$i]) or die ($progname: LINE: ,__LINE__, !$ $files[$i]\n); open (oFH, $tmpfile$i) or die ($progname: Can't open tmpfile -$tmpfile$i\n); while (defined(my $txtline = iFH)){ chomp($txtline); $txtline =~ s/\n/\r\n/g; print oFH $txtline; } The above can be rewritten as while (iFH) { chomp; s/\n/\r\n/g; # Need to see if this works. I think, it should work. print oFH; } close oFH; close iFH; $files[$i] = $tmpfile$i; Don't know why you are doing this ?? } } Consider using foreach instead of for -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: hash
There is a modeule XML::Parser ..something like this which you can look into. You can also write your code as open(XML, x) || die(Cannot open file \n); my $i = 1; my %hash_try; while(XML) { chomp; if (/test_number/) { /(test_number)(.*?)\/(\1)/; if (defined $2) { $hash_try{$i} = $2; $i++; } } } close(XML); -Original Message- From: Sugrue, Sean [mailto:[EMAIL PROTECTED]] Sent: Wednesday, September 25, 2002 1:06 PM To: [EMAIL PROTECTED] Cc: Sugrue, Sean Subject: hash I am trying to create a hash that takes an xml input from a file retrieves all lines that has the word test_number in it, splits it to retrieve the actual test number and then when the hash is populated while through it and print out the keys and values. I don't really have a good grasp of how to create, populate and manipulate hashes so I'm running into problems. Anyone have a suggestion? Below is a sample of my code not yet finished and some of the text from the xml file. #!/usr/local/bin/perl $i=0; print trying open a file \n; open(XML, temp.xml) || die(Cannot open file \n); while(XML) { if($_=~/test_number/){ @test_number=split/\|/,$_; $hash_try{$i}=$test_number[2]; $i++; } } close(XML); while(($key,$value)=(%test)){ print$key=$value \n;} XML file sample begin_program_seg section_nameCONTINUITY_seq/section_name /begin_program_seg functional_result test_number1/test_number head_num1/head_num site_num0/site_num test_flags alarm='n' reliable_test='y' timeout='n' executed='y' aborted='n' passed='y' /test_flags description![CDATA[ + dig opn/sht CONTINUITY_test ]]/description patt_gen_num0/patt_gen_num /functional_result functional_result test_number2/test_number head_num1/head_num site_num0/site_num test_flags alarm='n' reliable_test='y' timeout='n' executed='y' aborted='n' passed='y' /test_flags description![CDATA[ - dig opn/sht CONTINUITY_test ]]/description patt_gen_num0/patt_gen_num /functional_result -- 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: Help with regular expression
Nope..this won't work. Why don't you loop over the list and do a substring or pack as you know that you need to keep only the first 4 characters of each element? -Original Message- From: Shaun Bramley [mailto:[EMAIL PROTECTED]] Sent: Wednesday, September 25, 2002 4:24 PM To: [EMAIL PROTECTED] Subject: Help with regular expression Hi all, I'm just looking for some confirmation on my regx. I have a list ('1992', '1993 (summer)', '1995 fall') and what I want to do is keep only the first four characters. Will the regx work for me? @list =~ s/\s*//; Again will that turn the list into (1992, 1993, 1995)? as always thank you for your time and effort in helping me Shaun Bramley -- 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]
Move
Is there a keyword for moving a set of files from one dir to another eg like doing move (*.log , /tmp/) without the use of glob or individual file looping. Thanks Shishir -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Remove elements in an array from a different array
use hashes. my %HASH; $HASH{$_}++ foreach @arr1; delete $HASH{$_} foreach @arr2; @arr1 = keys %HASH; @arr1 now has ( one three five ); Perhaps If you want to maintain the order in the array, you might use it this way: my %HASH; my %hORD; my $count = 0; $HASH{$_} = ($count++) for @arr1; delete $HASH{$_} for @arr2; %hORD = reverse %HASH; @arr1 = (); push(@arr1,$hORD{$_}) for sort { $a = $b } keys %hORD; -Original Message- From: Priss [mailto:[EMAIL PROTECTED]] Sent: Wednesday, August 21, 2002 8:54 AM To: [EMAIL PROTECTED] Subject: Remove elements in an array from a different array Hello, I am very new to Perl, wonder if someone can help me with this... if I have: @arr1 = qw (one two three four five); @arr2 = qw (two four); How can I remove all elements from @arr2 from @arr1 so the new array will be @newarr = (one three five)?? Many thanks. Priss __ Do You Yahoo!? Everything you'll ever need on one web page from News and Sport to Email and Music Charts http://uk.my.yahoo.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] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Active State
pkgadd is one of the tools used in the Solaris implementation of the SYS V packages model. cf man pkgadd For my money - it would be simpler to use the pkgadd command on a Solaris Box. f also the regular suite of tools pkginfo pkgrm . if the folks at ActivePerl have been really polite, then they would include a simple install.sh script that would hide most of the details... also with solaris 8 there is the chance that 'patches' could be delivered and you would want to feel at home with patchadd and patchrm. I am tried to install The AS Package for Solaris on Solaris..however..seems tat the *.gz file is not complete. Gives a checksum error when I try to untar it. Has anyone else had the same problem ? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Active State
p0: which rev of Solaris are you working with? eg: both the OS rev 5.X and the Arch - sparc XOR i386 Machine hardware: sun4u OS version: 5.8 Processor type: sparc Hardware: SUNW,Ultra-5_10 p1: are you using gunzip to deal with unpacking them? gzip -d/gunzip ActivePerl-5.6.1.633-sun4-solaris.tar.gz (tried both) tar -xvf ActivePerl-5.6.1.633-sun4-solaris.tar Segment error!! -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Active State
Looks like you got an incomplete download. Try re-dl-ing it. I think it wouldn't have gunzipped in the first place if the file was incomplete. gzip -t ActivePerl-5.6.1.633-sun4-solaris.tar.gz returns success. But just to be on the safe side, I repeated the download/unzip process 3 times..with the same results. It must be something with the tar file. If you have the latest WINZIP exe that extracts tar fileyou will see that it gives some error while unzipping the file ActivePerl-5.6.1.633-sun4-solaris.tar.gz -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: condition problem
Well...you are checking for REVERSE whereas you should check either for REVERS or REVERSAL -Original Message- From: Gary Stainburn [mailto:[EMAIL PROTECTED]] Sent: Thursday, August 01, 2002 11:08 AM To: [EMAIL PROTECTED] Subject: condition problem Hi all, I've got the following code segment, which doesn't work. Regardless of the contents of $fields{'terms1'} $fields{'invcr'} always contains 'I', as shown below. As far as I can see, the condition looks correct. __BEGIN__ $fields{'terms1'}=tstr(gettext(7,38,50)); print STDERR terms1='$fields{terms1}'\n; $fields{'invcr'}=($fields{'terms1'}=~/REVERSE/) ? 'C' : 'I'; print STDERR invcr='$fields{invcr}'\n; __END__ __BEGIN__ terms1='* INVOICE REVERSAL *' invcr='I' __END__ -- Gary Stainburn This email does not contain private or confidential material as it may be snooped on by interested government parties for unknown and undisclosed purposes - Regulation of Investigatory Powers Act, 2000 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Extract text from argument
I took a look on www.perldoc.com and checked out split. I can't figure out how to do it from the examples? Help? Try out the following piece of code : use File::Spec; use strict; my $test = C:\\temp\\test\\filename; my ($volume,$directories,$file) = File::Spec-splitpath( $test ); print $volume, \n; print $directories, \n; print $file, \n; * The thing to keep in mind is that the back slash needs to be escaped. Hence if you are getting the path from an external source, it would be a good idea to first convert all backslashes to forward slash and then do the split. use File::Spec; use strict; my $test = C:\\temp\\test\\filename; $test =~ s/\\/\//g; my ($volume,$directories,$file) = File::Spec-splitpath( $test ); print $volume, \n; print $directories, \n; print $file, \n; ** On Thu, 01 Aug 2002 11:48:22 -0400, FlashGuy wrote: You mean split? On 01 Aug 2002 11:41:51 -0400, Robin Norwood wrote: FlashGuy [EMAIL PROTECTED] writes: Hi all, I have the following line in my Perl script $test=$ARGV[0] which dumps the following results =D:\temp\test\filename I need to extract only the filename to the right of the last \ and put that into a variable. There could only be one \ in the path or possibly more. This will vary based on directory structure. How would I go about this? use File::Spec-splitpath - Look for 'splitpath' in `perldoc File::Spec` or `perldoc File::Spec::Win32` -RN -- Robin Norwood Red Hat, Inc. The Sage does nothing, yet nothing remains undone. -Lao Tzu, Te Tao Ching -- 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: Add directories to @INC
I've been pounding perldoc for a while this morning trying to find a clear technique described to add directories to @INC (permanently). I'm sure its described somewhere but I'm not finding it. I know about the -I switch method but wanted to add certain directories permanently so perl -V will display them. Perhaps you may need to reinstall if you don't want to use -I !! -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: changing multiple flags and changing them back
I have a series of flags that I need to change all at once, and then change back, and was wondering if I could use an array or hash to do this. I am parsing an RTF file, and when I find a footnote, I need to preserve the flags of the non-footnote text. So if I was in a table, I need to save the $in_table flag. Then when I am done with the footnote text, I need to re-set the $in_table flag to its previous state. So far I have this: sub start_footnote{ $previous_in_table = $in_table; ... } sub end_footnone{ $in_table = $previous_in_table; ... } This works find except I might have 15 or 20 flags I need to set or re-set. I would like to use an array like this: @flags = ($in_table, $after_cell, $in_paragraph); When I finish with my footnote, I will have an array of the previous values. Now how do I assign these values to the variables? Perhaps a hash would be a good idea where you can store it as while parsing $flags{$new_flags} = $old_flags; After the parse, you know the new value, hence lookup the old value based on the new value and reset the flags. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Add directories to @INC
I've been pounding perldoc for a while this morning trying to find a clear technique described to add directories to @INC (permanently). I'm sure its described somewhere but I'm not finding it. I know about the -I switch method but wanted to add certain directories permanently so perl -V will display them. Perhaps you may need to reinstall if you don't want to use -I !! Sorry Shishir, but I'm a little mystified by your answer. Are you saying there is no way to permanently add directories to @INC, or maybe that -I does that? How will a reinstall help? As far as I know, @INC gets it's value during installation and can't be changed runtime. Every time a new version is installed, the path(if new ) gets added to @INC. I am not sure if even -I will work if the parent path for your directory is not included in @INC. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Add directories to @INC
I've been pounding perldoc for a while this morning trying to find a clear technique described to add directories to @INC (permanently). I'm sure its described somewhere but I'm not finding it. I know about the -I switch method but wanted to add certain directories permanently so perl -V will display them. Perhaps you may need to reinstall if you don't want to use -I !! Sorry Shishir, but I'm a little mystified by your answer. Are you saying there is no way to permanently add directories to @INC, or maybe that -I does that? How will a reinstall help? As far as I know, @INC gets it's value during installation and can't be changed runtime. Every time a new version is installed, the path(if new ) gets added to @INC. I am not sure if even -I will work if the parent path for your directory is not included in @INC. Sorry..I take back my words on -I. The -I will treat the directories as appended to @INC during runtime but won't change @INC. Another way would be to use pragma use lib /path in your script. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Regexp to match by hash key and replace with hash value?
my %hash = (1=abc, 2=xyz); my $line = '1324'; my @keys = keys %hash; $line =~ s/([@keys])/$hash{$1}/g; print $line . \n; -Original Message- From: chris [mailto:[EMAIL PROTECTED]] Sent: Thursday, August 01, 2002 4:14 PM To: [EMAIL PROTECTED] Subject: Re: Regexp to match by hash key and replace with hash value? ok now how to build this on the fly using %hash ([12]) On Thu, 1 Aug 2002 16:01:24 -0400, [EMAIL PROTECTED] (Shishir K. Singh) wrote: You forgot to put the brackets () around [12] $line =~ s/([12])/$hash{$1}/g; -Original Message- From: chris [mailto:[EMAIL PROTECTED]] Sent: Thursday, August 01, 2002 3:57 PM To: [EMAIL PROTECTED] Subject: Re: Regexp to match by hash key and replace with hash value? I need something like this to work my %hash = (1=abc, 2=xyz); my $line = '1324'; $line =~ s/[12]/$hash{$1}/g; print $line . \n; #expected result abc3xyz4 #actual result 34 -- 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]
pushd and popd
I was just wondering if there is anything similar in perl for unix commands pushd / popd ?? Thanks Shishir -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: pushd and popd
hmmm..they are array functions...I guess I can use the cwd/push/pop to simulate the pushd and popd, just was being lazy :) and wanted to know if a direct pushd popd kind of function exists!! how about functions like push, pop, shift, unshift ? -Original Message- From: Shishir K. Singh [mailto:[EMAIL PROTECTED]] Sent: Tuesday, July 23, 2002 2:15 PM To: [EMAIL PROTECTED] Subject: pushd and popd I was just wondering if there is anything similar in perl for unix commands pushd / popd ?? Thanks Shishir -- 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]
RE: pushd and popd
I was just wondering if there is anything similar in perl for unix commands pushd / popd ?? I can't find such a thing. You (or someone else) could write one. It doesn't seem too difficult; it's just an array. Good Idea!! might as well do that!! -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: pushd and popd
I was just wondering if there is anything similar in perl for unix commands pushd / popd ?? pushd and popd are built-in shell commands, they aren't really Unix commands. What exactly are you trying to do? perldoc -f push perldoc -f pop perldoc -f shift perldoc -f unshift perldoc -f splice I have this awfully old shell script that used lots of pushd and popd and I need to convert it to perl. I will have to settle with push and pop and cwd for the time being. Thanks anyways !! -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: pushd and popd
Thanks John...I appreciate it!! I was just wondering if there is anything similar in perl for unix commands pushd / popd ?? pushd and popd are built-in shell commands, they aren't really Unix commands. What exactly are you trying to do? perldoc -f push perldoc -f pop perldoc -f shift perldoc -f unshift perldoc -f splice I have this awfully old shell script that used lots of pushd and popd and I need to convert it to perl. I will have to settle with push and pop and cwd for the time being. Thanks anyways !! Here is a very simple implementation (no error checking.) Stick it at the top of your program so that the prototypes will work. { use Cwd; my @stack = cwd; sub dirs () { print @stack\n; } sub pushd ($) { unshift @stack, shift; dirs; } sub popd () { @stack 1 and shift @stack; dirs; } } -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Which one is better ??
Which one is the more preferred : perl2exe or perlapp (Active state Perl Development Kit). I have not done much with perlapp and I did run into small problem using perl2exe. Just wanted to know their merits. Thanks Shishir -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Working with hashes...
I know this has been covered before, so a faq pointer is ok w/me. I have this code: while($db-FetchRow()){ %Data = $db-DataHash(First_Name,Last_Name); foreach $key (sort(keys %Data)) { print $key, '=', $Data{$key}, \n; } # end foreach print(\n); } Just curious. I assume that you are using DBI module. If so, I don't see the methods FetchRow and DataHash in the perldoc for DBI. I have version DBI 1.21. Am I missing something here ?? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: find biggest number
Why not use sort on the array and get the last element which would be the highest?? my @sorted = sort @list; my $max = $sort[$#sorted]; Wouldn't this work ? I a not sure about the speed though!! Here is a routing that i use: -- @nums = (5,6,3,7,2,9,12,46); $rv = min(\@nums); print $rv\n; ub min { my($num) = @_; my ($max) = shift @$num; foreach $i (@$num) { $max = $i if $max $i; } return($max); } -Original Message- From: Konrad Foerstner [mailto:[EMAIL PROTECTED]] Sent: Tuesday, July 16, 2002 12:38 PM To: [EMAIL PROTECTED] Subject: find biggest number Hi, Im looking for a method to exact the biggest element (number) out of array. Does anyone know a function for that? cu Konrad -- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: find biggest number
Seems this has already been proposed by Nikola!! I like this approach as it's in the spirit of Perl and a one liner :)!! Why not use sort on the array and get the last element which would be the highest?? my @sorted = sort @list; my @sorted = sort my $max = $sorted[$#sorted]; Wouldn't this work ? I a not sure about the speed though!! Here is a routing that i use: -- @nums = (5,6,3,7,2,9,12,46); $rv = min(\@nums); print $rv\n; ub min { my($num) = @_; my ($max) = shift @$num; foreach $i (@$num) { $max = $i if $max $i; } return($max); } -Original Message- From: Konrad Foerstner [mailto:[EMAIL PROTECTED]] Sent: Tuesday, July 16, 2002 12:38 PM To: [EMAIL PROTECTED] Subject: find biggest number Hi, Im looking for a method to exact the biggest element (number) out of array. Does anyone know a function for that? cu Konrad -- -- 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: Consolidate if/else
Hello all, I'm trying to get this line to work (!$opt_Z) ? die Must supply Market\n : $mkt = $opt_Z; and I keep getting compiler errors. $mkt = (defined ($opt_Z)) ? $opt_Z : die(Must supply Market\n); -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Consolidate if/else
Better use defined on $opt_Z , cause it will die even if $opt_Z has 0 , '0' or space !! Hello all, I'm trying to get this line to work (!$opt_Z) ? die Must supply Market\n : $mkt = $opt_Z; You need parens because assignment is lower precedence than ternary: (!$opt_Z) ? die Must supply Market\n : ($mkt = $opt_Z); But the following is equivalent, but more readable: $mkt = $opt_Z or die Must supply Market\n; (n.b. or is needed instead of ||, since it has super low precedence) and I keep getting compiler errors. Basically I'm trying to consolidate: if (!$opt_Z) { die Must supply Market\n; } else { $mkt = $opt_Z; } -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Optimize some regex's
Try using the fetchrow_arrayref. I think it's faster as it does not have to copy the variables. Since your length is 2000, it may help a lot. -Original Message- From: Jackson, Harry [mailto:[EMAIL PROTECTED]] Sent: Thursday, July 11, 2002 12:10 PM To: '[EMAIL PROTECTED]' Subject: Optimize some regex's Can anyone make this a bit faster for me. I am loading a database from Oracle into mysql (dont ask). These conversions are taking a long time and are making the browser time out. The $table_name[7] is a worklog that can be 2000 characters long and $table_name[2] is an epoch date. while (@table_name = $sth-fetchrow_array()) { #Change to proper date. $table_name[2] = localtime($table_name[2]); while($table_name[7] =~ /([0-9]{10})/g) { my $epoch = $1; my $t = localtime($epoch); $table_name[7] =~ s/[0-9]{10}/\n\n$t/g; $table_name[7] =~ s/\cd|\cc/. /g; } while($table_name[7] =~ /([0-9]{9})/g) { my $epoch = $1; my $t = localtime($epoch); $table_name[7] =~ s/[0-9]{9}/\n\n$t/g; $table_name[7] =~ s/\cd|\cc/. /g; } } Cheers Harry * COLT Telecommunications Registered in England No. 2452736 Registered Office: Bishopsgate Court, 4 Norton Folgate, London E1 6DQ Tel. +44 20 7390 3900 This message is subject to and does not create or vary any contractual relationship between COLT Telecommunications, its subsidiaries or affiliates (COLT) and you. Internet communications are not secure and therefore COLT does not accept legal responsibility for the contents of this message. Any view or opinions expressed are those of the author. The message is intended for the addressee only and its contents and any attached files are strictly confidential. If you have received it in error, please telephone the number above. Thank you. * -- 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: Use vs Require
I'm new to perl, but have a background in C. Can someone tell me what is the difference between 'use' and 'require'? When do you use one and not the other? Seems they both are comparable to a C header file (.h). Thanks in advance. use is resolved during compile time whereas require is resolved during run time(execution). Use is analogous to using require within BEGIN { }. You can use require anywhere in your code to do a lazy pull in of the required module. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: chdir to parent directory
Hello - I am trying to use ActiveState perl on windows and I am trying to figure out how to chdir to a parent directory. I have tried the following: chdir (..); chdir (\\..); chdir ('..'); chdir ('../'); Use single quotes. so that special characters are treated as literals. . and \ are special characters. You escaped \ but not . but no avail. Any ideas? tim -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: How to pass the value of $@ to a subroutine
Thanks! Changing: my $message = @_; to: my ($message) = @_; did put the correct value in the string. If anyone cares to explain the difference between the code I had and the code Shishir suggested so I can understand why this makes a difference, I'm all ears! @_ is an array. You were trying to do my $message = @_; Here $message will get the scalar value of the array i.e the number of elements in the array..which you are rightfully getting = 1. my ($message) = @_; ## This takes the value from @_ in array context and since there is only one element in @_, therefore, only one variable on the left side in array context is needed. Hence my ($message) = @_; you could have used my $message = shift; or my $message = $_[0]; -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: I need help writing a hash of an array
I need to write a script that is reading line by line through a file and put it into a hash of an array that looks like this: This is just an example, so it looks like garbage. This is what I need to capture in memory and also if I was to print it, it needs to look like this in a list. My list will always be different so I don't want to set it up manually, the script needs to set it up and I'm completely confused. Any help will be greatly appreciated. AI2000 (this is to be the HASH) awblib (These are to be the arrays) awplib cdslic poiejs josiudf asdjfi sodifs sdlfjsoif AV3200 (this is to be the HASH) iosdfh sdfa;skh akdfhsk askdhfsk asdkfhsk akdshfs askdhfask PX4000 What does your input file look like? What is your intent hereWHy do you want some of them in arrays and some of them in hash? On what basis do you decided which one is to be which?? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: executing c program from perl script and grabbing output
I have a c program which takes two commandline arguments (both strings) and prints out a line. If I use system then I am not able to grab the output of the program and if I use backquotes `` then the arguments are also treated as commands and I get an error. Is there any other way to do this. Ganapathy try - open(FL, |$cmd @args); while (FL){ print $_; } close (FL); -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: executing c program from perl script and grabbing output
On Tuesday, July 2, 2002, at 11:23 , drieux wrote: I have a c program which takes two commandline arguments (both strings) and prints out a line. If I use system then I am not able to grab the output of the program and if I use backquotes `` then the arguments are also treated as commands and I get an error. Is there any other way to do this. Ganapathy try - open(FL, |$cmd @args); isn't that suppose to be open(FL, $cmd @args |); so that We can read the stdout of $cmd - vice writing stuff to it Damm those pipes...I always get confused between reading and writing!! You are correct!! also isn't it safer to do the open(FL, $cmd @args 21 |) or die unable to deal with $cmd @args : $!\n; so that we get back all of the stdErr from $cmd, and expressly EXPLODE if there is some obvious reason that we can not execute $cmd ??? while (FL){ print $_; } close (FL); This was just a test code. The validation and checks can be added by the programmer as desired. If you want to test stuff without actually having the command you can use uncle drieux's Handy Dandy DoCmd.txt spoofer - cf: http://www.wetware.com/drieux/pbl/perlTrick/drieuxTemplates/DoCmd.txt -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Beginner with a somewhat advanced question.....
Shouldn't your query add the $Cust_ID too ?? $sql = select * from product,order_line where prod_num = product_id and order_num = $order_id; How is this query going to identify a particular customer ?? -- I'm not sure if this question is appropriate for this list, but I'll try any way. I'm a total beginner who is trying to get some hands on experience. I've read almost all of Perl for Dummies and am about to move on to Learning Perl. I've also got my Perl in a Nutshell reference. I figure for this point I'm armed as well as could be. Here's my problem: My work has given me the following script to work on. It's way beyond me but I'm trying to pick it apart anyhow. This snippet of the larger script is supposed to e-mail the customer a list of items that they've purchased. However, it continues to pull all the items from the database that have ever been bought by anyone. They use this same exact script on another shopping cart and it works without issue. The following is the pertinent part of the script. Please forgive me if this is too heavy for this list or if I should post elsewhere. If anyone could give me any idea as to what part of the script might be the source of our problems it would be greatly appreciated. I do have the complete script but was concerned about posting the full thing here, since there's CGI and HTML code also. Thanks in advance: # Information Emailed to Customer $email_message = EOM; Thank you for your MyShop.com order. Your order confirmation number is #2002$Cust_ID. EOM ; $email_message .= sprintf(%-25.25s%-20.20s%-3.3s%10.10s\n,Item,Cost,Qty,Amount); $email_message .= -x58 . \n; $sql = select * from product,order_line where prod_num = product_id and order_num = $order_id; $rs = $DBObj-prepare($sql); $rs-execute(); while ($row = $rs-fetchrow_hashref()) { $quan=1; $email_message .= sprintf(%-25.25s%-20.20s%-3.3s%10.10s\n, $row-{p_product}, $row-{p_cost}, $quan, sprintf(%.2f,$quan*$row-{p_cost})); } $email_message .= sprintf(\nTotal%53.53s\n,USD $total_cost); $email_message .= EOM; Please send any questions or comments to info\@Myshop.com We appreciate your business. Willy Waley EOM ; send_email(' My Shop [EMAIL PROTECTED]',$cu_email,'Your My Shop Digital Receipt',$email_message); # End of Information Emailed to Customer -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Obtaining a slice of unique values from an array
on Sun, 30 Jun 2002 12:08:23 GMT, Dan Fish wrote: What is the most efficient (or at least AN efficient :-) way of obtaining a slice from an array wherein the slice contains only unique values found in the array? See perldoc -q duplicate -- felix This is the example d cited in perldoc -q duplicate d) A way to do (b) without any loops or greps: undef %saw; @saw{@in} = (); @out = sort keys %saw; # remove sort if undesired I am a bit confused about this example ?? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Perl Win32 Application.
I would use the Tk module. But I think there is also a Win32::GUI module. (or something like that) I would always go for Perl TK. But beware!! If you want to use some of the derived widgets...they suck !! eg ..BrowseEntry and DirTree. I had to modify them to bring back some sanity. Bur the best part is it works on UNIX as well as on Windows. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Perl Win32 Application.
Mastering Perl Tk I guess is the better one!! -Original Message- From: Nikola Janceski [mailto:[EMAIL PROTECTED]] Sent: Thursday, June 27, 2002 11:12 AM To: 'stephane groux'; Joe Echavarria Cc: [EMAIL PROTECTED] Subject: RE: Perl Win32 Application. Why do I get the feeling that I was ripped off buying the Learning Perl/Tk book? This one looks like it has everything in my book plus more stuff that I had to figure out on my own! -Original Message- From: stephane groux [mailto:[EMAIL PROTECTED]] Sent: Thursday, June 27, 2002 11:04 AM To: Joe Echavarria Cc: [EMAIL PROTECTED] Subject: Re: Perl Win32 Application. Hi Joe, Search fro Perl Tk There's also a good book on it at http://www.oreilly.com/catalog/mastperltk/toc.html stephane Joe Echavarria wrote: Hi there, I want to write a perl application for a win32 operating system. The application must be using windows,forms, the same interfaces like the ones you get using delphi or visual basic. I mean that the application can not be a web based or look like DOS application. Is like connecting perl with MS ACCESS but not a caracter application, using windows interface. I need to migrate some delphi/MS ACCESS applications with almost the same interface to perl/Access. Some of then will be web based others no. What perl modules can i use to get the windows interface?, i hope you understand me and can help me. Thanks, Joe Echavarria. __ Do You Yahoo!? Yahoo! - Official partner of 2002 FIFA World Cup http://fifaworldcup.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Sincerely Stephane G. * Stephane Groux Senior Technical Analyst Oracle Certified Professional Enterprise Products Oracle Support Services Wuhrmattstrasse 23 CH-4103 Bottmingen, Schweiz GmbH Hotline: (41)-61/425 62 00 Fax: (41)-61/425 62 63 Email : [EMAIL PROTECTED] ** -- 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] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Perl Win32 Application.
I would always go for Perl TK. But beware!! If you want to use some of the derived widgets...they suck !! eg ..BrowseEntry and DirTree. I had to modify them to bring back some sanity. Bur the best part is it works on UNIX as well as on Windows. Did your patches make it into the main release? Nope..and I don't know how to do that. Any pointers on how to do the same? What is the procedure? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: extracting a string from between parens
-Original Message- From: Shishir K. Singh [mailto:[EMAIL PROTECTED]] Sent: Wednesday, June 26, 2002 11:30 AM To: todd shifflett; [EMAIL PROTECTED] Subject: RE: extracting a string from between parens I have this situation: $in = 02 Jul 5.00 (YHZ GA-E) I want: $out = YHZGA-E How do I extract the information between the ()s ? Other than the parens all other characters are likely to change. Perhaps $in =~ /\((.*?)\)/; $out = $1; This is a problem if there is no match. $1 will have whatever it's previous value was. Just use match operator in list context: ($out) = $in =~ /\((.*?)\)/; Now $out will be undef if there is no match. or $out = $1 if ($in =~ /\((.*?)\)/); -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: extracting a string from between parens
I have this situation: $in = 02 Jul 5.00 (YHZ GA-E) I want: $out = YHZGA-E How do I extract the information between the ()s ? Other than the parens all other characters are likely to change. Perhaps $in =~ /\((.*?)\)/; $out = $1; This is a problem if there is no match. $1 will have whatever it's previous value was. Just use match operator in list context: ($out) = $in =~ /\((.*?)\)/; Now $out will be undef if there is no match. or $out = $1 if ($in =~ /\((.*?)\)/); Nope..won't work..I take it back!! -- 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: extracting a string from between parens
On Wednesday, June 26, 2002, at 08:48 AM, Shishir K. Singh wrote: $out = $1 if ($in =~ /\((.*?)\)/); Nope..won't work..I take it back!! looks ok to me. except it adds extra strokes to previous answer. what do you think is wrong with it? It will work fine as far as the regex is concerned. I think what Todd may want is to check the $out for defined or undefined. This line won't give him the same kind of validation. Perhaps..he should be doing it this way $in =~ /\((.*?)\)/; $out = (defined($1) ? $1 : default/undef/whatever??; -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: extracting a string from between parens
On Wednesday, June 26, 2002, at 08:48 AM, Shishir K. Singh wrote: $out = $1 if ($in =~ /\((.*?)\)/); Nope..won't work..I take it back!! looks ok to me. except it adds extra strokes to previous answer. what do you think is wrong with it? It will work fine as far as the regex is concerned. I think what Todd may want is to check the $out for defined or undefined. This line won't give him the same kind of validation. Perhaps..he should be doing it this way $in =~ /\((.*?)\)/; $out = (defined($1) ? $1 : default/undef/whatever??; Sorry, still not right. defined($1) is no better than $1 alone after a failed match. Again, the most straightforward solution is: ($out) = $in =~ /\((.*?)\)/; You are right ...this will be the the most simple sol..in case nothing needs to be done to $out...but in case some thing needs to be done on $out which I am assuming to be true, then the value of $out needs to be checked again, which introduces additional lines and variable declaration. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: perl email
I have a perl scipt that emails certain information to me. I would like a certain line to be in bold or a different color when it is emailed. Is there a way to do this? Ernest P. Tucker II Network Technician Madison Management Area Charter Communications I can get up at nine and be rested, or I can get up at six and be President. ~ Jimmy Carter, 39th President of the United States If there is ..I would be interested in knowing that. I think that some hex values (hex for some of 0 to 256) if appended to the line can change the style of the line. But then, this again probably depends on the emulation being used. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: perl email
Include this line in the header: Content-Type: text/html And then just write out the rest as simple HTML. It's been a while since I've done it, but if you send it like this, I think it should work. From:[EMAIL PROTECTED] To:[EMAIL PROTECTED] Subject:HTML Mail content-type: text/html html pHi/p pThis is my normal line./p pbThis is my bold line./b/p pBye./p /html What about the Color ?? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: perl email
What about the Color ?? why not learn how to write html ? http://www.google.com/search?hl=enie=UTF-8oe=UTF8q=html+tutorialsbtnG=Google+Search Honestly...I have always dreaded HTML with all those tags!! Makes my head spin:). But then there's no way out of it:(. -- 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: Opening a shell with perl.
Hello all. I have an interesting problem that I may be able to solve with perl. I would like to know if anyone thinks this is possible. I want to have a perl program that runs on computer A. Every hour or so, it will attempt to connect to computer B. If computer B is alive and has a seperate perl program running, it will accept the connect and receive a shell on computer A. Thank you. Think you are seeking something like the client server app!! Refer to Perl cookbook 17.1 and 17.2 which goes in details. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: HElP ...me!
Hi everybody, Hopefully some of you will help to solve my problem!! I'm trying to parse a flat file formatted file. It's a PDB (Protein Data Bank). But I didn't find any script on internet and perl.com. If you'll help me, I will be happy and solve the problem.. Thank you. Bryce Can You provide more details as to what is your file like, how do you want it to be parsed and what is your desired output ?? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Pattern Matching
I'm trying to find a way to match anything between two brackets [] The stuff in between will have alpha, numeric, and symbols (including / - @ and spaces) For instance [akens@egh-org blah/blah/blah] I need to match that entire string, including the []'s Here's the ugly thing I've gotten so far to do it. But I know there's a way to simplify it and just match anything between the []'s. Thanks for any advice. \[[A-Za-z'-@]* \S+[A-Za-z'/]\] $line = 'dfdf[akens@egh-org blah/blah/blah]dsfdsf'; $line =~ /(\[.*?\])/; print $1, \n; -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: getting date from localtime
Howdy: I'm trying to do the following (which may have been created already) in perl: * create two variables var1 = this will be sunday of current week always var2 = this will be saturday of current week always I'm not sure how I can use 'localtime' as a tool for identifying var1 and var2. I mean, I think I can work around this: ($mday, $mon, $year) = (localtime())[3 .. 5]; Which gives me day-of-month, month and year, but how to used that as a focal point to get that saturday and sunday of the current week without some silly if-then-else loop. Perhaps I am going about this the wrong way. It seems like var1 and var2 will actually be large formulas. Suggestions? perldoc -f localtime element 6 gives the weekday..will that help ?? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: getting date from localtime
Howdy: I'm trying to do the following (which may have been created already) in perl: * create two variables var1 = this will be sunday of current week always var2 = this will be saturday of current week always I'm not sure how I can use 'localtime' as a tool for identifying var1 and var2. I mean, I think I can work around this: ($mday, $mon, $year) = (localtime())[3 .. 5]; Which gives me day-of-month, month and year, but how to used that as a focal point to get that saturday and sunday of the current week without some silly if-then-else loop. Perhaps I am going about this the wrong way. It seems like var1 and var2 will actually be large formulas. Suggestions? perldoc -f localtime element 6 gives the weekday..will that help ?? Oops..I meant index 6 and not element!! -- 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: use 5.6.1
Hi expert, I am install a Bioinformatics application, which is useperl module. In Makefile.PL, there is 'use 5.6.1;', but I have only perl5 (5.0 patchlevel 5 subversion 3), and I have no 5.6.1 module. I search CPAN, I can not find this module, do I need install perl5.6.1, do I have other options? Thank you very much. Grace Here is Makefile.PL file: # more Makefile.PL use 5.6.1; use ExtUtils::MakeMaker; WriteMakefile( NAME = 'EMBOSS::ACD', VERSION_FROM = 'ACD.pm', PREREQ_PM = { 'Text::Abbrev' = 0 }, ABSTRACT_FROM = 'ACD.pm', AUTHOR= 'Luke McCarthy '[EMAIL PROTECTED]', ); # You are out of luck. You have to install the latest 5.6.1 perl. You can overwrite your current one or install it in some other place. Better to have all your working script confirm to one version cause it gets messy after sometime trying to support different version of perl. - Do You Yahoo!? Sign-up for Video Highlights of 2002 FIFA World Cup -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Reading File
Hi everybody, I've done a dummy test, and finalized that David's method is the Goal Method, that's really Really Very Great !!! I've made a 50MB Text file ( Fixed length, 1001 char per line, with \n) for this test, and have the following results : SCRIPT 1 # Suggested by Johnson $start = time; open (FH, text.txt); while (FH) { $data = $_ } close (FH); $end = time - $start; print $end.\n; ## END WITH 8 SECs ### # SCRIPT 2 Suggested by myself $start = time; open (FH, text.txt); @FD = FH; close (FH); $data = $FD[$#FD]; $end = time - $start; print $end.\n; ## END WITH 8 SECs ### # SCRIPT 3 # Suggested by David ( I've completing it =)) $start = time; open (FH, text.txt); seek (FH,0,2); ## I use 0 here as I assume the last line is not /^\n$/ $curpos = tell(FH); while (! $PrevEOL) { $data = FH; if ($data !~ /\n$/) { $curpos -- ; seek (FH, $curpos, 0); } else { $PrevEOL = 1 } } $data = FH; close (FH); $end = time - $start; print $end.\n; ## END WITH 0 SEC ( Actually 0.0x Sec) ### Please don't alarm me for omitted to use my , strict and -wT here, I will use them for doing my own script =) Besides, even though the time consume for Johnson's one and mine one are the same (nearly), however, it's better for try Johnson's one. That's beacuse if there are 5 or more clients query this File at the same time, mine one will surely halt the system (WinMe). Wish you have a nice day, Smiley Connie =) Connie..try this and pls see the time diff..this has been taken from Perl Cookbook 8.10 # SCRIPT 4 # $start = time; open (FH, text.txt); while (FH) { $addr = tell(FH) unless eof(FH); } $lastline = seek (FH, $addr,0); print $end.\n; ## END WITH 0 SEC ( Actually 0.0x Sec) ### -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: matching extracharacters
Hi all, I would like to match a string variable in a longer string retreiveing the match plus 5 extra characters at each side of the match. This what I mean: $var = 'something'; $line = 'SDFGHAsomethingWDFTsft'; and, I would like to get in a new variable the string 'DFGHAsomethingWDFTs'. Any help in doing this will be very appreciated. $line = 'SDFGHAsomethingWDFTsft'; $var = something; @x = ($line =~ /(\w{5})($var)(\w{5})/); ##or $newVar = $1.$2.$3; You may consider using eval to precompile the expression in case you have a lot's of records to regex on !! This will speed it up!! Cheers Shishir -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: matching extracharacters
How exactly does on pre-compile the regex? I would be interested in seeing this. [Jess] Three cases: a) Hardcode - /(\w{5})(something)(\w{5})/ b) Intepolate variable in the search variable, value remaining constant throughout the program $var = something /(\w{5})(something)(\w{5})/o c) If the value is going to change, then use eval to build up a whole block I am quoting an example from Perl Cookbook 6.10 (See 6.10 for more details..It discussed on speeding up Interpolated matches) ### @pop = qw(A,B,C,D,E,F,G); $code = 'while defined($line = )) {'; for $state (@pop) { $code .= \tif (\$line =~ /\\b$state\\b/) {print \$line;next;}\n; } $code .= '}'; eval $code; die if @!; # -Original Message- From: Shishir K. Singh [mailto:[EMAIL PROTECTED]] Sent: Monday, June 24, 2002 5:07 PM To: [EMAIL PROTECTED]; [EMAIL PROTECTED] Subject: RE: matching extracharacters Hi all, I would like to match a string variable in a longer string retreiveing the match plus 5 extra characters at each side of the match. This what I mean: $var = 'something'; $line = 'SDFGHAsomethingWDFTsft'; and, I would like to get in a new variable the string 'DFGHAsomethingWDFTs'. Any help in doing this will be very appreciated. $line = 'SDFGHAsomethingWDFTsft'; $var = something; @x = ($line =~ /(\w{5})($var)(\w{5})/); ##or $newVar = $1.$2.$3; You may consider using eval to precompile the expression in case you have a lot's of records to regex on !! This will speed it up!! Cheers Shishir -- 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: Formatting
Hi, Hello, I need to format a string in a fixed width field. The string may be less than the length of the format, or may be greater. If less, then it should get padded with spaces (left or right justified , like using - in sprintf), if greater, then the string should get truncated to the exact length. eg $myVar = 'ABCDEFGHIJKLMNOP'; $newVar = sprintf(%10s,$myVar); $newVar should have 'ABCDEFGHIJ'; # But has the full length i.e. 'ABCDEFGHIJKLMNOP' eg $myVar = 'ABCD'; (Right Aligned, padded with spaces) $newVar = sprintf(%10s,$myVar); $newVar should have ' ABCD'; # Works eg $myVar = 'ABCD'; (Left Aligned, padded with spaces) $newVar = sprintf(%-10s,$myVar); $newVar should have 'ABCD '; # Works I am not able to lay my finger on the correct format to achieve 1st and the 2nd with the same format. Am I missing something , or is there another way out? Any help would be greatly appreciated. Fun with sprintf. :-) $ perl -le' for $word ( qw/ABCDEFGHIJKLMNOP ABCD/ ) { $string = sprintf q/%10.10s %-10.10s %10s %-10s/, ($word) x 4; print $string; $string = sprintf q/%*.*s %-*.*s %*s %-*s/, (10,10,$word) x 2, (10,$word) x 2; print $string; } ' ABCDEFGHIJ ABCDEFGHIJ ABCDEFGHIJKLMNOP ABCDEFGHIJKLMNOP ABCDEFGHIJ ABCDEFGHIJ ABCDEFGHIJKLMNOP ABCDEFGHIJKLMNOP ABCD ABCD ABCD ABCD ABCD ABCD ABCD ABCD Thanks to Mark, John, David and Timothy!! I get the results if I use the combination of eg $myVar = 'ABCDEFGHIJKLMNOP'; $newVar = pack('A10',$myVar); $newVar should have 'ABCDEFGHIJ'; # Works and faster than sprintf eg $myVar = 'ABCD'; $newVar = pack('A10',$myVar); $newVar should have 'ABCD '; # Works and faster than sprintf eg $myVar = 'ABCD'; (Right Aligned, padded with spaces) $newVar = sprintf(%-10.10s, $myVar); $newVar should have ' ABCD'; # Works. Have to use sprintf as nothing available for right justify in pack. Think pack is an elegant way of truncating a string. Thanks Shishir -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Formatting
Hi, I need to format a string in a fixed width field. The string may be less than the length of the format, or may be greater. If less, then it should get padded with spaces (left or right justified , like using - in sprintf), if greater, then the string should get truncated to the exact length. eg $myVar = 'ABCDEFGHIJKLMNOP'; $newVar = sprintf(%10s,$myVar); $newVar should have 'ABCDEFGHIJ'; # But has the full length i.e. 'ABCDEFGHIJKLMNOP' eg $myVar = 'ABCD'; (Right Aligned, padded with spaces) $newVar = sprintf(%10s,$myVar); $newVar should have ' ABCD'; # Works eg $myVar = 'ABCD'; (Left Aligned, padded with spaces) $newVar = sprintf(%-10s,$myVar); $newVar should have 'ABCD '; # Works I am not able to lay my finger on the correct format to achieve 1st and the 2nd with the same format. Am I missing something , or is there another way out? Any help would be greatly appreciated. Thanks Shishir -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
C from Perl
Hi, I have a C program. In there is a function that I need for perl. This is the first time I am dealing with the C / Perl Interface. Is there any detailed reading material on how it's done ?? Any guidance would be highly appreciated. Thanks Shishir -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: C from Perl
It's an custom function in a program. It has relevance to what I am doing and I don't have the heart to translate it in perl right now:) (it's a big function). I was hoping maybe I could perhaps adapt it to be called from the perl program. And nope, there is no module for that in Perl. -Original Message- From: Nikola Janceski [mailto:[EMAIL PROTECTED]] Sent: Tuesday, June 18, 2002 10:06 AM To: Shishir K. Singh; [EMAIL PROTECTED] Subject: RE: C from Perl What's the C function? Is it something standard in C? Or did you/someone write it? and the big question: What does it do? (Most likely if it's general enough someone has written a module for it in Perl). -Original Message- From: Shishir K. Singh [mailto:[EMAIL PROTECTED]] Sent: Tuesday, June 18, 2002 9:58 AM To: [EMAIL PROTECTED] Subject: C from Perl Hi, I have a C program. In there is a function that I need for perl. This is the first time I am dealing with the C / Perl Interface. Is there any detailed reading material on how it's done ?? Any guidance would be highly appreciated. Thanks Shishir -- 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: Code Generating/Compiling
Wouldn't you be needing something like perl2exe or perl2app?? Oops, one problem...they come for a price!! -Original Message- From: Bob Showalter [mailto:[EMAIL PROTECTED]] Sent: Tuesday, June 18, 2002 10:22 AM To: 'Nigel Peck'; [EMAIL PROTECTED] Subject: RE: Code Generating/Compiling -Original Message- From: Nigel Peck [mailto:[EMAIL PROTECTED]] Sent: Tuesday, June 18, 2002 5:26 AM To: [EMAIL PROTECTED] Subject: Code Generating/Compiling Hi all, I realise that a Perl script is comiled just before it is run, and that there is no need to pre-compile a Perl script. However, it is the only way that I can think to be able to leave a Perl script at a customer's site without them being able to see/change the code. I've read the code generating section of the Camel and it clearly says that this technology should not be used in a production environment, so what I really need is some suggestions of how to do this, whether it is by compiling or some other means. As long as the code can't be changed or seen then I'll be happy. There's a FAQ on this: perldoc -q How can I hide the source for my Perl program? Warning: this is a religious topic... -- 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: combining data structures into one array
push (@myVar, @$_) for @$stats; push (@myVar, @$_) for @$totals; push (@myVar, $_) for @$loads; -Original Message- From: Kipp, James [mailto:[EMAIL PROTECTED]] Sent: Tuesday, June 18, 2002 10:32 AM To: [EMAIL PROTECTED] Subject: combining data structures into one array I have a subroutine that returns 3 array refs. so i have: my ($stats, $totals, $loads) = gets_stats(); $stats and $totals are reference to arrays of arrays. $loads is just a ref to an array. what i want to do is is combine each record of each array into one. here is how the structures look: $stats - @array - [user, cpu, mem] $totals - @array - [tot_cpu, tot_mem] $loads - [load1, load2] so i would like to itereate through the records of each of these arrays and end up with @stats = [ user, cpu, mem, tot_cpu, tot_mem, load1, load2] [ ..another record...] [ ..another record...] ...etc I have tried a few things, but no luck. Thanks Jim -- 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: combining data structures into one array
Oops..your Requirements was different.. To achieve, @stats = [ user, cpu, mem, tot_cpu, tot_mem, load1, load2] you need to do push (@$stats, @$totals, $loads); I am assuming User, cpu, mem, tot_cpu, tot_mem are again reference to an array Cheers Shihir -Original Message- From: Shishir K. Singh Sent: Tuesday, June 18, 2002 10:55 AM To: Kipp, James; [EMAIL PROTECTED] Subject: RE: combining data structures into one array push (@myVar, @$_) for @$stats; push (@myVar, @$_) for @$totals; push (@myVar, $_) for @$loads; -Original Message- From: Kipp, James [mailto:[EMAIL PROTECTED]] Sent: Tuesday, June 18, 2002 10:32 AM To: [EMAIL PROTECTED] Subject: combining data structures into one array I have a subroutine that returns 3 array refs. so i have: my ($stats, $totals, $loads) = gets_stats(); $stats and $totals are reference to arrays of arrays. $loads is just a ref to an array. what i want to do is is combine each record of each array into one. here is how the structures look: $stats - @array - [user, cpu, mem] $totals - @array - [tot_cpu, tot_mem] $loads - [load1, load2] so i would like to itereate through the records of each of these arrays and end up with @stats = [ user, cpu, mem, tot_cpu, tot_mem, load1, load2] [ ..another record...] [ ..another record...] ...etc I have tried a few things, but no luck. Thanks Jim -- 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]
RE: combining data structures into one array
Do you mean to say push (@$stats, @$totals, $loads); didn't work ?? -Original Message- From: Kipp, James [mailto:[EMAIL PROTECTED]] Sent: Tuesday, June 18, 2002 11:23 AM To: Shishir K. Singh; Kipp, James; [EMAIL PROTECTED] Subject: RE: combining data structures into one array I am assuming User, cpu, mem, tot_cpu, tot_mem are again reference to an array woops let me clarify. $stats is a ref to an array of anon arrays. so '$stats-[0]' contains a record lie [someuser, 5.5, 10.2] same goes for $totals $loads just refs a single anon array: $loads = [load1, load2] thanks Cheers Shihir -Original Message- From: Shishir K. Singh Sent: Tuesday, June 18, 2002 10:55 AM To: Kipp, James; [EMAIL PROTECTED] Subject: RE: combining data structures into one array push (@myVar, @$_) for @$stats; push (@myVar, @$_) for @$totals; push (@myVar, $_) for @$loads; -Original Message- From: Kipp, James [mailto:[EMAIL PROTECTED]] Sent: Tuesday, June 18, 2002 10:32 AM To: [EMAIL PROTECTED] Subject: combining data structures into one array I have a subroutine that returns 3 array refs. so i have: my ($stats, $totals, $loads) = gets_stats(); $stats and $totals are reference to arrays of arrays. $loads is just a ref to an array. what i want to do is is combine each record of each array into one. here is how the structures look: $stats - @array - [user, cpu, mem] $totals - @array - [tot_cpu, tot_mem] $loads - [load1, load2] so i would like to itereate through the records of each of these arrays and end up with @stats = [ user, cpu, mem, tot_cpu, tot_mem, load1, load2] [ ..another record...] [ ..another record...] ...etc I have tried a few things, but no luck. Thanks Jim -- 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]
No of lines in a file
Hi, Is there a way to get the number of lines in a file. Conditions: a) Without using backticks on wc -l b) Without opening the file and looping over the records Thanks Shishir -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: colon(:) in split --- what does it mean ?
Probably the record is like $split_cellname = ABCDEFGHIJK:12345678 ($cellname = $split_cellname) =~ s/:.*//; $cellname will now have ABCDEFGHIJK $split_cellname =~ s/:.*// = substitute any character starting with : till the end of the string (s/:.*/), in $split_cellname, to NULL (//) = and move this value to $cellname -Original Message- From: pn [mailto:[EMAIL PROTECTED]] Sent: Tuesday, June 18, 2002 11:45 AM To: [EMAIL PROTECTED] Subject: Re: colon(:) in split --- what does it mean ? I came across this snippet of code, in somebody's old code. ($cellname = $split_cellname) =~ s/:.*//; I would like to understand the usage of this statement in general, but in particular, i would like to know the significance of of the colon(:) character in the split function. Thanks PN __ Do You Yahoo!? Yahoo! - Official partner of 2002 FIFA World Cup http://fifaworldcup.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]
RE: No of lines in a file
Uh oh!! Thanks !! Guess I will have to do it the old fashioned way!! -Original Message- From: Bob Showalter [mailto:[EMAIL PROTECTED]] Sent: Tuesday, June 18, 2002 11:51 AM To: Shishir K. Singh; [EMAIL PROTECTED] Subject: RE: No of lines in a file -Original Message- From: Shishir K. Singh [mailto:[EMAIL PROTECTED]] Sent: Tuesday, June 18, 2002 11:47 AM To: [EMAIL PROTECTED] Subject: No of lines in a file Hi, Is there a way to get the number of lines in a file. Conditions: a) Without using backticks on wc -l b) Without opening the file and looping over the records (Of course, wc -l does just what (b) does...) If all the lines are the same length and you know that length: $no_lines = (stat($file))[7] / $record_length; Otherwise, you're stuck. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: combining data structures into one array
Oh Simple...What threw me off is that I though you wanted to use the rest of the arrays in the same format as $stats which is a reference to an anonymous array of anonymous arrays. $stats = [ user, cpu, mem, tot_cpu, tot_mem, load1, load2]; Now I see that you want something like this @stats = (user, cpu, mem, tot_cpu, tot_mem, load1, load2); You can do this # my @myVars = (); push (@myVars, @$stats, @$totals, $loads); ## -Original Message- From: Kipp, James [mailto:[EMAIL PROTECTED]] Sent: Tuesday, June 18, 2002 12:40 PM To: [EMAIL PROTECTED] Subject: RE: combining data structures into one array Shishir and Bob, still can't get it to work. also decided we can leave out $loads, so basically i want to combine $stats and $totals. as bob suggested, here is sample data: ($stats, $totals, $loads) = gets_stats(); when the get_stats() func is called $stats will contain something like this: $stats = [ [ oracle, 6.8, 11.2 ], [ ksh, 1.8, 1.2 ], etc ]; and $totals will have something like: $totals = [ [ 15.8, 17.2 ], [ 3.7, 3.9 ], etc ]; so i want to end up with something like: @stats = ( [oracle, 6.8, 11.2,15.8, 17.2 ], [ksh, 1.8, 1.2, 3.7, 3.9 ], etc... ); thanks. -Original Message- From: Shishir K. Singh [mailto:[EMAIL PROTECTED]] Sent: Tuesday, June 18, 2002 11:04 AM To: Kipp, James; [EMAIL PROTECTED] Subject: RE: combining data structures into one array Oops..your Requirements was different.. To achieve, @stats = [ user, cpu, mem, tot_cpu, tot_mem, load1, load2] you need to do push (@$stats, @$totals, $loads); I am assuming User, cpu, mem, tot_cpu, tot_mem are again reference to an array Cheers Shihir -Original Message- From: Shishir K. Singh Sent: Tuesday, June 18, 2002 10:55 AM To: Kipp, James; [EMAIL PROTECTED] Subject: RE: combining data structures into one array push (@myVar, @$_) for @$stats; push (@myVar, @$_) for @$totals; push (@myVar, $_) for @$loads; -Original Message- From: Kipp, James [mailto:[EMAIL PROTECTED]] Sent: Tuesday, June 18, 2002 10:32 AM To: [EMAIL PROTECTED] Subject: combining data structures into one array I have a subroutine that returns 3 array refs. so i have: my ($stats, $totals, $loads) = gets_stats(); $stats and $totals are reference to arrays of arrays. $loads is just a ref to an array. what i want to do is is combine each record of each array into one. here is how the structures look: $stats - @array - [user, cpu, mem] $totals - @array - [tot_cpu, tot_mem] $loads - [load1, load2] so i would like to itereate through the records of each of these arrays and end up with @stats = [ user, cpu, mem, tot_cpu, tot_mem, load1, load2] [ ..another record...] [ ..another record...] ...etc I have tried a few things, but no luck. Thanks Jim -- 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]
RE: literal to regex
Think you need to use \Q$string\E -Original Message- From: Nikola Janceski [mailto:[EMAIL PROTECTED]] Sent: Thursday, June 13, 2002 11:05 AM To: Beginners (E-mail) Subject: literal to regex I want to convert a bunch of strings to regexs but I want all special characters to be interpreted as themselves literally. so . will be \. and * will \*. so what do I need to change here: my @idl_object_ext = map { qr/$_/ } qw( _g.h s_g.cc c_g.cc ); Delivery Queue http://www/reldist-bin/build/assign/listassign.cgi?reverse=on Nikola Janceski Summit Systems, Inc. 212-896-3400 It is a miracle that curiosity survives formal education. -- Albert Einstein (1879-1955) 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] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: THIS IS A TEST - PLEASE DELETE THIS EMAIL - THANKS
Or..what the hell am I doing here ?? :) -Original Message- From: Nikola Janceski [mailto:[EMAIL PROTECTED]] Sent: Wednesday, June 12, 2002 5:19 PM To: '[EMAIL PROTECTED]' Subject: RE: THIS IS A TEST - PLEASE DELETE THIS EMAIL - THANKS I think these kinds of messages would be cooler if you asked an unanswerable or stupid question like: Can I use the perl debugger to get rid of the mosquitos in my room? -Original Message- From: Ho, Tony [mailto:[EMAIL PROTECTED]] Sent: Wednesday, June 12, 2002 5:12 PM To: '[EMAIL PROTECTED]' Subject: THIS IS A TEST - PLEASE DELETE THIS EMAIL - THANKS 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] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: chop off 1 white space?
Is it only one Trailing white space or any trailing white space?? If any trailing white space , then you can do $HASH{$key} =~ s/\s+$//; If One ... $HASH{$key} =~ s/\s+$//; And then you can compare if ($HASH{$key} eq $myVariable) { } -Original Message- From: Alaric Joseph Hammell [mailto:[EMAIL PROTECTED]] Sent: Tuesday, June 11, 2002 4:27 PM To: [EMAIL PROTECTED] Subject: chop off 1 white space? How would I get rid of one trailing white space character in $HASH{$key} and reassign the result OR how would I match a variable with 1 trailing white space to a variable that has no trailing white space character? Thanks, Al -- 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: chop off 1 white space?
oopsfor one you do $HASH{$key} =~ s/\s$//; -Original Message- From: Shishir K. Singh Sent: Tuesday, June 11, 2002 4:31 PM To: Alaric Joseph Hammell; [EMAIL PROTECTED] Subject: RE: chop off 1 white space? Is it only one Trailing white space or any trailing white space?? If any trailing white space , then you can do $HASH{$key} =~ s/\s+$//; If One ... $HASH{$key} =~ s/\s+$//; And then you can compare if ($HASH{$key} eq $myVariable) { } -Original Message- From: Alaric Joseph Hammell [mailto:[EMAIL PROTECTED]] Sent: Tuesday, June 11, 2002 4:27 PM To: [EMAIL PROTECTED] Subject: chop off 1 white space? How would I get rid of one trailing white space character in $HASH{$key} and reassign the result OR how would I match a variable with 1 trailing white space to a variable that has no trailing white space character? Thanks, Al -- 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]
RE: chop off 1 white space?
^ - Beginning o the string $ - End of the string $myVar =~ s/^\s+//; - Remove all Leading White Space $myVar =~ s/\s+$//; - Remove all Trailing White Space What is your actual requirement ?? -Original Message- From: Alaric Joseph Hammell [mailto:[EMAIL PROTECTED]] Sent: Tuesday, June 11, 2002 4:54 PM To: [EMAIL PROTECTED] Subject: Re: chop off 1 white space? At 01:34 PM 6/11/02 -0700, I wrote: At 04:26 PM 6/11/02 -0400, Alaric Joseph Hammell wrote: How would I get rid of one trailing white space character in $HASH{$key} and reassign the result If you're certain that the last character is a space: chop $HASH{$key}; If it might not be a space, and you only want to get rid of the last character if it is a space: $HASH{$key} =~ s/ $//; Oops, I missed the white part of white space. Then the question is whether you intend white space to include newline. Assuming you don't (which is Perl's definition of white space), then: $HASH{$key} =~ s/\s$//; Ok, What I meant by match was compare or test for equality. Sorry for the confusion. But, could someone explain the meaning of the $ in the above expression, s/\s$// . How would I incorporate in the expression the $string which occurs before the white space? (is that what the $ is for?) Thank you for all the helpful responses, Al -- 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]
IP address
Hello, I have a requirement to get the IP address of a user logged from a remote machine on to UNIX machine. Now the user can be using multiple logins through VPN or otherwise. I need to create something akin to command finger which will return the user his IP address based on his current session. Can someone point me in the right direction of how to do it?? Thanks Shishir -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: IP address
Thanks!! But I want something akin to the value of $REMOTEHOST under tcsh. This can be generalized under unix by doing who am i | sed 's/.*(\(.*\))$/\1/' # as was suggested by one the member..thanks to him!! but will not work under non Unix envi. Here comes in the perl. I was hoping for something which is shell/platform independent. Can it be done ?? -Original Message- From: drieux [mailto:[EMAIL PROTECTED]] Sent: Friday, June 07, 2002 2:18 PM To: perl beginners Subject: Re: IP address On Friday, June 7, 2002, at 09:41 , Shishir K. Singh wrote: I have a requirement to get the IP address of a user logged from a remote machine on to UNIX machine. Now the user can be using multiple logins through VPN or otherwise. I need to create something akin to command finger which will return the user his IP address based on his current session. Can someone point me in the right direction of how to do it?? well there are some problems that you will have here - since basically you seemt to want to track 'back' to the source (??) I will presume that you already have looked an 'man who' and hence can get information like: vladimir: 57:] who warpts/0May 24 13:46(oozer) drieux pts/1Jun 7 10:54(wetware) drieux pts/2Jun 7 10:55(jeeves) drieux pts/3Jun 7 10:57(gax) vladimir: 58:] which shows that I logged into vladimir from wetware - but it of course does not show that I arrived there from jeeves... so what you want is a WhoBe.pl that would gin up say: vladimir: 56:] perl whoBe.pl player drieux is in from: wetware jeeves gax player war is in from: oozer vladimir: 57:] http://www.wetware.com/drieux/pbl/Sys/Admin/whoParser.txt You will of course note, that this will work on solaris and linux and darwin, and will pick up only the 'remote users' - not anyone with a direct login on the box itself - as is the case for folks using those OS's for their desk top. Now you also have the issue that if your DNS is set up so that it can 'resolve' the name - then you will get the name from DNS and not the IP_ADDR - in the case that there is no way to reverse from the IP_ADDR to a name, then you will get a dotQuad. ciao drieux --- -- 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: IP address
My faultI meant the remote hostname. -Original Message- From: Timothy Johnson [mailto:[EMAIL PROTECTED]] Sent: Friday, June 07, 2002 4:38 PM To: 'drieux'; begin begin Subject: RE: IP address Maybe I misunderstood what he was asking. I thought he wanted to find out what the local IP of the clients that were connected were. This would work only if you can have the client run it. -Original Message- From: drieux [mailto:[EMAIL PROTECTED]] Sent: Friday, June 07, 2002 1:08 PM To: begin begin Subject: Re: IP address On Friday, June 7, 2002, at 12:45 , Timothy Johnson wrote: For the Win32 command, something like `ipconfig` =~ /(\d+\.\d+\.\d+\.\d+)/; would work if you just want the ip address, providing you can have the client run it... I thought that merely showed where the 'connections' were coming from... much that same as vladimir: 57:] netstat -naf inet | grep 513.*ESTABLISHED 199.108.16.3.513 199.108.16.6.1020 8760 0 8760 0 ESTABLISHED 199.108.16.3.513 199.108.16.11.70933304 1 10136 0 ESTABLISHED vladimir: 58:] but the problem then is associating the actual 'connected port' to the 'sessions'... or is there a flag I am missing here about ipconfig??? cf: http://www.computerhope.com/ipconfig.htm ciao drieux http://www.wetware.com/drieux/pbl/ -- This space left intentionally blank. -- 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]
RE: IP address
Okay ...the scenario was... I telnet from my PC (remote host) to a UNIX machine with user ABC. Now I can login from another PC on the same UNIX m/c as USER ABC, I just want to know the remote host name (who -m ) so that I can set my DISPLAY environment to the remote host I have achieved it for the time being by putting the following in my ..cshrc (cshell) by doing setenv DISPLAY `who -m | sed 's/.*(\(.*\))$/\1/'`:0.0 -Original Message- From: David T-G [mailto:[EMAIL PROTECTED]] Sent: Friday, June 07, 2002 5:12 PM To: perl beginners Cc: Shishir K. Singh Subject: Re: IP address Shishir -- Would you mind doing us the favor of restating your requirements? So far we have - remote host where the user is sitting (some N hops away) - remote host from which the user connected (0 or 1 hop) - this host when connecting remotely and all of them, of course, have various ramifications. TIA HAND maybe then we can help productively :-D -- David T-G * It's easier to fight for one's principles (play) [EMAIL PROTECTED] * than to live up to them. -- fortune cookie (work) [EMAIL PROTECTED] http://www.justpickone.org/davidtg/Shpx gur Pbzzhavpngvbaf Qrprapl Npg! -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Question- Archive::zip/tar
Hello, I haven't tried it yet and wanted to know if anyone has the clue before I delve deeper into it (just being lazy :)). According to the documentation , the Archive::Tar module supports the *.gz format. I didn't find anything about *.Z (the compress format on UNIX). Does Archive::Tar supports this format but and somehow was skipped in the documentation ? If not, is there a module that does the same for *.Z?? Thanks Shishir -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Question- Archive::zip/tar
Thanks BeauI have been scratching head since morning to see if there is a way out, but to no effect!! I basically wanted to have the Compression utility independent of any platforms, so that I can do uncompress/Compress on tar /gz files on Windows and Zip files on Unix. Except the *.Z format, the others work fine, thanks to Archive::Zip and Archive::Tar. The compress::Zlib does not support *.Z . After having a look at the source code for gzip, which is in C, found that *.Z(compression) is not supported, although *.Z(uncompression) is supported. I have no clue how to improvise the code to work for the *.Z. Any gurus out there who can help ?? Thanks Shishir -Original Message- From: Beau E. Cox [mailto:[EMAIL PROTECTED]] Sent: Wednesday, June 05, 2002 2:16 PM To: Shishir K. Singh; BeginnersPerl (E-mail) Subject: RE: Question- Archive::zip/tar Shishir - I'm using Win32 also (I have Linux on one machine but haven't done much with it yet.) I think that the unix 'tar' utility gives you a .tar file (uncompressed) and then that file is passed thru a compression utility: zip = .tar.z, gzip = .tar.gz, or something like bzip = .tar.bz. Of course, the modern 'tar' program will invoke a compression utility for you via command line switches. Most of the unix tarballs I have seen are in the .tar.gz format. I know this is like the blind leading the blind, but I hope it helps anyway. Aloha = Beau. -Original Message- From: Shishir K. Singh [mailto:[EMAIL PROTECTED]] Sent: Wednesday, June 05, 2002 4:10 AM To: BeginnersPerl (E-mail) Subject: Question- Archive::zip/tar Hello, I haven't tried it yet and wanted to know if anyone has the clue before I delve deeper into it (just being lazy :)). According to the documentation , the Archive::Tar module supports the *.gz format. I didn't find anything about *.Z (the compress format on UNIX). Does Archive::Tar supports this format but and somehow was skipped in the documentation ? If not, is there a module that does the same for *.Z?? Thanks Shishir -- 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: Help in Regular expression with array
Don't know if you can do a search on an array (until and unless you want to evaluate each element) In case you are trying to achieve the multiple lines search, maybe this or the 2nd example can help : open (FILE , $ARGV[0]); my @lines = FILE; close(FILE); $line = join( , @lines); print $line; if( $line =~ /Date:/m) { print ok;} --- else you may try this way in case you have only one file (note) --- while () { print ok if (/Date:/); } else the old way or looping over each element open (FILE , $ARGV[0]); print ok if ( map { /Date:/ } (FILE) ); close FILE; -Original Message- From: Ankit Gupta [mailto:[EMAIL PROTECTED]] Sent: Wednesday, June 05, 2002 3:49 PM To: [EMAIL PROTECTED] Subject: Help in Regular expression with array Hello, I am facing a problem in using regular expression on array. My code is written below: open(FILE, $dirvalue) ; my @lines = FILE; print @lines; # prints the file contents if( @lines =~ m/Date:/) { print ok;} close(FILE); here I can print @lines which gives me: Received: from pc_jrs.spacebel.be (pc_jr) by earth.spacebel (5.x/SMI-SVR4) id AA26092; Sun, 27 Oct 1996 16:44:52 +0100 Date: Sun, 27 Oct 96 17:38:51 PST From: John Reynolds [EMAIL PROTECTED] Subject: Ebnf2ps Now @lines does contain Date: characters but it does not return true anwswer. Could someone please help me as how I can achieve this. Thanx Ankit -- 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: Help in Regular expression with array
Beau..I guess , the evaluation of the expression is not going to be true if no Date: is found. Since map returns a list consisting of the results of each successive evaluation of the expression..., the map will return undef. Although, here..I think using grep would be a better idea!! -Original Message- From: Eric Beaudoin [mailto:[EMAIL PROTECTED]] Sent: Wednesday, June 05, 2002 4:29 PM To: Shishir K. Singh Cc: Ankit Gupta; [EMAIL PROTECTED] Subject: RE: Help in Regular expression with array At 16:12 2002.06.05, Shishir K. Singh wrote: open (FILE , $ARGV[0]); print ok if ( map { /Date:/ } (FILE) ); close FILE; map return an array with the result of the express apply to each line. Even if none of the lines in FILE contain Date:, you will have an array with one value for each line. This is a non empty array i.e. it has multiple lines and when evaluate in a scalar context (with the if() ), it would always be true unless there are no lines in FILE. I think you want grep there as in print ok if (grep /Date:/ ,(FILE)); or print ok if (map { /Date:/ ? $_ : () } , (FILE)); I may be wrong though. Best -- Éric Beaudoin mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Day Month Issues
try putting my before the declaration my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)=localtime(time); -Original Message- From: Lance Prais [mailto:[EMAIL PROTECTED]] Sent: Monday, June 03, 2002 1:55 PM To: Perl Subject: Day Month Issues I am getting the following error when I execute my script. It is not erroring out nor is it not working as I think it should. I am just curious why this is happening. Any Ideas? Thanks Lance CODE: ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)=localtime(time); ERROR: Name main::mday used only once: possible typo at E:\sea621\siebsrvr\BIN\Perl\ in\outlook.pl line 15. Name main::sec used only once: possible typo at E:\sea621\siebsrvr\BIN\Perl\b n\outlook.pl line 15. Name main::isdst used only once: possible typo at E:\sea621\siebsrvr\BIN\Perl bin\outlook.pl line 15. Name main::year used only once: possible typo at E:\sea621\siebsrvr\BIN\Perl\ in\outlook.pl line 15. Name main::mon used only once: possible typo at E:\sea621\siebsrvr\BIN\Perl\b n\outlook.pl line 15. Name main::wday used only once: possible typo at E:\sea621\siebsrvr\BIN\Perl\ in\outlook.pl line 15. Name main::yday used only once: possible typo at E:\sea621\siebsrvr\BIN\Perl\ in\outlook.pl line 15. -- 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: manipulating arrays/scalars
How about writing it like this ?? Assuming a) The numeric value is in 1st col and the text in 2nd col (after :) b) Wherever numeric value is not present, the text is in the first column. c) The numeric value needs to be picked up from the last successful read of the numeric value if not already defined in the input. ## open(MYFILE2, $TMP/$D) || die Cannot open $D: $!\n; my @elem = (); my $storage = ; # default value is space just in case your first record itself is not okay!! while (MYFILE2) { chomp; @elem = split /:/; if ($elem[1]) { push (@a1, $elem[0]); push (@a2, $elem[1]); $storage = $elem[0]; } else { push (@a1, $storage); push (@a2, $elem[0]); } } close(MYFILE2); print $_, \n for @a1; print $_, \n for @a2; __END__ ## it prints 13 12 12 fred nancy lional -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Monday, June 03, 2002 5:25 PM To: [EMAIL PROTECTED] Subject: manipulating arrays/scalars Hi any help appreciated... I am reading a file consisting of lines with upto 2 sets if data seperated by : ie 13:fred 12:nancy lional: each line is split into @a1 and @a2, here is my problem - if line does not have @a2 as in example line 3 above, I want it to take the value from line 2 ie - 12 here is my code that trys to do = foreach $D (@FILES) open(MYFILE2, $TMP/$D) || die Cannot open $D: $!\n; chomp (@source=MYFILE2); @a1=(); @a2=(); $srclen=@source; for ($a=0;$a$srclen;$a++) ($a1[$a], $a2[$a])=split(/:/, $source[$a]); if (grep (!/^[0-9]/, $a1[$a])) help what needs to go here ? # } } close(MYFILE2); } -- 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: help in regular expression
You forgot to add g (global)in the end... $dirstruct =~ s/([\W])/-/g; Cheers Shishir -Original Message- From: Ankit Gupta [mailto:[EMAIL PROTECTED]] Sent: Friday, May 31, 2002 10:53 AM To: [EMAIL PROTECTED] Subject: help in regular expression Hello Friends, I need help in the below written script. $dirstruct =~ s/([\W])/-/; print $dirstruct; here $dirstruct is c:\ankit\test what I need as output is c--ankit-test but the output given by my script is c-\ankit\test Thanx Ankit -- 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 array question
No of elements in an array is given by $#ARRAY_NAME eg the number of element in an array @array is $#array -Original Message- From: Barry Jones [mailto:[EMAIL PROTECTED]] Sent: Friday, May 31, 2002 11:17 AM To: Beginners @ Perl (E-mail) Subject: Simple array question What type of functions are built in to perl for arrays? Mainly, I'm looking to find out how to see how many elements are in an array without counting them, but I was wondering about others too. What about hashes? Barry Jones DATABUILT, Inc. The Global AEC Information Company 1476 Fording Island Rd. Bluffton, SC 29910 (843) 836-2166 office Life is like a dogsled team; if you ain't the lead dog, the scenery never changes. - Lewis Grizzard -- 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 array question
oops $#array is the index index of the last element -Original Message- From: Shishir K. Singh Sent: Friday, May 31, 2002 11:23 AM To: Barry Jones; Beginners @ Perl (E-mail) Subject: RE: Simple array question No of elements in an array is given by $#ARRAY_NAME eg the number of element in an array @array is $#array -Original Message- From: Barry Jones [mailto:[EMAIL PROTECTED]] Sent: Friday, May 31, 2002 11:17 AM To: Beginners @ Perl (E-mail) Subject: Simple array question What type of functions are built in to perl for arrays? Mainly, I'm looking to find out how to see how many elements are in an array without counting them, but I was wondering about others too. What about hashes? Barry Jones DATABUILT, Inc. The Global AEC Information Company 1476 Fording Island Rd. Bluffton, SC 29910 (843) 836-2166 office Life is like a dogsled team; if you ain't the lead dog, the scenery never changes. - Lewis Grizzard -- 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]
RE: Printing all elements of an Array except the first?
I generally do it the tough way :( ### open (CUST, $cust) or die Cant open it :$!; $newnum = 0; while (CUST) { chomp; @data = split /\|/; $newnum++; $hData{$data[1]}{$newnum} = [@data]; # 2 dimensional hash used in case your 2nd element may be same across records } close (CUST); open WRFILE, $wrfile; select (WRFILE); foreach (sort {$a = $b} keys %hData) { foreach $inIndex (sort {$a = $b} keys %{$hData{$_}}) { print ;, @{$hData{$_}{$inIndex}}, ;, \n; } } close (WRFILE); __END__ # if the file is huge and all the data cannot be stored in the hash for memory shortage, then I would create a temporary file in which the fist element would be be the 2nd element of the original file and then sort on the file and then edit the temporary file to remove the first element. Any better ideas friends?? -Original Message- From: Ned Cunningham [mailto:[EMAIL PROTECTED]] Sent: Friday, May 31, 2002 11:27 AM To: 'David T-G'; perl beginners Cc: Ned Cunningham Subject: RE: Printing all elements of an Array except the first? OOPS :-( I wanted to sort the file that I am writing, by the second element in @DATA? Snip open CUST, $cust or die Cant open it :$!; open WRFILE, $wrfile; while (defined ($line = CUST)) { chomp $line; @data = split(/\|/,$line); $newnum=$newnum+1; printf WRFILE (0%9d,$newnum); print WRFILE ;, @data, ;; print WRFILE \n; } -Original Message- From: David T-G [mailto:[EMAIL PROTECTED]] Sent: Friday, May 31, 2002 11:22 AM To: perl beginners Cc: Ned Cunningham Subject:Re: Printing all elements of an Array except the first? Ned -- ...and then Ned Cunningham said... % % Great, % Now how about sorting on the new first element of the array each time I % step through a file??? How about a little more detail? I'm not sure quite what you mean by new; you top-posted instead of providing any contextual reference. Given input of a b c d e f g h i a a a do you want to sort on the b/f/a elements, or something else? If you do, then - do you ever need the first elements, or can you just throw them away at read time and then sort naturally? - is there any reason not to whip up a little sort that's based on that element? In the last case, I envision something about like sort { $a[1] = $b[1] } or so... :-D -- David T-G * It's easier to fight for one's principles (play) [EMAIL PROTECTED] * than to live up to them. -- fortune cookie (work) [EMAIL PROTECTED] http://www.justpickone.org/davidtg/Shpx gur Pbzzhavpngvbaf Qrprapl Npg! -- 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]