Perl and Exchange Server
I have been trying for some time to get at the contacts in a mailbox on exchange server 5.5. I have been using Win32::OLE with CDO. I can get the contacts folder, the count of items in it, and even the name of each contact but I can't seem to get at any of the fields. I have found many examples in VB that use the outlook object model to do this but I need to get the data from the server without outlook. All my attempts at this have failed miserably. I have tried to understand the documentation on MSDN however there are no specific examples for getting the contacts from the server. All examples I have found deal with the contacts from the client not the server and the few I found written in perl don't seem to work at all. Since this is generally an Microscrap question, I have posted numerous times to the MS newsgroups for exchange with no responses. If someone can give me an example or point me in the right direction, I would be eternally grateful. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Perl and Exchange Server
Here is the last feeble attempt: #!\perl\bin\perl.exe -w use strict; use Win32::OLE; use Win32::OLE::Const; my $DEBUG_FLAG = 1; # set it to zero for real job #names have been changed to protect the innocent my $server = servername; my $fname = Firstname; my $lname = Lastname; my $alias = Alias; # Necessary for MAPI component Win32::OLE-Initialize(Win32::OLE::COINIT_OLEINITIALIZE); # Do this rather than 'use' as that interferes with the OLE Initialize code my $CDO_CONST = Win32::OLE::Const-Load('Microsoft CDO.*Library'); my $MAPI = Win32::OLE-new('MAPI.Session'); die Could instantiate MAPI Session: . Win32::OLE::LastError() if (! defined($MAPI)); my %LogonParms = ( 'ProfileInfo' = $server\n$alias ); $MAPI-logon(\%LogonParms); die Win32::OLE::LastError() if (Win32::OLE::LastError()); print USER: . $MAPI-{CurrentUser}-Value . \n; my $Contactsfolder = $MAPI-GetFolder($MAPI-{Inbox}-{Fields}-Item(0x36D10102),$MAPI-{Inbox}- {StoreID}); my $contacts = $Contactsfolder-{Messages}; my $ncon = $contacts-{'Count'}; print \tContacts - $ncon\n; my $con; my $field1; my $field2; my $email1; for my $ii (1 .. $ncon) { $con = $contacts-Item($ii); print $ii - $con-{'FullName'}\n; print email is $con-{0x8083}\n; print email is $con-{'0x8083'}\n; $field1 = {04200600C046}; $field2 = 0x8083; print email is $con-{$field1 . $field2}\n; print email is $con-{'Email1Address'}\n; #no matter what I try here I always get the contact's display name } exit; -Original Message- From: Tim Johnson [mailto:[EMAIL PROTECTED] Sent: Friday, July 11, 2003 11:25 AM To: 'Chris Rogers'; [EMAIL PROTECTED] Org (E-mail) Subject: RE: Perl and Exchange Server Maybe it would help if you gave us what you've tried? -Original Message- From: Chris Rogers [mailto:[EMAIL PROTECTED] Sent: Friday, July 11, 2003 8:24 AM To: [EMAIL PROTECTED] Org (E-mail) Subject: Perl and Exchange Server I have been trying for some time to get at the contacts in a mailbox on exchange server 5.5. I have been using Win32::OLE with CDO. I can get the contacts folder, the count of items in it, and even the name of each contact but I can't seem to get at any of the fields. I have found many examples in VB that use the outlook object model to do this but I need to get the data from the server without outlook. All my attempts at this have failed miserably. I have tried to understand the documentation on MSDN however there are no specific examples for getting the contacts from the server. All examples I have found deal with the contacts from the client not the server and the few I found written in perl don't seem to work at all. Since this is generally an Microscrap question, I have posted numerous times to the MS newsgroups for exchange with no responses. If someone can give me an example or point me in the right direction, I would be eternally grateful. -- 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: Perl and Exchange Server
Thanks for the answer but I am actually looking for the Contacts folder in a mailbox. The GAL is available easily using LDAP, CDO, or the admin.exe from the command line. -Original Message- From: Barry C. Hawkins [mailto:[EMAIL PROTECTED] Sent: Friday, July 11, 2003 12:27 PM To: Chris Rogers Cc: [EMAIL PROTECTED] Org (E-mail) Subject: Re: Perl and Exchange Server On Friday, Jul 11, 2003, at 11:24 US/Eastern, Chris Rogers wrote: I have been trying for some time to get at the contacts in a mailbox on exchange server 5.5. I have been using Win32::OLE with CDO. I can get the contacts folder, the count of items in it, and even the name of each contact but I can't seem to get at any of the fields. I have found many examples in VB that use the outlook object model to do this but I need to get the data from the server without outlook. All my attempts at this have failed miserably. I have tried to understand the documentation on MSDN however there are no specific examples for getting the contacts from the server. All examples I have found deal with the contacts from the client not the server and the few I found written in perl don't seem to work at all. Since this is generally an Microscrap question, I have posted numerous times to the MS newsgroups for exchange with no responses. If someone can give me an example or point me in the right direction, I would be eternally grateful. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] Chris, You might have better luck searching MSDN and the Knowledge Base for Global Address List (GAL). The GAL is the common name in Exchange-speak for what you are calling the Contacts folder on the server. My experience with CDO is limited to OLE-DB/ADO/VBScript, so alas, that's all I can tell you. Regards, -- Barry C. Hawkins Systems Consultant All Things Computed 404-795-9147 voice/fax http://www.allthingscomputed.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: fetchrow_array
It sounds more like you want the fetchall_arrayref function. This will return all the records into a single array reference that can accessed by $temp-[x][y] where x defines the record and y defines the field. For example: my $dbh = DBI-connect('DBI:mysql:dbname','user') or die Couldn't open database: . DBI-errstr . \n; my $statement = SELECT field1,field2,field3 WHERE field1 != \\; my $sth = $dbh-prepare($statement); my $rc = $sth-execute(); my $temp = $sth-fetchall_arrayref; for my $x(0..$#{$temp}) { print $temp-[$x][0], $temp-[$x][1], $temp-[$x][2]\n } Using an array reference as above will return all matching records in a single container and simplifies (in my opinion) the iteration of records. I have a PDF version of a MySQL reference manual. If you need a copy, just let me know and I'll send it to you. Also, there is another group out there ([EMAIL PROTECTED]) that may also be able to offer help. Hope this helps, Chris -Original Message- From: Dan Muey [mailto:[EMAIL PROTECTED] Sent: Tuesday, June 17, 2003 9:32 AM To: Benjamin Jeeves; [EMAIL PROTECTED] Subject: RE: fetchrow_array Hi All Howdy I my query a MySQL database and have the following code while (@temp = $table-fetchrow_array ()) { some code { I think you mean } not { :) my problem is that I want the results from the database query to be access by using $temp[0] for the first row then $temp[1] for the second row and so on. Sure is and you've already got that: while (@temp = $table-fetchrow_array ()) { print $temp[0] $temp[1] $temp[2] $temp[4]; # or whatever } Outside of the while loop you'll only have one version of @temp if any, so if you need to use $temp[n] outside the while loop you'll need to assignthe values to an outside variable Perhaps a hash. If there's only going to be one record returned you can just do: my @temp = $table-fetchrow_array($query); And skip the prepare and execute stuff. Then you could use $temp[n] wherever your @temp was declared So is it possable to do this and if so how or where can I find the info. perldoc DBI HTH DMuey -- 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]
Looking for Module
I'm looking for a perl module for CDO (Collaborative Data Objects) that I can use on a Linux box. I need this to be able to manipulate calendars, contacts, tasks, etc. on an Exchange 5.5 server. Or at least I think I need this. Info from microsoft on this topic is sketchy but from what I can tell, I need to be able to use CDO. Any help would be greatly appreciated. Thanks, Chris -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: check size of upload file
The command works on my box. The problem may be that you are trying to get the size of a file that is located on the client's machine. I think you will have to check the size of the file after it is uploaded and then decide if it's too big or not. If you want to check the file size before uploading, you will probably need to use some javascript. I may be way off base on this but it's the only way I know to do it. -Original Message- From: anthony [mailto:[EMAIL PROTECTED] Sent: Thursday, May 29, 2003 1:47 PM To: [EMAIL PROTECTED] Subject: check size of upload file Hi, when i upload a file to a website, I have the path C:\\pathtofile\\pic.gif to check the size I can do this $size = -s $file_path; but it does not work! any help is appreciated, because i don't want people to upload file to a website bigger that 500KB. Anthony -- 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: Check for duplicate entires
There are many ways to do this but one comes to mind that may shorten the code as well as speed things up just a little (REGEX's are usually very efficient). Try this out: sub update_categories { my($maincat,$subcat) = @_; my $process = 0; my @scats= (); $subcat =~ s!(.*?)\.cache!$1!g; open(CAT,$categoryfile) or die $1; my @catdata = CAT; close(CAT); open(CAT,$categoryfile) or die $!; for my $cdat (@catdata) { if(($cdat =~ /^$maincat\:\:/) ($cdat =~/(\:\:$subcat\:\:|\:\:$subcat\n$)/)) { $cdat =~ s/\n$/$subcat\n/; } print CAT $cdat; } # close for my close(CAT); return; } Hope this helps. Chris Rogers -Original Message- From: Mike Blezien [mailto:[EMAIL PROTECTED] Sent: Thursday, April 03, 2003 11:41 AM To: Perl List Subject: Check for duplicate entires Hello all, working on creating a category/sub category data file, somthing like this: Animations::Mini::3D-Miscellaneous Clip_Art::People-Stick_People::Business::Household-Furniture Icons::BMP-Computers::32x32icons-Computers the first field in each line is the main category, followed by their respective sub categories... and this file needs to be updated on a daily basices.. the problem I'm having is when adding new sub categories to a matching main category, is avoiding duplications of sub cateogories. Example: Clip_Art::People-Stick_People::Business::Household-Furniture Clip_Art is the main category, then all others on this line are it's sub categories of the Clip_Art main category. Now when updating the file, if the sub category being added is already in data record is not to add it or update the file. So if a sub category is passed, Business(which is already in the data record), what is the best way to check if the sub category exist, and the best approach to updated the file. this is a snip of the code we're using to add the sub categories to the file and it works fine, but we need to prevent duplications of sub categories for a matching main category. sub update_categories { my($maincat,$subcat) = @_; my $process = 0; my @scats= (); $subcat =~ s!(.*?)\.cache!$1!g; open(CAT,$categoryfile) or die $1; my @catdata = CAT; close(CAT); open(CAT,$categoryfile) or die $!; for my $cdat (@catdata) { chomp $cdat; @scats = split(/\::/,$cdat); if ($scats[0] eq $maincat) { push(@scats,$subcat); } my $newline = join(\::,@scats) . \n; print CAT $newline; } # close for my close(CAT); return; } TIA... :) -- MikemickaloBlezien =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= Thunder Rain Internet Publishing Providing Internet Solutions that work! http://www.thunder-rain.com Web Hosting http://www.justlightening.net Tel: 1(985)902-8484 MSN: [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: 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]
Array Iteration
Hi all, I backed myself into a corner and cold use a little help. I have a multi-dimensional array that has a know number of elements at the deepest level but the number of levels is unknown. Here is a brief example: $menuarray[5][0] = 5 $menuarray[5][1] = Sales $menuarray[5][2] = $menuarray[5][3] = 20 $menuarray[5][4] = 90 $menuarray[5][5] = 0 $menuarray[5][6] = $menuarray[5][7] = 5 $menuarray[7][1][0] = 11 $menuarray[7][1][1] = Home $menuarray[7][1][2] = $menuarray[7][1][3] = 20 $menuarray[7][1][4] = 160 $menuarray[7][1][5] = 7 $menuarray[7][1][6] = $menuarray[7][1][7] = 1 $menuarray[7][5][5][0] = 20 $menuarray[7][5][5][1] = Edit Call Schedule $menuarray[7][5][5][2] = $menuarray[7][5][5][3] = 20 $menuarray[7][5][5][4] = 160 $menuarray[7][5][5][5] = 15 $menuarray[7][5][5][6] = $menuarray[7][5][5][7] = 5 $menuarray[7][5][3][1][0] = 21 $menuarray[7][5][3][1][1] = Assets $menuarray[7][5][3][1][2] = $menuarray[7][5][3][1][3] = 20 $menuarray[7][5][3][1][4] = 160 $menuarray[7][5][3][1][5] = 18 $menuarray[7][5][3][1][6] = $menuarray[7][5][3][1][7] = 1 I need to be able to iterate over the entire array in order so that the sublevels are shown immediately after the preceding level. I know there must be a simple way of doing this but I just can't seem to make it work. I do know how to do: for $x(0..$#menuarray) { for $y(0..$#{$menuarray[$x]}) { . } } But that isn't going to work since I don't know how deep the array goes and that the number of sub levels may differ from one element to the next. Any help or hints will be greatly appreciated. Thanks, Chris -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Looking for module
Has anyone seen a module that will help me output a document in Microsoft Word format? Any hint in the right direction will be greatly appreciated. Thanks, Chris -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Looking for module
Thanks, but that won't work on a linux box (will it?) -Original Message- From: Kipp, James [mailto:James.Kipp;mbna.com] Sent: Thursday, October 31, 2002 2:30 PM To: 'Chris Rogers'; '[EMAIL PROTECTED]' Subject: RE: Looking for module take a look at Win32::OLE. not sure but it is woth a look -Original Message- From: Chris Rogers [mailto:chris.rogers;vifanusa.com] Sent: Thursday, October 31, 2002 2:18 PM To: '[EMAIL PROTECTED]' Subject: Looking for module Has anyone seen a module that will help me output a document in Microsoft Word format? Any hint in the right direction will be greatly appreciated. Thanks, Chris -- 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]
Looking for Info
Sorry to bother you guys with this completely unrelated subject but I have had no luck finding much needed information. Does anyone know of a good resource for RPC and NFS? I have been trying to mount to a remote filesystem but have had no luck. The information I found on linuxdoc.org was helpful but incomplete. I would really appreciate it if anyone can help out with info or a good resource. Again, sorry to bother you with this but I am getting desperate. Thanks, Chris -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Confusion with Regular Expressions
While regular expressions are one of the most powerful aspects of Perl, they are probably my weakest point. I have a string that is quite irregular and am trying to fix it using a regex. What I need to do is find a substring that begins with a quote then a space then any characters (not including quote, space, open parenthesis, or close parenthesis) and ends with a close parenthesis Here is the string: (APPLICATION MSWORD (name Liste des numéros de téléphone.doc) NIL NIL BASE64 61658 NIL (attachment (filename Liste des numéros de téléphone.doc)) NIL) The portion of the string that is: Liste des numéros de téléphone.doc should be enclosed in quotes. Chapter 5 in the Camel book has again completely confused me and I have tried many different regex's to accomplish this over the last two days but have had very little luck. Any help would be greatly appreciated. Thanks, Chris -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Confusion with Regular Expressions
OK. I have tried so many but haven't kept very good track of them. Original string: (APPLICATION MSWORD (name Liste des numéros de téléphone.doc) NIL NIL BASE64 61658 NIL (attachment (filename Liste des numéros de téléphone.doc)) NIL) I need to surround the Liste des numéros de téléphone.doc with quotes This one came closer than any other but it is still wrong: s/ ([a-zA-Z0-9_\. ]+)\)/ $1\)/g If I remove the \) at the end of the left side, it comes really close. I think it is the é that is throwing it off but I don't know how to include that in the character class. For all I know there may be more problems than that and definately a better way of doing it since I obviously have not included enough characters in the character class. -Original Message- From: Brett W. McCoy [mailto:[EMAIL PROTECTED]] Sent: Thursday, August 30, 2001 4:29 PM To: Chris Rogers Cc: Beginners@Perl. Org (E-mail) Subject: Re: Confusion with Regular Expressions should be enclosed in quotes. Chapter 5 in the Camel book has again completely confused me and I have tried many different regex's to accomplish this over the last two days but have had very little luck. Any help would be greatly appreciated. How about posting what you have tried so far? -- Brett http://www.chapelperilous.net/ A violent man will die a violent death. -- Lao Tsu -- 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: Confusion with Regular Expressions
OK. I have tried so many but haven't kept very good track of them. Original string: (APPLICATION MSWORD (name Liste des numéros de téléphone.doc) NIL NIL BASE64 61658 NIL (attachment (filename Liste des numéros de téléphone.doc)) NIL) I need to surround the Liste des numéros de téléphone.doc with quotes This one came closer than any other but it is still wrong: s/ ([a-zA-Z0-9_\. ]+)\)/ $1\)/g If I remove the \) at the end of the left side, it comes really close. I think it is the é that is throwing it off but I don't know how to include that in the character class. For all I know there may be more problems than that and definately a better way of doing it since I obviously have not included enough characters in the character class. -Original Message- From: Brett W. McCoy [mailto:[EMAIL PROTECTED]] Sent: Thursday, August 30, 2001 4:29 PM To: Chris Rogers Cc: Beginners@Perl. Org (E-mail) Subject: Re: Confusion with Regular Expressions should be enclosed in quotes. Chapter 5 in the Camel book has again completely confused me and I have tried many different regex's to accomplish this over the last two days but have had very little luck. Any help would be greatly appreciated. How about posting what you have tried so far? -- Brett http://www.chapelperilous.net/ A violent man will die a violent death. -- Lao Tsu -- 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: Confusion with Regular Expressions
Thanks, but that didn't catch the string. I'll keep on trying -Original Message- From: Gibbs Tanton - tgibbs [mailto:[EMAIL PROTECTED]] Sent: Thursday, August 30, 2001 4:41 PM To: 'Chris Rogers '; 'Beginners@Perl. Org (E-mail) ' Subject: RE: Confusion with Regular Expressions $line = get_line(); # or whatever $line =~ /\s[^ ()]+[)]/; The at the beginning will match to a quote followed by a space (\s). Then we match any character not in the character class [ ()] (by prepending it with ^. Finally, we match the literal ) [)]. This is what you described...I don't know if it will work for your app or not, but there it is! Good Luck! Tanton -Original Message- From: Chris Rogers To: Beginners@Perl. Org (E-mail) Sent: 8/30/2001 3:18 PM Subject: Confusion with Regular Expressions While regular expressions are one of the most powerful aspects of Perl, they are probably my weakest point. I have a string that is quite irregular and am trying to fix it using a regex. What I need to do is find a substring that begins with a quote then a space then any characters (not including quote, space, open parenthesis, or close parenthesis) and ends with a close parenthesis Here is the string: (APPLICATION MSWORD (name Liste des numéros de téléphone.doc) NIL NIL BASE64 61658 NIL (attachment (filename Liste des numéros de téléphone.doc)) NIL) The portion of the string that is: Liste des numéros de téléphone.doc should be enclosed in quotes. Chapter 5 in the Camel book has again completely confused me and I have tried many different regex's to accomplish this over the last two days but have had very little luck. Any help would be greatly appreciated. Thanks, Chris -- 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: Confusion with Regular Expressions
THANK YOU! THANK YOU! THANK YOU! That did the trick. I didn't think about that as a possibility. I have another question now. How would I go about defining ascii characters that are not on my keyboard in the character class? There must be a way of defining a character class using the ascii values instead of the actual character. I just don't know how to do it. Thanks, Chris -Original Message- From: Bob Showalter [mailto:[EMAIL PROTECTED]] Sent: Thursday, August 30, 2001 4:49 PM To: '[EMAIL PROTECTED]' Subject: RE: Confusion with Regular Expressions -Original Message- From: Chris Rogers [mailto:[EMAIL PROTECTED]] Sent: Thursday, August 30, 2001 4:38 PM To: Beginners@Perl. Org (E-mail) Subject: RE: Confusion with Regular Expressions OK. I have tried so many but haven't kept very good track of them. Original string: (APPLICATION MSWORD (name Liste des numéros de téléphone.doc) NIL NIL BASE64 61658 NIL (attachment (filename Liste des numéros de téléphone.doc)) NIL) I need to surround the Liste des numéros de téléphone.doc with quotes This one came closer than any other but it is still wrong: s/ ([a-zA-Z0-9_\. ]+)\)/ $1\)/g If I remove the \) at the end of the left side, it comes really close. I think it is the é that is throwing it off but I don't know how to include that in the character class. For all I know there may be more problems than that and definately a better way of doing it since I obviously have not included enough characters in the character class. How about just using a class consisting of anything except what you don't want: s/ ([^)]+)\)/ $1)/g The ^ after the opening bracket negates the character class. -- 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: Confusion with Regular Expressions
Thanks... Chris -Original Message- From: Carl Rogers [mailto:[EMAIL PROTECTED]] Sent: Thursday, August 30, 2001 5:12 PM To: Chris Rogers; '[EMAIL PROTECTED]' Subject: RE: Confusion with Regular Expressions There must be a way of defining a character class using the ascii values instead of the actual character. I just don't know how to do it. If you refer to the ASCII value in it's hexadecimal equivalent (i.e.: 'A-Z ' is equivalent to [\x41-\x5A]) that should do the trick. HTH Carl -- 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: index inside foreach{ ..}
I don't know if you can do it using a foreach but I would use a for loop. It may be just a tad slower but you'll get the results you're looking for. Using the loop below will start at the last index of the array @a and loop down to the first (assuming that the first index of the array is 0). @a = (a,b,c,d,e); for ($b=$#a; $b -1; $b--) { print $b $a[$b]\n; }; In the loop you showed using the $index counter, the $index would not be the actual index of the item in the array but the current index of the loop. Maybe one of the more experienced people on the list can offer you a way of doing it using a foreach loop that might be faster. Hope this helps, Chris -Original Message- From: matthschulz [mailto:[EMAIL PROTECTED]] Sent: Tuesday, August 14, 2001 6:40 PM To: [EMAIL PROTECTED] Subject: index inside foreach{ ..} I have read something but could not find an answer: I had to do a foreach like this: A @a = (a,b,c,d,e); foreach $b (reverse @a) { print $b\n; }; Now i needed to access the index inside the foreach to do: B @a = (a,b,c,d,e); foreach $b (reverse @a) { print $index $b\n; }; which i did with a additional variable C @a = (a,b,c,d,e); $index =0; foreach $b (reverse @a) { $index++; print $index $b\n; }; Is there a way to acces the internal index of the foreach loop as $index in example B ? Thanks in advance Matth -- 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: Very simple newbie problem
Looking at the second sub in your script (list_active), I am wondering what you are trying to print. The script works as written (doesn't produce any errors), but the statement: print if $lines =~ /vty/; doesn't print anything. Try this: print $lines if $lines =~ /vty/; Hope this helps. Chris Rogers -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Tuesday, August 14, 2001 2:43 PM To: [EMAIL PROTECTED] Subject: Very simple newbie problem Thank goodness for this kind of list. I'm very new and am experiencing some mass confusion of how things are done. I'm trying to write a simple script to interface with a router using Expect. This part works great, in the fact that it can log into the router and log to a file. The second part of the script looks in the file and searches for a particular connection type and prints the line. If I separate the two functions into separate scripts things work well. Combining them into the same script is driving me nuts. Here's the example: #!/usr/bin/perl -w # # This script is a test script to show what sites have active PPP sessions #use CGI; use Expect; use IO::Handle; use strict; my $count = 0; my $logfile = active-connections.txt; my $command; my $lines; check_active(); list_active(); sub check_active { system(rm -f $logfile); $command = Expect-spawn(telnet ip.add.re.ssB) or die Can not open telnet session to router: $!; $command-log_stdout(0); $command-log_file(active-connections.txt); print $command admin\n; print $command password\n; print $command sho caller\n; print $command exit\n; $command-soft_close(); #$command-hard_close(); } sub list_active { open (MYFILE, active-connections.txt) || die can not open file: $!; while ($lines = MYFILE) { print if $lines =~ /vty/; } } What's so difficult about this? - Scott -- 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]
Create an array of arrrays from a scalar
Maybe I'm crazy, but I would like to create an array of arrays from a single string. Here's an example of a string: ((TEXT PLAIN (format flowed) NIL NIL 7BIT 206 4 NIL NIL NIL)(TEXT PLAIN (name Display.txt format flowed) NIL NIL 8BIT 16330 412 NIL (attachment (filename Display.txt)) NIL) mixed (boundary =_NextPart_000_36cf_58cd_f54) NIL NIL) This string will be contained a single scalar variable. I have tried a few different things, all of which have failed miserably. My guess is that spaces will need to be changed to commas. Any help would be greatly appreciated. Thanks, Chris -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Mail::IMAPClient::BodyStructure
I am using the Mail::IMAPClient module and the extension BodyStructure to connect to Exchange Server 5.5. Everything seems to be working great ( I love this module ) except for one thing. When I use the BodyStructure extension, either nothing is being returned in the object or I don't know how to access it. I can log on to server, query the mailbox and all it's folders without any trouble but I can't seem to get a message bodystructure. The docs show one example but I can't seem to get it to work for me. Here's a snippet of code: # use CGI; use Mail::IMAPClient; use Mail::IMAPClient::BodyStructure; $imapp = Mail::IMAPClient-new ( Server = $servername, User = $username, Password = $password, Uid = 1, Debug = 1 ); $imapp-select($foldername); my $struct = Mail::IMAPClient::BodyStructure-new($imapp-fetch($msguid,bodystructure)) ; $btype = $struct-bodytype; $bsubtype = $struct-bodysubtype; # When the code is run, I don't get any errors but I don't get the bodystructure either. I have tried this many different ways but none seem to work. Having turned on the debug option, I can see that the request is sent to the server and the server does respond: 3 UID FETCH 12 bodystructure Sent 30 bytes Read: * 2 FETCH (BODYSTRUCTURE (TEXT PLAIN (CHARSET US-ASCII) NIL NIL 7BIT 489 9 NIL NIL NIL) UID 12) 3 OK FETCH completed If I print $struct, I get the following though the =HASH(...) part varies: Mail::IMAPClinet::BodyStructure=HASH(0x87d6b64) If anyone has any ideas, please let me know. Any help would be greatly appreciated. Thanks, Chris -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]