I recently needed to store some SKU information in a subdirectory. This is the simple example I arrived at. More experienced Monks are welcome to tear this apart with improvement suggestions:

#!/usr/bin/perl -w use strict; use Storable; use Data::Dumper; use Cwd; # Note it is possible to override chdir to update $ENV{PWD} +but I could not get it to work under strict my $dir; my $cwd = cwd; my %skuname = ( Lots of stuff here ) # Hard coded data to store in sub +directory # Where are we in working directory now? print "Current Directory by cwd is $cwd \n"; print "Current Directory by env is ", $ENV{'PWD'} , "\n"; # Lets take that info and create a new current working directory print "Appending skudbcurrent to dir\n"; $dir = $cwd . "/skudbcurrent"; print "We wish to move to $dir "; # This directory may or may not exist print "Checking to see if skudbcurrent exists, if not then create +it\n"; unless (-d $dir) { mkdir $dir; print "We had to make $dir \n"; }; # We created it if it was not already there so now move into it # Note that cwd chdir and $ENV{'PWD'} get out of sync although the mov +e was successful chdir $dir; #move into the new directory print "Moved to new directory:",$ENV{'PWD'} , "\n"; print "Which should match $dir\n"; # We made the move. Now store some data in the new location. store(\%skuname, 'skudb') or die "Can't store %a in new location!\ +n"; # Success! Now print out what we think was stored print "Done!\n"; print "Saved the file! er following:\n"; print Dumper( \%skuname );

I hope this brief example is useful for you.


SciDude
The first dog barks... all other dogs bark at the first dog.

In reply to Re: why my system call won't work? by SciDude
in thread why my system call won't work? by EchoAngel

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.