RE: Comparing Arrays
> > In the "quick and dirty" category, you can do something like this: > > > > (I'm trying to remember off the top of my head) > > > > ## > > > > my $result = ArrayCmp(\@array1,\@array2); > > #pass two array references > > > > sub ArrayCmp{ > > my($ref1,$ref2) = @_; > > my %tmp = (); > > if(@{$ref1} != @{$ref2}){ > > return 0; > > #if arrays are not same length, > > #then skip the rest > > } > > foreach(@{$ref1}){ > > $tmp{$_} = 1; > > #create a temporary hash with the elements > > #as keys > > } > > foreach(@{$ref2}){ > > return 0 unless $tmp{$_}; > > #fail if there is not a key with each > > #element of the second array > > } > > return 1; > > #if we make it this far, they're equal > > } > > But what if the @$ref1 contains an element not in @$ref2? > > I just found out I can shorten my one-liner to: > >@foo==@bar && "@{{map {$_, $_} @foo}}{@bar}" eq "@bar" Thanks, this was perfect for my situation, the arrays contain file listing in directories, so there cant be duplicates. Well unless u have a file like "foo" and "foo " but thats highly unlikely i think. I was hoping you could explain your one liner to me from what i can tell, it *should* be giving an error about being unable to coerce an array to a hash, but it seems to work fine, it's driving me nuts :) Merritt > > But mine has a similar defect: > >qw(foo foo bar) is considered equal to qw(foo bar bar) > > Rats! That's why to stick with proven modules! > > > > > # > > > > > > > > -Original Message- > > From: Bob Showalter > > To: 'Merritt Krakowitzer'; Beginners > > Sent: 7/23/02 5:49 AM > > Subject: RE: Comparing Arrays > > > > > -Original Message- > > > From: Merritt Krakowitzer [mailto:[EMAIL PROTECTED]] > > > Sent: Tuesday, July 23, 2002 3:48 AM > > > To: Beginners > > > Subject: Comparing Arrays > > > > > > > > > Hi > > > > > > I would like to know how to compare 2 arrays. > > > > > > I have 2 arrays and I would like to compare the contents of > > the data. > > > It doesn't matter in which order the data is stored so long > > > as its the same. > > > So comparing the bellow should read true, but if they didn't > > > match it would > > > be false. > > > > > > my @foo = qw( > > > foo bar cat dog > > > ); > > > my @bar = qw( > > >dog cat foo bar > > > ); > > > > > > Hope that made some sense. > > > I managed to find a module for comparing arrays but I would > > > prefer not to > > > do it that way. > > > > Well, they are equal without regard to order if the following is true: > > > > @foo==@bar && join($", @{{map {$_, $_} @foo}}{@bar}) eq "@bar" > > > > But the module approach is probably the way to go. :~) > > > > -- > > 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: Hi, newbie question
On Mon, 2002-07-22 at 14:41, Desmond Lee wrote: > Hi guys > > I'm trying to read a file, but it's just one massive line. I think that the > ^M is suppose to be an indication that that's wehre teh newline is suppose > to be. I've tried to replace ^M with a newline by executing something that i > found on the web: > > perl -pi.bak -e 's/\^M/\n/g' moby_threads_install.txt try: perl -pi.bak -e 's/\r/\n/g' moby_threads_install.txt -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Please help with Database issue
From: Wiggins d'Anconia <[EMAIL PROTECTED]> > > > > > Could you ask them if they would install (or have already installed) > > DBI and DBD::CSV or DBD::File? You could then convert your database > > to flat files or CSVs on your side (by a Perl script that would just > > connect the Access via DBD::ODBC, the CSVs/Files, and would copy all > > tables), upload the files and use them as a database. > > > > Even better option might be DBD::SQLite. That's a "whole" SQL > > compatible database in Perl module. It is quicker than > > DBD::CSV/DBD::File and the whole database is just one file, just > > like Access. > > > > With respect to asking them to install those various modules, if my > understanding is correct, even if you can't get htem to install the > modules you should be able to install them into your personal file > space and call them from there, though there may be compilation issues > (of the modules themselves that is), and manipulation of @INC, etc. I > defer to the "elders" on this matter, though it worked for me when my > hosting provider wouldn't install Email::Valid (granted this is a much > simpler module). Yes you could do this. I do not think though you will be able to compile them ON the server. Therefore you need access to a computer with the same OS and perl. On that computer you may then compile the module: cd temp/the-module-x.y perl Makefile.PL make make test and then copy the directories and files from ./blib/arch and ../blib/lib to the server, to a directory that's not accessible via web. All modules may go to the same directory. Just make sure you copy the directory structure. The fact that ./blib/arch and ./blib/lib may contain the same subdirectories and even .exists files is OK. If you then need to use on of the modules you installed yourself then add use lib '/path/to/the/directory/where/you/uploaded/it'; on top of your script and you should be done. If the server is using Windows and you do not have a compiler, just download the PPM distribution, unpack it to get the blib directory and then continue at explained above. The modules in the ActiveState repository may be found at http://www.activestate.com/PPMPackages/zips/6xx-builds-only/?_x=1 There you can download ZIPs that contain a .ppd and a .tar.gz. You have to extract the .tar.gz and then unpack that one. If you need something from my repository (like the DBD::SQLite for example) you just download the *-PPM.tar.gz from http://Jenda.Krynicky.cz/perl/ HTH, Jenda === [EMAIL PROTECTED] == http://Jenda.Krynicky.cz == There is a reason for living. There must be. I've seen it somewhere. It's just that in the mess on my table ... and in my brain I can't find it. --- me -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Comparing Arrays
> -Original Message- > From: Merritt Krakowitzer [mailto:[EMAIL PROTECTED]] > Sent: Wednesday, July 24, 2002 4:19 AM > To: Bob Showalter; 'Timothy Johnson'; 'Beginners ' > Subject: RE: Comparing Arrays > > > I just found out I can shorten my one-liner to: > > > >@foo==@bar && "@{{map {$_, $_} @foo}}{@bar}" eq "@bar" > > Thanks, this was perfect for my situation, the arrays contain > file listing > in directories, > so there cant be duplicates. Well unless u have a file like > "foo" and "foo " > but thats highly unlikely i think. > > I was hoping you could explain your one liner to me from what > i can tell, it > *should* > be giving an error about being unable to coerce an array to a > hash, but it > seems to > work fine, it's driving me nuts :) OK, here's how it works. @foo==@bar && "@{{map {$_, $_} @foo}}{@bar}" eq "@bar" ^^ Part A Part B Part A checks that the length of the two arrays is the same. The use of "==" causes the two operands to be evaulated in scalar context. Since an array name in scalar context evaluates to the number of elements in the array, we are comparing the lengths of the arrays. Part B checks that @foo contains each of the elements in @bar. Let's break it down: map {$_, $_} @foo map() constructs a list by evaluating the block repeatedly for each element in the input array, @foo. The block is evaulated in list context, so can return multiple values. Inside the block, $_ is aliased to the current value from @foo being processed. So the block {$_, $_} returns a pair of values for each input value. If @foo contains qw(foo bar baz), then the output of map will be qw(foo foo bar bar baz baz). { map {$_, $_} @foo } The braces here are an anonymous hash constructor. This turns the list into a reference to a hash. So, if @foo was qw(foo bar baz), we now have a hash that looks like foo=>'foo', bar=>'bar', baz=>'baz' @{{map {$_, $_} @foo}}{@bar} This is a hash slice operation. The basic format is: @{hashref}{list} The hashref is the anonymous hash created above. The list is the list of values from @bar. The hash slice returns a list of *values* from the hash which correspond to the *keys* named in the second list (i.e. @bar). Since the hash values and hash keys are the same (from the map() operation), and are just the entries from @foo, the result of the hash slice is a list of @foo entries matching each @bar entry, and in the order they appear in @bar. Now, if @bar contains an entry NOT found in the hash, the slice operation will return undef in that position in the list. For example, if @foo is qw(foo bar baz) and @bar is qw(baz qux foo), the hash slice will return the list 'baz', undef, 'foo'. Now the trick is to just compare these two lists. "@{{map {$_, $_} @foo}}{@bar}" eq "@bar" By enclosing the arrays in double quotes, I'm taking advantage of Perl's variable interpolation. When an array appears in double quotes, its elements are concatenated, with elements separated by the value of $" (by default, a space). So, in the example above, this expands to: "baz foo" eq "baz qux foo" (The undef in the second position expands to a zero-length string) Since these strings aren't equal, the two arrays aren't equal. Part A (checking the length of the arrays) is done to make sure @foo doesn't have "extra" elements not in @bar. The hash slicing business would not detect that. There may be other defects in this besides the duplicate issue I mentioned. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How to expand Unix command in echo statement?
On Tuesday, July 23, 2002, at 03:43 , kent ho wrote: > Please help. I want to expand the "date" command in the echo command: > > Ex: > > $log="/tmp/ito.log" > `echo Warning: some text > $log` > > I need to expand the "date" command somewhere in this echo command, please > show me how. why go outside of perl to invoke the 'write to stdout' of 'echo' and then redirect it to a file??? in the shell the command would have looked like echo "Warning: `date` some text" > $log hence you would want something like: [jeeves:~] drieux% perl -e 'my $word_up = `echo -n "Warning \`date\` some text"`;\ print "<< $word_up>>\n";' as others have noted you may wish to look at doing this IN perl with perl's time functions cf: perldoc localtime you may also want to think in terms of a 'log_me' function that knows how to hide that ciao drieux --- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
please help with CPAN
Hello: I have an account on linux box but I am not root. I would like to install some module like Bioperl in my own directory using CPAN. Is it possible to do this. if so, what do I configure to install in my own directory or what is command? Please help me with CPAN. I tried the documents about CPAN, I might have missed it. Thank you. Dinakar -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
PM installation problem
I 've just downloaded a "Imager" module, however, that's a .tar.gz file and I am using Win Me. After I extract the file, there are quite sort of files and dirs. So... how can I install it to my Perl lib or site/lib ? Rgds, Connie -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
That seems interesting ? but I don't know why ?
In normal case, when we want to swap 2 var, , say $x and $y, we do in this way : $z = $x; $x = $y; $y = $z; # Swapped today, I suddenly found a code like this : $x ^= $y ; $y ^= $x ; $x ^= $y; # Swapped It works !! but how that works ? Could anybody tell me ? Rgds, Connie -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
C Beginners List? question, sorry,...
please forgive this su*perl*flu*ous question. This board is a great resource to try, ask, study and learn. Does anyone here know if there is such a board (a 'high' volume, daily archive, not just google groups/usenet) for the C Language and 'new' users in particular. I know, depending on who you ask C is "dead" but it still runs *nix. Thank you (running GNU Compiler (gcc-2.95) in particular) -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
threads in perl
Hello All, I want to execute same perl procedure with different parameters at the almost same time in a perl program indefendantly. (next process should be started without waiting for the end of previous one) The procedure is located in .pm file. How can I use thread in perl to get my work done? regards Rohana. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
trouble comparing dates from two different modules
Hello all, I am using add_delta_workdays() from Date::Calendar to determine whether yesterday was or was not a business day. In order to do this, I am trying to compare it with a date output from Add_Delta_Days from Date::Calc. What I'd *like* to do is stringify the output from both of these functions, as they both return objects. Is this possible? If I do something like: ($year,$month,$day) = Today(); $yesterday = Add_Delta_Days($year,$month,$day, -1); $cal = Date::Calendar->new( $Profiles->{'US'} ); ($prev_business_day,$rest) = $cal->add_delta_workdays($year,$month,$day, -1); I can print out the contents of $yesterday and $prev_business_day and seemingly get stringified output, but if I try to do something like: if ($yesterday ne $prev_business_day) { } I get "Date::Calc::_not_equal_date_time_(): can't compare a date and a delta vector at test.pl" So my question is either 1) Can I stringify an object or 2) What is the best way to perform the comparison I am trying to perform? Thanks much in advance. -I -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: That seems interesting ? but I don't know why ?
On Jul 25, Connie Chan said: >In normal case, when we want to swap 2 var, >, say $x and $y, we do in this way : > >$z = $x; $x = $y; $y = $z; # Swapped Perl allows you to do ($x, $y) = ($y, $x); >$x ^= $y ; $y ^= $x ; $x ^= $y; # Swapped > >It works !! but how that works ? Because of the way XOR works. A XOR (A XOR B) = B Here's a less tricky example: $x = 10; $y = 13; $x = $x + $y; # 10 + 13 = 23 $y = $x - $y; # 23 - 13 = 10 $x = $x - $y; # 23 - 10 = 13 And then with XOR: $x = 10; # 1010 $y = 13; # 1101 $x = $x ^ $y; # 1010 ^ 1101 = 0111 $y = $x ^ $y; # 1101 ^ 0111 = 1010 $x = $x ^ $y; # 0111 ^ 1010 = 1101 -- Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/ ** Look for "Regular Expressions in Perl" published by Manning, in 2002 ** what does y/// stand for? why, yansliterate of course. [ I'm looking for programming work. If you like my work, let me know. ] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: threads in perl
perldoc thread This turned up a library on how to thread processes in perl. Seemed fairly straightforward. (though it did say it was experimental, so there may be a better module out there?) -Tony -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Wednesday, July 24, 2002 1:57 AM To: [EMAIL PROTECTED] Subject: threads in perl Hello All, I want to execute same perl procedure with different parameters at the almost same time in a perl program indefendantly. (next process should be started without waiting for the end of previous one) The procedure is located in .pm file. How can I use thread in perl to get my work done? regards Rohana. -- 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: That seems interesting ? but I don't know why ?
> -Original Message- > From: Connie Chan [mailto:[EMAIL PROTECTED]] > Sent: Wednesday, July 24, 2002 12:08 PM > To: [EMAIL PROTECTED] > Subject: That seems interesting ? but I don't know why ? > > > In normal case, when we want to swap 2 var, > , say $x and $y, we do in this way : > > $z = $x; $x = $y; $y = $z; # Swapped Nah, that's the C way. See below... > > today, I suddenly found a code like this : > > $x ^= $y ; $y ^= $x ; $x ^= $y; # Swapped > > It works !! but how that works ? > Could anybody tell me ? Well, it only works for integers. It's because of the way ^ (bitwise xor) works. Given x=0 and y=1, for instance: x = x ^ yy = y ^ x x = x ^ y x = 0 ^ 1y = 1 ^ 1 x = 1 ^ 0 x = 1y = 0 x = 1 So, now x=1 and y=0. You can prove this for any combination of x and y in the range 0..1 (1 bit). The ^ performs the operation on each bit of a larger integer. But the "Perl way" to swap any given $x and $y is: ($x, $y) = ($y, $x); -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: PM installation problem
If you're using activestate perl on your windows box, just use ppm. Just type ppm to enter the package manager, then install package:name and it does the work for you. -Tony -Original Message- From: Connie Chan [mailto:[EMAIL PROTECTED]] Sent: Wednesday, July 24, 2002 11:04 AM To: [EMAIL PROTECTED] Subject: PM installation problem I 've just downloaded a "Imager" module, however, that's a .tar.gz file and I am using Win Me. After I extract the file, there are quite sort of files and dirs. So... how can I install it to my Perl lib or site/lib ? Rgds, Connie -- 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: C Beginners List? question, sorry,...
hi david: try cprogramming.com. regards, francis david wrote: > please forgive this su*perl*flu*ous question. > > This board is a great resource to try, ask, study and learn. Does anyone here > know if there is such a board (a 'high' volume, daily archive, not just > google groups/usenet) for the C Language and 'new' users in particular. > > I know, depending on who you ask C is "dead" but it still runs *nix. Thank you > > (running GNU Compiler (gcc-2.95) in particular) > > -- > 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]
trouble comparing dates from two different modules
Hello all, I am using add_delta_workdays() from Date::Calendar to determine whether yesterday was or was not a business day. In order to do this, I am trying to compare it with a date output from Add_Delta_Days from Date::Calc. What I'd *like* to do is stringify the output from both of these functions, as they both return objects. Is this possible? If I do something like: ($year,$month,$day) = Today(); $yesterday = Add_Delta_Days($year,$month,$day, -1); $cal = Date::Calendar->new( $Profiles->{'US'} ); ($prev_business_day,$rest) = $cal->add_delta_workdays($year,$month,$day, -1); I can print out the contents of $yesterday and $prev_business_day and seemingly get stringified output, but if I try to do something like: if ($yesterday ne $prev_business_day) { } I get "Date::Calc::_not_equal_date_time_(): can't compare a date and a delta vector at test.pl" So my question is either 1) Can I stringify an object or 2) What is the best way to perform the comparison I am trying to perform? Thanks much in advance. -I -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: C Beginners List? question, sorry,...
yep, [EMAIL PROTECTED] just got to yahoo and yahoo groups and sign up for it. C is very much alive > -Original Message- > From: david [mailto:[EMAIL PROTECTED]] > Sent: Wednesday, July 24, 2002 1:53 AM > To: [EMAIL PROTECTED] > Subject: C Beginners List? question, sorry,... > > > please forgive this su*perl*flu*ous question. > > This board is a great resource to try, ask, study and learn. > Does anyone here > know if there is such a board (a 'high' volume, daily > archive, not just > google groups/usenet) for the C Language and 'new' users in > particular. > > I know, depending on who you ask C is "dead" but it still > runs *nix. Thank you > > (running GNU Compiler (gcc-2.95) in particular) > > -- > 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: PM installation problem
Thanks a lot =) but this method don't work for me... because the cpan server ( I guess ) don't carry this module.. so, both ppm and ppm3 not work. So have to download it by myself, but ... dunno how to install. Any else further advise ? Rgds, Connie - Original Message - From: "Akens, Anthony" <[EMAIL PROTECTED]> To: "Connie Chan" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]> Sent: Thursday, July 25, 2002 12:26 AM Subject: RE: PM installation problem If you're using activestate perl on your windows box, just use ppm. Just type ppm to enter the package manager, then install package:name and it does the work for you. -Tony -Original Message- From: Connie Chan [mailto:[EMAIL PROTECTED]] Sent: Wednesday, July 24, 2002 11:04 AM To: [EMAIL PROTECTED] Subject: PM installation problem I 've just downloaded a "Imager" module, however, that's a .tar.gz file and I am using Win Me. After I extract the file, there are quite sort of files and dirs. So... how can I install it to my Perl lib or site/lib ? Rgds, Connie -- 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: That seems interesting ? but I don't know why ?
Warning: lots of 0 and 1 ahead. Typos are lurking... On Thu, Jul 25, 2002 at 12:08:09AM +0800, Connie Chan wrote: > In normal case, when we want to swap 2 var, > , say $x and $y, we do in this way : > > $z = $x; $x = $y; $y = $z; # Swapped > > today, I suddenly found a code like this : > > $x ^= $y ; $y ^= $x ; $x ^= $y; # Swapped > > It works !! but how that works ? > Could anybody tell me ? XORing a variable twice with the same value restores its original value: $a = 0x55 $b = 0xff $a xor $b xor $b gives the old $a 0x55 xor 0xff xor 0xff is a no-op. Now, letst do one xor and store this in $a. No information is lost and $a now documents the differences between $a_old and $b. Note that the order in an xor operation is interchangable $a xor $b <=> $b xor $a So, by doing the xor again, but not storing it in $a and recovering the initial state, but storing it in $b, we've assigned the initial $a to $b. Now, $a still contains the initial differences between the two and $b contains the initial $a. Remember, the XORs are interchangeble. We have the initial $a and the differences, which must result in the initial $b when XORed. Assigning the result to $a finishes the swap. 0. $a = 0x55 => 01010101 binary $b = 0xff => binary 1. $a 01010101 XOR $b Is 10101010 which goes into $a (These are the differences) 2. $a 10101010 XOR $b Is 01010101 which goes into $b ($b now contains $a_initial) 3. $a 10101010 XOR $b Is 01010101 which then goes into $a ($a now contains $b_initial) Vila! Try different numbers like 0x55 vs 0xaa or 0x33 vs 0xaa... It's an old trick from the Assembler times. XOR was 1cycle op and the whole thing only needed 2 registers. The alternative would have been a 3rd register or a memory/stack operation. Drieux might provide us with some benchmarks about which one's faster these days... ;-) -- Well, then let's give that Java-Wussie a beating... (me) Michael Lamertz| +49 221 445420 / +49 171 6900 310 Nordstr. 49| [EMAIL PROTECTED] 50733 Cologne | http://www.lamertz.net Germany| http://www.perl-ronin.de -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: trouble comparing dates from two different modules
On Wednesday, July 24, 2002, at 09:05 , Ian Zapczynski wrote: [..] > What I'd *like* to do is stringify the output from both of these > functions, as they both return objects. Is this possible? If I do > something like: > > ($year,$month,$day) = Today(); > $yesterday = Add_Delta_Days($year,$month,$day, -1); > > $cal = Date::Calendar->new( $Profiles->{'US'} ); > ($prev_business_day,$rest) = $cal->add_delta_workdays($year,$month,$day, > -1); > > I can print out the contents of $yesterday and $prev_business_day and > seemingly get stringified output, but if I try to do something like: > > if ($yesterday ne $prev_business_day) { > > } > > I get "Date::Calc::_not_equal_date_time_(): can't compare a date and a > delta vector at test.pl" > A strategy you may want to play is to use the Data::Dumper and see if you can 'dig into' the "object" a bit... to find what they really 'share' in common that you can compare with. Your basic 'strategy' seems reasonable - since if you can get to the 'julian date' then you can have your numerical compare... eg: [jeeves:~] drieux% cal -j July 2002 S M Tu W Th F S 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 [jeeves:~] drieux% for some strange reason - people talk about the 'string' july 4th rather than 185 + $leapyear The problem of course is that this year for some Julian Day 186 was a 'banking holiday' and/or 'half day' for others it was just another 'Hawaiian T-shirt Friday' ciao drieux --- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Fw: Checking if a file is downloading
> Content-type: application/octet-stream > Content-Disposition: attachment\; filename=$file This seems IE way, if I don't remember it wrongly, this does not work at NS Anyway, how about this ? $| = 1; my $file = 'yourfile.ext'; print "Content-type: application/(your file type)\r\n\r\n"; open FH, $file; binmode(FH); binmode(STDOUT); until (eof FH) { read (FH, my $buf, 1) ; print $buf } close (FH); unlink ($file); # Code not tested, try it if you would like to =) Rgds, Connie -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
another sort question (flame away)
Hello all, My hash keys look something like this: >1234 x5 So I am thinking a cmp, as opposed to <=> is best. What I want is for the keys to be sorted as follows: >1 x >2 x >3 x .. .. .. >n x This is what I have in my script at the moment: my @sort_this = keys %final_list; my @sorted = sort { $a cmp $b } @sort_this; for (@sorted) { print OUT "$_\n$final_list{$_}\n" } This gives >1 x >10 x >100 x >1000 x >1001 x etc. Any suggestions? I'm not asking for you to spell it out for me with code and all unless you really want to. Sorry if this is a dumb question. cheers, nathanael "I think for my lunch tomorrow I'll make a tuna and pickle triangle bunwich." -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: another sort question (flame away)
If you want ascending numeric then <=> vs cmp ( ascii ) and you have it. Wags ;) -Original Message- From: nkuipers [mailto:[EMAIL PROTECTED]] Sent: Wednesday, July 24, 2002 10:39 To: [EMAIL PROTECTED] Subject: another sort question (flame away) Hello all, My hash keys look something like this: >1234 x5 So I am thinking a cmp, as opposed to <=> is best. What I want is for the keys to be sorted as follows: >1 x >2 x >3 x ... ... ... >n x This is what I have in my script at the moment: my @sort_this = keys %final_list; my @sorted = sort { $a cmp $b } @sort_this; for (@sorted) { print OUT "$_\n$final_list{$_}\n" } This gives >1 x >10 x >100 x >1000 x >1001 x etc. Any suggestions? I'm not asking for you to spell it out for me with code and all unless you really want to. Sorry if this is a dumb question. cheers, nathanael "I think for my lunch tomorrow I'll make a tuna and pickle triangle bunwich." -- 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: another sort question (flame away)
not a dumb question... I actually have the same problem. I have version numbers that look like this: V1.2.3 V1.2.20 V1.2.23 and it sorts it wrong with cmp and <=> soo.. I had to come up with my own sort subroutine here is very generic one that breaks up the elements by \w (word types [a-Z0-9]) that I made and works like a champion. to use it: use strict; use warnings; my @sorted = sort { wordtype() } @your_array; # for reverse my @sorted = sort { wordtype($b, $a) } @your_array; sub wordtype { # # Inputs: $a, $b (not required) # # Globals: $a $b # # Subs called: NONE # # Purpose: sort \w chars in groups # numerically if numbers # # Returns: sort ordering (1,0,-1) # my ($a, $b); if(exists $_[0]){ $a = $_[0]; } else { no strict 'refs'; $a = ${caller()."::a"}; } if(exists $_[1]){ $b = $_[1]; } else { no strict 'refs'; $b = ${caller()."::b"}; } my @first = split /\W/, $a; my @second = split /\W/, $b; for(my $n = 0; $n <= $#first; $n++){ if($first[$n] =~ /^\d+$/ && $second[$n] =~ /^\d+$/){ return $first[$n] <=> $second[$n] if $first[$n] <=> $second[$n]; } else { return $first[$n] cmp $second[$n] if $first[$n] cmp $second[$n]; } } return 0; } ## END wordtype > -Original Message- > From: nkuipers [mailto:[EMAIL PROTECTED]] > Sent: Wednesday, July 24, 2002 1:39 PM > To: [EMAIL PROTECTED] > Subject: another sort question (flame away) > > > Hello all, > > My hash keys look something like this: > > >1234 x5 > > So I am thinking a cmp, as opposed to <=> is best. > > What I want is for the keys to be sorted as follows: > > >1 x > >2 x > >3 x > .. > .. > .. > >n x > > This is what I have in my script at the moment: > > my @sort_this = keys %final_list; > my @sorted = sort { $a cmp $b } @sort_this; > for (@sorted) { print OUT "$_\n$final_list{$_}\n" } > > This gives > > >1 x > >10 x > >100 x > >1000 x > >1001 x > > etc. > > Any suggestions? I'm not asking for you to spell it out for > me with code and > all unless you really want to. Sorry if this is a dumb question. > > cheers, > > nathanael > > "I think for my lunch tomorrow I'll make a tuna and pickle > triangle bunwich." > > > -- > 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: another sort question (flame away)
> -Original Message- > From: nkuipers [mailto:[EMAIL PROTECTED]] > Sent: Wednesday, July 24, 2002 1:39 PM > To: [EMAIL PROTECTED] > Subject: another sort question (flame away) > > > Hello all, > > My hash keys look something like this: > > >1234 x5 > > So I am thinking a cmp, as opposed to <=> is best. > > What I want is for the keys to be sorted as follows: > > >1 x > >2 x > >3 x > .. > .. > .. > >n x > > This is what I have in my script at the moment: > > my @sort_this = keys %final_list; > my @sorted = sort { $a cmp $b } @sort_this; > for (@sorted) { print OUT "$_\n$final_list{$_}\n" } > > This gives > > >1 x > >10 x > >100 x > >1000 x > >1001 x > > etc. > > Any suggestions? I'm not asking for you to spell it out for > me with code and > all unless you really want to. <=> should probably still work, because when evaluating a string as a number, Perl will evaluate up to the first character that doesn't look like part of a number. so "1234 x5" evalutates as the number 1234 (stops at the space char). If the number you want to sort by is not at the beginning of the string (leading blanks are OK), you have to write a more elaborate comparison routine. Have you tried just using <=>? If it doesn't work for you, post a specific example that illustrates the problem. > Sorry if this is a dumb question. Nah, it's a good question. Anyway, we get spanked if we even look sideways at somebody (speaking as one who's been spanked) :~) -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: another sort question (flame away)
Nikola Janceski wrote at Wed, 24 Jul 2002 19:45:54 +0200: > not a dumb question... I actually have the same problem. I have version numbers that >look like > this: > > V1.2.3 > V1.2.20 > V1.2.23 > > and it sorts it wrong with cmp and <=> > > soo.. I had to come up with my own sort subroutine For that special purpose it wouldn't be necessary. Sort::Versions from the CPAN could it do, too. Greetings, Janek -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: threads in perl
rohana wrote at Wed, 24 Jul 2002 08:57:17 +0200: > I want to execute same perl procedure with different parameters at the almost same >time in a perl > program indefendantly. (next process should be started without waiting for the end >of previous > one) The procedure is located in .pm file. How can I use thread in perl to get my >work done? It's easy when you have perl 5.8.0 installed. Then a simple perldoc threads will help you. E.g. use threads; $| = 1; threads->create(sub {while (1) { print "1"; sleep 1 } }); threads->create(sub {while (1) { print "2"; sleep 1 } }); while ("don't stop the main loop") { sleep (1); } shows behaviour of threads. Best Wishes, Janek -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: another sort question (flame away)
yeah.. but that's not all I use it for =P > -Original Message- > From: Janek Schleicher [mailto:[EMAIL PROTECTED]] > Sent: Wednesday, July 24, 2002 1:22 PM > To: [EMAIL PROTECTED] > Subject: RE: another sort question (flame away) > > > Nikola Janceski wrote at Wed, 24 Jul 2002 19:45:54 +0200: > > > not a dumb question... I actually have the same problem. I > have version numbers that look like > > this: > > > > V1.2.3 > > V1.2.20 > > V1.2.23 > > > > and it sorts it wrong with cmp and <=> > > > > soo.. I had to come up with my own sort subroutine > > For that special purpose it wouldn't be necessary. > Sort::Versions > from the CPAN could it do, too. > > > Greetings, > Janek > > > -- > 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: another sort question (flame away)
Bob wrote: <=> should probably still work, because when evaluating a string as a number, Perl will evaluate up to the first character that doesn't look like part of a number. so "1234 x5" evalutates as the number 1234 (stops at the space char). * I didn't know that. What I did after reading this was change the keys from >somenumber xsomenumber to somenumber xsomenumber and used <=> rather than cmp. Then when printing I simply prefixed each key with >. So, it works, and thank you kindly, Bob. However, the following (example) is thrown to the screen for every key sorted: Argument "1315 x320" isn't numeric in sort at myxmlparser line 55, line 4475131. Is there a way to mask these messages? Would trapping it in an eval be what the doctor ordered? Thanks to everyone, and I will take a look at that Sort::Versions module Janek recommended also. cheers, nathanael "I think for my lunch tomorrow I'll make a tuna and pickle triangle bunwich." -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: another sort question (flame away)
>Would trapping it an eval be what the doctor ordered? To answer my own question, no, it would not. #use warnings; would be better. =D Hope y'all got a good chuckle out of it anyway. "I think for my lunch tomorrow I'll make a tuna and pickle triangle bunwich." -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: another sort question (flame away)
>From: nkuipers [mailto:[EMAIL PROTECTED]] > >>Would trapping it an eval be what the doctor ordered? > >To answer my own question, no, it would not. > >#use warnings; > >would be better. It would probably be best to use no warnings; before the sort line in your script and use warnings; on the following line. You can also check out perldoc warnings for more information. /\/\ark -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: another sort question (flame away)
> -Original Message- > From: nkuipers [mailto:[EMAIL PROTECTED]] > Sent: Wednesday, July 24, 2002 3:03 PM > To: [EMAIL PROTECTED] > Subject: RE: another sort question (flame away) > > > >Would trapping it an eval be what the doctor ordered? > > To answer my own question, no, it would not. > > #use warnings; > > would be better. Or, for fine-grain control: { no warnings 'numeric'; # disable warning until end of block @foo = sort { $a <=> $b } @foo; } perldoc perllexwarn -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: another sort question (flame away)
or just use my subroutine =P > -Original Message- > From: Bob Showalter [mailto:[EMAIL PROTECTED]] > Sent: Wednesday, July 24, 2002 3:11 PM > To: 'nkuipers'; [EMAIL PROTECTED] > Subject: RE: another sort question (flame away) > > > > -Original Message- > > From: nkuipers [mailto:[EMAIL PROTECTED]] > > Sent: Wednesday, July 24, 2002 3:03 PM > > To: [EMAIL PROTECTED] > > Subject: RE: another sort question (flame away) > > > > > > >Would trapping it an eval be what the doctor ordered? > > > > To answer my own question, no, it would not. > > > > #use warnings; > > > > would be better. > > Or, for fine-grain control: > >{ > no warnings 'numeric'; # disable warning until end of block > @foo = sort { $a <=> $b } @foo; >} > > perldoc perllexwarn > > -- > 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: threads in perl
On Wed, 2002-07-24 at 02:57, [EMAIL PROTECTED] wrote: > Hello All, > > I want to execute same perl procedure with different parameters at > the almost same time in a perl program indefendantly. (next process > should be started without waiting for the end of previous one) The > procedure is located in .pm file. How can I use thread in perl to get > my work done? > > regards > Rohana. You need to question whether or not you need threads. You can achieve much the same result with fork. If your subroutine does things without needing to modify variables in the main script then fork is probably a better solution. Read perldoc -f fork for more info. -- Today is Setting Orange the 59th day of Confusion in the YOLD 3168 Keep the Lasagna flying! Missile Address: 33:48:3.521N 84:23:34.786W -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: threads in perl
It is possible to change vars in the main script with fork if you use IPC::Shareable But be forewarned it's gets pretty cumbersome when you have 2+ processes sharing vars. > -Original Message- > From: Chas Owens [mailto:[EMAIL PROTECTED]] > Sent: Wednesday, July 24, 2002 3:29 PM > To: [EMAIL PROTECTED] > Cc: [EMAIL PROTECTED] > Subject: Re: threads in perl > > > On Wed, 2002-07-24 at 02:57, [EMAIL PROTECTED] wrote: > > Hello All, > > > > I want to execute same perl procedure with different parameters at > > the almost same time in a perl program indefendantly. (next process > > should be started without waiting for the end of previous one) The > > procedure is located in .pm file. How can I use thread in > perl to get > > my work done? > > > > regards > > Rohana. > > You need to question whether or not you need threads. You can achieve > much the same result with fork. If your subroutine does > things without > needing to modify variables in the main script then fork is probably a > better solution. Read perldoc -f fork for more info. > > -- > Today is Setting Orange the 59th day of Confusion in the YOLD 3168 > Keep the Lasagna flying! > > Missile Address: 33:48:3.521N 84:23:34.786W > > > -- > 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]
Using Cwd; in practice how have you used...
I read (ok, skimmed...) the results from perldoc -m cwd. I don't understand cwd (current working directory). My questions apply to this general scenario: In practice, I'd like to work with my .pl or .plx files in say, /myhome/bin/ Suppose I want to do some looping on some files in /data/path/files, or even on NT \\hostname\d$\inetpub\wwwroot\virtualdir Would use Cwd; even be necessary? What are some scenarios you've used Cwd.pm in the past? Why? If all files to be looped over are in, say, /data/path/files is it used to declare in pseudocode: <> The docs note: It is recommended that cwd (or another *cwd() function) is used in all code to ensure portability. Rob -- Rob McCormick -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: PM installation problem
Do you have a C compiler? -Original Message- From: Connie Chan [mailto:[EMAIL PROTECTED]] Sent: Wednesday, July 24, 2002 9:40 AM To: [EMAIL PROTECTED] Subject: Re: PM installation problem Thanks a lot =) but this method don't work for me... because the cpan server ( I guess ) don't carry this module.. so, both ppm and ppm3 not work. So have to download it by myself, but ... dunno how to install. Any else further advise ? Rgds, Connie - Original Message - From: "Akens, Anthony" <[EMAIL PROTECTED]> To: "Connie Chan" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]> Sent: Thursday, July 25, 2002 12:26 AM Subject: RE: PM installation problem If you're using activestate perl on your windows box, just use ppm. Just type ppm to enter the package manager, then install package:name and it does the work for you. -Tony -Original Message- From: Connie Chan [mailto:[EMAIL PROTECTED]] Sent: Wednesday, July 24, 2002 11:04 AM To: [EMAIL PROTECTED] Subject: PM installation problem I 've just downloaded a "Imager" module, however, that's a .tar.gz file and I am using Win Me. After I extract the file, there are quite sort of files and dirs. So... how can I install it to my Perl lib or site/lib ? Rgds, Connie -- 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: That seems interesting ? but I don't know why ?
Bob Showalter wrote: > > Well, it only works for integers. It's because of the way ^ > (bitwise xor) works. Given x=0 and y=1, for instance: > >x = x ^ yy = y ^ x x = x ^ y >x = 0 ^ 1y = 1 ^ 1 x = 1 ^ 0 >x = 1y = 0 x = 1 Actually in perl it works with strings as well. :-) $ perl -le' $x = "abcde"; $y = "fgh"; print "\$x = $x \$y = $y"; $x ^= $y; $y ^= $x; $x ^= $y; print "\$x = $x \$y = $y"; ' $x = abcde $y = fgh $x = fgh $y = abcde John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: another sort question (flame away)
Nkuipers wrote: > > Hello all, Hello, > My hash keys look something like this: > > >1234 x5 > > So I am thinking a cmp, as opposed to <=> is best. > > What I want is for the keys to be sorted as follows: > > >1 x > >2 x > >3 x > .. > .. > .. > >n x > > This is what I have in my script at the moment: > > my @sort_this = keys %final_list; > my @sorted = sort { $a cmp $b } @sort_this; > for (@sorted) { print OUT "$_\n$final_list{$_}\n" } > > This gives > > >1 x > >10 x > >100 x > >1000 x > >1001 x > > etc. > > Any suggestions? I'm not asking for you to spell it out for me with code and > all unless you really want to. Sorry if this is a dumb question. This should work, assuming the digits at the start of the key are no longer then 10. my @sorted = map { /\0(.+)/ } sort map { sprintf "%010d%s\0%s", /(\d+)(.+)/, $_ } keys %final_list; print OUT "$_\n$final_list{$_}\n" for @sorted; John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: another sort question (flame away)
This should not matter what the size is but would expect a number at the beginning: foreach my $MyKey (sort {$a->[1] <=> $b->[1]} map{[ $_, /^(\d+)/ ]} keys %final_list) { printf "%-s\n", $MyKey->[0]; } Wags ;) -Original Message- From: John W. Krahn [mailto:[EMAIL PROTECTED]] Sent: Wednesday, July 24, 2002 13:54 To: [EMAIL PROTECTED] Subject: Re: another sort question (flame away) Nkuipers wrote: > > Hello all, Hello, > My hash keys look something like this: > > >1234 x5 > > So I am thinking a cmp, as opposed to <=> is best. > > What I want is for the keys to be sorted as follows: > > >1 x > >2 x > >3 x > .. > .. > .. > >n x > > This is what I have in my script at the moment: > > my @sort_this = keys %final_list; > my @sorted = sort { $a cmp $b } @sort_this; > for (@sorted) { print OUT "$_\n$final_list{$_}\n" } > > This gives > > >1 x > >10 x > >100 x > >1000 x > >1001 x > > etc. > > Any suggestions? I'm not asking for you to spell it out for me with code and > all unless you really want to. Sorry if this is a dumb question. This should work, assuming the digits at the start of the key are no longer then 10. my @sorted = map { /\0(.+)/ } sort map { sprintf "%010d%s\0%s", /(\d+)(.+)/, $_ } keys %final_list; print OUT "$_\n$final_list{$_}\n" for @sorted; John -- use Perl; program fulfillment -- 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: Using Cwd; in practice how have you used...
On Wed, 24 Jul 2002, McCormick, Rob E wrote: > > I read (ok, skimmed...) the results from perldoc -m cwd. I don't > understand cwd (current working directory). My questions apply to this > general scenario: > > In practice, I'd like to work with my .pl or .plx files in say, /myhome/bin/ > > Suppose I want to do some looping on some files in /data/path/files, or even > on NT You can do this by using the glob operator (perldoc -f glob), opendir, readdir, closedir (perldoc -f opendir, perldoc -f readdir, perldoc -f closedir). If you want to traverse /data/path/files recursively you can use File::Find (perldoc File::Find) $dir is the directory that you want to loop through. Run both the glob and opendir, readdir, closedir examples, you will notice the different form of output. # glob while (<$dir/*>) { print "$_\n"; } # opendir, readdir, closedir opendir(DIRHNDL, $dir) or die "Cannot open $dir : $!\n"; while (my $file = readdir(DIRHNDL)) { print "$file\n"; } closedir(DIRHNDL); # File::Find find (sub { print "$File::Find::name\n" }, $dir); > > \\hostname\d$\inetpub\wwwroot\virtualdir > > Would use Cwd; even be necessary? For just looping through the files in a directory no, but depends on what you are trying to do. > What are some scenarios you've used Cwd.pm in the past? > Why? When you are changing directories (perldoc -f chdir) in your program a lot, Cwd.pm can be used to get your current working directory. There was a thread in this list about pushd and popd that had an example of Cwd's use. > > If all files to be looped over are in, say, /data/path/files is it used to > declare in pseudocode: > > <> > > The docs note: It is recommended that cwd (or another *cwd() function) is > used in all code to ensure portability. > > Rob > -- > Rob McCormick > > > > > > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
del files
I want to delete files. I am not able to delete , what is the wrong thing I am doing here. I am able to see the file in @privates I am getting following output: 0 deleted Attempting to delete M:\jav_test\train\k k k.mkelem.mkelem #!c:\perl\bin\perl @privates =`cleartool lsprivate -tag jav_test -other`; #print "@privates"; #print "Enter a pattern:"; #my $pattern =<>; #chomp $pattern; foreach (@privates) { print "\nAttempting to delete $_\n"; $delo=unlink @private; print "\n $delo deleted"; }