Sponsored Content
Top Forums Shell Programming and Scripting Large Variable content size caveats? Post 303031979 by Corona688 on Friday 8th of March 2019 10:58:00 AM
Old 03-08-2019
Main caveat, it's almost almost always a dumb idea. Ad-hoc data, "dump-and-fix-later", is the modern UUOC, wasteful and pointless. If you know what you actually want, you can either deal with it in a structured way or avoid storing it entirely.

Another caveat, most shells don't let you keep binary data in variables. Mass dumping unchecked data into variables can occasionally surprise you.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

prevent file size is too large

We have EDP members will do some testing job in my system , but sometimes these process will generate some error to the system log or any file ( usually the members don't know the log is reached to this level ) , then make the system crashed , could suggest the way how can to prevent this problem ?... (2 Replies)
Discussion started by: ust
2 Replies

2. UNIX for Dummies Questions & Answers

Editing a large size file

I would like to edit a doc which is large file size. I can't use "vi" command due to out of memory. $ vi large.dat ex: 0602-101 Out of memory saving lines for undo. Please help. Thanks. (2 Replies)
Discussion started by: Rock
2 Replies

3. Shell Programming and Scripting

Split a large file with patterns and size

Hi, I have a large file with a repeating pattern in it. Now i want the file split into the block of patterns with a specified no. of lines in each file. i.e. The file is like 1... 2... 2... 3... 1... 2... 3... 1... 2... 2... 2... 2... 2... 3... where 1 is the start of the block... (5 Replies)
Discussion started by: sudhamacs
5 Replies

4. Web Development

Content Management System for uploading large files

Hi everybody, I am currently trying to develop a simple content management system where I have an internal website for my users to upload large files onto the server. The site is password protected and my users won't be trying to hack into the system so security is a non-factor (as least for... (3 Replies)
Discussion started by: z1dane
3 Replies

5. Shell Programming and Scripting

Creating large number of files of specific size

Hi I am new to shell scripting.I want to create a batch file which creates a desired number of files with a specific size say 1MB each to consume space.How can i go about it using for loop /any other loop condition using shell script? Thanks (3 Replies)
Discussion started by: swatideswal
3 Replies

6. UNIX for Advanced & Expert Users

Need help with configuring large packet size on Solaris 7 / e6500

We're running Solaris 7 on FDDI n/w on an E6500 host and wish to use MTU (packet size) > 1500, more like 3072 bytes to begin with and possibly up to 4096 bytes. Linux has /etc/network/interfaces. Does ANYONE remember the equivalent in Unix? When I do ifconfig eth0 mtu 4000, I get the error... (0 Replies)
Discussion started by: sharique
0 Replies

7. Solaris

Need help with configuring large packet size on Solaris 7 / e6500

Greetings, I'm stuck in a time warp using ancient machines from the prehistoric era that should be rightfully displayed in the Smithsonian. We're running Solaris 7 on FDDI n/w on an E6500 host and wish to use MTU (packet size) > 1500, more like 3072 bytes to begin with and possibly up to 4096... (9 Replies)
Discussion started by: sharique
9 Replies

8. Red Hat

Empty directory, large size and performance

Hi, I've some directory that I used as working directory for a program. At the end of the procedure, the content is deleted. This directory, when I do a ls -l, appears to still take up some space. After a little research, I've seen on a another board of this forum that it's not really taking... (5 Replies)
Discussion started by: bdx
5 Replies

9. Shell Programming and Scripting

Help with Splitting a Large XML file based on size AND tags

Hi All, This is my first post here. Hoping to share and gain knowledge from this great forum !!!! I've scanned this forum before posting my problem here, but I'm afraid I couldn't find any thread that addresses this exact problem. I'm trying to split a large XML file (with multiple tag... (7 Replies)
Discussion started by: Aviktheory11
7 Replies

10. Programming

Best Method For Query Content In Large JSON Files

I wanted to know what is the best way to query json formatted files for content? Ex. Data https://usn.ubuntu.com/usn-db/database-all.json.bz2 When looking at keys as in: import json json_data = json.load(open('database-all.json')) for keys in json_data.iterkeys(): print 'Keys--> {}... (0 Replies)
Discussion started by: metallica1973
0 Replies
Data::Dumper::Simple(3pm)				User Contributed Perl Documentation				 Data::Dumper::Simple(3pm)

NAME
Data::Dumper::Simple - Easily dump variables with names SYNOPSIS
use Data::Dumper::Simple; warn Dumper($scalar, @array, %hash); warn Dumper($scalar, @array, \%hash); warn Dumper $scalar, @array, %hash; ABSTRACT
This module allow the user to dump variables in a Data::Dumper format. Unlike the default behavior of Data::Dumper, the variables are named (instead of $VAR1, $VAR2, etc.) Data::Dumper provides an extended interface that allows the programmer to name the variables, but this interface requires a lot of typing and is prone to tyops (sic). This module fixes that. DESCRIPTION
"Data::Dumper::Simple" is actually a source filter that replaces all instances of "Dumper($some, @args)" in your code with a call to "Data::Dumper->Dump()". You can use the one function provided to make dumping variables for debugging a trivial task. Note that this is primarily a debugging tool. "Data::Dumper" offers a bit more than that, so don't expect this module to be more than it is. Note that if you strongly object to source filters, I've also released Data::Dumper::Names. It does what this module does by it uses Pad- Walker instead of a source filter. Unfortunately, it has a few limitations and is not as powerful as this module. Think of Data::Dumper::Names as a "proof of concept". The Problem Frequently, we use "Data::Dumper" to dump out some variables while debugging. When this happens, we often do this: use Data::Dumper; warn Dumper($foo, $bar, $baz); And we get simple output like: $VAR1 = 3; $VAR2 = 2; $VAR3 = 1; While this is usually what we want, this can be confusing if we forget which variable corresponds to which variable printed. To get around this, there is an extended interface to "Data::Dumper": warn Data::Dumper->Dump( [$foo, $bar, $baz], [qw/*foo *bar *baz/] ); This provides much more useful output. $foo = 3; $bar = 2; $baz = 1; (There's more control over the output than what I've shown.) You can even use this to output more complex data structures: warn Data::Dumper->Dump( [$foo, @array], [qw/*foo *array/] ); And get something like this: $foo = 3; @array = ( 8, 'Ovid' ); Unfortunately, this can involve a lot of annoying typing. warn Data::Dumper->Dump( [$foo, \%this, @array, \%that], [qw/*foo *that *array *this/] ); You'll also notice a typo in the second array ref which can cause great confusion while debugging. The Solution With "Data::Dumper::Simple" you can do this instead: use Data::Dumper::Simple. warn Dumper($scalar, @array, %hash); Note that there's no need to even take a reference to the variables. The output of the above resembles this (sample data, of course): $scalar = 'Ovid'; @array = ( 'Data', 'Dumper', 'Simple', 'Rocks!' ); %hash = ( 'it' => 'does', 'I' => 'hope', 'at' => 'least' ); Taking a reference to an array or hash works as expected, but taking a reference to a scalar is effectively a no-op (because it can turn into a confusing reference to a reference); my $foo = { hash => 'ref' }; my @foo = qw/foo bar baz/; warn Dumper ($foo, @foo); Produces: $foo = { 'hash' => 'ref' }; $foo = [ 'foo', 'bar', 'baz' ]; Note that this means similarly named variables can get quite confusing, as in the example above. If you already have a &Dumper function, you can specify a different function name with the "as" key in the import list: use Data::Dumper::Simple as => 'display'; warn display( $scalar, @array, %hash ); Also, if you really, really can't stand typing "warn" or "print", you can turn on "autowarn": use Data::Dumper::Simple as => 'display', autowarn => 1; display($scalar, @array, $some->{ data }); Or you can send the output (as a list) to a different function: use Data::Dumper::Simple as => 'debug', autowarn => 'to_log'; sub to_log { my @data = @_; # some logging function } debug( $customer => @order_nums ); # yeah, we support the fat comma "=>" and newlines EXPORT
The only thing exported is the Dumper() function. Well, actually that's not really true. Nothing is exported. However, a source filter is used to automatically rewrite any apparent calls to "Dumper()" so that it just Does The Right Thing. SEE ALSO
* Data::Dumper - Stringified perl data structures * Filter::Simple - Simplified source filtering BUGS
This module uses a source filter. If you don't like that, don't use this. There are no known bugs but there probably are some as this is Alpha Code. LIMITATIONS
* Calling with a sub Do not try to call "Dumper()" with a subroutine in the argument list: Dumper($foo, some_sub()); # Bad! The filter gets confused by the parentheses. Your author was going to fix this but it became apparent that there was no way that "Dumper()" could figure out how to name the return values from the subroutines, thus ensuring further breakage. So don't do that. * Multiple enreferencing Getting really crazy by using multiple enreferencing will confuse things (e.g., "\\\$foo"), don't do that, either. I might use "Text::Balanced" at some point to fix this if it's an issue. * Slices List and hash slices are not supported at this time. * String interpolation "Dumper($foo)" can potentially interpolate if it's in a string. This is because of a weird edge case with "FILTER_ONLY code" which caused a failure on some items being dumped. I've fixed that, but made the module a wee bit less robust. This will hopefully be fixed in the next release of Text::Balanced. * Line numbers may be wrong Because this module uses a source filter, line numbers reported from syntax or other errors may be thrown off a little. This is probably a bug in the source filter implementation, which should use "#line" directives. As a workaround until this is fixed, put a directive (such as "#line 10000") a few lines ahead of the suspected bug. If the error is reported as happening in line 10007, you know to look about eight lines below your directive for the bug. Be sure to remove the bogus directive once you find the bug! * The parentheses are optional, but the syntax isn't bulletproof If you try, it's not hard to confuse the parser. Patches welcome. Note that this is not a drop-in replacement for "Data::Dumper". If you need the power of that module, use it. AUTHOR
Curtis "Ovid" Poe, <eop_divo_sitruc@yahoo.com> Reverse the name to email me. COPYRIGHT AND LICENSE
Copyright 2004 by Curtis "Ovid" Poe This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.8.8 2008-03-08 Data::Dumper::Simple(3pm)
All times are GMT -4. The time now is 11:28 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy