Professional Web Applications Themes

required help - PERL Beginners

I believe you meant to send this message to the Perl Beginner's List. On Monday, October 6, 2003, at 01:51 AM, vaishali wrote: > I am having my text file called ldap1.txt in the following format > > uid : department : branch > vaishali.chitale : Corporate Entertainment : Mumbai > rajesh.chandran : Planet M - Powai (Retail) : pune > > > I have written a code so that I can take department and branch > according to uid in > my program but this code is not working . Let's see if we can fix it up. > ...

  1. #1

    Default Re: required help

    I believe you meant to send this message to the Perl Beginner's List.

    On Monday, October 6, 2003, at 01:51 AM, vaishali wrote:
    > I am having my text file called ldap1.txt in the following format
    >
    > uid : department : branch
    > vaishali.chitale : Corporate Entertainment : Mumbai
    > rajesh.chandran : Planet M - Powai (Retail) : pune
    >
    >
    > I have written a code so that I can take department and branch
    > according to uid in
    > my program but this code is not working .
    Let's see if we can fix it up.
    > # open ldap1 text file and chunk the elements into a hash
    >
    > open(F,'<'.$file_name) or die "Can't open $file_name: $!\n";
    Good start.
    > my file=<F>;
    Why store the whole file in an array so you can later walk it line by
    line? Let's just do all our processing right here, instead of the line
    above. Here's how I would do it:

    my %lp1;
    while (<F>) {
    my($uid, $department, $branch) = split /\s*:\s*/, $_;
    $lp1{$uid} = { department => $department, branch => $branch };
    }
    > close(F);
    Nothing below this line is needed, but I'll go through it with comments
    anyway
    > my %lp1;
    >
    > for my $file
    > (file) {
    > my lp1=(split(/\s*:\s*/,$file))[0];
    This is the program's main problem. You're splitting the fields and
    then throwing away all but the first one with your indexed list
    assignment. That's why you're seeing uninitialized warnings, $lp1[1]
    and $lp1[2] never receive a value. You could fix this by removing the
    ( ... )[0] around your split.

    Hope that helps.

    James
    > $lp1{$lp1[0]}{'department'}=$lp1[1];
    > $lp1{$lp1[0]}{'branch'}=$lp1[2];
    >
    > }
    >
    > undef file;
    >
    > In above code I am not able to print department and branch
    > it is giving me error for the following
    >
    > $lp1{$lp1[0]}{'department'}=$lp1[1];
    > $lp1{$lp1[0]}{'branch'}=$lp1[2];
    >
    > Use of uninitialized value
    >
    > what is the problem ?
    >
    >
    >
    >
    >
    >
    >
    > ---
    > NOTICE-----------------------------------------------------------------
    > ---------------------------------
    > This E-mail (including the attachment/(s) if any ) has been scanned
    > for viruses and dangerous content. For more information mail to
    > [email]mumbai_admintimesgroup.com[/email]
    > -----------------------------------------------------------------------
    > ------------------------------------
    > ---
    > DISCLAIMER-------------------------------------------------------------
    > ---------------------------------
    > The contents of this E-mail (including the contents of the
    > enclosure/(s) or attachment/(s) if any) are privileged and
    > confidential material of Bennett, Coleman & Co. Ltd. (BCCL)and should
    > not be disclosed to, used by or copied in any manner by anyone other
    > than the intended addressee/(s). If this E-mail (including the
    > enclosure/(s) or attachment/(s) if any ) has been received in error,
    > please advise the sender immediately and delete it from your system.
    > The views expressed in this E-mail message (including the
    > enclosure/(s) or attachment/(s) if any) are those of the individual
    > sender.
    > -----------------------------------------------------------------------
    > ------------------------------------
    >
    James Edward Gray II Guest

  2. #2

    Default Re: required help

    Again, you MUST send these to the Perl Beginner's List, if you want
    answers.

    On Monday, October 6, 2003, at 10:48 PM, vaishali wrote:
    > thanks my problem is solved
    > I am having another query.
    > I am having mysql and the table is sms_log. In that my sender field
    > format is
    >
    > xyz abc <xyz.abctest.com>
    >
    > I want only the part ie after < sign and before sign ie only xyz.abc.
    > How to extract this part from the above field
    my $address = 'xyz abc <xyz.abctest.com>';
    my $name;
    if ($address =~ /<([^]+)/) { $name = $1; }
    else { die "Malformed address $address.\n"; }

    James

    James Edward Gray II Guest

  3. Moderated Post

    Default required help

    Removed by Administrator
    Vaishali Guest
    Moderated Post

  4. Moderated Post

    Default Re: required help

    Removed by Administrator
    James Edward Gray II Guest
    Moderated Post

  5. #5

    Default Fwd: required help

    [ forwarded to list by James Gray ]

    Begin forwarded message:
    > From: vaishali <vaishali.chitaletimesgroup.com>
    > Date: Fri Oct 10, 2003 5:06:21 AM US/Central
    > To: James Edward Gray II <jamesgrayproductions.net>
    > Subject: Re: required help
    > Reply-To: [email]vaishali.chitaletimesgroup.com[/email]
    >
    > how to define multiple connect statements
    >
    > Actually I am having one database ie smsd and table sms_log in
    > 10.100.208.254.
    > I have created one database called smsd and table sms_log1 on
    > 10.100.200.47 ie in another machine
    >
    > I want to insert data from sms_log ie 10.100.208.254 server to
    > 10.100.200.47 table ie sms_log1.
    >
    > how to do this task using perl DBI
    >
    > fields from sms_log ie 10.100.208.254 are
    > sender char(40)
    > receiver char(40)
    > sent datetime
    >
    > fields from sms_log1 ie 10.100.200.47 are
    > sender char(40),
    > receiver char(40),
    > sent datetime,
    > dept char(40),
    > branch char(40)
    James Edward Gray II Guest

  6. #6

    Default Re: Fwd: required help

    On Fri, 10 Oct 2003 08:40:17 -0500, James Edward Gray II wrote:
    > I want to insert data from sms_log ie 10.100.208.254 server to
    > 10.100.200.47 table ie sms_log1.
    Well. What have you tried so far? It should be easy as long as you
    create two database connections?


    --
    Tore Aursand <toreaursand.no>

    Tore Aursand Guest

Similar Threads

  1. Help Required
    By Dinesh Upare in forum ASP.NET Security
    Replies: 6
    Last Post: May 3rd, 12:35 AM
  2. ASP help required please
    By Stephen in forum ASP Components
    Replies: 4
    Last Post: February 25th, 01:06 PM
  3. Help required please!
    By Alex Cotgreave in forum Adobe Photoshop Elements
    Replies: 0
    Last Post: July 9th, 01:41 PM
  4. what is required for job(?)
    By doc in forum Macromedia Flash Sitedesign
    Replies: 3
    Last Post: July 8th, 03:16 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139