Ask a Question related to PERL Beginners, Design and Development.

  1. #1

    Default Packaging my stuff


    Hi All,

    I am sure people must be doing that regularly.

    How do i package my Application to give to the customer??.

    Like creating packages for different platforms linux, debian, sun, windows etc.

    Any pointers would be greatly appreciated.

    Thanx,
    -Sharad
    Sharad Gupta Guest

  2. Similar Questions and Discussions

    1. Packaging and Deployment
      So I've banged my head against a wall for a couple of hours this morning trying to get the deployment manager to work... I don't want to have to...
    2. Packaging the project
      How can i package my project to a WAR file K,Browne Developer
    3. Packaging looking for fonts not used (on XP)
      I'm just starting with Indesign CS (long time PageMaker user) on my Windows XP box. When running "Save for Service Provider", the preflight (and...
    4. Packaging applications
      Reading the red book 'Developing and Porting C and C++ Applications on AIX', it seems that mkinstallp is only provided from AIX 5.2. Is there any...
    5. packaging .dll's
      Good afternoon I used 8.0 and just upgraded to MX. I am still confused about putting the .dll's in the xtras folder. We have done about 8...
  3. #2

    Default Sort Text File

    Hello,

    I'm rather new to PERL. How do I go about sorting
    a simple text file using PERL? This is what I want
    to accomplish.

    # sort /etc/passwd > /etc/passwd-new
    # mv /etc/passwd-new /etc/passwd

    Thanks in advance for your help.

    -Dean
    ---
    Outgoing mail is certified Virus Free.
    Checked by AVG anti-virus system ([url]http://www.grisoft.com[/url]).
    Version: 6.0.517 / Virus Database: 315 - Release Date: 9/8/03

    Dean Do Guest

  4. #3

    Default Re: Sort Text File

    On Friday, October 3, 2003, at 01:45 PM, Dean Do wrote:
    > Hello,
    Howdy.
    > I'm rather new to PERL. How do I go about sorting
    > a simple text file using PERL? This is what I want
    > to accomplish.
    >
    > # sort /etc/passwd > /etc/passwd-new
    > # mv /etc/passwd-new /etc/passwd
    Any good reason not to use the above? :)

    Well, what would be the steps?

    1. open /etc/passwd/
    2. read all entries into memory
    3. close /etc/passwd/
    4. sort entries
    5. open new file
    6. print all entries
    7. close new file
    8. rename new file

    Can you walk down that list replacing it with Perl statements?

    James

    James Edward Gray II Guest

  5. #4

    Default Re: Sort Text File

    Dean Do wrote:
    >
    > Hello,
    Hello,
    > I'm rather new to PERL. How do I go about sorting
    > a simple text file using PERL? This is what I want
    > to accomplish.
    >
    > # sort /etc/passwd > /etc/passwd-new
    > # mv /etc/passwd-new /etc/passwd
    Are you sure you want to modify /etc/passwd? Which field do you want to sort on?

    #!/usr/bin/perl
    # *** UNTESTED ***
    use warnings;
    use strict;
    use Fcntl qw( :flock :seek );

    my $file = '/etc/passwd';
    open my $fh, '+<', $file or die "Cannot open $file: $!";
    flock $fh, LOCK_EX or die "Cannot lock $file: $!";

    # sort on the user name field
    my @records = map $_->[ 1 ],
    sort { $a->[ 0 ] cmp $b->[ 0 ] }
    map [ (split /:/)[ 0 ], $_ ],
    <$fh>;

    # sort on the UID field
    #my @records = map $_->[ 1 ],
    # sort { $a->[ 0 ] <=> $b->[ 0 ] }
    # map [ (split /:/)[ 2 ], $_ ],
    # <$fh>;

    seek $fh, 0, SEEK_SET or die "Cannot seek on $file: $!";
    # you could also use truncate() here but since you are not
    # changing the size of the data it is not necessary.
    print $fh @records or die "Cannot print to $file: $!";
    # close and unlock the file
    close $fh;

    __END__


    If you are going to try this out, MAKE A BACKUP COPY of the file first!
    If you screw up the /etc/passwd file without a backup you are going to
    be in a world of hurt.


    John
    --
    use Perl;
    program
    fulfillment
    John W. Krahn Guest

  6. #5

    Default Re: Sort Text File

    >>>>> "John" == John W Krahn <krahnj@acm.org> writes:

    John> Are you sure you want to modify /etc/passwd? Which field do you
    John> want to sort on?

    And if you want to modify /etc/passwd, you should be using vipw,
    because vipw will lock the file for you, and verify some sanity checks
    the updated data to keep you from shooting yourself in the foot.

    #!/usr/bin/perl

    unless (@ARGV) {
    # no argument passed, so call ourselves inside vipw:
    $ENV{EDITOR} = $0; # vipw will call us now instead of vi/emacs/whatever
    exec "vipw";
    die "Cannot exec vipw: $!";
    }

    # argument passed means that vipw has called us with a temp filename

    # edit it inplace
    $^I = "~";
    # and all at once (for reasons that are hard to explain here)
    $/ = undef;

    my @lines = split /\n/, <>; # only one read gets the entire file
    # anything we print replaces that entire file
    @lines = sort @lines; # here's the active step - replace as you wish
    print map "$_\n", @lines;

    --
    Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
    <merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
    Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
    See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
    Randal L. Schwartz Guest

Posting Permissions

  • You may not post new threads
  • You may 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