RE: arrays
Thanks everyone for your help.. Jonathan Musto BT Global Services Telephone - 0113 237 3277 Fax - 0113 244 1413 E-mail - [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]> http://www.technet.bt.com/sit/public British Telecommunications plc Registered office: 81 Newgate Street London EC1A 7AJ Registered in England no. 180 This electronic message contains information from British Telecommunications plc which may be privileged or confidential. The information is intended to be for the use of the individual(s) or entity named above. If you are not the intended recipient be aware that any disclosure, copying, distribution or use of the contents of this information is prohibited. If you have received this electronic message in error, please notify us by telephone or email (to the numbers or address above) immediately. -Original Message- From: awarsd [mailto:[EMAIL PROTECTED] Sent: Monday, August 04, 2003 11:50 To: [EMAIL PROTECTED] Subject: Re: arrays Hi, if we have @routers. you can do this my ($c, $line); $c=0; foreach $line(@routers){ $line = $line." P *NULL*"; push @newrouters, $line; } or to use the $c foreach $line (@routers){ @routers[$c] = $line." P *NULL*"; $c++; } "Jonathan Musto" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hi there, > > I've got an array of lines, split up by spaces as follows: > > Sun-router rack1.2 leeds > Cisco-router rack3.2 skem > Sun-switch rack2.3 manchester > etc. > > How can i add the following to the end of each line, P *NULL*?... e.g. > > Sun-router rack1.2 leeds P *NULL* > Cisco-router rack3.2 skem P *NULL* > Sun-switch rack2.3 manchester P *NULL* > > Any help would be much appreciated, thanks in advance! > > Regards, > > > Jonathan Musto > > > > BT Global Services > Telephone - 0113 237 3277 > Fax - 0113 244 1413 > E-mail - <mailto:[EMAIL PROTECTED]> [EMAIL PROTECTED] > http://www.technet.bt.com/sit/public <http://www.technet.bt.com/sit/public> > > > British Telecommunications plc > Registered office: 81 Newgate Street London EC1A 7AJ > Registered in England no. 180 > This electronic message contains information from British Telecommunications > plc which may be privileged or confidential. The information is intended to > be for the use of the individual(s) or entity named above. If you are not > the intended recipient be aware that any disclosure, copying, distribution > or use of the contents of this information is prohibited. If you have > received this electronic message in error, please notify us by telephone or > email (to the numbers or address above) immediately. > > > > > > -- 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]
arrays
Hi there, I've got an array of lines, split up by spaces as follows: Sun-router rack1.2 leeds Cisco-router rack3.2 skem Sun-switch rack2.3 manchester etc. How can i add the following to the end of each line, P *NULL*?... e.g. Sun-router rack1.2 leeds P *NULL* Cisco-router rack3.2 skem P *NULL* Sun-switch rack2.3 manchester P *NULL* Any help would be much appreciated, thanks in advance! Regards, Jonathan Musto BT Global Services Telephone - 0113 237 3277 Fax - 0113 244 1413 E-mail - <mailto:[EMAIL PROTECTED]> [EMAIL PROTECTED] http://www.technet.bt.com/sit/public <http://www.technet.bt.com/sit/public> British Telecommunications plc Registered office: 81 Newgate Street London EC1A 7AJ Registered in England no. 180 This electronic message contains information from British Telecommunications plc which may be privileged or confidential. The information is intended to be for the use of the individual(s) or entity named above. If you are not the intended recipient be aware that any disclosure, copying, distribution or use of the contents of this information is prohibited. If you have received this electronic message in error, please notify us by telephone or email (to the numbers or address above) immediately.
Comparing 2 lists
Hi all, Sorry i'm very new to this. I have 2 lists of companies, not neccessarly in order, and i want to produce a list of companies which apear in both lists. Eg. List 1... Macdonalds HMV Virgin Dixons Compared with List 2... HMV Flannels Currys Dixons Will output... HMV Dixons Jonathan Musto BT Global Services Telephone - 0113 237 3277 Fax - 0113 244 1413 E-mail - <mailto:[EMAIL PROTECTED]> [EMAIL PROTECTED] http://www.technet.bt.com/sit/public <http://www.technet.bt.com/sit/public> British Telecommunications plc Registered office: 81 Newgate Street London EC1A 7AJ Registered in England no. 180 This electronic message contains information from British Telecommunications plc which may be privileged or confidential. The information is intended to be for the use of the individual(s) or entity named above. If you are not the intended recipient be aware that any disclosure, copying, distribution or use of the contents of this information is prohibited. If you have received this electronic message in error, please notify us by telephone or email (to the numbers or address above) immediately.
RE: Removing duplicate lines.
Thanks all, that worked a treat. Jonathan Musto BT Global Services Telephone - 0113 237 3277 Fax - 0113 244 1413 E-mail - [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]> http://www.technet.bt.com/sit/public British Telecommunications plc Registered office: 81 Newgate Street London EC1A 7AJ Registered in England no. 180 This electronic message contains information from British Telecommunications plc which may be privileged or confidential. The information is intended to be for the use of the individual(s) or entity named above. If you are not the intended recipient be aware that any disclosure, copying, distribution or use of the contents of this information is prohibited. If you have received this electronic message in error, please notify us by telephone or email (to the numbers or address above) immediately. -Original Message- From: Jenda Krynicky [mailto:[EMAIL PROTECTED] Sent: Monday, July 21, 2003 13:33 To: [EMAIL PROTECTED] Subject: Re: Removing duplicate lines. From: [EMAIL PROTECTED] > I have a text file which contains a list of companies: > > NORTH DOWN AND ARDS INSTITUTE > NOTTINGHAM HEALTH AUTHORITY > 1ST CONTACT GROUP LTD > 1ST CONTACT GROUP LTD > 1ST CONTACT GROUP LTD > 1ST CONTACT GROUP LTD > 4D TELECOM & KINGSTON INMEDIA > A E COOK LTD > A E COOK LTD > > etc.. > > How can a write a simple perl script to remove the duplicates and > leave just one of each customer? Any help would be great. Is it safe to assume that all duplicates are together like this? If so all you have to do is to 1) read the file line by line 2) only print the line you just read if it's different from the last one 3) remember the line or if I word it differently. 1) read the file 2) skip the line if it's the same as the last one 3) print it and remember it my $last = ''; while (<>) { next if $_ eq $last; print $_; $last = $; } If the duplicates are scattered all over the place, then the easiest solution is to use a hash, That will get rid of the duplicates for you: while (<>) { chomp; $seen{$_}++; } foreack my $item (keys %seen) { print $item,"\n"; } If the list of companies is huge you may need to store the hash on disk to prevent swapping: use DB_File; tie %seen, 'DB_File', $filename; ... Jenda = [EMAIL PROTECTED] === http://Jenda.Krynicky.cz = When it comes to wine, women and song, wizards are allowed to get drunk and croon as much as they like. -- Terry Pratchett in Sourcery -- 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]
Removing duplicate lines.
I have a text file which contains a list of companies: NORTH DOWN AND ARDS INSTITUTE NOTTINGHAM HEALTH AUTHORITY 1ST CONTACT GROUP LTD 1ST CONTACT GROUP LTD 1ST CONTACT GROUP LTD 1ST CONTACT GROUP LTD 4D TELECOM & KINGSTON INMEDIA A E COOK LTD A E COOK LTD etc.. How can a write a simple perl script to remove the duplicates and leave just one of each customer? Any help would be great. Regards, Jonathan Musto BT Global Services Telephone - 0113 237 3277 Fax - 0113 244 1413 E-mail - <mailto:[EMAIL PROTECTED]> [EMAIL PROTECTED] http://www.technet.bt.com/sit/public <http://www.technet.bt.com/sit/public> British Telecommunications plc Registered office: 81 Newgate Street London EC1A 7AJ Registered in England no. 180 This electronic message contains information from British Telecommunications plc which may be privileged or confidential. The information is intended to be for the use of the individual(s) or entity named above. If you are not the intended recipient be aware that any disclosure, copying, distribution or use of the contents of this information is prohibited. If you have received this electronic message in error, please notify us by telephone or email (to the numbers or address above) immediately.
RE: CGI help
The permissions are set to 777 on the file, that was the first thing i though of, and there is nothing showing in the error_log file!? Jonathan Musto BT Ignite Solutions Telephone - 0113 237 3277 Fax - 0113 244 1413 E-mail - [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]> http://www.technet.bt.com/sit/public British Telecommunications plc Registered office: 81 Newgate Street London EC1A 7AJ Registered in England no. 180 This electronic message contains information from British Telecommunications plc which may be privileged or confidential. The information is intended to be for the use of the individual(s) or entity named above. If you are not the intended recipient be aware that any disclosure, copying, distribution or use of the contents of this information is prohibited. If you have received this electronic message in error, please notify us by telephone or email (to the numbers or address above) immediately. -Original Message- From: Stefan Lidman [mailto:[EMAIL PROTECTED] Sent: Tuesday, March 25, 2003 10:24 Cc: [EMAIL PROTECTED] Subject: Re: CGI help > in the browser, but as soon as i add a file handle to obtian the userid from > the username it stops working, nothing is displayed. > > open (FH,"hl_of_users.txt") || &CgiDie("Can't open user file!"); > > I will be pereforming various actions on this file handle but at the moment > i can't do anything because as soon as i add this line i get a blank page > returned. Do the script have permisson to read the file? What does the error_log say? /Stefan -- 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]
CGI help
I'm writing a simple cgi script that takes the user name from the url and outputs it in the html. For example the url: blar...blar/cgi-bin/sis_home.cgi?un=mustoj Here is my script which works fine: #!/usr/local/bin/perl # script name: sis_home.cgi use CGI qw(:standard); my $q = new CGI; my $username = $q->param("un"); #print the html print "Content-type: text/html\n\n"; print <<__HTML__; Simple Program User Name = $username __HTML__ This works fine and i get the output: User Name = mustoj in the browser, but as soon as i add a file handle to obtian the userid from the username it stops working, nothing is displayed. open (FH,"hl_of_users.txt") || &CgiDie("Can't open user file!"); I will be pereforming various actions on this file handle but at the moment i can't do anything because as soon as i add this line i get a blank page returned. Has anyone come across this problem before? Any help would be much appreciated, thanks in advance. Regards, Jonathan Musto BT Ignite Solutions Telephone - 0113 237 3277 Fax - 0113 244 1413 E-mail - [EMAIL PROTECTED] http://www.technet.bt.com/sit/public British Telecommunications plc Registered office: 81 Newgate Street London EC1A 7AJ Registered in England no. 180 This electronic message contains information from British Telecommunications plc which may be privileged or confidential. The information is intended to be for the use of the individual(s) or entity named above. If you are not the intended recipient be aware that any disclosure, copying, distribution or use of the contents of this information is prohibited. If you have received this electronic message in error, please notify us by telephone or email (to the numbers or address above) immediately. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
localtime
Hi all, Does anyone know how to get the last six months into an array? ive got: my $month = (split ' ', uc localtime)[1]; to get the current month and now i want to get the previous 5 months, is there any way to perform arithmetic on the month value!?? Any help would be much appreciated, cheers. Jonathan Musto BT Ignite Solutions Telephone - 0113 237 3277 Fax - 0113 244 1413 E-mail - <mailto:[EMAIL PROTECTED]> [EMAIL PROTECTED] http://www.technet.bt.com/sit/public <http://www.technet.bt.com/sit/public> British Telecommunications plc Registered office: 81 Newgate Street London EC1A 7AJ Registered in England no. 180 This electronic message contains information from British Telecommunications plc which may be privileged or confidential. The information is intended to be for the use of the individual(s) or entity named above. If you are not the intended recipient be aware that any disclosure, copying, distribution or use of the contents of this information is prohibited. If you have received this electronic message in error, please notify us by telephone or email (to the numbers or address above) immediately.
RE: Comparing array elements with scalar variables.
Thanks for that Nigel it worked a treat. I understand that it would be more efficient not to have the months in a database table, but unfortunately for the peice of software we are using the database with requires it!! we are hoping it will be ironed out in a later release tho. Cheers for time anyway! Jonathan Musto BT Ignite Solutions Telephone - 0113 237 3277 Fax - 0113 244 1413 E-mail - [EMAIL PROTECTED] <mailto:Jonathan.Musto@;bt.com> http://www.technet.bt.com/sit/public British Telecommunications plc Registered office: 81 Newgate Street London EC1A 7AJ Registered in England no. 180 This electronic message contains information from British Telecommunications plc which may be privileged or confidential. The information is intended to be for the use of the individual(s) or entity named above. If you are not the intended recipient be aware that any disclosure, copying, distribution or use of the contents of this information is prohibited. If you have received this electronic message in error, please notify us by telephone or email (to the numbers or address above) immediately. -Original Message- From: Nigel Wetters [mailto:nigel.wetters@;rivalsdm.com] Sent: Wednesday, October 30, 2002 09:59 To: Musto,J,Jonathan,IVYD3 C Cc: [EMAIL PROTECTED] Subject: Re: Comparing array elements with scalar variables. On Wed, 2002-10-30 at 09:33, [EMAIL PROTECTED] wrote: > I've have some code that prints a column of a database table into a html > form. The column of the table is just the last 6 months of the year: see previous post database lookups are expensive. the last 6 months of the year are fairly constant, you should probably not need to store them in a database. -- Nigel Wetters, Senior Programmer, Development Group Rivals Digital Media Ltd, 151 Freston Road, London W10 6TH Tel. 020 8962 1346 (direct line), Fax. 020 8962 1311 http://www.rivalsdm.com/ <[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]
Comparing array elements with scalar variables.
I've have some code that prints a column of a database table into a html form. The column of the table is just the last 6 months of the year: my @emonth; while ( @emonth = $end_Months->fetchrow_array()) { print HTML "@emonth\n"; } returns: MAY JUN JUL AUG SEP OCT i've got the current month stored in a scalar variable: my $thisMonth = (split ' ', uc localtime)[1];#equates to 'OCT' i want to print MAY JUN JUL AUG SEP OCT i've tried many ways of doing this and it seems that perl can't compare scalar variable with array elements, does anyone know of a way of doing this?? any help would be much appreciated, cheers! Jonathan Musto BT Ignite Solutions Telephone - 0113 237 3277 Fax - 0113 244 1413 E-mail - <mailto:Jonathan.Musto@;bt.com> [EMAIL PROTECTED] http://www.technet.bt.com/sit/public <http://www.technet.bt.com/sit/public> British Telecommunications plc Registered office: 81 Newgate Street London EC1A 7AJ Registered in England no. 180 This electronic message contains information from British Telecommunications plc which may be privileged or confidential. The information is intended to be for the use of the individual(s) or entity named above. If you are not the intended recipient be aware that any disclosure, copying, distribution or use of the contents of this information is prohibited. If you have received this electronic message in error, please notify us by telephone or email (to the numbers or address above) immediately.
RE: Easy one
i've tried that and got no joy it's because the $string is a system command! my $string = system("date '+%b'"); $string = uc $string; Jonathan Musto BT Ignite Solutions Telephone - 0113 237 3277 Fax - 0113 244 1413 E-mail - [EMAIL PROTECTED] <mailto:Jonathan.Musto@;bt.com> http://www.technet.bt.com/sit/public British Telecommunications plc Registered office: 81 Newgate Street London EC1A 7AJ Registered in England no. 180 This electronic message contains information from British Telecommunications plc which may be privileged or confidential. The information is intended to be for the use of the individual(s) or entity named above. If you are not the intended recipient be aware that any disclosure, copying, distribution or use of the contents of this information is prohibited. If you have received this electronic message in error, please notify us by telephone or email (to the numbers or address above) immediately. -Original Message- From: Jeff 'japhy' Pinyan [mailto:japhy@;perlmonk.org] Sent: Friday, October 25, 2002 14:56 To: Musto,J,Jonathan,IVYD3 C Cc: [EMAIL PROTECTED] Subject: Re: Easy one On Oct 25, [EMAIL PROTECTED] said: >How do a convert a string $string into uppercase?? perldoc -f uc $big = uc $little; -- 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]
Easy one
How do a convert a string $string into uppercase?? Jonathan Musto BT Ignite Solutions Telephone - 0113 237 3277 Fax - 0113 244 1413 E-mail - <mailto:Jonathan.Musto@;bt.com> [EMAIL PROTECTED] http://www.technet.bt.com/sit/public <http://www.technet.bt.com/sit/public> British Telecommunications plc Registered office: 81 Newgate Street London EC1A 7AJ Registered in England no. 180 This electronic message contains information from British Telecommunications plc which may be privileged or confidential. The information is intended to be for the use of the individual(s) or entity named above. If you are not the intended recipient be aware that any disclosure, copying, distribution or use of the contents of this information is prohibited. If you have received this electronic message in error, please notify us by telephone or email (to the numbers or address above) immediately.
Removing "s
I have a SQL statement using DBI that pulls a list of devices from a data base column: $device_Names->execute or die "...etc..."; I'm printing the output to a file: my @device; while ( @device = $device_Names->fetchrow_array()) { print FILE "@device\n"; } some of the device are surrounded my quotations ie "router01". does anyone know of a way to remove these " if they are present before i write to the file?? i've tried using a regexp @device =~ s/\"//; before the print statement but had no joy :-( Any help would be much appreciated, Cheers! Jonathan Musto BT Ignite Solutions Telephone - 0113 237 3277 Fax - 0113 244 1413 E-mail - <mailto:Jonathan.Musto@;bt.com> [EMAIL PROTECTED] http://www.technet.bt.com/sit/public <http://www.technet.bt.com/sit/public> British Telecommunications plc Registered office: 81 Newgate Street London EC1A 7AJ Registered in England no. 180 This electronic message contains information from British Telecommunications plc which may be privileged or confidential. The information is intended to be for the use of the individual(s) or entity named above. If you are not the intended recipient be aware that any disclosure, copying, distribution or use of the contents of this information is prohibited. If you have received this electronic message in error, please notify us by telephone or email (to the numbers or address above) immediately.
MORE Tidying up repeated data
Hi again all, Thanks for the help before it worked a treat. What i'm looking to do now with this file: ght-Skem ght-Skem ght-Skem hjy-TOB hjy-TOB hjy-TOB etcetc Aswell as removing the repeated data, i could also do with some type of count next to the device that shows how many times it was repeated. Like: ght-Skem 3 hjy-TOB 3 etc...etc... Does anyone know of a way this could be done? Cheers! Jonathan Musto BT Ignite Solutions Telephone - 0113 237 3277 Fax - 0113 244 1413 E-mail - [EMAIL PROTECTED] <mailto:Jonathan.Musto@;bt.com> http://www.technet.bt.com/sit/public British Telecommunications plc Registered office: 81 Newgate Street London EC1A 7AJ Registered in England no. 180 This electronic message contains information from British Telecommunications plc which may be privileged or confidential. The information is intended to be for the use of the individual(s) or entity named above. If you are not the intended recipient be aware that any disclosure, copying, distribution or use of the contents of this information is prohibited. If you have received this electronic message in error, please notify us by telephone or email (to the numbers or address above) immediately. -Original Message- From: [EMAIL PROTECTED] Sent: Monday, October 21, 2002 16:09 To: [EMAIL PROTECTED] Subject: Tidying up repeated data Hi all, If i have a text file with a list of values i.e. ght-Skem ght-Skem ght-Skem hjy-TOB hjy-TOB hjy-TOB etcetc does anyone know of a regular expression to get rid off all the repeated data, so that i just have a list as follows ght-Skem hjy-TOB Any help would be much aprreciated! cheers Jonathan Musto BT Ignite Solutions Telephone - 0113 237 3277 Fax - 0113 244 1413 E-mail - <mailto:Jonathan.Musto@;bt.com> [EMAIL PROTECTED] http://www.technet.bt.com/sit/public <http://www.technet.bt.com/sit/public> British Telecommunications plc Registered office: 81 Newgate Street London EC1A 7AJ Registered in England no. 180 This electronic message contains information from British Telecommunications plc which may be privileged or confidential. The information is intended to be for the use of the individual(s) or entity named above. If you are not the intended recipient be aware that any disclosure, copying, distribution or use of the contents of this information is prohibited. If you have received this electronic message in error, please notify us by telephone or email (to the numbers or address above) immediately. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Tidying up repeated data
Hi all, If i have a text file with a list of values i.e. ght-Skem ght-Skem ght-Skem hjy-TOB hjy-TOB hjy-TOB etcetc does anyone know of a regular expression to get rid off all the repeated data, so that i just have a list as follows ght-Skem hjy-TOB Any help would be much aprreciated! cheers Jonathan Musto BT Ignite Solutions Telephone - 0113 237 3277 Fax - 0113 244 1413 E-mail - <mailto:Jonathan.Musto@;bt.com> [EMAIL PROTECTED] http://www.technet.bt.com/sit/public <http://www.technet.bt.com/sit/public> British Telecommunications plc Registered office: 81 Newgate Street London EC1A 7AJ Registered in England no. 180 This electronic message contains information from British Telecommunications plc which may be privileged or confidential. The information is intended to be for the use of the individual(s) or entity named above. If you are not the intended recipient be aware that any disclosure, copying, distribution or use of the contents of this information is prohibited. If you have received this electronic message in error, please notify us by telephone or email (to the numbers or address above) immediately.